GigaSpaces XAP 7.0 API

org.openspaces.events.polling.receive
Class AbstractNonBlockingReceiveOperationHandler

java.lang.Object
  extended by org.openspaces.events.polling.receive.AbstractNonBlockingReceiveOperationHandler
All Implemented Interfaces:
ReceiveOperationHandler
Direct Known Subclasses:
ExclusiveReadReceiveOperationHandler, MultiExclusiveReadReceiveOperationHandler, MultiReadReceiveOperationHandler, MultiTakeReceiveOperationHandler, SingleReadReceiveOperationHandler, SingleTakeReceiveOperationHandler

public abstract class AbstractNonBlockingReceiveOperationHandler
extends Object
implements ReceiveOperationHandler

Support class to perform either non blocking or blocking receive operation.

Author:
kimchy

Constructor Summary
AbstractNonBlockingReceiveOperationHandler()
           
 
Method Summary
protected abstract  Object doReceiveBlocking(Object template, GigaSpace gigaSpace, long receiveTimeout)
          Performs a receive operations in a blocking manner.
protected abstract  Object doReceiveNonBlocking(Object template, GigaSpace gigaSpace)
          Performs a receive operations in a non blocking manner.
 Object receive(Object template, GigaSpace gigaSpace, long receiveTimeout)
          Performs the receive operation.
 void setNonBlocking(boolean nonBlocking)
          Allows to configure the take operation to be performed in a non blocking manner.
 void setNonBlockingFactor(int nonBlockingFactor)
          The factor (number of times) to perform the receive operation when working in non blocking mode within the given receive timeout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractNonBlockingReceiveOperationHandler

public AbstractNonBlockingReceiveOperationHandler()
Method Detail

setNonBlocking

public void setNonBlocking(boolean nonBlocking)
Allows to configure the take operation to be performed in a non blocking manner.

If configured to use non blocking, will perform setNonBlockingFactor(int) number of non blocking operations (default to 10) within the receive timeout.


setNonBlockingFactor

public void setNonBlockingFactor(int nonBlockingFactor)
The factor (number of times) to perform the receive operation when working in non blocking mode within the given receive timeout. Defaults to 10.


receive

public Object receive(Object template,
                      GigaSpace gigaSpace,
                      long receiveTimeout)
               throws DataAccessException
Performs the receive operation. If blocking, we call doReceiveBlocking(Object,org.openspaces.core.GigaSpace,long) and expect it to block for the receive timeout (or until a match is found). If non blocking, will perform setNonBlockingFactor(int) number of doReceiveNonBlocking(Object,org.openspaces.core.GigaSpace) operations within the receive timeout (default factor is 10).

Specified by:
receive in interface ReceiveOperationHandler
Parameters:
template - The template to use for the receive operation.
gigaSpace - The GigaSpace interface to perform the receive operations with
receiveTimeout - Receive timeout value
Returns:
The receive result. null indicating no receive occurred. Single object or an array of objects indicating the receive operation result.
Throws:
DataAccessException

doReceiveBlocking

protected abstract Object doReceiveBlocking(Object template,
                                            GigaSpace gigaSpace,
                                            long receiveTimeout)
                                     throws DataAccessException
Performs a receive operations in a blocking manner.

Throws:
DataAccessException

doReceiveNonBlocking

protected abstract Object doReceiveNonBlocking(Object template,
                                               GigaSpace gigaSpace)
                                        throws DataAccessException
Performs a receive operations in a non blocking manner.

Throws:
DataAccessException

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.