public class RecoveryTarget extends AbstractRefCounted implements RecoveryTargetHandler
RecoveriesCollection.| Constructor and 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 indexShard
|
| Modifier and Type | Method and 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()
The finalize request clears unreferenced translog files, refreshes the engine now that
new segments are available, and enables garbage collection of
tombstone files.
|
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.
|
IndexShard |
indexShard() |
void |
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(int totalTranslogOps,
long maxUnsafeAutoIdTimestamp)
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 RecoveryTarget to retry recovery from the same source node onto the same IndexShard 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(int totalTranslogOps,
long maxUnsafeAutoIdTimestamp)
throws java.io.IOException
RecoveryTargetHandlerprepareForTranslogOperations in interface RecoveryTargetHandlertotalTranslogOps - total translog operations expected to be sentmaxUnsafeAutoIdTimestamp - the max timestamp that is used to de-optimize documents with auto-generated IDs in the engine.
This is used to ensure we don't add duplicate documents when we assume an append only case based on auto-generated IDsjava.io.IOExceptionpublic void finalizeRecovery()
RecoveryTargetHandlerfinalizeRecovery in interface RecoveryTargetHandlerpublic void ensureClusterStateVersion(long clusterStateVersion)
RecoveryTargetHandlerensureClusterStateVersion in interface RecoveryTargetHandlerpublic void indexTranslogOperations(java.util.List<Translog.Operation> operations, int totalTranslogOps) throws TranslogRecoveryPerformer.BatchOperationException
RecoveryTargetHandlerindexTranslogOperations in interface RecoveryTargetHandleroperations - operations to indextotalTranslogOps - current number of total operations expected to be indexedTranslogRecoveryPerformer.BatchOperationExceptionpublic 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