com.neeve.ods
Class StoreBinding

java.lang.Object
  extended by com.neeve.ods.StoreBinding
All Implemented Interfaces:
IEventSource, IStoreBinding

public final class StoreBinding
extends Object
implements IStoreBinding

A store binding implementation

Threading:
A store binding is safe for concurrent access by multiple threads.

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.neeve.ods.IStoreBinding
IStoreBinding.InterClusterReplicationRole, IStoreBinding.Operation, IStoreBinding.Role, IStoreBinding.StartupExpectation, IStoreBinding.State
 
Field Summary
 
Fields inherited from interface com.neeve.ods.IStoreBinding
CLOSE_ICR_AS_FAIL, NO_COMMIT_COMPLETIONS, SUPPRESS_COMPLETION_EVENT_DISPATCH_IF_SYNC_COMPLETION
 
Method Summary
 IStoreQueryRepository asQueryRepository()
          Implementation of IStoreBinding.asQueryRepository()
 void close(int flags)
          Implementation of IStoreBinding.close(int)
 IStoreCommitCompletionEvent commit(IStoreCommitCompletionEvent completionEvent)
          Implementation of IStoreBinding.commit(long, long, com.neeve.ods.IStoreObject[], int, com.neeve.ods.IStoreCommitCompletionEvent, int)
 IStoreCommitCompletionEvent commit(long transactionId, long stableTransactionId, IStoreCommitCompletionEvent completionEvent, int flags)
          Implementation of IStoreBinding.commit(long, long, com.neeve.ods.IStoreObject[], int, com.neeve.ods.IStoreCommitCompletionEvent, int)
 IStoreCommitCompletionEvent commit(long transactionId, long stableTransactionId, IStoreObject[] messages, int messageCount, IStoreCommitCompletionEvent completionEvent, int flags)
          Implementation of IStoreBinding.commit(long, long, com.neeve.ods.IStoreObject[], int, com.neeve.ods.IStoreCommitCompletionEvent, int)
static IStoreBinding create(String memberName, StoreDescriptor descriptor, IStoreEventHandler eventHandler, int flags)
          Create a store binding
static IStoreBinding create(String memberName, StoreDescriptor descriptor, IStoreEventHandler eventHandler, IStoreReplicatorNotificationHandler replicatorNotificationHandler, int flags)
          Create a store binding
 IStoreCommitCompletionEvent createCommitCompletionEvent()
          Implementation of IStoreBinding.createCommitCompletionEvent()
 int createSavepoint()
          Creates a savepoint in the current store transaction.
 void fail(Exception e)
          Implementation of IStoreBinding.fail(java.lang.Exception)
 IStoreObject get(com.eaio.uuid.UUID id)
          Implementation of IStoreBinding.get(com.eaio.uuid.UUID)
 StoreDescriptor getDescriptor()
          Implementation of IStoreBinding.getDescriptor()
 IStoreEventHandler getEventHandler()
          Implementation of IStoreBinding.getEventHandler()
 IStoreSender getICRSender()
          Implementation of IStoreBinding.getICRSender()
 IStoreBinding.InterClusterReplicationRole getInterClusterReplicationRole()
          Implementation of IStoreBinding.getInterClusterReplicationRole()
 int getLastSavepoint()
          Get the last savepoint created for the current transaction.
 IStoreMember getMember()
          Implementation of IStoreBinding.getMember()
 int getMemberCount()
          Implementation of IStoreBinding.getMemberCount()
 String getName()
          Implementation of IEventSource.getName()
 IStorePersister getPersister()
          Implementation of IStoreBinding.getPersister()
 IStoreQueryEngine getQueryEngine()
          Implementation of IStoreBinding.getQueryEngine()
 IStoreBinding.Role getRole()
          Implementation of IStoreBinding.getRole()
 IStoreBinding.State getState()
          Implementation of IStoreBinding.getState()
 IStoreBindingStats getStats()
          Implementation of IStoreBinding.getStats()
 IStoreTransactionLog getTransactionLog()
          Implementation of IStoreBinding.getTransactionLog()
 IStoreBinding getUnderlyingBinding()
          Get the underlying binding
 boolean isPersistenceQuorumMet()
          Implementation of IStoreBinding.isPersistenceQuorumMet()
 void open()
          Implementation of IStoreBinding.open(java.util.Map>)
 void open(Map<IStoreBinding.StartupExpectation,Enum<?>> expectations)
          Implementation of IStoreBinding.open(java.util.Map>)
 void processMemberControlEvent(IStoreMemberControlEvent event)
          Implementation of IStoreBinding.processMemberControlEvent(com.neeve.ods.IStoreMemberControlEvent)
 IStoreBinding put(IStoreObject object)
          Implementation of IStoreBinding.put(com.neeve.ods.IStoreObject)
