Show / Hide Table of Contents

# Interface IClusterGroup

Defines grid projection which represents a common functionality over a group of nodes. Grid projection allows to group Ignite nodes into various subgroups to perform distributed operations on them. All 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 grid projections:

    var g = Ignition.GetIgnite();

    // Projection over remote nodes.
    var remoteNodes = g.ForRemotes();

    // Projection over random remote node.
    var randomNode = g.ForRandom();

    // Projection over all nodes with cache named "myCache" enabled.
    var cacheNodes = g.ForCacheNodes("myCache");

    // Projection over all nodes that have user attribute "group" set to value "worker".
    var workerNodes = g.ForAttribute("group", "worker");

Grid projection provides functionality for executing tasks and closures over nodes in this projection using GetCompute().

All members are thread-safe and may be used concurrently from multiple threads.

###### Namespace: Apache.Ignite.Core.Cluster

###### Assembly: Apache.Ignite.Core.dll

##### Syntax

    public interface IClusterGroup

### Properties

#### Ignite

Instance of Ignite.

##### Declaration

    IIgnite Ignite { get; }

##### Property Value

Type | Description
--- | ---
IIgnite |

### Methods

#### ClearStatistics(IEnumerable<String>)

Clears statistics for caches cluster wide.

##### Declaration

    void ClearStatistics(IEnumerable<string> caches)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Collections.Generic.IEnumerable<System.String> | caches | Collection of cache names.

#### EnableStatistics(IEnumerable<String>, Boolean)

Sets statistics enabled flag globally for the caches

##### Declaration

    void EnableStatistics(IEnumerable<string> cacheNames, bool enabled)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Collections.Generic.IEnumerable<System.String> | cacheNames | Collection of cache names to set the flag
System.Boolean | enabled | Enabled flag

#### ForAttribute(String, String)

Creates projection for nodes containing given name and value specified in user attributes.

##### Declaration

    IClusterGroup ForAttribute(string name, string val)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | name | Name of the attribute.
System.String | val | Optional attribute value to match.

##### Returns

Type | Description
--- | ---
IClusterGroup | Grid projection for nodes containing specified attribute.

#### ForCacheNodes(String)

Creates projection for all nodes that have cache with specified name running.

##### Declaration

    IClusterGroup ForCacheNodes(string name)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | name | Cache name to include into projection.

##### Returns

Type | Description
--- | ---
IClusterGroup | Projection over nodes that have specified cache running.

#### ForClientNodes(String)

Creates projection for all nodes that have cache with specified name running and cache distribution mode is CLIENT_ONLY or NEAR_ONLY.

##### Declaration

    IClusterGroup ForClientNodes(string name)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | name | Cache name to include into projection.

##### Returns

Type | Description
--- | ---
IClusterGroup | Projection over nodes that have specified cache running.

#### ForDaemons()

Gets a cluster group consisting of the daemon nodes.

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 cluster group. 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 Ignite and needs to participate in the topology, but also needs to be excluded from the "normal" topology, so that it won't participate in the task execution or in-memory data grid storage.

##### Declaration

    IClusterGroup ForDaemons()

##### Returns

Type | Description
--- | ---
IClusterGroup | Cluster group consisting of the daemon nodes.

#### ForDataNodes(String)

Creates projection for all nodes that have cache with specified name running and cache distribution mode is PARTITIONED_ONLY or NEAR_PARTITIONED.

##### Declaration

    IClusterGroup ForDataNodes(string name)

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | name | Cache name to include into projection.

##### Returns

Type | Description
--- | ---
IClusterGroup | Projection over nodes that have specified cache running.

#### ForDotNet()

Creates grid projection for nodes supporting .Net, i.e. for nodes started with Apache.Ignite.exe.

##### Declaration

    IClusterGroup ForDotNet()

##### Returns

Type | Description
--- | ---
IClusterGroup | Grid projection for nodes supporting .Net.

#### ForHost(IClusterNode)

Gets grid projection consisting from the nodes in this projection residing on the same host as given node.

##### Declaration

    IClusterGroup ForHost(IClusterNode node)

##### Parameters

Type | Name | Description
--- | --- | ---
IClusterNode | node | Node residing on the host for which projection is created.

##### Returns

Type | Description
--- | ---
IClusterGroup | Projection for nodes residing on the same host as passed in node.

#### ForNodeIds(IEnumerable<Guid>)

Creates a grid projection over a given set of node IDs.

##### Declaration

    IClusterGroup ForNodeIds(IEnumerable<Guid> ids)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Collections.Generic.IEnumerable<System.Guid> | ids | Collection of node IDs to create a projection from.

##### Returns

Type | Description
--- | ---
IClusterGroup | Projection over provided Ignite node IDs.

#### ForNodeIds(Guid[])

Creates a grid projection over a given set of node IDs.

##### Declaration

    IClusterGroup ForNodeIds(params Guid[] ids)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Guid[] | ids | Collection of node IDs to create a projection from.

##### Returns

Type | Description
--- | ---
IClusterGroup | Projection over provided Ignite node IDs.

#### ForNodes(IClusterNode[])

Creates a grid projection over a given set of nodes.

##### Declaration

    IClusterGroup ForNodes(params IClusterNode[] nodes)

##### Parameters

Type | Name | Description
--- | --- | ---
IClusterNode[] | nodes | Collection of nodes to create a projection from.

##### Returns

Type | Description
--- | ---
IClusterGroup | Projection over provided Ignite nodes.

#### ForNodes(IEnumerable<IClusterNode>)

Creates a grid projection over a given set of nodes.

##### Declaration

    IClusterGroup ForNodes(IEnumerable<IClusterNode> nodes)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Collections.Generic.IEnumerable<IClusterNode> | nodes | Collection of nodes to create a projection from.

##### Returns

Type | Description
--- | ---
IClusterGroup | Projection over provided Ignite nodes.

#### ForOldest()

Creates grid projection with one oldest node in the current projection. The resulting projection is dynamic and will always pick the next oldest node if the previous one leaves topology even after the projection has been created.

##### Declaration

    IClusterGroup ForOldest()

##### Returns

Type | Description
--- | ---
IClusterGroup | Grid projection with one oldest node from the current projection.

#### ForPredicate(Func<IClusterNode, Boolean>)

Creates a grid projection which includes all nodes that pass the given predicate filter.

##### Declaration

    IClusterGroup ForPredicate(Func<IClusterNode, bool> p)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Func<IClusterNode, System.Boolean> | p | Predicate filter for nodes to include into this projection.

##### Returns

Type | Description
--- | ---
IClusterGroup | Grid projection for nodes that passed the predicate filter.

#### ForRandom()

Creates grid projection with one random node from current projection.

##### Declaration

    IClusterGroup ForRandom()

##### Returns

Type | Description
--- | ---
IClusterGroup | Grid projection with one random node from current projection.

#### ForRemotes()

Gets grid projection consisting from the nodes in this projection excluding the local node.

##### Declaration

    IClusterGroup ForRemotes()

##### Returns

Type | Description
--- | ---
IClusterGroup | Grid projection consisting from the nodes in this projection excluding the local node.

#### ForServers()

Creates a cluster group of nodes started in server mode (ClientMode).

##### Declaration

    IClusterGroup ForServers()

##### Returns

Type | Description
--- | ---
IClusterGroup | Cluster group of nodes started in server mode.

#### ForYoungest()

Creates grid projection with one youngest node in the current projection. The resulting projection is dynamic and will always pick the newest node in the topology, even if more nodes entered after the projection has been created.

##### Declaration

    IClusterGroup ForYoungest()

##### Returns

Type | Description
--- | ---
IClusterGroup | Grid projection with one youngest node from the current projection.

#### GetCompute()

Gets compute functionality over this grid projection. All operations on the returned ICompute instance will only include nodes from this projection.

##### Declaration

    ICompute GetCompute()

##### Returns

Type | Description
--- | ---
ICompute | Compute instance over this grid projection.

#### GetEvents()

Gets events facade over nodes within this cluster group. All operations on the returned IEvents> instance will only include nodes from current cluster group.

##### Declaration

    IEvents GetEvents()

##### Returns

Type | Description
--- | ---
IEvents | Events instance over this cluster group.

#### GetMessaging()

Gets messaging facade over nodes within this cluster group. All operations on the returned IMessaging> instance will only include nodes from current cluster group.

##### Declaration

    IMessaging GetMessaging()

##### Returns

Type | Description
--- | ---
IMessaging | Messaging instance over this cluster group.

#### GetMetrics()

Gets a metrics snapshot for this projection

##### Declaration

    IClusterMetrics GetMetrics()

##### Returns

Type | Description
--- | ---
IClusterMetrics | Grid projection metrics snapshot.

#### GetNode()

Gets first node from the list of nodes in this projection.

##### Declaration

    IClusterNode GetNode()

##### Returns

Type | Description
--- | ---
IClusterNode | Node.

#### GetNode(Guid)

Gets a node for given ID from this grid projection.

##### Declaration

    IClusterNode GetNode(Guid id)

##### Parameters

Type | Name | Description
--- | --- | ---
System.Guid | id | Node ID.

##### Returns

Type | Description
--- | ---
IClusterNode | Node with given ID from this projection or null if such node does not exist in this projection.

#### GetNodes()

Gets read-only collections of nodes in this projection.

##### Declaration

    ICollection<IClusterNode> GetNodes()

##### Returns

Type | Description
--- | ---
System.Collections.Generic.ICollection<IClusterNode> | All nodes in this projection.

#### GetServices()

Gets services facade over nodes within this cluster group. All operations on the returned IServices> instance will only include nodes from current cluster group.

##### Declaration

    IServices GetServices()

##### Returns

Type | Description
--- | ---
IServices | Services instance over this cluster group.