IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

com.ibm.websphere.objectgrid.datagrid
Interface ReduceGridAgent

All Superinterfaces:
Serializable

public interface ReduceGridAgent
extends Serializable

A ReduceGridAgent is used to process a set of entries and reduce them to a single result.

An agent is submitted using an ObjectMap's AgentManager and is run on the server ObjectGrid instances that host the data in the map. The agent is routed to one or more server instances based on the partitions that the optional keys resolve to. If the map is associated with an entity, then the provided key should be an entity instance and the keys returned from processAllEntries map should be an entity with at least all the key attributes populated. Agent implementations should implement the EntityAgentMixin interface to allow automatic key to entity conversion.

ReduceGridAgents are invoked in a separate, independent transaction from the client's transaction. A single client request may result in multiple transactions. This can happen if the ObjectGrid processes a thousand keys using 10 transactions on 10 threads for example, 100 keys per thread.

Keys are processed in arbitrary order sequentially or in parallel and may be grouped into one or more transactions. Agents may run more than once for a key if a subsequent agent call fails in the same transaction, however an agent will only commit a successful process call one time.

Since:
WAS XD 6.1
See Also:
EntityAgentMixin

Method Summary
 Object reduce(Session s, ObjectMap map)
          This method is called on each partition.
 Object reduce(Session s, ObjectMap map, Collection keys)
          The method should reduce the entries referenced by the key collection to a single value.
 Object reduceResults(Collection results)
          This is called when further reduction is needed.
 

Method Detail

reduce

Object reduce(Session s,
              ObjectMap map,
              Collection keys)
The method should reduce the entries referenced by the key collection to a single value. An example would be a method that returns an average value for an attribute in a collection of objects. Transactions are managed by the caller. Any exception results in a rollback. If this map is associated with an entity, then a collection of populated entities are provided to the collection instead Tuple keys. The class used for the entity is identified using the EntityAgentMixin interface.

Parameters:
s - The Session to use for any work. Transactions are controlled by the caller.
map - The ObjectMap this agent was invoked for.
keys - The collection of keys or entities whose values should be reduced.
Returns:
The reduced value calculated from processing the entries specified.

reduce

Object reduce(Session s,
              ObjectMap map)
This method is called on each partition. The Agent may have extra state including possible a query to eliminate some partition entries.

Parameters:
s - The Session to use for any work. Transactions are controlled by the caller.
map - The ObjectMap this agent was invoked for
Returns:
The single value calculated from processing the entries for the partition.

reduceResults

Object reduceResults(Collection results)
This is called when further reduction is needed.

Parameters:
results - the intermediate results to reduce.
Returns:
The single value calculated from processing the intermediate results.

IBM WebSphereTM eXtreme Scale, Release 8.6
API Specification

© Copyright International Business Machines Corp 2005,2012. All rights reserved.