<T> void
recordFieldUpdate(IStoreObject object, IStoreField<T> field, T oldValue, T newValue)
          Implementation of IStoreBinding.recordFieldUpdate(com.neeve.ods.IStoreObject, com.neeve.ods.IStoreField, T, T)
 IStoreBinding remove(IStoreObject object)
          Implementation of IStoreBinding.remove(com.neeve.ods.IStoreObject)
 IStoreBinding rollback()
          Implementation of IStoreBinding.rollback()
 IStoreBinding rollback(int savepoint)
          Implementation of IStoreBinding.rollback()
 IStoreBinding send(IStoreObject object)
          Implementation of IStoreBinding.send(com.neeve.ods.IStoreObject)
 int size()
          Implementation of IStoreBinding.size()
 int sizeUnprotected()
          Implementation of IStoreBinding.sizeUnprotected()
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

create

public static final IStoreBinding create(String memberName,
                                         StoreDescriptor descriptor,
                                         IStoreEventHandler eventHandler,
                                         IStoreReplicatorNotificationHandler replicatorNotificationHandler,
                                         int flags)
                                  throws OdsException
Create a store binding

Throws:
OdsException

create

public static final IStoreBinding create(String memberName,
                                         StoreDescriptor descriptor,
                                         IStoreEventHandler eventHandler,
                                         int flags)
                                  throws OdsException
Create a store binding

Throws:
OdsException

getName

public final String getName()
Implementation of IEventSource.getName()

Specified by:
getName in interface IEventSource

open

public final void open()
                throws OdsException
Implementation of IStoreBinding.open(java.util.Map>)

Specified by:
open in interface IStoreBinding
Throws:
OdsException

open

public final void open(Map<IStoreBinding.StartupExpectation,Enum<?>> expectations)
                throws OdsException
Implementation of IStoreBinding.open(java.util.Map>)

Specified by:
open in interface IStoreBinding
Parameters:
expectations - The set of expectations to open the store with. This method will throw an exception if any of the expectations specified are not met.
Throws:
OdsException

getMember

public final IStoreMember getMember()
Implementation of IStoreBinding.getMember()

Specified by:
getMember in interface IStoreBinding

getDescriptor

public final StoreDescriptor getDescriptor()
Implementation of IStoreBinding.getDescriptor()

Specified by:
getDescriptor in interface IStoreBinding

getEventHandler

public final IStoreEventHandler getEventHandler()
Implementation of IStoreBinding.getEventHandler()

Specified by:
getEventHandler in interface IStoreBinding

getState

public final IStoreBinding.State getState()
Implementation of IStoreBinding.getState()

Specified by:
getState in interface IStoreBinding

getStats

public final IStoreBindingStats getStats()
Implementation of IStoreBinding.getStats()

Specified by:
getStats in interface IStoreBinding

getRole

public final IStoreBinding.Role getRole()
Implementation of IStoreBinding.getRole()

Specified by:
getRole in interface IStoreBinding

getInterClusterReplicationRole

public final IStoreBinding.InterClusterReplicationRole getInterClusterReplicationRole()
Implementation of IStoreBinding.getInterClusterReplicationRole()

Specified by:
getInterClusterReplicationRole in interface IStoreBinding
Returns:
Returns the ICR role. A value of null is returned if the binding is not configured for inter-cluster replication

getMemberCount

public final int getMemberCount()
Implementation of IStoreBinding.getMemberCount()

Specified by:
getMemberCount in interface IStoreBinding

isPersistenceQuorumMet

public final boolean isPersistenceQuorumMet()
Implementation of IStoreBinding.isPersistenceQuorumMet()

Specified by:
isPersistenceQuorumMet in interface IStoreBinding

getPersister

public final IStorePersister getPersister()
Implementation of IStoreBinding.getPersister()

Specified by:
getPersister in interface IStoreBinding

getICRSender

public final IStoreSender getICRSender()
Implementation of IStoreBinding.getICRSender()

Specified by:
getICRSender in interface IStoreBinding

getTransactionLog

public final IStoreTransactionLog getTransactionLog()
Implementation of IStoreBinding.getTransactionLog()

Specified by:
getTransactionLog in interface IStoreBinding
Returns:
The binding's transaction log

getQueryEngine

public final IStoreQueryEngine getQueryEngine()
Implementation of IStoreBinding.getQueryEngine()

Specified by:
getQueryEngine in interface IStoreBinding
Returns:
The binding's query engine.

asQueryRepository

public final IStoreQueryRepository asQueryRepository()
Implementation of IStoreBinding.asQueryRepository()

Specified by:
asQueryRepository in interface IStoreBinding
Returns:
The IStoreQueryRepository for this engine or null, if it is not configured for query.

createCommitCompletionEvent

public final IStoreCommitCompletionEvent createCommitCompletionEvent()
Implementation of IStoreBinding.createCommitCompletionEvent()

Specified by:
createCommitCompletionEvent in interface IStoreBinding

sizeUnprotected

public final int sizeUnprotected()
Implementation of IStoreBinding.sizeUnprotected()

Specified by:
sizeUnprotected in interface IStoreBinding
Returns:
the number of objects in the store.

size

public final int size()
Implementation of IStoreBinding.size()

Specified by:
size in interface IStoreBinding
Returns:
the number of objects in the store.

processMemberControlEvent

public final void processMemberControlEvent(IStoreMemberControlEvent event)
Implementation of IStoreBinding.processMemberControlEvent(com.neeve.ods.IStoreMemberControlEvent)

Specified by:
processMemberControlEvent in interface IStoreBinding
Parameters:
event - The event to process

This method should be invoked in response when the following events are received from the store binding. - IStoreMemberFoundEvent - IStoreMemberConnectEvent - IStoreMemberHandshakeStartReadyEvent - IStoreMemberHandshakePrimaryHelloEvent - IStoreMemberHandshakeBackupHelloEvent - IStoreMemberInitReadyEvent - IStoreMemberLostEvent The method should be invoked serialized with the invocation of other binding 'action' methods. Users of the StoreBinding do not have to invoke this method since the StoreBinding automatically invokes this method. This method only needs to be invoked by users who want to control the scheduling of the above event with other user events.


recordFieldUpdate

public final <T> void recordFieldUpdate(IStoreObject object,
                                        IStoreField<T> field,
                                        T oldValue,
                                        T newValue)
Implementation of IStoreBinding.recordFieldUpdate(com.neeve.ods.IStoreObject, com.neeve.ods.IStoreField, T, T)

Specified by:
recordFieldUpdate in interface IStoreBinding
Parameters:
object - The object being updated.
field - The field that can be used to access the field value. If the field is not supplied it will not be indexed even if the store supports indexing.
oldValue - The old field value.
newValue - The new field value.

put

public final IStoreBinding put(IStoreObject object)
Implementation of IStoreBinding.put(com.neeve.ods.IStoreObject)

Specified by:
put in interface IStoreBinding
Parameters:
object - The object to be added to the store.
Returns:
Returns this object for invocation chaining.

send

public final IStoreBinding send(IStoreObject object)
Implementation of IStoreBinding.send(com.neeve.ods.IStoreObject)

Specified by:
send in interface IStoreBinding
Parameters:
object - The object sent via the store.
Returns:
Returns this object for invocation chaining.

get

public final IStoreObject get(com.eaio.uuid.UUID id)
Implementation of IStoreBinding.get(com.eaio.uuid.UUID)

Specified by:
get in interface IStoreBinding
Parameters:
id - The object's id

remove

public final IStoreBinding remove(IStoreObject object)
Implementation of IStoreBinding.remove(com.neeve.ods.IStoreObject)

Specified by:
remove in interface IStoreBinding
Returns:
Returns this object for invocation chaining.

commit

public final IStoreCommitCompletionEvent commit(long transactionId,
                                                long stableTransactionId,
                                                IStoreObject[] messages,
                                                int messageCount,
                                                IStoreCommitCompletionEvent completionEvent,
                                                int flags)
                                         throws OdsException
Implementation of IStoreBinding.commit(long, long, com.neeve.ods.IStoreObject[], int, com.neeve.ods.IStoreCommitCompletionEvent, int)

