@Documented @Retention(value=RUNTIME) @Target(value=METHOD) public @interface GridifySetToSet
GridifySetToSet
annotation allows to grid-enable existing code with specific semantics.
This annotation can be applied to any public method that needs to be grid-enabled, static or non-static. When this annotation is applied to a method, the method execution is considered to be grid-enabled. In general, the execution of this method can be transferred to another node in the grid, potentially splitting it into multiple subtasks to be executed in parallel on multiple grid nodes. But from the caller perspective this method still looks and behaves like a local apply. This is achieved by utilizing AOP-based interception of the annotated code and injecting all the necessary grid logic into the method execution.
GridifySetToSet
used as extended version of Gridify
annotation.
It provides automated gridification of two popular types of mathematical
functions that allow for "embarrassingly" simple parallelization (for example,
find prime numbers in collection or find maximum in collection). The goal of this
annotation is to provide very simple and easy to use ForkJoin gridification
for some often used use cases. Note that in a standard Gridify
annotation
the user has to write ComputeTask
to provide ForkJoin behavior.
In a proposed design - the ForkJoin will be achieved automatically.
Let F be the function or a method in Java language and St be a set of values
of type t
or a typed Collection<T> in Java. Let also R
be
the result value. These are the types of functions that will be supported (defined in
terms of their properties):
F (S 1, S 2, ..., S k) => {R 1, R 2, ..., R n,}, where F (S 1, S 2, ..., S k) == {F (S 1), F (S 2), ..., F (S k)}
which defines a function whose result can be constructed as concatenation of results
of the same function applied to subsets of the original set.
In definition above we used Collection<T> for the purpose of example. The following Java types and their subtypes will have to be supported as return values or method parameters:
Note that when using @GridifySetToSet
annotation the state of the whole instance will be
serialized and sent out to remote node. Therefore the class must implement
Serializable
interface. If you cannot make the class Serializable
,
then you must implement custom grid task which will take care of proper state
initialization. In either case, Ignite must be able to serialize the state passed to remote node.
Example for these types of functions would be any function that is looking for a subset of data in a given input collection. For example:
... @GridifySetToSet(threshold = 2) public static Collection<Number> findAllPrimeNumbers(Collection<Number> input) {...} ...This function searches all elements in the input collection and returns another collection containing only prime numbers found in the original collection. We can split this collection into two sub-collection, find primes in each - and then simply concatenate two collections to get the final set of all primes.
The formal definition of (or requirement for) such method:
-javaagent:[path to jboss-aop-jdk50-4.x.x.jar]
-Djboss.aop.class.path=[path to ignite.jar]
-Djboss.aop.exclude=org,com -Djboss.aop.include=org.apache.ignite.examples
javassist-3.x.x.jar
jboss-aop-jdk50-4.x.x.jar
jboss-aspect-library-jdk50-4.x.x.jar
jboss-common-4.x.x.jar
trove-1.0.2.jar
-javaagent:${IGNITE_HOME}/libs/aspectjweaver-1.7.2.jar
GridifySpringEnhancer.enhance(java.lang.Object)
for the object
that has method with GridifySetToSet
annotation.
Note that this method of weaving is rather inconvenient and AspectJ or JBoss AOP is recommended over it. Spring AOP can be used in situation when code augmentation is undesired and cannot be used. It also allows for very fine grained control of what gets weaved.
Modifier and Type | Optional Element and Description |
---|---|
String |
gridName
Deprecated.
Use
igniteInstanceName() . Nonempty igniteInstanceName() takes precedence. |
String |
igniteInstanceName
Name of the Ignite instance to use.
|
Class<? extends GridifyInterceptor> |
interceptor
Optional interceptor class.
|
Class<? extends GridifyNodeFilter> |
nodeFilter
Optional node filter to filter nodes participated in job split.
|
int |
splitSize
Optional parameter that defines a split size.
|
int |
threshold
Optional parameter that defines the minimal value below which the
execution will NOT be grid-enabled.
|
long |
timeout
Optional gridify task execution timeout.
|
public abstract Class<? extends GridifyNodeFilter> nodeFilter
public abstract long timeout
0
which indicates that task will not timeout.public abstract int threshold
public abstract int splitSize
This value should be greater than zero and can be less, equal or greater than threshold()
value. In most cases, however, the optimal value for the split size is the threshold()
value.
For example, if input collection size is 100, number of nodes 10 and split size is set to 5 - Ignition
will submit 2 sub-collections of 5 elements each to each node (provided in order by load
balancing SPI).
By default (when split size is zero) - Ignite will automatically determine the split size based on number of nodes and collection size - if collection size is available (not an iterator). If collection size cannot be determined - the split size will default to threshold. If threshold is not set - a runtime exception will be thrown.
public abstract Class<? extends GridifyInterceptor> interceptor
@Deprecated public abstract String gridName
igniteInstanceName()
. Nonempty igniteInstanceName()
takes precedence.Ignition
for information about named grids.
GridGain In-Memory Computing Platform : ver. 8.9.14 Release Date : November 5 2024