Class ReplicationTarget
java.lang.Object
org.opensearch.common.util.concurrent.AbstractRefCounted
org.opensearch.indices.replication.common.ReplicationTarget
- All Implemented Interfaces:
org.opensearch.common.util.concurrent.RefCounted
- Direct Known Subclasses:
RecoveryTarget
,SegmentReplicationTarget
public abstract class ReplicationTarget
extends org.opensearch.common.util.concurrent.AbstractRefCounted
Represents the target of a replication operation performed on a shard
- Opensearch.internal:
-
Field Summary
Modifier and TypeFieldDescriptionprotected final CancellableThreads
protected final AtomicBoolean
protected final IndexShard
protected final ReplicationListener
protected final org.apache.logging.log4j.Logger
protected final ReplicationLuceneIndex
protected final Store
-
Constructor Summary
ConstructorDescriptionReplicationTarget
(String name, IndexShard indexShard, ReplicationLuceneIndex stateIndex, ReplicationListener listener) -
Method Summary
Modifier and TypeMethodDescriptionvoid
cancel the replication.protected void
org.opensearch.core.action.ActionListener
<Void> createOrFinishListener
(TransportChannel channel, String action, RecoveryTransportRequest request) org.opensearch.core.action.ActionListener
<Void> createOrFinishListener
(TransportChannel channel, String action, RecoveryTransportRequest request, org.opensearch.common.CheckedFunction<Void, org.opensearch.core.transport.TransportResponse, Exception> responseFn) abstract String
protected void
void
fail
(ReplicationFailedException e, boolean sendShardFailure) fail the replication and call listenerlong
getId()
protected abstract String
void
handleFileChunk
(FileChunkRequest request, ReplicationTarget replicationTarget, AtomicLong bytesSinceLastPause, org.apache.lucene.store.RateLimiter rateLimiter, org.opensearch.core.action.ActionListener<Void> listener) Handle a FileChunkRequest for aReplicationTarget
.long
return the last time this ReplicationStatus was used (based on System.nanoTime()void
mark the current replication as doneorg.opensearch.core.action.ActionListener
<Void> markRequestReceivedAndCreateListener
(long requestSeqNo, org.opensearch.core.action.ActionListener<Void> listener) abstract void
notifyListener
(ReplicationFailedException e, boolean sendShardFailure) protected void
protected abstract void
onDone()
abstract boolean
reset
(CancellableThreads newTargetCancellableThreads) abstract ReplicationTarget
void
sets the lasAccessTime flag to noworg.opensearch.core.index.shard.ShardId
shardId()
abstract ReplicationState
state()
store()
abstract void
writeFileChunk
(StoreFileMetadata metadata, long position, org.opensearch.core.common.bytes.BytesReference content, boolean lastChunk, int totalTranslogOps, org.opensearch.core.action.ActionListener<Void> listener) Methods inherited from class org.opensearch.common.util.concurrent.AbstractRefCounted
alreadyClosed, decRef, getName, incRef, refCount, tryIncRef
-
Field Details
-
finished
-
indexShard
-
store
-
listener
-
logger
protected final org.apache.logging.log4j.Logger logger -
cancellableThreads
-
stateIndex
-
-
Constructor Details
-
ReplicationTarget
public ReplicationTarget(String name, IndexShard indexShard, ReplicationLuceneIndex stateIndex, ReplicationListener listener)
-
-
Method Details
-
getPrefix
-
onDone
protected abstract void onDone() -
onCancel
-
state
-
retryCopy
-
description
-
getListener
-
cancellableThreads
-
notifyListener
-
getId
public long getId() -
reset
- Throws:
IOException
-
lastAccessTime
public long lastAccessTime()return the last time this ReplicationStatus was used (based on System.nanoTime() -
setLastAccessTime
public void setLastAccessTime()sets the lasAccessTime flag to now -
markRequestReceivedAndCreateListener
-
indexShard
-
store
-
shardId
public org.opensearch.core.index.shard.ShardId shardId() -
markAsDone
public void markAsDone()mark the current replication as done -
cancel
cancel the replication. calling this method will clean temporary files and release the store unless this object is in use (in which case it will be cleaned once all ongoing users callAbstractRefCounted.decRef()
-
fail
fail the replication and call listener- Parameters:
e
- exception that encapsulates the failuresendShardFailure
- indicates whether to notify the master of the shard failure
-
ensureRefCount
protected void ensureRefCount() -
createOrFinishListener
@Nullable public org.opensearch.core.action.ActionListener<Void> createOrFinishListener(TransportChannel channel, String action, RecoveryTransportRequest request) -
createOrFinishListener
@Nullable public org.opensearch.core.action.ActionListener<Void> createOrFinishListener(TransportChannel channel, String action, RecoveryTransportRequest request, org.opensearch.common.CheckedFunction<Void, org.opensearch.core.transport.TransportResponse, Exception> responseFn) -
handleFileChunk
public void handleFileChunk(FileChunkRequest request, ReplicationTarget replicationTarget, AtomicLong bytesSinceLastPause, org.apache.lucene.store.RateLimiter rateLimiter, org.opensearch.core.action.ActionListener<Void> listener) throws IOException Handle a FileChunkRequest for aReplicationTarget
.- Parameters:
request
-FileChunkRequest
Request containing the file chunk.bytesSinceLastPause
-AtomicLong
Bytes since the last pause.rateLimiter
-RateLimiter
Rate limiter.listener
-ActionListener
listener that completes when the chunk has been written.- Throws:
IOException
- When there is an issue pausing the rate limiter.
-
writeFileChunk
public abstract void writeFileChunk(StoreFileMetadata metadata, long position, org.opensearch.core.common.bytes.BytesReference content, boolean lastChunk, int totalTranslogOps, org.opensearch.core.action.ActionListener<Void> listener) -
closeInternal
protected void closeInternal()- Specified by:
closeInternal
in classorg.opensearch.common.util.concurrent.AbstractRefCounted
-