Specified by:
commit in interface IStoreBinding
Parameters:
transactionId - A user supplied transaction id that will be set in each of the objects committed by this method. This id is not interpreted by ODS. It is only accepted here to set in objects in the transaction to tie the objects committed by the store with other objects in the same transaction.
stableTransactionId - A user supplied stable transaction id that will be set in each of the objects committed by this method. This id is not interpreted by ODS. It is only accepted here to set in objects in the transaction to tie the objects committed by the store with other objects in the same transaction.
completionEvent - The completion event that will be used to communicate the completion of and replication status for the commit operation. A value of null indicates the caller is not interested in the results of the commit operation.
flags - Flags that qualify the commit operation. The following flags are permitted for use:
- IStoreBinding.SUPPRESS_COMPLETION_EVENT_DISPATCH_IF_SYNC_COMPLETION
Returns:
Returns the commit completion event object supplied to the commit method.
Throws:
OdsException - Thrown if and only if an error is encountered before the replication phse of the the commit process. In such as case, it is guaranteed that the state of the store and transaction log is restored to pre-commit state before the exception is thrown.

This method commits all changes made to a store via a binding using the calling thread since the last commit. The commit operation essentially consists of replicating changes recorded in a store's transaction log to other (backup) store members. When invoked, this method first prepares for the replication process. Any failure in this pre-replication phase is reported to the user via an exception thrown by this method. If the replication preparation completes successfully, the commit kicks off the replication and returns to the caller. Any failure in the replication is now reported to the user via the commit completion event object supplied to this method (the user should not modify the completion event until the commit has completed). Upon completion of the replication, the ODS runtime sets a commit completion status in the completion event (see IStoreCommitCompletionStatus) and notifies the user of the completion. The notification is performed using the the notification mode set by the user in the completion event object.

This method can be only be invoked on a binding in the open state.

This method cannot be invoked from within an event handler. Doing so can result in a deadlock.


commit

public final IStoreCommitCompletionEvent commit(long transactionId,
                                                long stableTransactionId,
                                                IStoreCommitCompletionEvent completionEvent,
                                                int flags)
                                         throws OdsException
Implementation of IStoreBinding.commit(long, long, com.neeve.ods.IStoreObject[], int, com.neeve.ods.IStoreCommitCompletionEvent, int)

Specified by:
commit in interface IStoreBinding
Throws:
OdsException

commit

public final IStoreCommitCompletionEvent commit(IStoreCommitCompletionEvent completionEvent)
                                         throws OdsException
Implementation of IStoreBinding.commit(long, long, com.neeve.ods.IStoreObject[], int, com.neeve.ods.IStoreCommitCompletionEvent, int)

Specified by:
commit in interface IStoreBinding
Throws:
OdsException

createSavepoint

public final int createSavepoint()
Description copied from interface: IStoreBinding
Creates a savepoint in the current store transaction.

A savepoint serves as a delimiter that can used to partially rollback a transaction. A subsequent call to IStoreBinding.rollback(int) with the returned savepoint version will roll the transaction back to the state at the time of this call.

Specified by:
createSavepoint in interface IStoreBinding
Returns:
The new savepoint.

getLastSavepoint

public final int getLastSavepoint()
Description copied from interface: IStoreBinding
Get the last savepoint created for the current transaction.

Returns the savepoint version created by the last call to IStoreBinding.createSavepoint() or the transaction's initial savepoint (0) if no savepoint has been created.

Specified by:
getLastSavepoint in interface IStoreBinding
Returns:
the current savepoint.

rollback

public final IStoreBinding rollback()
Implementation of IStoreBinding.rollback()

Specified by:
rollback in interface IStoreBinding
Returns:
Returns this object for invocation chaining.

rollback

public final IStoreBinding rollback(int savepoint)
Implementation of IStoreBinding.rollback()

Specified by:
rollback in interface IStoreBinding
Parameters:
savepoint - The savepoint to roll back to.
Returns:
Returns this object for invocation chaining.
See Also:
IStoreBinding.createSavepoint()

fail

public final void fail(Exception e)
Implementation of IStoreBinding.fail(java.lang.Exception)

Specified by:
fail in interface IStoreBinding
Parameters:
e - The exception that describes the failures. This exception object will be attached to the binding failed event dispatched to the user as a consequence of this method.

close

public final void close(int flags)
Implementation of IStoreBinding.close(int)

Specified by:
close in interface IStoreBinding
Parameters:
flags - Flags that qualify the close operation. The following are the permissible flags that can be used with this method:
- IStoreBinding.NO_COMMIT_COMPLETIONS - IStoreBinding.CLOSE_ICR_AS_FAIL

getUnderlyingBinding

public final IStoreBinding getUnderlyingBinding()
Get the underlying binding



Copyright © 2016 Neeve Research, LLC. All Rights Reserved.