public class RecoveryTarget extends AbstractRefCounted implements RecoveryTargetHandler
RecoveriesCollection
.Constructor and Description |
---|
RecoveryTarget(IndexShard indexShard,
DiscoveryNode sourceNode,
PeerRecoveryTargetService.RecoveryListener listener,
Callback<java.lang.Long> ensureClusterStateVersionCallback) |
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
|
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
|
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, tryIncRef
public RecoveryTarget(IndexShard indexShard, DiscoveryNode sourceNode, PeerRecoveryTargetService.RecoveryListener listener, Callback<java.lang.Long> ensureClusterStateVersionCallback)
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.IOException
public 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 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.IOException
protected void closeInternal()
closeInternal
in class AbstractRefCounted
public java.lang.String toString()
toString
in class java.lang.Object
public void prepareForTranslogOperations(int totalTranslogOps, long maxUnsafeAutoIdTimestamp) throws java.io.IOException
RecoveryTargetHandler
prepareForTranslogOperations
in interface RecoveryTargetHandler
totalTranslogOps
- 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.IOException
public void finalizeRecovery()
RecoveryTargetHandler
finalizeRecovery
in interface RecoveryTargetHandler
public void ensureClusterStateVersion(long clusterStateVersion)
RecoveryTargetHandler
ensureClusterStateVersion
in interface RecoveryTargetHandler
public void indexTranslogOperations(java.util.List<Translog.Operation> operations, int totalTranslogOps) throws TranslogRecoveryPerformer.BatchOperationException
RecoveryTargetHandler
indexTranslogOperations
in interface RecoveryTargetHandler
operations
- operations to indextotalTranslogOps
- current number of total operations expected to be indexedTranslogRecoveryPerformer.BatchOperationException
public 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)
RecoveryTargetHandler
receiveFileInfo
in interface RecoveryTargetHandler
public void cleanFiles(int totalTranslogOps, Store.MetadataSnapshot sourceMetaData) throws java.io.IOException
RecoveryTargetHandler
cleanFiles
in interface RecoveryTargetHandler
totalTranslogOps
- an update number of translog operations that will be replayed later onsourceMetaData
- meta data of the source storejava.io.IOException
public void writeFileChunk(StoreFileMetaData fileMetaData, long position, BytesReference content, boolean lastChunk, int totalTranslogOps) throws java.io.IOException
RecoveryTargetHandler
writeFileChunk
in interface RecoveryTargetHandler
java.io.IOException