GridGain™ 2.1.0
Java API Specification

org.gridgain.grid
Annotation Type GridTaskSpis


@Documented
@Retention(value=RUNTIME)
@Target(value=TYPE)
@Apache20LicenseCompatible
public @interface GridTaskSpis

This annotation allows task to specify what SPIs it wants to use. Starting with GridGain 2.1 you can start multiple instances of GridTopologySpi, GridLoadBalancingSpi, GridFailoverSpi, and GridCheckpointSpi. If you do that, you need to tell a task which SPI to use (by default it will use the fist SPI in the list).

Example

This example shows how to configure different SPI's for different tasks. Let's assume that you have two worker nodes, Node1 and Node2. Let's also assume that you configure Node1 to belong to SegmentA and Node2 to belong to SegmentB. Here is a sample configuration for Node1
 <bean id="grid.cfg" class="org.gridgain.grid.GridConfigurationAdapter" scope="singleton">
     <property name="userAttributes">
         <map>
             <entry key="segment" value="A"/>
         </map>
     </property>
 </bean>
 
Node2 configuration looks similar to Node1 with 'segment' attribute set to 'B'.
 <bean id="grid.cfg" class="org.gridgain.grid.GridConfigurationAdapter" scope="singleton">
     <property name="userAttributes">
         <map>
             <entry key="segment" value="B"/>
         </map>
     </property>
 </bean>
 
Now, if you have Task1 and Task2 starting from some master node NodeM, you can easily configure Task1 to only run on SegmentA and Task2 to only run on SegmentB. Here is how configuration on master node NodeM would look like:
 <bean id="grid.cfg" class="org.gridgain.grid.GridConfigurationAdapter" scope="singleton">
     <!--
         Topology SPIs. We have two named SPIs: One picks up nodes
         that have attribute "segment" set to "A" and another one sees
         nodes that have attribute "segment" set to "B".
     -->
     <property name="topologySpi">
         <list>
             <bean class="org.gridgain.grid.spi.topology.nodefilter.GridNodeFilterTopologySpi">
                 <property name="name" value="topologyA"/>
                 <property name="filter">
                     <bean class="org.gridgain.grid.GridJexlNodeFilter">
                         <property name="expression" value="node.attributes['segment'] == 'A'"/>
                     </bean>
                 </property>
             </bean>
             <bean class="org.gridgain.grid.spi.topology.nodefilter.GridNodeFilterTopologySpi">
                 <property name="name" value="topologyB"/>
                 <property name="filter">
                     <bean class="org.gridgain.grid.GridJexlNodeFilter">
                         <property name="expression" value="node.attributes['segment'] == 'B'"/>
                     </bean>
                 </property>
             </bean>
         </list>
     </property>
 </bean>
 
Then your Task1 and Task2 would look as follows (note the @GridTaskSpis annotation).
 @GridTaskSpis(topologySpi="topologyA")
 public class GridSegmentATask extends GridTaskSplitAdapter<String, Integer> {
 ...
 }
 
and
 @GridTaskSpis(topologySpi="topologyB")
 public class GridSegmentBTask extends GridTaskSplitAdapter<String, Integer> {
 ...
 }
 




See Also:

  Documentation
  Email Support
  Online Forums
  Issue Tracking

Author:   2005-2008 Copyright © GridGain Systems. All Rights Reserved. ver. 2.1.0

 

Optional Element Summary
 String checkpointSpi
          Optional checkpoint SPI name.
 String failoverSpi
          Optional failover SPI name.
 String loadBalancingSpi
          Optional load balancing SPI name.
 String topologySpi
          Optional topology SPI name.
 

loadBalancingSpi

public abstract String loadBalancingSpi
Optional load balancing SPI name. By default, SPI name is equal to the name of the SPI class. You can change SPI name by explicitely supplying GridSpi.getName() parameter in grid configuration.

Default:
""

failoverSpi

public abstract String failoverSpi
Optional failover SPI name. By default, SPI name is equal to the name of the SPI class. You can change SPI name by explicitely supplying GridSpi.getName() parameter in grid configuration.

Default:
""

topologySpi

public abstract String topologySpi
Optional topology SPI name. By default, SPI name is equal to the name of the SPI class. You can change SPI name by explicitely supplying GridSpi.getName() parameter in grid configuration.

Default:
""

checkpointSpi

public abstract String checkpointSpi
Optional checkpoint SPI name. By default, SPI name is equal to the name of the SPI class. You can change SPI name by explicitely supplying GridSpi.getName() parameter in grid configuration.

Default:
""

GridGain™ 2.1.0
Java API Specification

GridGain™ - Grid Computing Made Simple, ver. 2.1.0.19122008
2005-2008 Copyright © GridGain Systems. All Rights Reserved.