RefCounted, RecoveryTargetHandlerpublic class RecoveryTarget extends AbstractRefCounted implements RecoveryTargetHandler
RecoveriesCollection.| Constructor | Description |
|---|---|
RecoveryTarget(IndexShard indexShard,
DiscoveryNode sourceNode,
PeerRecoveryTargetService.RecoveryListener listener,
java.util.function.LongConsumer ensureClusterStateVersionCallback) |
Creates a new recovery target object that represents a recovery to the provided shard.
|
| Modifier and Type | Method | Description |
|---|---|---|
void |
cancel(java.lang.String reason) |
cancel the recovery.
|
CancellableThreads |
cancellableThreads() |
|
void |
cleanFiles(int totalTranslogOps,
Store.MetadataSnapshot sourceMetaData) |
After all source files has been sent over, this command is sent to the target so it can clean any local
files that are not part of the source store
|
protected void |
closeInternal() |
|
void |
ensureClusterStateVersion(long clusterStateVersion) |
Blockingly waits for cluster state with at least clusterStateVersion to be available
|
void |
fail(RecoveryFailedException e,
boolean sendShardFailure) |
fail the recovery and call listener
|
void |
finalizeRecovery(long globalCheckpoint) |
The finalize request refreshes the engine now that new segments are available, enables garbage collection of tombstone files, and
updates the global checkpoint.
|
org.apache.lucene.store.IndexOutput |
getOpenIndexOutput(java.lang.String key) |
|
java.lang.String |
getTempNameForFile(java.lang.String origFile) |
Get a temporary name for the provided file name.
|
void |
handoffPrimaryContext(GlobalCheckpointTracker.PrimaryContext primaryContext) |
Handoff the primary context between the relocation source and the relocation target.
|
IndexShard |
indexShard() |
|
long |
indexTranslogOperations(java.util.List<Translog.Operation> operations,
int totalTranslogOps) |
Index a set of translog operations on the target
|
long |
lastAccessTime() |
return the last time this RecoveryStatus was used (based on System.nanoTime()
|
void |
markAsDone() |
mark the current recovery as done
|
void |
notifyListener(RecoveryFailedException e,
boolean sendShardFailure) |
|
org.apache.lucene.store.IndexOutput |
openAndPutIndexOutput(java.lang.String fileName,
StoreFileMetaData metaData,
Store store) |
Creates an
IndexOutput for the given file name. |
void |
prepareForTranslogOperations(boolean createNewTranslog,
int totalTranslogOps) |
Implementation of
RecoveryTargetHandler |
void |
receiveFileInfo(java.util.List<java.lang.String> phase1FileNames,
java.util.List<java.lang.Long> phase1FileSizes,
java.util.List<java.lang.String> phase1ExistingFileNames,
java.util.List<java.lang.Long> phase1ExistingFileSizes,
int totalTranslogOps) |
Notifies the target of the files it is going to receive
|
long |
recoveryId() |
|
org.apache.lucene.store.IndexOutput |
removeOpenIndexOutputs(java.lang.String name) |
remove and
IndexOutput for a given file. |
void |
renameAllTempFiles() |
renames all temporary files to their true name, potentially overriding existing files
|
RecoveryTarget |
retryCopy() |
Returns a fresh recovery target to retry recovery from the same source node onto the same shard and using the same listener.
|
void |
setLastAccessTime() |
sets the lasAccessTime flag to now
|
ShardId |
shardId() |
|
DiscoveryNode |
sourceNode() |
|
RecoveryState.Stage |
stage() |
|
RecoveryState |
state() |
|
Store |
store() |
|
java.lang.String |
toString() |
|
void |
writeFileChunk(StoreFileMetaData fileMetaData,
long position,
BytesReference content,
boolean lastChunk,
int totalTranslogOps) |
writes a partial file chunk to the target store
|
alreadyClosed, decRef, getName, incRef, refCount, tryIncRefpublic RecoveryTarget(IndexShard indexShard, DiscoveryNode sourceNode, PeerRecoveryTargetService.RecoveryListener listener, java.util.function.LongConsumer ensureClusterStateVersionCallback)
indexShard - local shard where we want to recover tosourceNode - source node of the recovery where we recover fromlistener - called when recovery is completed/failedensureClusterStateVersionCallback - callback to ensure that the current node is at least on a cluster state with the provided
version; necessary for primary relocation so that new primary knows about all other ongoing
replica recoveries when replicating documents (see RecoverySourceHandler)public RecoveryTarget retryCopy()
public long recoveryId()
public ShardId shardId()
public IndexShard indexShard()
public DiscoveryNode sourceNode()
public RecoveryState state()
public CancellableThreads cancellableThreads()
public long lastAccessTime()
public void setLastAccessTime()
public Store store()
public RecoveryState.Stage stage()
public void renameAllTempFiles()
throws java.io.IOException
java.io.IOExceptionpublic void cancel(java.lang.String reason)
AbstractRefCounted.decRef()
if cancellableThreads() was used, the threads will be interrupted.
public void fail(RecoveryFailedException e, boolean sendShardFailure)
e - exception that encapsulating the failuresendShardFailure - indicates whether to notify the master of the shard failurepublic void notifyListener(RecoveryFailedException e, boolean sendShardFailure)
public void markAsDone()
public java.lang.String getTempNameForFile(java.lang.String origFile)
public org.apache.lucene.store.IndexOutput getOpenIndexOutput(java.lang.String key)
public org.apache.lucene.store.IndexOutput removeOpenIndexOutputs(java.lang.String name)
IndexOutput for a given file. It is the caller's responsibility to close itpublic org.apache.lucene.store.IndexOutput openAndPutIndexOutput(java.lang.String fileName,
StoreFileMetaData metaData,
Store store)
throws java.io.IOException
IndexOutput for the given file name. Note that the
IndexOutput actually point at a temporary file.
Note: You can use getOpenIndexOutput(String) with the same filename to retrieve the same IndexOutput
at a later stage
java.io.IOExceptionprotected void closeInternal()
closeInternal in class AbstractRefCountedpublic java.lang.String toString()
toString in class java.lang.Objectpublic void prepareForTranslogOperations(boolean createNewTranslog,
int totalTranslogOps)
throws java.io.IOException
RecoveryTargetHandlerprepareForTranslogOperations in interface RecoveryTargetHandlercreateNewTranslog - whether or not to delete the local translog on the targettotalTranslogOps - total translog operations expected to be sentjava.io.IOExceptionpublic void finalizeRecovery(long globalCheckpoint)
throws java.io.IOException
RecoveryTargetHandlerfinalizeRecovery in interface RecoveryTargetHandlerglobalCheckpoint - the global checkpoint on the recovery sourcejava.io.IOExceptionpublic void ensureClusterStateVersion(long clusterStateVersion)
RecoveryTargetHandlerensureClusterStateVersion in interface RecoveryTargetHandlerpublic void handoffPrimaryContext(GlobalCheckpointTracker.PrimaryContext primaryContext)
RecoveryTargetHandlerhandoffPrimaryContext in interface RecoveryTargetHandlerprimaryContext - the primary context from the relocation sourcepublic long indexTranslogOperations(java.util.List<Translog.Operation> operations, int totalTranslogOps) throws java.io.IOException
RecoveryTargetHandlerindexTranslogOperations in interface RecoveryTargetHandleroperations - operations to indextotalTranslogOps - current number of total operations expected to be indexedjava.io.IOExceptionpublic void receiveFileInfo(java.util.List<java.lang.String> phase1FileNames,
java.util.List<java.lang.Long> phase1FileSizes,
java.util.List<java.lang.String> phase1ExistingFileNames,
java.util.List<java.lang.Long> phase1ExistingFileSizes,
int totalTranslogOps)
RecoveryTargetHandlerreceiveFileInfo in interface RecoveryTargetHandlerpublic void cleanFiles(int totalTranslogOps,
Store.MetadataSnapshot sourceMetaData)
throws java.io.IOException
RecoveryTargetHandlercleanFiles in interface RecoveryTargetHandlertotalTranslogOps - an update number of translog operations that will be replayed later onsourceMetaData - meta data of the source storejava.io.IOExceptionpublic void writeFileChunk(StoreFileMetaData fileMetaData, long position, BytesReference content, boolean lastChunk, int totalTranslogOps) throws java.io.IOException
RecoveryTargetHandlerwriteFileChunk in interface RecoveryTargetHandlerjava.io.IOException