org.objectweb.proactive.core.body.request
Class RequestQueueImpl

java.lang.Object
  extended byorg.objectweb.proactive.core.event.AbstractEventProducer
      extended byorg.objectweb.proactive.core.body.request.RequestQueueImpl
All Implemented Interfaces:
RequestQueue, java.io.Serializable
Direct Known Subclasses:
BlockingRequestQueueImpl

public class RequestQueueImpl
extends AbstractEventProducer
implements java.io.Serializable, RequestQueue

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.objectweb.proactive.core.event.AbstractEventProducer
AbstractEventProducer.ListenerList
 
Field Summary
protected  UniqueID ownerID
           
protected  CircularArrayList requestQueue
           
protected static boolean SEND_ADD_REMOVE_EVENT
           
 
Fields inherited from class org.objectweb.proactive.core.event.AbstractEventProducer
eventListeners, logger, shouldSerializeListeners
 
Constructor Summary
RequestQueueImpl(UniqueID ownerID)
           
 
Method Summary
 int add(Request request)
          Adds the given request to the end of the queue
 void addRequestQueueEventListener(RequestQueueEventListener listener)
           
 int addToFront(Request request)
          Adds the given request to the front of the queue before all other request already in the queue
 void clear()
           
 CircularArrayList getInternalQueue()
          Return the internal queue as a CircularArrayList
 Request getOldest()
          Returns the oldest request from the queue or null if the queue is empty Do not remove it from the queue
 Request getOldest(RequestFilter requestFilter)
          Returns the oldest request that matches the criteria defined by the given filter Do not remove it from the request line
 Request getOldest(java.lang.String methodName)
          Returns the oldest request whose method name is s or null if no match Do not remove it from the queue
 Request getYoungest()
          Returns the youngest request from the queue or null if the queue is empty Do not remove it from the request line
 Request getYoungest(RequestFilter requestFilter)
          Returns the youngest request that matches the criteria defined by the given filter Do not remove it from the request line
 Request getYoungest(java.lang.String methodName)
          Returns the youngest request whose method name is s or null if no match Do not remove it from the request line
 boolean hasRequest(java.lang.String s)
           
 boolean isEmpty()
           
 java.util.Iterator iterator()
          Returns an iterator over all the requests in the request queue.
protected  void notifyOneListener(ProActiveListener listener, ProActiveEvent event)
          Notifies one listener with the event.
 void processRequests(RequestProcessor processor, Body body)
          Processes all requests in the queue using the given RequestProcessor.
 Request removeOldest()
          Removes the oldest request from the queue and returns it Null is returned is the queue is empty
 Request removeOldest(RequestFilter requestFilter)
          Removes the oldest request that matches the criteria defined by the given filter Null is returned is no match
 Request removeOldest(java.lang.String methodName)
          Removes the oldest request whose method name is s and returns it.
 void removeRequestQueueEventListener(RequestQueueEventListener listener)
           
 Request removeYoungest()
          Removes the youngest request from the queue and returns it Null is returned is the queue is empty
 Request removeYoungest(RequestFilter requestFilter)
          Removes the youngest request that matches the criteria defined by the given filter Null is returned is no match
 Request removeYoungest(java.lang.String methodName)
          Removes the youngest request whose method name is s and returns it.
 int size()
           
 java.lang.String toString()
           
 
Methods inherited from class org.objectweb.proactive.core.event.AbstractEventProducer
addListener, hasListeners, notifyAllListeners, removeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

requestQueue

protected CircularArrayList requestQueue

ownerID

protected UniqueID ownerID

SEND_ADD_REMOVE_EVENT

protected static final boolean SEND_ADD_REMOVE_EVENT
See Also:
Constant Field Values
Constructor Detail

RequestQueueImpl

public RequestQueueImpl(UniqueID ownerID)
Method Detail

iterator

public java.util.Iterator iterator()
Description copied from interface: RequestQueue
Returns an iterator over all the requests in the request queue. It is up to the programmer to protect himself against any change in the request queue while using this iterator.

Specified by:
iterator in interface RequestQueue

getInternalQueue

public CircularArrayList getInternalQueue()
Description copied from interface: RequestQueue
Return the internal queue as a CircularArrayList

Specified by:
getInternalQueue in interface RequestQueue
Returns:
the internal queue as a CircularArrayList

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface RequestQueue

size

public int size()
Specified by:
size in interface RequestQueue

hasRequest

public boolean hasRequest(java.lang.String s)
Specified by:
hasRequest in interface RequestQueue

clear

public void clear()
Specified by:
clear in interface RequestQueue

getOldest

public Request getOldest()
Description copied from interface: RequestQueue
Returns the oldest request from the queue or null if the queue is empty Do not remove it from the queue

Specified by:
getOldest in interface RequestQueue
Returns:
the oldest request or null

getOldest

