org.terracotta.async
Class ProcessingBucket<I>

java.lang.Object
  extended by org.terracotta.async.ProcessingBucket<I>
Type Parameters:
I - the type of the work items processed by the bucket

public class ProcessingBucket<I>
extends Object

ProcessingBucket instances are used a striped collection to store the work items that are awaiting processing on each node.


Method Summary
 void add(I item)
          Enqueue an item for execution by this bucket.
 void addListener(ProcessingBucketListener listener)
          Register a ProcessingBucketListener with this bucket.
 long getLastProcessing()
          Returns the time at which item processing last occurred.
 int getQuarantinedCount()
          Returns the number of items selected for execution by this bucket.
 String getThreadName()
          Return the name used (or to be used) by this bucket's processing thread.
 int getWaitCount()
          Returns the number of items awaiting processing in this bucket.
 void removeListener(ProcessingBucketListener listener)
          Remove a ProcessingBucketListener from this bucket's listeners.
 void setQuarantinedItemsFilter(QuarantinedItemsFilter<I> filter)
          Assign a quarantined item filter to this bucket.
 void setThreadName(String name)
          Set the name to be used by this bucket's processing thread
 void stop()
          Stops this bucket, and prevents it from executing any more items.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLastProcessing

public long getLastProcessing()
Returns the time at which item processing last occurred.

Returns:
time of last processing

setQuarantinedItemsFilter

public void setQuarantinedItemsFilter(QuarantinedItemsFilter<I> filter)
Assign a quarantined item filter to this bucket.

Parameters:
filter - filter to apply
See Also:
AsyncCoordinator.setQuarantinedItemsFilter(QuarantinedItemsFilter)

getWaitCount

public int getWaitCount()
Returns the number of items awaiting processing in this bucket.

Returns:
number of items waiting

getQuarantinedCount

public int getQuarantinedCount()
Returns the number of items selected for execution by this bucket.

Returns:
number of quarantined items

stop

public void stop()
Stops this bucket, and prevents it from executing any more items.


add

public void add(I item)
Enqueue an item for execution by this bucket.

If the item is null then it is ignored.

Parameters:
item - item to be executed

setThreadName

public void setThreadName(String name)
                   throws ExistingRunningThreadException
Set the name to be used by this bucket's processing thread

Parameters:
name - thread name
Throws:
ExistingRunningThreadException - if this bucket is already started

getThreadName

public String getThreadName()
Return the name used (or to be used) by this bucket's processing thread.

If the name is not yet defined then null is returned

Returns:
the name or future name of this buckets processing thread

addListener

public void addListener(ProcessingBucketListener listener)
Register a ProcessingBucketListener with this bucket.

If the listener is null, or the listener is already registered with this bucket, then this operation is a no-op.

Parameters:
listener - listener to be registered

removeListener

public void removeListener(ProcessingBucketListener listener)
Remove a ProcessingBucketListener from this bucket's listeners.

If the listener is null, or the listener is not registered with this bucket, then this operation is a no-op.

Parameters:
listener - listener to be removed


Copyright © 2015 Terracotta, Inc.. All Rights Reserved.