|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IStoreBinding
Represents a binding to an ODS store.
A store binding serves as an interface to an ODS store. It provides
the mechanism by which a user stores and retrieves objects in an ODS
store. A user creates store bindings directly using StoreBinding
or using the StoreBindingFactory
for advanced use.
Nested Class Summary | |
---|---|
static class |
IStoreBinding.InterClusterReplicationRole
Enumerates the different inter-cluster replication roles of a binding. |
static class |
IStoreBinding.Operation
Enumerates the various operations that can be performed on a store binding |
static class |
IStoreBinding.Role
Enumerates the different roles of a binding in a store cluster. |
static class |
IStoreBinding.StartupExpectation
Enumerates the set of startup expectations that can be requested. |
static class |
IStoreBinding.State
Enumerates the different binding states |
Field Summary | |
---|---|
static int |
CLOSE_ICR_AS_FAIL
Specifies that ICR sender/receiver should be closed with failure. |
static int |
NO_COMMIT_COMPLETIONS
Specifies that commit completion events should not be dispatched on close. |
static int |
SUPPRESS_COMPLETION_EVENT_DISPATCH_IF_SYNC_COMPLETION
Specifies that the commit operation should not dispatch the commit completion event if the commit completed synchronously i.e. within the commit call itself. |
Method Summary | ||
---|---|---|
IStoreQueryRepository |
asQueryRepository()
Returns a view of this IStoreBinding as a IStoreQueryRepository . |
|
void |
close(int flags)
Close a store binding. |
|
IStoreCommitCompletionEvent |
commit(IStoreCommitCompletionEvent completionEvent)
Commits changes made to the store since last commit without a transaction id. |
|
IStoreCommitCompletionEvent |
commit(long transactionId,
long stableTransactionId,
IStoreCommitCompletionEvent completionEvent,
int flags)
|
|
IStoreCommitCompletionEvent |
commit(long transactionId,
long stableTransactionId,
IStoreObject[] messages,
int messageCount,
IStoreCommitCompletionEvent completionEvent,
int flags)
Commit changes made to store since last commit. |
|
IStoreCommitCompletionEvent |
createCommitCompletionEvent()
Create a new commit completion event. |
|
int |
createSavepoint()
Creates a savepoint in the current store transaction. |
|
void |
fail(Exception e)
Force fail a store binding. |
|
IStoreObject |
get(com.eaio.uuid.UUID id)
Get an object from a store |
|
StoreDescriptor |
getDescriptor()
Get the descriptor used to created a store binding. |
|
IStoreEventHandler |
getEventHandler()
Get a binding's event handler. |
|
IStoreSender |
getICRSender()
Get a binding's ICR sender |
|
IStoreBinding.InterClusterReplicationRole |
getInterClusterReplicationRole()
Get a binding's inter-cluster replication role. |
|
int |
getLastSavepoint()
Get the last savepoint created for the current transaction. |
|
IStoreMember |
getMember()
Get the member represented by a store binding. |
|
int |
getMemberCount()
Get a store's member count. |
|
IStorePersister |
getPersister()
Get a binding's persister. |
|
IStoreQueryEngine |
getQueryEngine()
Get a binding's IStoreQueryEngine . |
|
IStoreBinding.Role |
getRole()
Get a binding's role. |
|
IStoreBinding.State |
getState()
Get a binding's state. |
|
IStoreBindingStats |
getStats()
Get a binding's statistics object. |
|
IStoreTransactionLog |
getTransactionLog()
Get a binding's transaction log. |
|
boolean |
isPersistenceQuorumMet()
Get whether membership is at or above persistence quorum. |
|
void |
open()
Open a store binding with no expectations. |
|
void |
open(Map<IStoreBinding.StartupExpectation,Enum<?>> expectations)
Open a store binding with expectations. |
|
void |
processMemberControlEvent(IStoreMemberControlEvent event)
Process a member control event |
|
IStoreBinding |
put(IStoreObject object)
Add an object to a store. |
|
|
recordFieldUpdate(IStoreObject object,
IStoreField<T> field,
T oldValue,
T newValue)
Record a field update for the given object in the store's transaction log and updates store indexes. |
|
IStoreBinding |
remove(IStoreObject object)
Remove an object from a store. |
|
IStoreBinding |
rollback()
Rollback changes made to a store. |
|
IStoreBinding |
rollback(int savepoint)
Rollback changes made to a store up through a given savepoint. |
|
IStoreBinding |
send(IStoreObject object)
Send a message object. |
|
int |
size()
Get the number of objects in a store. |
|
int |
sizeUnprotected()
Get the number of objects in a store. |
Methods inherited from interface com.neeve.event.IEventSource |
---|
getName |
Field Detail |
---|
static final int NO_COMMIT_COMPLETIONS
By default, commit completion events are dispatched for incomplete
commits when a store binding is closed. The user should specify this
flag to the close(int)
method to suppress the dispatch of these
events.
static final int CLOSE_ICR_AS_FAIL
Specifying this flag indicates that the ICR sender/receiver should be closed indicating a failure. Closing with failure causes the ICR sender/receiver to close the underlying messaging bindings in a manner to not explictly leave joined channels i.e. leave subscriptions open.
static final int SUPPRESS_COMPLETION_EVENT_DISPATCH_IF_SYNC_COMPLETION
Method Detail |
---|
void open(Map<IStoreBinding.StartupExpectation,Enum<?>> expectations) throws OdsException
Note that IStoreBinding.StartupExpectation
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.
OdsException
void open() throws OdsException
This method invokes open(null)
OdsException
IStoreMember getMember()
A binding to a store essentially represents a member of the store. This method returns the member represented by a binding.
This method can be invoked on a binding in any state.
StoreDescriptor getDescriptor()
This method can be invoked on a binding in any state.
IStoreEventHandler getEventHandler()
This method can be invoked on a binding in any state.
IStoreBinding.State getState()
This method can be invoked on a binding in any state.
IStoreBindingStats getStats()
This method can be invoked on a binding in any state.
IStoreBinding.Role getRole()
This method can be only be invoked on a binding in any state other than the closed state.
IStoreBinding.InterClusterReplicationRole getInterClusterReplicationRole()
This method can be only be invoked on a binding in any state.
int getMemberCount()
This method returns the number of members in a store including the member represented by the binding on which this method is called e.g. a value of 1 returned by this method implies there are no additional members in the store.
This method can be invoked on a binding in the opening or open state.
boolean isPersistenceQuorumMet()
This method can be invoked on a binding in the opening or open state.
IStorePersister getPersister()
This method can be only be invoked on a binding in any state other than failed or closed states.
IStoreSender getICRSender()
This method can be only be invoked on a binding in any state other than failed or closed states.
IStoreTransactionLog getTransactionLog()
A binding's transaction log records operations performed on store objects by the binding. This method returns a binding's transaction log.
This method can be only be invoked on a binding in a post open state.
IStoreQueryEngine getQueryEngine()
IStoreQueryEngine
.
A binding's IStoreQueryEngine
allows the store to be queried.
This method can be only be invoked on a binding in a post open state.
IStoreQueryRepository asQueryRepository()
IStoreBinding
as a IStoreQueryRepository
.
A binding configured for query provides this view to its IStoreQueryEngine
.
This method can be only be invoked on a binding in a post open state.
IStoreQueryRepository
for this engine or null, if it is not configured for query.IStoreCommitCompletionEvent createCommitCompletionEvent()
This method creates a new commit completion for use with commit(long, long, com.neeve.ods.IStoreObject[], int, com.neeve.ods.IStoreCommitCompletionEvent, int)
This method can be invoked on a binding in any state.
int sizeUnprotected()
This method differs from size()
in that it is guaranteed not to
block, but its accuracy is not guaranteed.
This method can be invoked on a binding in any state, though its
accuracy is not reliable in a state other than IStoreBinding.State.Open
int size()
This method can be invoked on a binding in any state, though its
accuracy is not guaranteed in a state other than IStoreBinding.State.Open
This method cannot be invoked from within an event handler. Doing so can result in a deadlock.
void processMemberControlEvent(IStoreMemberControlEvent event)
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.
<T> void recordFieldUpdate(IStoreObject object, IStoreField<T> field, T oldValue, T newValue)
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.IStoreBinding put(IStoreObject object)
object
- The object to be added to the store.
IllegalArgumentException
- Thrown if the specified object is null
or the object is already in a store.
IllegalStateException
- Thrown if the binding is not open or if
the binding has the backup role.
This method adds a new object to a store. This method will throw an exception in an object with the same id as the object being added already exists in the store.
An object put into a store is immediately visible to any thread of
control accessing the store using the binding that put the object
into the store. With regard to visibility to other store members
(bindings), an object put into a store is not visible to other store
members (bindings) until the next commit(long, long, com.neeve.ods.IStoreObject[], int, com.neeve.ods.IStoreCommitCompletionEvent, int)
.
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.
IStoreBinding send(IStoreObject object)
object
- The object sent via the store.
IllegalArgumentException
- Thrown if the specified object is null
or the object is already in a store.
IllegalStateException
- Thrown if the binding is not open or if
the binding has the backup role.
This method sends an object as a message through the store. Messages
sent using this method are enqueued in the store until the next commit
or rollback. While enqueued, the messages are invisible to get(com.eaio.uuid.UUID)
and remove(com.neeve.ods.IStoreObject)
but field updates are recorded in the transaction
log. At the next commit, the enqueued messages are transmitted (along
with other store updates) to the peer members and the message records
removed from the store. On rollback, the message records are just
removed from the store. A message can only be sent once per commit
i.e. a subsequent send of the same message before a commit will throw
an exception. Upon completion of a commit or rollback, messages sent in
the committed/rolled back transaction can be resent.
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.
IStoreObject get(com.eaio.uuid.UUID id)
id
- The object's id
IllegalArgumentException
- Thrown if the specified id is null.
IllegalStateException
- Thrown if the binding is not open or if
the binding has the backup role.
This method retrieves an object with the specified id from a store. A value of null is returned if there is no object with the specified id in the store visible to the binding used to perform the get.
This method can be only be invoked on a binding in the initializing or open state.
This method cannot be invoked on a primary member from within an
event handler. Doing so can result in a deadlock. On a backup member,
this method can be called only from the IStoreObjectAddedEvent
,
the IStoreObjectUpdatedEvent
and IStoreObjectRemovedEvent
event handlers. It should not be called from elsewhere.
IStoreBinding remove(IStoreObject object)
IllegalArgumentException
- Thrown if the specified object is null
or the object is not in the store.
IllegalStateException
- Thrown if the binding is not open or if
the binding has the backup role.
Isolation semantics for removal are the same as for object addition (see
put(com.neeve.ods.IStoreObject)
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.
IStoreCommitCompletionEvent commit(long transactionId, long stableTransactionId, IStoreObject[] messages, int messageCount, IStoreCommitCompletionEvent completionEvent, int flags) throws OdsException
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:SUPPRESS_COMPLETION_EVENT_DISPATCH_IF_SYNC_COMPLETION
IllegalStateException
- Thrown if the binding is not open or if
the binding has the backup role.
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.
IStoreCommitCompletionEvent commit(long transactionId, long stableTransactionId, IStoreCommitCompletionEvent completionEvent, int flags) throws OdsException
OdsException
IStoreCommitCompletionEvent commit(IStoreCommitCompletionEvent completionEvent) throws OdsException
This method invokes commit(0, completionEvent)
OdsException
int createSavepoint()
A savepoint serves as a delimiter that can used to partially rollback a transaction.
A subsequent call to rollback(int)
with the returned savepoint version will
roll the transaction back to the state at the time of this call.
int getLastSavepoint()
Returns the savepoint version created by the last call to createSavepoint()
or the transaction's initial savepoint (0) if no savepoint has been created.
IStoreBinding rollback()
This method rolls back changes made to the store since the last commit. The rollback operation plays back and undoes all operations recorded in the calling thread's transaction log. The transaction log is then cleared.
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.
IllegalStateException
- Thrown if the binding is not open or if
the binding has the backup role.IStoreBinding rollback(int savepoint)
This method rolls back changes made to the store since the given savepoint. The rollback operation plays back and undoes all operations recorded in the calling thread's transaction log. The transaction log is then cleared after that point.
This method preserves the savepoint marker passed in, i.e. after this call
getLastSavepoint()
will return the provided savepoint, and all subseqeuent
savepoints are discarded.
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.
savepoint
- The savepoint to roll back to.
IllegalStateException
- Thrown if the binding is not open or if
the binding has the backup role.
IllegalArgumentException
- if the savepoint is greater than the
current savepoint or less than 0.createSavepoint()
void fail(Exception e)
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.
IllegalStateException
- Thrown if the binding is not open.
This method force fails a binding. The method will trigger the binding's
failure handling machinery. This will result in the dispatch of the
IStoreBindingFailedEvent
just as if the binding actually failed.
The principal purpose of this method is to simulate binding failures
for fault tolerance testing purposes. The user typically has no use for
this method and should use close(int)
when done with the binding.
A binding implictly closes itself (although it leaves its state as
IStoreBinding.State.Failed
) when it fails. Therefore, there is is not
necessary to call close() after a binding fails although it is
permissible to do so.
This method can be invoked on bindings in the open state.
This method cannot be invoked from within an event handler. Doing so can result in a deadlock.
void close(int flags)
flags
- Flags that qualify the close operation. The following
are the permissible flags that can be used with this method:NO_COMMIT_COMPLETIONS
- CLOSE_ICR_AS_FAIL
This method closes a store binding. Closing a store binding will remove it from the store (other member will receive a 'member down' event). Commit operations pending completion are discarded
This method can be invoked on bindings in any state. It is safe to invoke the method multiple times.
This method cannot be invoked from within an event handler. Doing so can result in a deadlock.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |