com.preemptive.instrumentation
Class ConfigurableFlowController

java.lang.Object
  extended by com.preemptive.instrumentation.ConfigurableFlowController
All Implemented Interfaces:
FlowController

public final class ConfigurableFlowController
extends Object
implements FlowController

A configurable flow controller that adjusts its interval time based on the number of messages that have been enqueued.

The following aspects can be configured:


Constructor Summary
ConfigurableFlowController()
          Create a new controller.
 
Method Summary
 int control(int numMessages, long deltaT)
          Called to control the transmission of messages.
 boolean hasBatchExpired(Date date, int attempts)
          Should the batch be deleted?
 int messagesToDrop(int currentMessageCount)
          Called to determine if messages should be dropped and if so, how many.
 boolean okToTransmit()
          Called to determine if it is OK to attempt a transmission
 void onSend(boolean success)
          Informs the FlowController if the a transmission attempt was successful or not, allowing it to determine if messages should still be sent.
 void setDropPoint(int value)
          Set the point at which the controller will start discarding messages.
 void setFlushPoint(int value)
          Set the point at which the controller will request that all messages should be sent.
 void setIntervalStep(int value)
          Set the amount that the control will adjust its wait time.
 void setMaximumInterval(int value)
          Set the maximum amount of time that the control should wait between checking the message queue.
 void setMaximumSequentialFailure(int num)
          Sets the maximum number of sequential times transmission can fail before taking action.
 void setMinimumFailureCount(int minFailureCount)
          Sets the minimum number of failed transmissions.
 void setRange(int low, int high)
          Set the range of messages that the controller should use to adjust its wait time.
 void setRetryTimeout(long time)
          Sets the number of milliseconds the system should wait before attempting to send messages again.
 void setTimeToLive(long ttl)
          Sets the time to live.
 String toString()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConfigurableFlowController

public ConfigurableFlowController()
Create a new controller. The following values are defaulted: The initial wait time starts at 10sec and is adjusted based on the volume of incoming messages.

Method Detail

control

public int control(int numMessages,
                   long deltaT)
Description copied from interface: FlowController
Called to control the transmission of messages.

Specified by:
control in interface FlowController
Parameters:
numMessages - Number of queued messages.
deltaT - The total time the last iteration took to send numMessages (pollInterval + sendTime) in ms.
Returns:
A new polling interval in ms.

messagesToDrop

public int messagesToDrop(int currentMessageCount)
Description copied from interface: FlowController
Called to determine if messages should be dropped and if so, how many.

Specified by:
messagesToDrop in interface FlowController
Parameters:
currentMessageCount - The number of queued messages.
Returns:
The number of messages to drop.

toString

public String toString()
Overrides:
toString in class Object
Returns:
The resulting string contains information about the current configuration.

setMaximumInterval

public void setMaximumInterval(int value)
Set the maximum amount of time that the control should wait between checking the message queue.

Parameters:
value - time in ms

setIntervalStep

public void setIntervalStep(int value)
Set the amount that the control will adjust its wait time. If the controller determines that it should increase the wait time it will repeatedly add this amount to the wait time. If the controller determines that is should decrease the wait time it will repeatedly subtract this amount from the wait time.

Parameters:
value - time in ms

setRange

public void setRange(int low,
                     int high)
Set the range of messages that the controller should use to adjust its wait time. Note that changing these values may cause the flush point and drop point to change.

Parameters:
low - the low count of the messages. When there are fewer messages than low the controller will increase its wait time.
high - the high count of the messages. When there are greater messages than high the controller will decrease its wait time.
See Also:
setDropPoint(int), setFlushPoint(int)

setDropPoint

public void setDropPoint(int value)
Set the point at which the controller will start discarding messages. When more than value are queued the controller will discard older messages until the high value set by setRange(int, int) has been reached. This value must be greater than high and shoul also be greater than the value set by setFlushPoint(int).

Parameters:
value - the drop point

setFlushPoint

public void setFlushPoint(int value)
Set the point at which the controller will request that all messages should be sent. This value must be greater than the high value set by setRange(int, int) and should be lower than the value set in setDropPoint(int).

Parameters:
value - the flush point

setMaximumSequentialFailure

public void setMaximumSequentialFailure(int num)
Sets the maximum number of sequential times transmission can fail before taking action.

Parameters:
num - the number of times transmissions can fail before the system should wait and start caching (if supported). 0 means unlimited

setRetryTimeout

public void setRetryTimeout(long time)
Sets the number of milliseconds the system should wait before attempting to send messages again. 0 means don't retry.


okToTransmit

public boolean okToTransmit()
Called to determine if it is OK to attempt a transmission

Specified by:
okToTransmit in interface FlowController

onSend

public void onSend(boolean success)
Informs the FlowController if the a transmission attempt was successful or not, allowing it to determine if messages should still be sent.

Specified by:
onSend in interface FlowController
Parameters:
success - TRUE if transmission was successful.

setTimeToLive

public void setTimeToLive(long ttl)
Sets the time to live. This is the number of seconds a batch should exist before it gets deleted from offline storage.

Parameters:
ttl - The number of seconds. The default is 259200 (3 days of seconds)

setMinimumFailureCount

public void setMinimumFailureCount(int minFailureCount)
Sets the minimum number of failed transmissions. This is the minimum number of attempts before a batch can be deleted from offline storage.

Parameters:
minFailureCount - The minimum number of failures. The default is 150.

hasBatchExpired

public boolean hasBatchExpired(Date date,
                               int attempts)
Description copied from interface: FlowController
Should the batch be deleted?

Specified by:
hasBatchExpired in interface FlowController
Parameters:
date - The date/time the message batch was created.
attempts - The number of transmission attempts.
Returns:
true if the batch has expired and should be deleted.


Copyright © 2013 PreEmptive Solutions, LLC. All Rights Reserved.