MINOR: BlobstoreRepository Cleanups (#36140)
* Removed redundant private getter * Removed unused `version` field
This commit is contained in:
parent
9c49aacbcf
commit
f763037b03
|
@ -458,7 +458,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
if (indexMetaData != null) {
|
||||
for (int shardId = 0; shardId < indexMetaData.getNumberOfShards(); shardId++) {
|
||||
try {
|
||||
delete(snapshotId, snapshot.version(), indexId, new ShardId(indexMetaData.getIndex(), shardId));
|
||||
delete(snapshotId, indexId, new ShardId(indexMetaData.getIndex(), shardId));
|
||||
} catch (SnapshotException ex) {
|
||||
final int finalShardId = shardId;
|
||||
logger.warn(() -> new ParameterizedMessage("[{}] failed to delete shard data for shard [{}][{}]",
|
||||
|
@ -864,7 +864,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
|
||||
@Override
|
||||
public void restoreShard(IndexShard shard, SnapshotId snapshotId, Version version, IndexId indexId, ShardId snapshotShardId, RecoveryState recoveryState) {
|
||||
final RestoreContext snapshotContext = new RestoreContext(shard, snapshotId, version, indexId, snapshotShardId, recoveryState);
|
||||
final RestoreContext snapshotContext = new RestoreContext(shard, snapshotId, indexId, snapshotShardId, recoveryState);
|
||||
try {
|
||||
snapshotContext.restore();
|
||||
} catch (Exception e) {
|
||||
|
@ -874,7 +874,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
|
||||
@Override
|
||||
public IndexShardSnapshotStatus getShardSnapshotStatus(SnapshotId snapshotId, Version version, IndexId indexId, ShardId shardId) {
|
||||
Context context = new Context(snapshotId, version, indexId, shardId);
|
||||
Context context = new Context(snapshotId, indexId, shardId);
|
||||
BlobStoreIndexShardSnapshot snapshot = context.loadSnapshot();
|
||||
return IndexShardSnapshotStatus.newDone(snapshot.startTime(), snapshot.time(),
|
||||
snapshot.incrementalFileCount(), snapshot.totalFileCount(),
|
||||
|
@ -916,8 +916,8 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
* @param snapshotId snapshot id
|
||||
* @param shardId shard id
|
||||
*/
|
||||
private void delete(SnapshotId snapshotId, Version version, IndexId indexId, ShardId shardId) {
|
||||
Context context = new Context(snapshotId, version, indexId, shardId, shardId);
|
||||
private void delete(SnapshotId snapshotId, IndexId indexId, ShardId shardId) {
|
||||
Context context = new Context(snapshotId, indexId, shardId, shardId);
|
||||
context.delete();
|
||||
}
|
||||
|
||||
|
@ -929,10 +929,6 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
']';
|
||||
}
|
||||
|
||||
BlobStoreFormat<BlobStoreIndexShardSnapshot> indexShardSnapshotFormat(Version version) {
|
||||
return indexShardSnapshotFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Context for snapshot/restore operations
|
||||
*/
|
||||
|
@ -944,15 +940,12 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
|
||||
protected final BlobContainer blobContainer;
|
||||
|
||||
protected final Version version;
|
||||
|
||||
Context(SnapshotId snapshotId, Version version, IndexId indexId, ShardId shardId) {
|
||||
this(snapshotId, version, indexId, shardId, shardId);
|
||||
Context(SnapshotId snapshotId, IndexId indexId, ShardId shardId) {
|
||||
this(snapshotId, indexId, shardId, shardId);
|
||||
}
|
||||
|
||||
Context(SnapshotId snapshotId, Version version, IndexId indexId, ShardId shardId, ShardId snapshotShardId) {
|
||||
Context(SnapshotId snapshotId, IndexId indexId, ShardId shardId, ShardId snapshotShardId) {
|
||||
this.snapshotId = snapshotId;
|
||||
this.version = version;
|
||||
this.shardId = shardId;
|
||||
blobContainer = blobStore().blobContainer(basePath().add("indices").add(indexId.getId()).add(Integer.toString(snapshotShardId.getId())));
|
||||
}
|
||||
|
@ -973,7 +966,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
int fileListGeneration = tuple.v2();
|
||||
|
||||
try {
|
||||
indexShardSnapshotFormat(version).delete(blobContainer, snapshotId.getUUID());
|
||||
indexShardSnapshotFormat.delete(blobContainer, snapshotId.getUUID());
|
||||
} catch (IOException e) {
|
||||
logger.debug("[{}] [{}] failed to delete shard snapshot file", shardId, snapshotId);
|
||||
}
|
||||
|
@ -994,7 +987,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
*/
|
||||
BlobStoreIndexShardSnapshot loadSnapshot() {
|
||||
try {
|
||||
return indexShardSnapshotFormat(version).read(blobContainer, snapshotId.getUUID());
|
||||
return indexShardSnapshotFormat.read(blobContainer, snapshotId.getUUID());
|
||||
} catch (IOException ex) {
|
||||
throw new SnapshotException(metadata.name(), snapshotId, "failed to read shard snapshot file for " + shardId, ex);
|
||||
}
|
||||
|
@ -1175,7 +1168,7 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
* @param snapshotStatus snapshot status to report progress
|
||||
*/
|
||||
SnapshotContext(Store store, SnapshotId snapshotId, IndexId indexId, IndexShardSnapshotStatus snapshotStatus, long startTime) {
|
||||
super(snapshotId, Version.CURRENT, indexId, store.shardId());
|
||||
super(snapshotId, indexId, store.shardId());
|
||||
this.snapshotStatus = snapshotStatus;
|
||||
this.store = store;
|
||||
this.startTime = startTime;
|
||||
|
@ -1316,7 +1309,6 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
// finalize the snapshot and rewrite the snapshot index with the next sequential snapshot index
|
||||
finalize(newSnapshotsList, fileListGeneration + 1, blobs, "snapshot creation [" + snapshotId + "]");
|
||||
snapshotStatus.moveToDone(System.currentTimeMillis());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1476,8 +1468,8 @@ public abstract class BlobStoreRepository extends AbstractLifecycleComponent imp
|
|||
* @param snapshotShardId shard in the snapshot that data should be restored from
|
||||
* @param recoveryState recovery state to report progress
|
||||
*/
|
||||
RestoreContext(IndexShard shard, SnapshotId snapshotId, Version version, IndexId indexId, ShardId snapshotShardId, RecoveryState recoveryState) {
|
||||
super(snapshotId, version, indexId, shard.shardId(), snapshotShardId);
|
||||
RestoreContext(IndexShard shard, SnapshotId snapshotId, IndexId indexId, ShardId snapshotShardId, RecoveryState recoveryState) {
|
||||
super(snapshotId, indexId, shard.shardId(), snapshotShardId);
|
||||
this.recoveryState = recoveryState;
|
||||
this.targetShard = shard;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue