mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-08 22:14:59 +00:00
parent
9aa6f7c434
commit
598e00a689
@ -531,11 +531,11 @@ public class PeerRecoveryTargetService implements IndexEventListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void messageReceived(RecoveryFilesInfoRequest request, TransportChannel channel, Task task) throws Exception {
|
public void messageReceived(RecoveryFilesInfoRequest request, TransportChannel channel, Task task) throws Exception {
|
||||||
try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId()
|
try (RecoveryRef recoveryRef = onGoingRecoveries.getRecoverySafe(request.recoveryId(), request.shardId())) {
|
||||||
)) {
|
final ActionListener<TransportResponse> listener = new ChannelActionListener<>(channel, Actions.FILES_INFO, request);
|
||||||
recoveryRef.target().receiveFileInfo(request.phase1FileNames, request.phase1FileSizes, request.phase1ExistingFileNames,
|
recoveryRef.target().receiveFileInfo(
|
||||||
request.phase1ExistingFileSizes, request.totalTranslogOps);
|
request.phase1FileNames, request.phase1FileSizes, request.phase1ExistingFileNames, request.phase1ExistingFileSizes,
|
||||||
channel.sendResponse(TransportResponse.Empty.INSTANCE);
|
request.totalTranslogOps, ActionListener.map(listener, nullVal -> TransportResponse.Empty.INSTANCE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -406,17 +406,25 @@ public class RecoverySourceHandler {
|
|||||||
logger.trace("recovery [phase1]: recovering_files [{}] with total_size [{}], reusing_files [{}] with total_size [{}]",
|
logger.trace("recovery [phase1]: recovering_files [{}] with total_size [{}], reusing_files [{}] with total_size [{}]",
|
||||||
phase1FileNames.size(), new ByteSizeValue(totalSizeInBytes),
|
phase1FileNames.size(), new ByteSizeValue(totalSizeInBytes),
|
||||||
phase1ExistingFileNames.size(), new ByteSizeValue(existingTotalSizeInBytes));
|
phase1ExistingFileNames.size(), new ByteSizeValue(existingTotalSizeInBytes));
|
||||||
cancellableThreads.execute(() -> recoveryTarget.receiveFileInfo(
|
final StepListener<Void> sendFileInfoStep = new StepListener<>();
|
||||||
phase1FileNames, phase1FileSizes, phase1ExistingFileNames, phase1ExistingFileSizes, translogOps.getAsInt()));
|
final StepListener<Void> cleanFilesStep = new StepListener<>();
|
||||||
sendFiles(store, phase1Files.toArray(new StoreFileMetaData[0]), translogOps);
|
cancellableThreads.execute(() ->
|
||||||
|
recoveryTarget.receiveFileInfo(phase1FileNames, phase1FileSizes, phase1ExistingFileNames,
|
||||||
|
phase1ExistingFileSizes, translogOps.getAsInt(), sendFileInfoStep));
|
||||||
|
|
||||||
|
sendFileInfoStep.whenComplete(r -> {
|
||||||
|
sendFiles(store, phase1Files.toArray(new StoreFileMetaData[0]), translogOps);
|
||||||
|
cleanFiles(store, recoverySourceMetadata, translogOps, globalCheckpoint, cleanFilesStep);
|
||||||
|
}, listener::onFailure);
|
||||||
|
|
||||||
final long totalSize = totalSizeInBytes;
|
final long totalSize = totalSizeInBytes;
|
||||||
final long existingTotalSize = existingTotalSizeInBytes;
|
final long existingTotalSize = existingTotalSizeInBytes;
|
||||||
cleanFiles(store, recoverySourceMetadata, translogOps, globalCheckpoint, ActionListener.map(listener, aVoid -> {
|
cleanFilesStep.whenComplete(r -> {
|
||||||
final TimeValue took = stopWatch.totalTime();
|
final TimeValue took = stopWatch.totalTime();
|
||||||
logger.trace("recovery [phase1]: took [{}]", took);
|
logger.trace("recovery [phase1]: took [{}]", took);
|
||||||
return new SendFileResult(phase1FileNames, phase1FileSizes, totalSize, phase1ExistingFileNames,
|
listener.onResponse(new SendFileResult(phase1FileNames, phase1FileSizes, totalSize, phase1ExistingFileNames,
|
||||||
phase1ExistingFileSizes, existingTotalSize, took);
|
phase1ExistingFileSizes, existingTotalSize, took));
|
||||||
}));
|
}, listener::onFailure);
|
||||||
} else {
|
} else {
|
||||||
logger.trace("skipping [phase1]- identical sync id [{}] found on both source and target",
|
logger.trace("skipping [phase1]- identical sync id [{}] found on both source and target",
|
||||||
recoverySourceMetadata.getSyncId());
|
recoverySourceMetadata.getSyncId());
|
||||||
|
@ -378,17 +378,20 @@ public class RecoveryTarget extends AbstractRefCounted implements RecoveryTarget
|
|||||||
List<Long> phase1FileSizes,
|
List<Long> phase1FileSizes,
|
||||||
List<String> phase1ExistingFileNames,
|
List<String> phase1ExistingFileNames,
|
||||||
List<Long> phase1ExistingFileSizes,
|
List<Long> phase1ExistingFileSizes,
|
||||||
int totalTranslogOps) {
|
int totalTranslogOps,
|
||||||
final RecoveryState.Index index = state().getIndex();
|
ActionListener<Void> listener) {
|
||||||
for (int i = 0; i < phase1ExistingFileNames.size(); i++) {
|
ActionListener.completeWith(listener, () -> {
|
||||||
index.addFileDetail(phase1ExistingFileNames.get(i), phase1ExistingFileSizes.get(i), true);
|
final RecoveryState.Index index = state().getIndex();
|
||||||
}
|
for (int i = 0; i < phase1ExistingFileNames.size(); i++) {
|
||||||
for (int i = 0; i < phase1FileNames.size(); i++) {
|
index.addFileDetail(phase1ExistingFileNames.get(i), phase1ExistingFileSizes.get(i), true);
|
||||||
index.addFileDetail(phase1FileNames.get(i), phase1FileSizes.get(i), false);
|
}
|
||||||
}
|
for (int i = 0; i < phase1FileNames.size(); i++) {
|
||||||
state().getTranslog().totalOperations(totalTranslogOps);
|
index.addFileDetail(phase1FileNames.get(i), phase1FileSizes.get(i), false);
|
||||||
state().getTranslog().totalOperationsOnStart(totalTranslogOps);
|
}
|
||||||
|
state().getTranslog().totalOperations(totalTranslogOps);
|
||||||
|
state().getTranslog().totalOperationsOnStart(totalTranslogOps);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,7 +88,8 @@ public interface RecoveryTargetHandler {
|
|||||||
List<Long> phase1FileSizes,
|
List<Long> phase1FileSizes,
|
||||||
List<String> phase1ExistingFileNames,
|
List<String> phase1ExistingFileNames,
|
||||||
List<Long> phase1ExistingFileSizes,
|
List<Long> phase1ExistingFileSizes,
|
||||||
int totalTranslogOps);
|
int totalTranslogOps,
|
||||||
|
ActionListener<Void> listener);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After all source files has been sent over, this command is sent to the target so it can clean any local
|
* After all source files has been sent over, this command is sent to the target so it can clean any local
|
||||||
|
@ -129,14 +129,13 @@ public class RemoteRecoveryTargetHandler implements RecoveryTargetHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveFileInfo(List<String> phase1FileNames, List<Long> phase1FileSizes, List<String> phase1ExistingFileNames,
|
public void receiveFileInfo(List<String> phase1FileNames, List<Long> phase1FileSizes, List<String> phase1ExistingFileNames,
|
||||||
List<Long> phase1ExistingFileSizes, int totalTranslogOps) {
|
List<Long> phase1ExistingFileSizes, int totalTranslogOps, ActionListener<Void> listener) {
|
||||||
|
|
||||||
RecoveryFilesInfoRequest recoveryInfoFilesRequest = new RecoveryFilesInfoRequest(recoveryId, shardId,
|
RecoveryFilesInfoRequest recoveryInfoFilesRequest = new RecoveryFilesInfoRequest(recoveryId, shardId,
|
||||||
phase1FileNames, phase1FileSizes, phase1ExistingFileNames, phase1ExistingFileSizes, totalTranslogOps);
|
phase1FileNames, phase1FileSizes, phase1ExistingFileNames, phase1ExistingFileSizes, totalTranslogOps);
|
||||||
transportService.submitRequest(targetNode, PeerRecoveryTargetService.Actions.FILES_INFO, recoveryInfoFilesRequest,
|
transportService.submitRequest(targetNode, PeerRecoveryTargetService.Actions.FILES_INFO, recoveryInfoFilesRequest,
|
||||||
TransportRequestOptions.builder().withTimeout(recoverySettings.internalActionTimeout()).build(),
|
TransportRequestOptions.builder().withTimeout(recoverySettings.internalActionTimeout()).build(),
|
||||||
EmptyTransportResponseHandler.INSTANCE_SAME).txGet();
|
new ActionListenerResponseHandler<>(ActionListener.map(listener, r -> null),
|
||||||
|
in -> TransportResponse.Empty.INSTANCE, ThreadPool.Names.GENERIC));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -145,11 +145,13 @@ public class PeerRecoveryTargetServiceTests extends IndexShardTestCase {
|
|||||||
final DiscoveryNode rNode = getFakeDiscoNode(targetShard.routingEntry().currentNodeId());
|
final DiscoveryNode rNode = getFakeDiscoNode(targetShard.routingEntry().currentNodeId());
|
||||||
targetShard.markAsRecovering("test-peer-recovery", new RecoveryState(targetShard.routingEntry(), rNode, pNode));
|
targetShard.markAsRecovering("test-peer-recovery", new RecoveryState(targetShard.routingEntry(), rNode, pNode));
|
||||||
final RecoveryTarget recoveryTarget = new RecoveryTarget(targetShard, null, null);
|
final RecoveryTarget recoveryTarget = new RecoveryTarget(targetShard, null, null);
|
||||||
|
final PlainActionFuture<Void> receiveFileInfoFuture = new PlainActionFuture<>();
|
||||||
recoveryTarget.receiveFileInfo(
|
recoveryTarget.receiveFileInfo(
|
||||||
mdFiles.stream().map(StoreFileMetaData::name).collect(Collectors.toList()),
|
mdFiles.stream().map(StoreFileMetaData::name).collect(Collectors.toList()),
|
||||||
mdFiles.stream().map(StoreFileMetaData::length).collect(Collectors.toList()),
|
mdFiles.stream().map(StoreFileMetaData::length).collect(Collectors.toList()),
|
||||||
Collections.emptyList(), Collections.emptyList(), 0
|
Collections.emptyList(), Collections.emptyList(), 0, receiveFileInfoFuture
|
||||||
);
|
);
|
||||||
|
receiveFileInfoFuture.actionGet();
|
||||||
List<RecoveryFileChunkRequest> requests = new ArrayList<>();
|
List<RecoveryFileChunkRequest> requests = new ArrayList<>();
|
||||||
for (StoreFileMetaData md : mdFiles) {
|
for (StoreFileMetaData md : mdFiles) {
|
||||||
try (IndexInput in = sourceShard.store().directory().openInput(md.name(), IOContext.READONCE)) {
|
try (IndexInput in = sourceShard.store().directory().openInput(md.name(), IOContext.READONCE)) {
|
||||||
|
@ -753,7 +753,8 @@ public class RecoverySourceHandlerTests extends ESTestCase {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveFileInfo(List<String> phase1FileNames, List<Long> phase1FileSizes, List<String> phase1ExistingFileNames,
|
public void receiveFileInfo(List<String> phase1FileNames, List<Long> phase1FileSizes, List<String> phase1ExistingFileNames,
|
||||||
List<Long> phase1ExistingFileSizes, int totalTranslogOps) {
|
List<Long> phase1ExistingFileSizes, int totalTranslogOps, ActionListener<Void> listener) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -69,8 +69,9 @@ public class AsyncRecoveryTarget implements RecoveryTargetHandler {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveFileInfo(List<String> phase1FileNames, List<Long> phase1FileSizes, List<String> phase1ExistingFileNames,
|
public void receiveFileInfo(List<String> phase1FileNames, List<Long> phase1FileSizes, List<String> phase1ExistingFileNames,
|
||||||
List<Long> phase1ExistingFileSizes, int totalTranslogOps) {
|
List<Long> phase1ExistingFileSizes, int totalTranslogOps, ActionListener<Void> listener) {
|
||||||
target.receiveFileInfo(phase1FileNames, phase1FileSizes, phase1ExistingFileNames, phase1ExistingFileSizes, totalTranslogOps);
|
executor.execute(() -> target.receiveFileInfo(
|
||||||
|
phase1FileNames, phase1FileSizes, phase1ExistingFileNames, phase1ExistingFileSizes, totalTranslogOps, listener));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user