public class GCloudSessionDataStore extends AbstractSessionDataStore
Modifier and Type | Class and Description |
---|---|
static class |
GCloudSessionDataStore.EntityDataModel
EntityDataModel
Names of type of Entity and Entity properties for sessions.
|
static class |
GCloudSessionDataStore.ExpiryInfo
ExpiryInfo
Information related to session expiry
|
AbstractLifeCycle.AbstractLifeCycleListener
LifeCycle.Listener
Container.InheritedListener, Container.Listener
Modifier and Type | Field and Description |
---|---|
protected int |
_backoff |
protected com.google.cloud.datastore.Datastore |
_datastore |
protected boolean |
_dsProvided |
protected boolean |
_indexesPresent |
protected com.google.cloud.datastore.KeyFactory |
_keyFactory |
protected int |
_maxResults |
protected int |
_maxRetries |
protected GCloudSessionDataStore.EntityDataModel |
_model |
protected boolean |
_modelProvided |
static int |
DEFAULT_BACKOFF_MS |
static int |
DEFAULT_MAX_QUERY_RESULTS |
static int |
DEFAULT_MAX_RETRIES |
_context, _gracePeriodSec, _lastExpiryCheckTime
FAILED, RUNNING, STARTED, STARTING, STOP_ON_FAILURE, STOPPED, STOPPING
Constructor and Description |
---|
GCloudSessionDataStore() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkIndexes()
Check to see if indexes are available, in which case
we can do more performant queries.
|
boolean |
delete(String id)
Delete session data
|
Set<String> |
doGetExpired(Set<String> candidates)
Implemented by subclasses to resolve which sessions this node
should attempt to expire.
|
protected void |
doStart()
Starts the managed lifecycle beans in the order they were added.
|
protected void |
doStop()
Stops the managed lifecycle beans in the reverse order they were added.
|
void |
doStore(String id,
SessionData data,
long lastSaveTime)
Store the session data persistently.
|
protected com.google.cloud.datastore.Entity |
entityFromSession(SessionData session,
com.google.cloud.datastore.Key key)
Generate a gcloud datastore Entity from SessionData
|
boolean |
exists(String id)
Test if data exists for a given session id.
|
int |
getBackoffMs() |
GCloudSessionDataStore.EntityDataModel |
getEntityDataModel() |
int |
getMaxResults() |
int |
getMaxRetries() |
String |
getNamespace() |
protected boolean |
isExpired(long timestamp)
Check to see if the given time is in the past.
|
boolean |
isPassivating()
True if this type of datastore will passivate session objects
|
SessionData |
load(String id)
Read in session data.
|
protected com.google.cloud.datastore.Key |
makeKey(String id,
SessionContext context)
Make a unique key for this session.
|
protected Set<GCloudSessionDataStore.ExpiryInfo> |
queryExpiryByEntity()
A less efficient query to find sessions whose expiry time has passed:
retrieves the whole Entity.
|
protected Set<GCloudSessionDataStore.ExpiryInfo> |
queryExpiryByIndex()
An efficient query to find sessions whose expiry time has passed:
uses a projection query, which requires indexes to be uploaded.
|
protected SessionData |
sessionFromEntity(com.google.cloud.datastore.Entity entity)
Generate SessionData from an Entity retrieved from gcloud datastore.
|
void |
setBackoffMs(int ms) |
void |
setDatastore(com.google.cloud.datastore.Datastore datastore) |
void |
setEntityDataModel(GCloudSessionDataStore.EntityDataModel model) |
void |
setMaxResults(int maxResults) |
void |
setMaxRetries(int retries) |
void |
setNamespace(String namespace) |
String |
toString() |
checkStarted, getExpired, getGracePeriodSec, initialize, newSessionData, setGracePeriodSec, store
addBean, addBean, addBean, addEventListener, addManaged, contains, destroy, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpStdErr, dumpThis, getBean, getBeans, getBeans, isManaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addLifeCycleListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop
public static final int DEFAULT_MAX_QUERY_RESULTS
public static final int DEFAULT_MAX_RETRIES
public static final int DEFAULT_BACKOFF_MS
protected com.google.cloud.datastore.Datastore _datastore
protected com.google.cloud.datastore.KeyFactory _keyFactory
protected int _maxResults
protected int _maxRetries
protected int _backoff
protected boolean _dsProvided
protected boolean _indexesPresent
protected GCloudSessionDataStore.EntityDataModel _model
protected boolean _modelProvided
public void setEntityDataModel(GCloudSessionDataStore.EntityDataModel model)
public GCloudSessionDataStore.EntityDataModel getEntityDataModel()
public void setBackoffMs(int ms)
public void setNamespace(String namespace)
public String getNamespace()
public int getBackoffMs()
public void setMaxRetries(int retries)
public int getMaxRetries()
protected void doStart() throws Exception
ContainerLifeCycle
doStart
in class AbstractSessionDataStore
Exception
AbstractSessionDataStore.doStart()
protected void doStop() throws Exception
ContainerLifeCycle
doStop
in class ContainerLifeCycle
Exception
AbstractLifeCycle.doStop()
public void setDatastore(com.google.cloud.datastore.Datastore datastore)
public int getMaxResults()
public void setMaxResults(int maxResults)
public SessionData load(String id) throws Exception
SessionDataMap
id
- identity of session to loadException
- if unable to load session dataSessionDataMap.load(java.lang.String)
public boolean delete(String id) throws Exception
SessionDataMap
id
- identity of session to deleteException
- if unable to delete session dataSessionDataMap.delete(java.lang.String)
public Set<String> doGetExpired(Set<String> candidates)
AbstractSessionDataStore
doGetExpired
in class AbstractSessionDataStore
candidates
- the ids of sessions the SessionDataStore thinks has expiredSessionDataStore.getExpired(Set)
protected Set<GCloudSessionDataStore.ExpiryInfo> queryExpiryByEntity() throws Exception
Exception
- if datastore experiences a problemprotected Set<GCloudSessionDataStore.ExpiryInfo> queryExpiryByIndex() throws Exception
Exception
- if datastore experiences a problempublic boolean exists(String id) throws Exception
SessionDataStore
id
- Identity of session whose existance should be checkedException
- if problem checking existance with persistence layerSessionDataStore.exists(java.lang.String)
protected boolean isExpired(long timestamp)
timestamp
- the time to checkpublic void doStore(String id, SessionData data, long lastSaveTime) throws Exception
AbstractSessionDataStore
doStore
in class AbstractSessionDataStore
id
- identity of session to storedata
- info of the sessionlastSaveTime
- time of previous save or 0 if never savedException
- if unable to store dataAbstractSessionDataStore.doStore(java.lang.String, org.eclipse.jetty.server.session.SessionData, long)
protected com.google.cloud.datastore.Key makeKey(String id, SessionContext context)
id
- the idcontext
- the session contextprotected boolean checkIndexes()
protected com.google.cloud.datastore.Entity entityFromSession(SessionData session, com.google.cloud.datastore.Key key) throws Exception
session
- the session datakey
- the keyException
- if there is a deserialization errorprotected SessionData sessionFromEntity(com.google.cloud.datastore.Entity entity) throws Exception
entity
- the entityException
- if unable to get the entitypublic boolean isPassivating()
SessionDataStore
SessionDataStore.isPassivating()
public String toString()
toString
in class AbstractSessionDataStore
AbstractSessionDataStore.toString()
Copyright © 1995–2017 Webtide. All rights reserved.