public class DistributedKVStoreService
extends java.lang.Object
implements jadex.bridge.service.types.dht.IDistributedKVStoreService, jadex.bridge.service.types.dht.IDistributedKVStoreDebugService
Modifier and Type | Field and Description |
---|---|
protected jadex.bridge.IInternalAccess |
agent
The local agent access.
|
protected static long |
CHECK_STORED_DATA_DELAY
Delay in ms between two stabilize runs
|
protected jadex.bridge.IComponentStep<java.lang.Void> |
checkDataStep |
protected jadex.bridge.component.IExecutionFeature |
executor
The execution Feature of the agent.
|
protected boolean |
initialized
Flag that indicates whether this Service is already usable.
|
protected java.util.Map<java.lang.String,jadex.bridge.service.types.dht.StoreEntry> |
keyMap
Map that stores the actual data.
|
protected java.util.logging.Logger |
logger
The logger.
|
protected jadex.bridge.service.types.dht.IID |
myId
The local ID
|
protected jadex.bridge.service.types.dht.IRingApplicationService |
ring
The local Ring Node to access the DHT Ring.
|
Constructor and Description |
---|
DistributedKVStoreService()
Constructor.
|
Modifier and Type | Method and Description |
---|---|
jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> |
add(java.lang.String key,
java.lang.Object value)
Add a key/value pair to the collection addressed by the given key.
|
jadex.commons.future.IFuture<java.lang.Void> |
checkData()
Check all entries for validity and move them to another node, if necessary.
|
void |
disableSchedules() |
protected void |
eventReceived(jadex.bridge.service.types.dht.RingNodeEvent event)
Called upon events received from the ring service.
|
jadex.commons.future.IFuture<java.util.Set<java.lang.String>> |
getLocalKeySet()
Returns all keys stored in this node.
|
jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IDistributedKVStoreService> |
getStoreService(jadex.bridge.service.types.dht.IFinger finger)
Lookup the storage service for a given finger.
|
boolean |
isInitialized()
Gets the initialized flag.
|
protected void |
log(java.lang.String message) |
jadex.commons.future.IFuture<?> |
lookup(java.lang.String key)
Lookup a key in the ring and return the saved value, if any.
|
jadex.commons.future.IFuture<?> |
lookup(java.lang.String key,
jadex.bridge.service.types.dht.IID idHash)
Lookup a key in the ring and return the saved value, if any.
|
jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> |
lookupResponsibleStore(java.lang.String key)
Lookup a key and return the responsible Node ID.
|
void |
onServiceStarted() |
jadex.commons.future.IFuture<java.util.Collection<jadex.bridge.service.types.dht.StoreEntry>> |
pullEntries(jadex.bridge.service.types.dht.IID targetNodeId)
Returns all entries that belong to the given node Id
and deletes them on this node.
|
jadex.commons.future.IFuture<java.lang.Void> |
pushEntries(java.util.Collection<jadex.bridge.service.types.dht.StoreEntry> entries) |
jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> |
put(java.lang.String key,
java.lang.Object value)
Publish a key/value pair in the corresponding node.
|
void |
setInitialized(boolean value)
Sets the initialized flag.
|
void |
setRingService(jadex.bridge.service.types.dht.IRingApplicationService ring)
Set the local ringNode.
|
protected jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> |
store(jadex.bridge.service.types.dht.IID hash,
java.lang.String key,
java.lang.Object value,
boolean addToCollection) |
protected jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> |
store(java.lang.String key,
java.lang.Object value,
boolean addToCollection) |
protected jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> |
storeLocal(jadex.bridge.service.types.dht.IID hash,
java.lang.String key,
java.lang.Object value,
boolean addToCollection)
Store a key/value pair in the local map.
|
protected static final long CHECK_STORED_DATA_DELAY
protected java.util.Map<java.lang.String,jadex.bridge.service.types.dht.StoreEntry> keyMap
protected jadex.bridge.service.types.dht.IRingApplicationService ring
protected jadex.bridge.service.types.dht.IID myId
protected jadex.bridge.IInternalAccess agent
protected java.util.logging.Logger logger
protected boolean initialized
protected jadex.bridge.component.IExecutionFeature executor
protected jadex.bridge.IComponentStep<java.lang.Void> checkDataStep
public void setInitialized(boolean value)
setInitialized
in interface jadex.bridge.service.types.dht.IDistributedKVStoreService
public boolean isInitialized()
isInitialized
in interface jadex.bridge.service.types.dht.IDistributedKVStoreService
public void onServiceStarted()
public void setRingService(jadex.bridge.service.types.dht.IRingApplicationService ring)
setRingService
in interface jadex.bridge.service.types.dht.IDistributedKVStoreService
ring
- the new ringNodepublic jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> put(java.lang.String key, java.lang.Object value)
put
in interface jadex.bridge.service.types.dht.IDistributedKVStoreService
key
- The Key.value
- The Value.public jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> add(java.lang.String key, java.lang.Object value)
add
in interface jadex.bridge.service.types.dht.IDistributedKVStoreService
key
- The Key.value
- The Value to add.protected jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> store(java.lang.String key, java.lang.Object value, boolean addToCollection)
protected jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> store(jadex.bridge.service.types.dht.IID hash, java.lang.String key, java.lang.Object value, boolean addToCollection)
protected jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> storeLocal(jadex.bridge.service.types.dht.IID hash, java.lang.String key, java.lang.Object value, boolean addToCollection)
hash
- The hashkey
- The keyvalue
- The valuepublic jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IID> lookupResponsibleStore(java.lang.String key)
lookupResponsibleStore
in interface jadex.bridge.service.types.dht.IDistributedKVStoreService
key
- Requested key.public jadex.commons.future.IFuture<?> lookup(java.lang.String key)
lookup
in interface jadex.bridge.service.types.dht.IDistributedKVStoreService
key
- Requested key.public jadex.commons.future.IFuture<?> lookup(java.lang.String key, jadex.bridge.service.types.dht.IID idHash)
lookup
in interface jadex.bridge.service.types.dht.IDistributedKVStoreService
key
- Requested key.idHash
- The hashed key to find the corresponding node.public jadex.commons.future.IFuture<java.util.Set<java.lang.String>> getLocalKeySet()
getLocalKeySet
in interface jadex.bridge.service.types.dht.IDistributedKVStoreService
public jadex.commons.future.IFuture<java.util.Collection<jadex.bridge.service.types.dht.StoreEntry>> pullEntries(jadex.bridge.service.types.dht.IID targetNodeId)
pullEntries
in interface jadex.bridge.service.types.dht.IDistributedKVStoreService
targetNodeId
- public jadex.commons.future.IFuture<java.lang.Void> pushEntries(java.util.Collection<jadex.bridge.service.types.dht.StoreEntry> entries)
pushEntries
in interface jadex.bridge.service.types.dht.IDistributedKVStoreService
public jadex.commons.future.IFuture<jadex.bridge.service.types.dht.IDistributedKVStoreService> getStoreService(jadex.bridge.service.types.dht.IFinger finger)
finger
- IDistributedKVStoreService
public void disableSchedules()
disableSchedules
in interface jadex.bridge.service.types.dht.IDistributedKVStoreDebugService
public jadex.commons.future.IFuture<java.lang.Void> checkData()
checkData
in interface jadex.bridge.service.types.dht.IDistributedKVStoreDebugService
protected void eventReceived(jadex.bridge.service.types.dht.RingNodeEvent event)
event
- protected void log(java.lang.String message)