Skip to content

Commit

Permalink
Spotless fixes
Browse files Browse the repository at this point in the history
Signed-off-by: Sachin Kale <kalsac@amazon.com>
  • Loading branch information
Sachin Kale committed Nov 15, 2022
1 parent 3bdc3d5 commit 7a287bc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@
import org.apache.lucene.store.IOContext;
import org.apache.lucene.store.IndexInput;
import org.apache.lucene.store.IndexOutput;
import org.opensearch.common.UUIDs;
import org.opensearch.common.concurrent.GatedCloseable;
import org.opensearch.index.engine.EngineException;
import org.opensearch.index.store.RemoteSegmentStoreDirectory;

import java.io.IOException;
import java.nio.file.NoSuchFileException;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
Expand Down Expand Up @@ -140,7 +138,7 @@ public void afterRefresh(boolean didRefresh) {
logger.warn("Exception while reading SegmentInfosSnapshot", e);
} finally {
try {
if(segment_info_snapshot_filename != null) {
if (segment_info_snapshot_filename != null) {
storeDirectory.deleteFile(segment_info_snapshot_filename);
}
} catch (IOException e) {
Expand All @@ -162,11 +160,7 @@ public void afterRefresh(boolean didRefresh) {
String uploadSegmentInfosSnapshot(String latestSegmentsNFilename, SegmentInfos segmentInfosSnapshot) throws IOException {
long localCheckpoint = indexShard.getEngine().getProcessedLocalCheckpoint();
String commitGeneration = latestSegmentsNFilename.substring("segments_".length());
String segment_info_snapshot_filename = SEGMENT_INFO_SNAPSHOT_FILENAME +
"__" +
commitGeneration +
"__" +
localCheckpoint;
String segment_info_snapshot_filename = SEGMENT_INFO_SNAPSHOT_FILENAME + "__" + commitGeneration + "__" + localCheckpoint;
IndexOutput indexOutput = storeDirectory.createOutput(segment_info_snapshot_filename, IOContext.DEFAULT);
segmentInfosSnapshot.write(indexOutput);
indexOutput.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,13 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.stream.Collectors;

import static org.opensearch.common.unit.TimeValue.timeValueMillis;
import static org.opensearch.index.seqno.SequenceNumbers.LOCAL_CHECKPOINT_KEY;

/**
* This package private utility class encapsulates the logic to recover an index shard from either an existing index on
Expand Down Expand Up @@ -469,7 +467,7 @@ private void recoverFromRemoteStore(IndexShard indexShard) throws IndexShardReco
String segmentInfosSnapshotFilename = null;
for (String file : remoteDirectory.listAll()) {
storeDirectory.copyFrom(remoteDirectory, file, file, IOContext.DEFAULT);
if(file.startsWith("segment_infos_snapshot_filename")) {
if (file.startsWith("segment_infos_snapshot_filename")) {
segmentInfosSnapshotFilename = file;
}
}
Expand All @@ -480,9 +478,11 @@ private void recoverFromRemoteStore(IndexShard indexShard) throws IndexShardReco
Integer.parseInt(segmentInfosSnapshotFilename.split("__")[1])
);

store.commitSegmentInfos(infos_snapshot,
store.commitSegmentInfos(
infos_snapshot,
Long.parseLong(segmentInfosSnapshotFilename.split("__")[2]),
Long.parseLong(segmentInfosSnapshotFilename.split("__")[2]));
Long.parseLong(segmentInfosSnapshotFilename.split("__")[2])
);

// This creates empty trans-log for now
// ToDo: Add code to restore from remote trans-log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ public IndexInput openInput(String name, IOContext context) throws IOException {

public void copyFrom(Directory from, String src, String dest, IOContext context, boolean override) throws IOException {
String remoteFilename;
if(override && segmentsUploadedToRemoteStore.containsKey(dest)) {
if (override && segmentsUploadedToRemoteStore.containsKey(dest)) {
remoteFilename = segmentsUploadedToRemoteStore.get(dest).uploadedFilename;
} else {
remoteFilename = getNewRemoteSegmentFilename(dest);
Expand Down

0 comments on commit 7a287bc

Please sign in to comment.