public Request getOldest(java.lang.String methodName)
Description copied from interface: RequestQueue
Returns the oldest request whose method name is s or null if no match Do not remove it from the queue

Specified by:
getOldest in interface RequestQueue
Parameters:
methodName - the name of the method to look for
Returns:
the oldest matching request or null

getOldest

public Request getOldest(RequestFilter requestFilter)
Description copied from interface: RequestQueue
Returns the oldest request that matches the criteria defined by the given filter Do not remove it from the request line

Specified by:
getOldest in interface RequestQueue
Parameters:
requestFilter - the filter accepting request on a given criteria
Returns:
the oldest matching request or null

removeOldest

public Request removeOldest()
Description copied from interface: RequestQueue
Removes the oldest request from the queue and returns it Null is returned is the queue is empty

Specified by:
removeOldest in interface RequestQueue
Returns:
the oldest request or null

removeOldest

public Request removeOldest(java.lang.String methodName)
Description copied from interface: RequestQueue
Removes the oldest request whose method name is s and returns it. Null is returned is no match

Specified by:
removeOldest in interface RequestQueue
Parameters:
methodName - the name of the method to look for
Returns:
the oldest matching request or null

removeOldest

public Request removeOldest(RequestFilter requestFilter)
Description copied from interface: RequestQueue
Removes the oldest request that matches the criteria defined by the given filter Null is returned is no match

Specified by:
removeOldest in interface RequestQueue
Parameters:
requestFilter - the filter accepting request on a given criteria
Returns:
the oldest matching request or null

getYoungest

public Request getYoungest()
Description copied from interface: RequestQueue
Returns the youngest request from the queue or null if the queue is empty Do not remove it from the request line

Specified by:
getYoungest in interface RequestQueue
Returns:
the youngest request or null

getYoungest

public Request getYoungest(java.lang.String methodName)
Description copied from interface: RequestQueue
Returns the youngest request whose method name is s or null if no match Do not remove it from the request line

Specified by:
getYoungest in interface RequestQueue
Parameters:
methodName - the name of the method to look for
Returns:
the youngest matching request or null

getYoungest

public Request getYoungest(RequestFilter requestFilter)
Description copied from interface: RequestQueue
Returns the youngest request that matches the criteria defined by the given filter Do not remove it from the request line

Specified by:
getYoungest in interface RequestQueue
Parameters:
requestFilter - the filter accepting request on a given criteria
Returns:
the youngest matching request or null

removeYoungest

public Request removeYoungest()
Description copied from interface: RequestQueue
Removes the youngest request from the queue and returns it Null is returned is the queue is empty

Specified by:
removeYoungest in interface RequestQueue
Returns:
the youngest request or null

removeYoungest

public Request removeYoungest(java.lang.String methodName)
Description copied from interface: RequestQueue
Removes the youngest request whose method name is s and returns it. Null is returned is no match

Specified by:
removeYoungest in interface RequestQueue
Parameters:
methodName - the name of the method to look for
Returns:
the youngest matching request or null

removeYoungest

public Request removeYoungest(RequestFilter requestFilter)
Description copied from interface: RequestQueue
Removes the youngest request that matches the criteria defined by the given filter Null is returned is no match

Specified by:
removeYoungest in interface RequestQueue
Parameters:
requestFilter - the filter accepting request on a given criteria
Returns:
the youngest matching request or null

add

public int add(Request request)
Description copied from interface: RequestQueue
Adds the given request to the end of the queue

Specified by:
add in interface RequestQueue
Parameters:
request - the request to add
Returns:
value for fault tolerance protocol

addToFront

public int addToFront(Request request)
Description copied from interface: RequestQueue
Adds the given request to the front of the queue before all other request already in the queue

Specified by:
addToFront in interface RequestQueue
Parameters:
request - the request to add
Returns:
value for fault tolerance protocol

processRequests

public void processRequests(RequestProcessor processor,
                            Body body)
Description copied from interface: RequestQueue
Processes all requests in the queue using the given RequestProcessor. Requests are removed from the queue and served depending on the result returned by the processor

Specified by:
processRequests in interface RequestQueue
Parameters:
processor - the RequestProcessor to use
body - the body that processes the requests

toString

public java.lang.String toString()

addRequestQueueEventListener

public void addRequestQueueEventListener(RequestQueueEventListener listener)
Specified by:
addRequestQueueEventListener in interface RequestQueue

removeRequestQueueEventListener

public void removeRequestQueueEventListener(RequestQueueEventListener listener)
Specified by:
removeRequestQueueEventListener in interface RequestQueue

notifyOneListener

protected void notifyOneListener(ProActiveListener listener,
                                 ProActiveEvent event)
Description copied from class: AbstractEventProducer
Notifies one listener with the event.

Specified by:
notifyOneListener in class AbstractEventProducer
Parameters:
listener - the listener to notify.
event - the event to fire to the listener.


Copyright ? April 2005 INRIA All Rights Reserved.