com.crankuptheamps.client
Interface Store

All Known Implementing Classes:
BlockPublishStore, HybridPublishStore, MemoryPublishStore, PublishStore

public interface Store

Represents a message store. The AMPS client uses message stores for recovery purposes. The store is responsible for maintaining the state of published messages and recovering that state in the event of a disconnection. Optionally, the store may persist message state and recover that state if the application restarts.


Nested Class Summary
static interface Store.StoreReplayer
          Replay the messages saved in a store.
 
Field Summary
static int SOWDeleteByData
           
static int SOWDeleteByFilter
           
static int SOWDeleteByKeys
           
 
Method Summary
 void discardUpTo(long index)
          Discard all operations up to the index provided.
 void flush()
          Wait for the store to discard everything that has been stored up to the point in time when flush is called, then return.
 void flush(long timeout)
          Wait for the store to discard everything that has been stored up to the point in time when flush is called, then return.
 long getLowestUnpersisted()
          Return the oldest index in the store.
 void replay(Store.StoreReplayer replayer)
          Replay all operations in the store using the provided StoreReplayer.
 void replaySingle(Store.StoreReplayer replayer, long index)
          Replay the operation at the specified index.
 void setResizeHandler(PublishStoreResizeHandler handler)
          Set the resize handler for the publish store.
 void store(long index, int operation, byte[] topic, long topicOffset, long topicLength, byte[] data, long dataOffset, long dataLength, byte[] correlationId, long correlationIdOffset, long correlationIdLength)
          Store the provided operation.
 void store(long index, int operation, byte[] topic, long topicOffset, long topicLength, byte[] data, long dataOffset, long dataLength, byte[] correlationId, long correlationIdOffset, long correlationIdLength, int expiration)
          Store the provided operation.
 void store(long index, int operation, byte[] topic, long topicOffset, long topicLength, byte[] data, long dataOffset, long dataLength, int expiration, CommandId cmdId)
          Store the provided operation.
 long unpersistedCount()
          Return the number of operations in the store.
 

Field Detail

SOWDeleteByData

static final int SOWDeleteByData
See Also:
Constant Field Values

SOWDeleteByFilter

static final int SOWDeleteByFilter
See Also:
Constant Field Values

SOWDeleteByKeys

static final int SOWDeleteByKeys
See Also:
Constant Field Values
Method Detail

store

void store(long index,
           int operation,
           byte[] topic,
           long topicOffset,
           long topicLength,
           byte[] data,
           long dataOffset,
           long dataLength,
           byte[] correlationId,
           long correlationIdOffset,
           long correlationIdLength)
           throws StoreException
Store the provided operation. The index provided is a key that the client can later use to replay the operation or remove the operation from the store. Implementations may assume that the index increases monotonically.

Parameters:
index - an index that identifies this operation
operation - the operation to store
topic - a byte array containing the name of the topic for this operation
topicOffset - the offset in the topic array where the topic name begins
topicLength - the length of the topic name
data - a byte array containing the data for this operation
dataOffset - the offset into the data array where the data begins
dataLength - the length of the data
correlationId - the correlation ID for this message
correlationIdOffset - the offset into the correlation ID array where the correlation ID begins
correlationIdLength - the length of the correlation ID
Throws:
StoreException

store

void store(long index,
           int operation,
           byte[] topic,
           long topicOffset,
           long topicLength,
           byte[] data,
           long dataOffset,
           long dataLength,
           byte[] correlationId,
           long correlationIdOffset,
           long correlationIdLength,
           int expiration)
           throws StoreException
Store the provided operation. The index provided is a key that the client can later use to replay the operation or remove the operation from the store. Implementations may assume that the index increases monotonically.

Parameters:
index - an index that identifies this operation
operation - the operation to store
topic - a byte array containing the name of the topic for this operation
topicOffset - the offset in the topic array where the topic name begins
topicLength - the length of the topic name
data - a byte array containing the data for this operation
dataOffset - the offset into the data array where the data begins
dataLength - the length of the data
expiration - the expiration to set on the operation
correlationId - the correlation ID for this message
correlationIdOffset - the offset into the correlation ID array where the correlation ID begins
correlationIdLength - the length of the correlation ID
Throws:
StoreException

store

void store(long index,
           int operation,
           byte[] topic,
           long topicOffset,
           long topicLength,
           byte[] data,
           long dataOffset,
           long dataLength,
           int expiration,
           CommandId cmdId)
           throws StoreException
Store the provided operation. The index provided is a key that the client can later use to replay the operation or remove the operation from the store. Implementations may assume that the index increases monotonically.

Parameters:
index - an index that identifies this operation
operation - the operation to store
topic - a byte array containing the name of the topic for this operation
topicOffset - the offset in the topic array where the topic name begins
topicLength - the length of the topic name
data - a byte array containing the data for this operation
dataOffset - the offset into the data array where the data begins
dataLength - the length of the data
expiration - the expiration to set on the operation
cmdId - the commandId to set on the operation
Throws:
StoreException

discardUpTo

void discardUpTo(long index)
                 throws StoreException
Discard all operations up to the index provided.

Parameters:
index - the index number to keep -- all previous index numbers will be discarded
Throws:
StoreException

replay

void replay(Store.StoreReplayer replayer)
            throws StoreException,
                   DisconnectedException
Replay all operations in the store using the provided StoreReplayer.

Parameters:
replayer - the StoreReplayer to use to replay the operations
Throws:
StoreException
DisconnectedException

replaySingle

void replaySingle(Store.StoreReplayer replayer,
                  long index)
                  throws StoreException,
                         DisconnectedException
Replay the operation at the specified index.

Throws:
StoreException
DisconnectedException

unpersistedCount

long unpersistedCount()
Return the number of operations in the store.


getLowestUnpersisted

long getLowestUnpersisted()
Return the oldest index in the store.


flush

void flush()
           throws TimedOutException
Wait for the store to discard everything that has been stored up to the point in time when flush is called, then return.

Throws:
TimedOutException

flush

void flush(long timeout)
           throws TimedOutException
Wait for the store to discard everything that has been stored up to the point in time when flush is called, then return. Throw an exception if this is not completed in the number of milliseconds specified by the timeout.

Parameters:
timeout - the number of milliseconds to wait for the flush
Throws:
TimedOutException

setResizeHandler

void setResizeHandler(PublishStoreResizeHandler handler)
Set the resize handler for the publish store. An implementation can call the resize handler in the event that it needs to grow the size of the publish store.