protected class AbstractJournal.BasicHA extends Object implements HAGlue
| Modifier and Type | Class and Description |
|---|---|
protected class |
AbstractJournal.BasicHA.VoteNoTask
Task votes NO (unconditional).
|
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractJournal.BasicHA(UUID serviceId,
InetSocketAddress writePipelineAddr) |
| Modifier and Type | Method and Description |
|---|---|
Future<Void> |
abort2Phase(IHA2PhaseAbortMessage abortMessage)
Discard the current write set using
AbstractJournal.abort(),
reloading all state from the last root block, etc. |
long |
awaitHAReady(long timeout,
TimeUnit units)
Await the service being ready to partitipate in an HA quorum.
|
IHANotifyReleaseTimeResponse |
awaitServiceJoin(IHAAwaitServiceJoinRequest req)
A follower uses this message to request that the quorum leader await the
visibility of the zookeeper event in which the service join becomes
visible to the leader.
|
Future<Void> |
commit2Phase(IHA2PhaseCommitMessage commitMessage)
Commit using the root block from the corresponding prepare message.
|
IHADigestResponse |
computeDigest(IHADigestRequest req)
Compute the digest of the entire backing store - THIS METHOD IS
ONLY FOR DIAGNOSTIC PURPOSES.
|
IHALogDigestResponse |
computeHALogDigest(IHALogDigestRequest req)
Compute the digest of the entire HALog file - THIS METHOD IS ONLY
FOR DIAGNOSTIC PURPOSES.
|
IHASnapshotDigestResponse |
computeHASnapshotDigest(IHASnapshotDigestRequest req)
Compute the digest of the entire snapshot file - THIS METHOD IS
ONLY FOR DIAGNOSTIC PURPOSES. This digest is computed for the
compressed data so it may be compared directly with the digest of the
backing store from which the snapshot was obtained.
|
void |
destroy()
Destroy the service.
|
void |
gatherMinimumVisibleCommitTime(IHAGatherReleaseTimeRequest req)
Message used to request information about the earliest commit point that
is pinned on a follower.
|
String |
getExtendedRunState()
The extended run state of the service - this embeds more information but
is not designed for progamatic interpretation.
|
IHALogRootBlocksResponse |
getHALogRootBlocksForWriteSet(IHALogRootBlocksRequest msg)
Request the root blocks for the HA Log for the specified commit point.
|
HAStatusEnum |
getHAStatus()
A simplified summary of the HA status of the service.
|
IHAWriteSetStateResponse |
getHAWriteSetState(IHAWriteSetStateRequest req)
Request metadata about the current write set from the quorum leader.
|
String |
getHostname()
The host on which this service is running.
|
AbstractJournal |
getIndexManager()
Return the backing
IIndexManager (non-RMI method). |
int |
getNSSPort()
The port that the NanoSparqlServer is running on.
|
protected <E> Future<E> |
getProxy(Future<E> future)
Return a proxy object for a
Future suitable for use in an RMI
environment (the default implementation returns its argument). |
protected <E> Future<E> |
getProxy(Future<E> future,
boolean asyncFuture)
Return a proxy object for a
Future suitable for use in an RMI
environment (the default implementation returns its argument). |
IHARootBlockResponse |
getRootBlock(IHARootBlockRequest msg)
Return the then current root block for the persistence store.
|
RunState |
getRunState()
The
RunState of the service - this does NOT tell you whether the
service is ready to act as a leader or follower. |
UUID |
getServiceId()
The
UUID of this service. |
Class |
getServiceIface()
Return the most interesting interface for the service.
|
String |
getServiceName()
Return name by which a user might recognize this service.
|
UUID |
getServiceUUID()
The unique identifier for this service.
|
InetSocketAddress |
getWritePipelineAddr()
Return the address at which this service will listen for write pipeline
messages sent from the upstream service.
|
Future<Void> |
moveToEndOfPipeline()
Instruct the service to move to the end of the write pipeline.
|
long |
nextTimestamp()
This exposes the clock used to assign transaction identifiers and
commit times.
|
IHANotifyReleaseTimeResponse |
notifyEarliestCommitTime(IHANotifyReleaseTimeRequest req)
Message used by the follower to notify the leader about the new release
time that will be visible for new transaction starts.
|
Future<Boolean> |
prepare2Phase(IHA2PhasePrepareMessage prepareMessage)
Save a reference to the caller's root block, flush writes to the backing
channel and acknowledge "yes" if ready to commit.
|
Future<IHAReadResponse> |
readFromDisk(IHAReadRequest msg)
Read a record an
IRawStore managed by the service. |
Future<Void> |
rebuildFromLeader(IHARemoteRebuildRequest req)
Disaster recovery (REBUILD) of the local database instance from the
leader of a met quorum.
|
Future<Void> |
receiveAndReplicate(IHASyncRequest req,
IHASendState snd,
IHAWriteMessage msg)
Accept metadata describing an NIO buffer transfer along the write
pipeline.
|
Future<IHAPipelineResetResponse> |
resetPipeline(IHAPipelineResetRequest req)
Reset the pipeline (blocking).
|
Future<Void> |
sendHALogForWriteSet(IHALogRequest msg)
The recipient will send the
WriteCache blocks for the specified
write set on the write pipeline. |
Future<IHASendStoreResponse> |
sendHAStore(IHARebuildRequest msg)
Send the raw blocks for the requested backing store across the write
pipeline.
|
<T> Future<T> |
submit(IIndexManagerCallable<T> callable,
boolean asyncFuture)
Run the caller's task on the service.
|
Future<IHASnapshotResponse> |
takeSnapshot(IHASnapshotRequest req)
Request that the service take a snapshot.
|
protected void |
validateNewRootBlock(boolean isLeader,
IRootBlockView oldRB,
IRootBlockView newRB)
Validate the new root block against the current root block.
|
protected AbstractJournal.BasicHA(UUID serviceId, InetSocketAddress writePipelineAddr)
public AbstractJournal getIndexManager()
IIndexManager (non-RMI method).public UUID getServiceId()
HAGlueBaseUUID of this service.getServiceId in interface HAGlueBasepublic InetSocketAddress getWritePipelineAddr()
HAPipelineGluegetWritePipelineAddr in interface HAPipelineGluepublic int getNSSPort()
HAGluegetNSSPort in interface HAGluepublic RunState getRunState()
HAGlueRunState of the service - this does NOT tell you whether the
service is ready to act as a leader or follower.getRunState in interface HAGluepublic String getExtendedRunState()
HAGluegetExtendedRunState in interface HAGluepublic HAStatusEnum getHAStatus()
HAGlueHAStatusEnum.Leader, a
HAStatusEnum.Follower, or HAStatusEnum.NotReady. This is
exposed both here (an RMI interface) and by the REST API.getHAStatus in interface HAGluepublic long awaitHAReady(long timeout,
TimeUnit units)
throws AsynchronousQuorumCloseException,
InterruptedException,
TimeoutException
HAGlue#setQuorumToken(long)commitCounter:=0, then the root blocks from the leader have
been installed on the follower.awaitHAReady in interface HAGluetimeout - The timeout to await this condition.AsynchronousQuorumCloseExceptionInterruptedExceptionTimeoutExceptionpublic IHANotifyReleaseTimeResponse awaitServiceJoin(IHAAwaitServiceJoinRequest req) throws AsynchronousQuorumCloseException, InterruptedException, TimeoutException
AbstractHATransactionService.runWithBarrierLock(Runnable).awaitServiceJoin in interface HAGluereq - The request.InterruptedExceptionTimeoutException - if the timeout is exceeded before the service join becomes
visible to this service.AsynchronousQuorumCloseExceptionpublic IHADigestResponse computeDigest(IHADigestRequest req) throws IOException, NoSuchAlgorithmException, DigestException
HAGlueThe digest is useless if there are concurrent writes since it can not be meaningfully compared with the digest of another store unless both stores are known to be stable.
computeDigest in interface HAGlueIOExceptionNoSuchAlgorithmExceptionDigestExceptionpublic IHALogDigestResponse computeHALogDigest(IHALogDigestRequest req) throws IOException, NoSuchAlgorithmException, DigestException
HAGlueThe digest is useless if there are concurrent writes since it can not be meaningfully compared with the digest of another store unless both stores are known to be stable.
computeHALogDigest in interface HAGlueFileNotFoundException - if the HALog for the specified commit point does not exist.IOExceptionNoSuchAlgorithmExceptionDigestExceptionpublic IHASnapshotDigestResponse computeHASnapshotDigest(IHASnapshotDigestRequest req) throws IOException, NoSuchAlgorithmException, DigestException
HAGluecomputeHASnapshotDigest in interface HAGlueFileNotFoundException - if no snapshot exists for that commit point.IOExceptionNoSuchAlgorithmExceptionDigestExceptionpublic Future<IHASnapshotResponse> takeSnapshot(IHASnapshotRequest req) throws IOException
HAGlueFuture for that request will be returned.takeSnapshot in interface HAGluereq - The request (optional). When null, the
Future for any existing snapshot operation will be
returned but the request WILL NOT schedule a snapshot if none
is running.Future for the snapshot -or- null if no
snapshot is running and none will be taken for that request.IOExceptionpublic Future<Void> rebuildFromLeader(IHARemoteRebuildRequest req) throws IOException
HAGlueHAStatusEnum#Ready leader.HAStatusEnum.NotReady.HAJournalServer must not be running a RESTORE (we don't
want it to accidentally interrupt a RESTORE that is in progress).rebuildFromLeader in interface HAGlueFuture of the REBUILD operation -or-
null if any of the pre-conditions were violated.IOExceptionprotected final <E> Future<E> getProxy(Future<E> future)
Future suitable for use in an RMI
environment (the default implementation returns its argument).future - The future.protected <E> Future<E> getProxy(Future<E> future, boolean asyncFuture)
Future suitable for use in an RMI
environment (the default implementation returns its argument).future - The future.asyncFuture - When true, the service should not wait for
the Future to complete but should return a proxy
object that may be used by the client to monitor or cancel
the Future. When false, the method
should wait for the Future to complete and then
return a "thick" Future which wraps the completion
state but does not permit asynchronous monitoring or
cancellation of the operation wrapped by the
Future.public Future<Boolean> prepare2Phase(IHA2PhasePrepareMessage prepareMessage)
HACommitGlueprepare2Phase in interface HACommitGlueprepareMessage - The message used to prepare for the commit.Future which evaluates to a yes/no vote on whether the
service is prepared to commit.protected void validateNewRootBlock(boolean isLeader,
IRootBlockView oldRB,
IRootBlockView newRB)
isLeader - iff this service is the leader for this commit.oldRB - the old (aka current) root block.newRB - the new (aka proposed) root block.public Future<Void> commit2Phase(IHA2PhaseCommitMessage commitMessage)
HACommitGluecommit2Phase in interface HACommitGluecommitMessage - The commit message.public Future<Void> abort2Phase(IHA2PhaseAbortMessage abortMessage)
HACommitGlueAbstractJournal.abort(),
reloading all state from the last root block, etc.
Note: A service automatically does a local abort() if it leaves the pool of services joined with the quorum or if the leader fails over. Therefore a service should reject this message if the token has been invalidated since the service either has dine or will shortly do a low-level abort() on its own initiative.
abort2Phase in interface HACommitGluepublic Future<IHAReadResponse> readFromDisk(IHAReadRequest msg)
IRawStore managed by the service. Services MUST
NOT refer this message to another service. If the read can not be
satisfied, for example because the IRawStore has been released or
because there is a checksum error when reading on the IRawStore,
then that exception should be thrown back to the caller.readFromDisk in interface HAReadGluemsg - The IHAReadRequest.Future of an operation which evaluated to the desired
record.QuorumRead.readFromQuorum(UUID, long)public Future<Void> receiveAndReplicate(IHASyncRequest req, IHASendState snd, IHAWriteMessage msg) throws IOException
HAPipelineGluereceiveAndReplicate in interface HAPipelineGluereq - A request for an HALog (optional). This is only non-null when
historical WriteCache blocks are being replayed down
the write pipeline in order to synchronize a service.snd - Metadata about the state of the sender and potentially the
routing of the payload along the write replication pipeline.msg - The metadata.Future which will become available once the buffer
transfer is complete.IOExceptionpublic IHALogRootBlocksResponse getHALogRootBlocksForWriteSet(IHALogRootBlocksRequest msg) throws IOException
HAPipelineGluegetHALogRootBlocksForWriteSet in interface HAPipelineGluemsg - The request (specifies the desired HA Log by the commit
counter of the closing root block).IOExceptionpublic Future<Void> sendHALogForWriteSet(IHALogRequest msg) throws IOException
HAPipelineGlueWriteCache blocks for the specified
write set on the write pipeline. These WriteCache blocks will be
visible to ALL services in the write pipeline. It is important that all
services ignore WriteCache blocks that are not in
sequence for the current write set unless they have explicitly requested
an HALog using this method.
Note: The WriteCache blocks are sent on the write pipeline.
Therefore, a service MUST NOT request the write set from a service that
is downstream from it in the write pipeline. It is always safe to request
the data from the leader.
Note: The HAWriteMessage includes a quorum token. When historical
WriteCache blocks are being replicated in response to this
method, the will be replicated using the quorum token that was in effect
for that write set. Implementations MUST NOT perform asserts on the
quorum token until after they have determined that the message is for the
current write set.
Note: DO NOT use a ThickFuture for the returned Future.
That will defeat the ability of the requester to cancel the
Future.
sendHALogForWriteSet in interface HAPipelineGlueFuture that may be used to cancel the remote process
sending the data through the write pipeline.IOExceptionpublic Future<IHASendStoreResponse> sendHAStore(IHARebuildRequest msg) throws IOException
HAPipelineGlueNote: This method supports disaster recovery of a service from a met quorum. This procedure can only be used when a met quorum exists.
Note: DO NOT use a ThickFuture for the returned Future.
That will defeat the ability of the requester to cancel the
Future.
sendHAStore in interface HAPipelineGlueFuture that may be used to cancel the remote process
sending the data through the write pipeline. The Future
will report the current root block in effect as of the moment
when the sendHAStore operation was completed.IOExceptionpublic IHAWriteSetStateResponse getHAWriteSetState(IHAWriteSetStateRequest req)
HAPipelineGluegetHAWriteSetState in interface HAPipelineGluereq - The request.public IHARootBlockResponse getRootBlock(IHARootBlockRequest msg)
HAGlueNote: The initial root blocks are identical, so this may be used to create a new journal in a quorum by replicating the root blocks of the quorum leader.
getRootBlock in interface HAGluemsg - The message requesting the then current root block.public Future<Void> moveToEndOfPipeline()
This implementation does pipeline remove() followed by pipline add().
moveToEndOfPipeline in interface HAPipelineGluepublic Future<IHAPipelineResetResponse> resetPipeline(IHAPipelineResetRequest req) throws IOException
HAPipelineGlueHAReceiveService (including the inner HASendService). The
next message and payload relayed from the leader will cause new socket
connections to be established.resetPipeline in interface HAPipelineGlueFuture for the operation on the remote service.IOExceptionpublic void gatherMinimumVisibleCommitTime(IHAGatherReleaseTimeRequest req) throws IOException
Note: This message is used as part of a pattern where the leader
instructs the followers to message the leader with their earliest commit
point pinned by either a transaction or the minReleaseAge of their
ITransactionService using
#notifyEarliestCommitTime(IHANotifyReleaseTimeResponse).
The message is a sync RMI call. The follower will clear an outcome and
execute a task which runs asynchronously and messages back to the leader
with its IHANotifyReleaseTimeResponse. The leader will report
back the consensus release time. The outcome of these on the follower is
not directly reported back to the leader, e.g., through a remote
Future because this causes a DGC thread leak on the follower. See
the ticket below. Instead, the follower notes the outcome of the gather
operation and will vote "NO" in
HACommitGlue.prepare2Phase(IHA2PhasePrepareMessage) unless it
completes its side of the release time consensus protocol without error
(that is, the otherwise unmonitored outcome of the asynchronous task for
HATXSGlue.gatherMinimumVisibleCommitTime(IHAGatherReleaseTimeRequest)).
gatherMinimumVisibleCommitTime in interface HATXSGluereq - The request from the leader.IOExceptionpublic IHANotifyReleaseTimeResponse notifyEarliestCommitTime(IHANotifyReleaseTimeRequest req) throws IOException, InterruptedException, BrokenBarrierException
HATXSGluenotifyEarliestCommitTime in interface HATXSGlueInterruptedExceptionBrokenBarrierExceptionIOExceptionpublic long nextTimestamp()
Note: This method is NOT exposed to RMI. However, it can still be overridden by the unit tests.
public UUID getServiceUUID() throws IOException
IService
Note: Some service discovery frameworks (Jini) will assign the service a
UUID asynchronously after a new service starts, in which case
this method will return null until the service
UUID has been assigned.
getServiceUUID in interface IServiceIOException - since you can use this method with RMI.public Class getServiceIface() throws IOException
IServicegetServiceIface in interface IServiceIOException - since you can use this method with RMI.public String getHostname() throws IOException
IServicegetHostname in interface IServiceIOException - since you can use this method with RMI.public String getServiceName() throws IOException
IServicegetServiceName in interface IServiceIOException - since you can use this method with RMI.public void destroy()
throws RemoteException
IServiceDestroyAdmin#destroy().destroy in interface IServiceRemoteExceptionpublic <T> Future<T> submit(IIndexManagerCallable<T> callable, boolean asyncFuture) throws IOException
HAGlue
Note: This interface provides direct access to the raw index manager.
Caller's requiring concurrency control should submit an IApiTask
in order to have their task queue for the necessary locks and run on the
appropriate executor service.
submit in interface HAGluecallable - The task to run on the service.asyncFuture - true if the task will execute asynchronously
and return a Future for the computation that may
be used to inspect and/or cancel the computation.
false if the task will execute synchronously
and return a thick Future.IOExceptionCopyright © 2006–2019 SYSTAP, LLC DBA Blazegraph. All rights reserved.