csip.LocalSessionStore Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of csip-core Show documentation
Show all versions of csip-core Show documentation
The Cloud Services Integration Platform is a SoA implementation to offer a Model-as-a-Service framework, Application Programming Interface, deployment infrastructure, and service implementations for environmental modeling.
/*
* $Id: LocalSessionStore.java 27bed8415b8b 2019-01-31 od $
*
* This file is part of the Cloud Services Integration Platform (CSIP),
* a Model-as-a-Service framework, API and application suite.
*
* 2012-2019, Olaf David and others, OMSLab, Colorado State University.
*
* OMSLab licenses this file to you under the MIT license.
* See the LICENSE file in the project root for more information.
*/
package csip;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* This is a local session store. One instance only, no failover.
*/
class LocalSessionStore implements SessionStore {
Map m = Collections.synchronizedMap(new HashMap());
public LocalSessionStore() {
Config.LOG.info("Using local session store.");
}
@Override
public void close() throws Exception {
m.clear();
}
@Override
public void setSession(String key, ModelSession session) throws Exception {
m.put(key, session);
}
@Override
public ModelSession getSession(String key) throws Exception {
return m.get(key);
}
@Override
public void removeSession(String key) {
m.remove(key);
}
@Override
public Set keys(int skip, int limit, String sortby, boolean sortAscending) {
return m.keySet();
}
@Override
public long getCount() {
return m.size();
}
@Override
public void ping() {
if (m == null) {
throw new NullPointerException("Illegal hashtable store.");
}
}
@Override
public boolean hasSession(String suid) throws Exception {
return m.containsKey(suid);
}
@Override
public long countSessionsByState(String state) {
long l = 0;
for (ModelSession s : m.values()) {
if (s.getStatus().equals(state)) {
l++;
}
}
return l;
}
@Override
public void registerResources(boolean register) {
Config.LOG.warning("Not implemented.");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy