Package org.glassfish.ha.store.api
Class BackingStore<K extends Serializable,V extends Serializable>
java.lang.Object
org.glassfish.ha.store.api.BackingStore<K,V>
- Direct Known Subclasses:
NoOpBackingStore
An object that stores a given value against an id. This class defines the
set of operations that a container could perform on a store.
An instance of BackingStore is created by calling
BackingStoreFactory.createBackingStore()
method.
The BackingStore instance is created and used for storing data that belongs
to a single application or container.
The store implementation must be thread safe.
- Author:
- [email protected], [email protected]
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Typically called during shutdown of the process.protected ObjectInputStream
protected ObjectOutputStream
void
destroy()
Called when the store is no longer needed.protected BackingStoreConfiguration<K,
V> abstract BackingStoreFactory
protected void
initialize
(BackingStoreConfiguration<K, V> conf) abstract V
Load and return the data for the given id.abstract void
Remove the association for the id.int
Remove expired entriesint
removeExpired
(long idleForMillis) abstract String
Save the value whose key is id.abstract int
size()
Get the current size of the storevoid
updateTimestamp
(K key, long time) TODO: BEGIN: REMOVE after shoal integrationupdateTimestamp
(K key, String version, Long accessTime) Recomended way is to just do a save(k, v)
-
Constructor Details
-
BackingStore
public BackingStore()
-
-
Method Details
-
initialize
- Throws:
BackingStoreException
-
getBackingStoreConfiguration
-
getBackingStoreFactory
-
load
Load and return the data for the given id. The store is expected to return the largest ever version that was saved in the stored using thesave()
method.- Parameters:
key
- the key whose value must be returned- Returns:
- the value if this store contains it or null. The implementation must return the exact same type as that was passed to it in the save method.
- Throws:
NullPointerException
- if the id is nullBackingStoreException
- if the underlying store implementation encounters any exception
-
save
Save the value whose key is id. The store is NOT expected to throw an exception if isNew is false but the entry doesn't exist in the store. (This is possible in some implementations (like in-memory) where packets could be lost.)- Parameters:
key
- the idvalue
- The Metadata to be stored- Returns:
- A (possibly null) String indicating the instance name where the data was saved.
- Throws:
BackingStoreException
- if the underlying store implementation encounters any exception
-
remove
Remove the association for the id. After this call, any call toload(id)
must return null. In addition, any association betweenid
and container extra params must also be removed.- Parameters:
key
- the id of the Metadata- Throws:
BackingStoreException
- if the underlying store implementation encounters any exception
-
updateTimestamp
TODO: BEGIN: REMOVE after shoal integration- Throws:
BackingStoreException
-
removeExpired
- Throws:
BackingStoreException
-
updateTimestamp
Recomended way is to just do a save(k, v)- Parameters:
key
-version
-accessTime
-- Throws:
BackingStoreException
-
removeExpired
Remove expired entries- Throws:
BackingStoreException
-
size
Get the current size of the store- Returns:
- the (approximate) number of entries in the store
- Throws:
BackingStoreException
- if the underlying store implementation encounters any exception
-
close
Typically called during shutdown of the process. The store must not be used after this call- Throws:
BackingStoreException
-
destroy
Called when the store is no longer needed. Must clean up and close any opened resources. The store must not be used after this call.- Throws:
BackingStoreException
-
createObjectOutputStream
- Throws:
IOException
-
createObjectInputStream
- Throws:
IOException
-