public interface GridProjection
Grid interface itself also extends GridProjection which makes
an instance of Grid a projection over all grid nodes.
'forXXX(...)' methods will create a child grid projection
from existing projection. If you create a new projection from current one, then the resulting
projection will include a subset of nodes from current projection. The following code snippet
shows how to create and nest grid projections:
Grid g = GridGain.grid();
// Projection over remote nodes.
GridProjection remoteNodes = g.forRemotes();
// Projection over random remote node.
GridProjection randomNode = remoteNodes.forRandom();
// Projection over all nodes with cache named "myCache" enabled.
GridProjection cacheNodes = g.forCache("myCache");
// Projection over all nodes that have user attribute "group" set to value "worker".
GridProjection workerNodes = g.forAttribute("group", "worker");
GridCompute - functionality for executing tasks and closures over nodes in this projection.GridMessaging - functionality for topic-based message exchange over nodes in this projection.GridEvents - functionality for querying and listening to events on nodes in this projection.| Modifier and Type | Method and Description |
|---|---|
GridCompute |
compute()
Gets
compute functionality over this grid projection. |
GridEvents |
events()
Gets
events functionality over this grid projection. |
GridProjection |
forAttribute(String name,
String val)
Creates projection for nodes containing given name and value
specified in user attributes.
|
GridProjection |
forCache(String cacheName,
String... cacheNames)
Creates projection for all nodes that have cache with specified name running.
|
GridProjection |
forDaemons()
Gets projection consisting from the daemon nodes in this projection.
|
GridProjection |
forHost(GridNode node)
Gets grid projection consisting from the nodes in this projection residing on the
same host as given node.
|
GridProjection |
forNode(GridNode node,
GridNode... nodes)
Creates a grid projection for the given node.
|
GridProjection |
forNodeId(UUID id,
UUID... ids)
Creates a grid projection for a node with specified ID.
|
GridProjection |
forNodeIds(Collection<UUID> ids)
Creates a grid projection over nodes with specified node IDs.
|
GridProjection |
forNodes(Collection<? extends GridNode> nodes)
Creates a grid projection over a given set of nodes.
|
GridProjection |
forOthers(GridNode node,
GridNode... nodes)
Creates a grid projection for nodes other than given nodes.
|
GridProjection |
forOthers(GridProjection prj)
Creates a grid projection for nodes not included into given projection.
|
GridProjection |
forPredicate(GridPredicate<GridNode> p)
Creates a grid projection which includes all nodes that pass the given predicate filter.
|
GridProjection |
forRandom()
Creates grid projection with one random node from current projection.
|
GridProjection |
forRemotes()
Gets grid projection consisting from the nodes in this projection excluding the local node.
|
GridProjection |
forStreamer(String streamerName,
String... streamerNames)
Creates projection for all nodes that have streamer with specified name running.
|
Grid |
grid()
Gets instance of grid.
|
GridMessaging |
message()
Gets
messaging functionality over this grid projection. |
GridProjectionMetrics |
metrics()
Gets a metrics snapshot for this projection.
|
GridNode |
node()
Gets first node from the list of nodes in this projection.
|
GridNode |
node(UUID nid)
Gets a node for given ID from this grid projection.
|
Collection<GridNode> |
nodes()
Gets read-only collections of nodes in this projection.
|
GridPredicate<GridNode> |
predicate()
Gets predicate that defines a subset of nodes for this projection.
|
Grid grid()
GridCompute compute()
compute functionality over this grid projection. All operations
on the returned GridCompute instance will only include nodes from
this projection.GridMessaging message()
messaging functionality over this grid projection. All operations
on the returned GridMessaging instance will only include nodes from
this projection.GridEvents events()
events functionality over this grid projection. All operations
on the returned GridEvents instance will only include nodes from
this projection.GridProjection forNodes(Collection<? extends GridNode> nodes)
nodes - Collection of nodes to create a projection from.GridProjection forNode(GridNode node, GridNode... nodes)
node - Node to get projection for.nodes - Optional additional nodes to include into projection.GridProjection forOthers(GridNode node, GridNode... nodes)
node - Node to exclude from new grid projection.nodes - Optional additional nodes to exclude from projection.GridProjection forOthers(GridProjection prj)
prj - Projection to exclude from new grid projection.GridProjection forNodeIds(Collection<UUID> ids)
ids - Collection of node IDs.GridProjection forNodeId(UUID id, UUID... ids)
id - Node ID to get projection for.ids - Optional additional node IDs to include into projection.GridProjection forPredicate(GridPredicate<GridNode> p)
p - Predicate filter for nodes to include into this projection.GridProjection forAttribute(String name, @Nullable String val)
User attributes for every node are optional and can be specified in
grid node configuration. See GridConfiguration.getUserAttributes()
for more information.
name - Name of the attribute.val - Optional attribute value to match.GridProjection forCache(String cacheName, @Nullable String... cacheNames)
cacheName - Cache name.cacheNames - Optional additional cache names to include into projection.GridProjection forStreamer(String streamerName, @Nullable String... streamerNames)
streamerName - Streamer name.streamerNames - Optional additional streamer names to include into projection.GridProjection forRemotes()
GridProjection forHost(GridNode node)
node - Node residing on the host for which projection is created.GridProjection forDaemons()
Daemon nodes are the usual grid nodes that participate in topology but not visible on the main APIs, i.e. they are not part of any projections. The only way to see daemon nodes is to use this method.
Daemon nodes are used primarily for management and monitoring functionality that is build on GridGain and needs to participate in the topology but also needs to be excluded from "normal" topology so that it won't participate in task execution or in-memory data grid storage.
GridProjection forRandom()
Collection<GridNode> nodes()
@Nullable GridNode node(UUID nid)
nid - Node ID.null if such node does not exist in this
projection.@Nullable GridNode node()
null if projection is empty.GridPredicate<GridNode> predicate()
GridProjectionMetrics metrics() throws GridException
GridException - If projection is empty.Copyright © 2014. All rights reserved.