com.cloudtran.replicator.localStore
Interface LocalStore

All Known Implementing Classes:
CacheLocalStoreImpl

public interface LocalStore

To avoid confusion with the persistence path in the local data center, we avoid the term 'persistence' here - especially as one way to do it is via a cache The goal of the LocalStore subsystem is to provide high-performance backed-up storage for the Replicator. There needs to be two sides: one for inbound transactions, the other for outbound. The outbound side needs to store the in-play transaction IDs - that have not committed at the other end - and the data, as well as clearing them when they're acknowledged by the remote end. The inbound side only needs to store and remove the transactions we've received from the other end. The default implementation simply writes to a cache, one at a time. Other techniques that can be used here are: - aggregating the writes to the caches, which will be particularly effective when we're only writing the transaction IDs (for writing the data for outbound transactions, it may be less effective). Note: we can't even use putAll... - having a special cache, that is only storage-enable for the Replicators; - having secondary NICs specifically for this cache, so it doesn't interfere with the Isolator. I seriously doubt whether we need to that far - using SSD. See C:\jeewiz_sales_and_marketing\CloudTran\Flash_SSD_PCIe_Enterprise. The cache approach might be sufficient if - it can be backed up with a dual-ported SSD, which normally only the primary writes to, but can be enabled by the backup replicator - the flash journal (elastic data There will be one instance of this class instantiated by the replicator.


Field Summary
static String GREEN_ZONE
           
static String RED_ZONE
           
static String YELLOW_ZONE
           
 
Method Summary
 boolean releaseOutbound(long txSeqNum)
          Releases the ReplicatorPacket stored under the txSeqNum.
 Long[] resync()
          Call this on each isolator instance when initializing replicator to set up the local store.
 ReplicatorPacket retrieveOutbound(long txSeqNum)
          After a resync() is called, any un-replicated packets must be sent to the remote DC.
 String storeOutbound(AtomicLong txSeqNumAL, ReplicatorOutboundRequest ror)
          Stores the ReplicatorPacket so it can be retrieved or marked as deleted from the replicator's storage by the embedded myTxSeqNum.
 

Field Detail

RED_ZONE

static final String RED_ZONE
See Also:
Constant Field Values

YELLOW_ZONE

static final String YELLOW_ZONE
See Also:
Constant Field Values

GREEN_ZONE

static final String GREEN_ZONE
See Also:
Constant Field Values
Method Detail

resync

Long[] resync()
Call this on each isolator instance when initializing replicator to set up the local store.

Returns:
a Long array containing (a) the first TxSeqNum to resend to the peer (b) the number of transactions to resend to the peer. Once complete, the first TxSeqNum in the new run will be the sum of these two.

retrieveOutbound

ReplicatorPacket retrieveOutbound(long txSeqNum)
After a resync() is called, any un-replicated packets must be sent to the remote DC. This call assumes that the resync() has been called before any further storeOutbound()/releaseOutbound() calls.

Parameters:
txSeqNum - the (replicator's) sequence number of the packet to retrieve.
Returns:
the ReplicatorPacket for the given txSeqNum.

storeOutbound

String storeOutbound(AtomicLong txSeqNumAL,
                     ReplicatorOutboundRequest ror)
Stores the ReplicatorPacket so it can be retrieved or marked as deleted from the replicator's storage by the embedded myTxSeqNum. **NB** This call is made inside a synchronized block so it is single-threaded - there is no need to synchronize within the implementation of this method Note the side effects: (a) incrementing txSeqNum (b) storing packet.myTxSeqNum in the packet (c)release of ror.finishOutboundRequestSem

Parameters:
txSeqNumAL - the AtomicLong counter to generate the sequence number to store for the transaction. This number starts @ 0 after a drive/directory reformat and is then incremented as packets are sent. (This numbering sequence is continued across runs: it only gets reset by a reformat of the SSD drives.) The AtomicLong passed here belongs to the DCConnection. On input, it will be the highest previous txSeqNum set by this replicator. Therefore, the first packet sent will be (input txSeqNum + 1) etc. **NB** This method must set the sequenceNumber for this packet into the ror.packets[i].myTxSeqNum.
ror - ReplicatorOutboundRequest holding the packets to store. The packets include the local data center's internalTxId field for the transaction. **NB** This method must release ReplicatorOutboundRequest.finishOutboundRequestSem before returning.
Returns:
returns the String for the zone - GREEEN_ZONE, YELLOW_ZONE, RED_ZONE. If the RED_ZONE is returned, the caller must retry. Otherwise, the ReplicatorOutboundRequest has been restored. **NB** Just before returning, this method must release ror.finishOutboundRequestSem unless the RED_ZONE is returned.

releaseOutbound

boolean releaseOutbound(long txSeqNum)
Releases the ReplicatorPacket stored under the txSeqNum.

Parameters:
txSeqNum - the transaction sequence number, as passed in storeOutbound.
Returns:
returns true if the packet was correctly stored. If false is returned the caller should retry.