public interface GridSpiContext
| Modifier and Type | Method and Description |
|---|---|
void |
addLocalEventListener(GridLocalEventListener lsnr,
int... types)
Adds an event listener for local events.
|
void |
addMessageListener(GridMessageListener lsnr,
String topic)
Register a message listener to receive messages sent by remote nodes.
|
GridSecuritySubject |
authenticatedSubject(UUID subjId)
Gets security subject based on subject ID.
|
Collection<GridSecuritySubject> |
authenticatedSubjects()
Gets collection of authenticated subjects together with their permissions.
|
<K> boolean |
containsKey(String cacheName,
K key)
Returns
true if this cache contains a mapping for the specified key. |
void |
deregisterPort(int port,
GridPortProtocol proto)
Deregisters closed port.
|
void |
deregisterPorts()
Deregisters all closed ports.
|
<K,V> V |
get(String cacheName,
K key)
Gets object from cache.
|
boolean |
isEventRecordable(int... types)
Checks whether all provided event types are recordable.
|
GridNode |
localNode()
Gets local grid node.
|
GridNode |
node(UUID nodeId)
Gets a node instance based on its ID.
|
Collection<GridNode> |
nodes()
Gets a collection of all grid nodes.
|
int |
partition(String cacheName,
Object key)
Calculates partition number for given key.
|
boolean |
pingNode(UUID nodeId)
Pings a remote node.
|
<K,V> V |
put(String cacheName,
K key,
V val,
long ttl)
Puts object in cache.
|
<K,V> V |
putIfAbsent(String cacheName,
K key,
V val,
long ttl)
Puts object into cache if there was no previous object associated with
given key.
|
boolean |
readDelta(UUID nodeId,
Class<?> msgCls,
ByteBuffer buf)
Reads delta for provided node and message type.
|
<T> T |
readFromOffheap(String spaceName,
int part,
Object key,
byte[] keyBytes,
ClassLoader ldr)
Reads object from off-heap.
|
<T> T |
readFromSwap(String spaceName,
GridSwapKey key,
ClassLoader ldr)
Reads object from swap.
|
void |
recordEvent(GridEvent evt)
Records local event.
|
void |
registerPort(int port,
GridPortProtocol proto)
Registers open port.
|
Collection<GridNode> |
remoteNodes()
Gets a collection of remote grid nodes.
|
<K,V> V |
remove(String cacheName,
K key)
Removes object from cache.
|
boolean |
removeFromOffheap(String spaceName,
int part,
Object key,
byte[] keyBytes)
Removes data from off-heap memory.
|
void |
removeFromSwap(String spaceName,
Object key,
ClassLoader ldr)
Removes object from swap.
|
boolean |
removeLocalEventListener(GridLocalEventListener lsnr)
Removes local event listener.
|
boolean |
removeMessageListener(GridMessageListener lsnr,
String topic)
Removes a previously registered message listener.
|
void |
send(GridNode node,
Serializable msg,
String topic)
Sends a message to a remote node.
|
GridNodeValidationResult |
validateNode(GridNode node)
Validates that new node can join grid topology, this method is called on coordinator
node before new node joins topology.
|
boolean |
writeDelta(UUID nodeId,
Class<?> msgCls,
ByteBuffer buf)
Writes delta for provided node and message type.
|
void |
writeToOffheap(String spaceName,
int part,
Object key,
byte[] keyBytes,
Object val,
byte[] valBytes,
ClassLoader ldr)
Writes data to off-heap memory.
|
void |
writeToSwap(String spaceName,
Object key,
Object val,
ClassLoader ldr)
Writes object to swap.
|
Collection<GridNode> remoteNodes()
GridDiscoverySpi implementation used. Unlike nodes(),
this method does not include local grid node.localNode(),
nodes(),
GridDiscoverySpiCollection<GridNode> nodes()
GridDiscoverySpi implementation used. Unlike remoteNodes(),
this method does include local grid node.localNode(),
remoteNodes(),
GridDiscoverySpiGridNode localNode()
GridDiscoverySpi
implementation used.GridDiscoverySpi@Nullable GridNode node(UUID nodeId)
nodeId - ID of a node to get.null is such not has not been discovered.GridDiscoverySpiboolean pingNode(UUID nodeId)
GridDiscoverySpi.pingNode(UUID) implementation.
Discovery SPIs usually have some latency in discovering failed nodes. Hence, communication to remote nodes may fail at times if an attempt was made to establish communication with a failed node. This method can be used to check if communication has failed due to node failure or due to some other reason.
nodeId - ID of a node to ping.true if node for a given ID is alive, false otherwise.GridDiscoverySpivoid send(GridNode node, Serializable msg, String topic) throws GridSpiException
GridCommunicationSpi implementation used.node - Node to send a message to.msg - Message to send.topic - Topic to send message to.GridSpiException - If failed to send a message to remote node.void addMessageListener(GridMessageListener lsnr, String topic)
GridCommunicationSpi implementation used.
This method can be used by jobs to communicate with other nodes in the grid. Remote nodes
can send messages by calling send(GridNode, Serializable, String) method.
lsnr - Message listener to register.topic - Topic to register listener for.boolean removeMessageListener(GridMessageListener lsnr, String topic)
lsnr - Message listener to remove.topic - Topic to unregister listener for.true of message listener was removed, false if it was not
previously registered.void addLocalEventListener(GridLocalEventListener lsnr, int... types)
lsnr - Event listener for local events.types - Optional types for which this listener will be notified. If no types are provided
this listener will be notified for all local events.GridEventboolean removeLocalEventListener(GridLocalEventListener lsnr)
lsnr - Local event listener to remove.true if listener was removed, false otherwise.boolean isEventRecordable(int... types)
types - Event types to check.void recordEvent(GridEvent evt)
evt - Local grid event to record.void registerPort(int port,
GridPortProtocol proto)
port - Port.proto - Protocol.void deregisterPort(int port,
GridPortProtocol proto)
port - Port.proto - Protocol.void deregisterPorts()
@Nullable <K,V> V get(String cacheName, K key) throws GridException
cacheName - Cache name.key - Object key.GridException - Thrown if any exception occurs.@Nullable <K,V> V put(String cacheName, K key, V val, long ttl) throws GridException
K - Key type.V - Value type.cacheName - Cache name.key - Object key.val - Cached object.ttl - Time to live, 0 means the entry will never expire.null.GridException - Thrown if any exception occurs.@Nullable <K,V> V putIfAbsent(String cacheName, K key, V val, long ttl) throws GridException
K - Cache key type.V - Cache value type.cacheName - Cache name.key - Cache key.val - Cache value.ttl - Time to live.null if there was no value for given key.GridException - If put failed.@Nullable <K,V> V remove(String cacheName, K key) throws GridException
K - Key type.V - Value type.cacheName - Cache name.key - Object key.null.GridException - Thrown if any exception occurs.<K> boolean containsKey(String cacheName, K key)
true if this cache contains a mapping for the specified key.K - Key type.cacheName - Cache name.key - Object key.true if this cache contains a mapping for the specified key.void writeToSwap(String spaceName, Object key, @Nullable Object val, @Nullable ClassLoader ldr) throws GridException
spaceName - Swap space name.key - Key.val - Value.ldr - Class loader (optional).GridException - If any exception occurs.@Nullable <T> T readFromSwap(String spaceName, GridSwapKey key, @Nullable ClassLoader ldr) throws GridException
spaceName - Swap space name.key - Key.ldr - Class loader (optional).GridException - If any exception occurs.@Nullable <T> T readFromOffheap(@Nullable String spaceName, int part, Object key, @Nullable byte[] keyBytes, @Nullable ClassLoader ldr) throws GridException
spaceName - Off-heap space name.part - Partition.key - Key.keyBytes - Key bytes.ldr - Class loader for unmarshalling.GridException - If failed.void writeToOffheap(@Nullable String spaceName, int part, Object key, @Nullable byte[] keyBytes, Object val, @Nullable byte[] valBytes, @Nullable ClassLoader ldr) throws GridException
spaceName - Off-heap space name.part - Partition.key - Key.keyBytes - Optional key bytes.val - Value.valBytes - Optional value bytes.ldr - Class loader.GridException - If failed.boolean removeFromOffheap(@Nullable String spaceName, int part, Object key, @Nullable byte[] keyBytes) throws GridException
spaceName - Off-heap space name.part - Partition.key - Key.keyBytes - Optional key bytes.true If succeeded.GridException - If failed.int partition(String cacheName, Object key)
cacheName - Cache name.key - Key.void removeFromSwap(String spaceName, Object key, @Nullable ClassLoader ldr) throws GridException
spaceName - Swap space name.key - Key.ldr - Class loader (optional).GridException - If any exception occurs.@Nullable GridNodeValidationResult validateNode(GridNode node)
node - Joining node.null in case of success.boolean writeDelta(UUID nodeId, Class<?> msgCls, ByteBuffer buf)
nodeId - Node ID.msgCls - Message type.buf - Buffer to write to.boolean readDelta(UUID nodeId, Class<?> msgCls, ByteBuffer buf)
nodeId - Node ID.msgCls - Message type.buf - Buffer to read from.Collection<GridSecuritySubject> authenticatedSubjects() throws GridException
GridExceptionGridSecuritySubject authenticatedSubject(UUID subjId) throws GridException
subjId - Subject ID.GridExceptionCopyright © 2014. All rights reserved.