|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface KeyAffinityService<K>
Defines a service that generates keys to be mapped to specific nodes in a distributed(vs. replicated) cluster.
The service is instantiated through through one of the factory methods from KeyAffinityServiceFactory
.
Cache>String,Long< cache = getDistributedCache();
KeyAffinityService<String> service = KeyAffinityServiceFactory.newKeyAffinityService(cache, 100);
...
String sessionId = sessionObject.getId();
String newCollocatedSession = service.getCollocatedKey(sessionId);
//this will reside on the same node in the cluster
cache.put(newCollocatedSession, someInfo);
Uniqueness: the service does not guarantee that the generated keys are unique. It relies on an
KeyGenerator
for obtaining and distributing the generated keys. If key uniqueness is
needed that should be enforced in the generator.
The service might also drop key generated through the KeyGenerator
.
KeyAffinityServiceFactory
Method Summary | |
---|---|
K |
getCollocatedKey(K otherKey)
Returns a key that will be distributed on the same node as the supplied key. |
K |
getKeyForAddress(Address address)
Returns a key that will be distributed on the cluster node identified by address. |
boolean |
isStarted()
Checks weather or not the service is started. |
Methods inherited from interface org.infinispan.lifecycle.Lifecycle |
---|
start, stop |
Method Detail |
---|
K getKeyForAddress(Address address)
address
- identifying the cluster node.
IllegalStateException
- if the service has not been started or it is shutdownK getCollocatedKey(K otherKey)
otherKey
- the key for which we need a collocation
IllegalStateException
- if the service has not been started or it is shutdownboolean isStarted()
|
--> | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |