com.preemptive.instrumentation
Class DefaultFlowController

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

public class DefaultFlowController
extends Object
implements FlowController

A trivial flow controller that returns a fixed interval and never drops messages.


Constructor Summary
DefaultFlowController(int interval)
          Create a new flow 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 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 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFlowController

public DefaultFlowController(int interval)
Create a new flow controller.

Parameters:
interval - the pooling interval in milliseconds. Must be greater than 0.
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.

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.