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 Dec 23, 2022
1 parent 4e87f36 commit e6a5e13
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4178,7 +4178,8 @@ public void syncSegmentsFromRemoteSegmentStore(boolean override) throws IOExcept
// are uploaded to the remote segment store.
assert remoteDirectory instanceof RemoteSegmentStoreDirectory : "remoteDirectory is not an instance of RemoteSegmentStoreDirectory";
((RemoteSegmentStoreDirectory) remoteDirectory).init();
Map<String, RemoteSegmentStoreDirectory.UploadedSegmentMetadata> uploadedSegments = ((RemoteSegmentStoreDirectory) remoteDirectory).getSegmentsUploadedToRemoteStore();
Map<String, RemoteSegmentStoreDirectory.UploadedSegmentMetadata> uploadedSegments = ((RemoteSegmentStoreDirectory) remoteDirectory)
.getSegmentsUploadedToRemoteStore();
final Directory storeDirectory = store.directory();
store.incRef();
remoteStore.incRef();
Expand All @@ -4188,7 +4189,7 @@ public void syncSegmentsFromRemoteSegmentStore(boolean override) throws IOExcept
for (String file : uploadedSegments.keySet()) {
long checksum = Long.parseLong(uploadedSegments.get(file).getChecksum());
if (override || localDirectoryContains(storeDirectory, file, checksum) == false) {
if(localSegmentFiles.contains(file)) {
if (localSegmentFiles.contains(file)) {
storeDirectory.deleteFile(file);
}
logger.info("Downloading segments file: {} ", file);
Expand Down Expand Up @@ -4226,7 +4227,7 @@ public void syncSegmentsFromRemoteSegmentStore(boolean override) throws IOExcept
private boolean localDirectoryContains(Directory localDirectory, String file, long checksum) {
try (IndexInput indexInput = localDirectory.openInput(file, IOContext.DEFAULT)) {
return checksum == CodecUtil.retrieveChecksum(indexInput);
} catch(IOException e) {
} catch (IOException e) {
logger.debug("Exception while reading checksum of file: {}, this can happen if file does not exist", file);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

import org.apache.lucene.index.IndexCommit;
import org.apache.lucene.index.SegmentInfos;
import org.apache.lucene.store.Directory;
import org.junit.Assert;
import org.opensearch.action.ActionListener;
import org.opensearch.action.delete.DeleteRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ protected ReplicationGroup createGroup(int replicas, Settings settings, EngineFa
return createGroup(replicas, settings, indexMapping, engineFactory);
}

protected ReplicationGroup createGroup(int replicas, Settings settings, String mappings, EngineFactory engineFactory) throws IOException {
protected ReplicationGroup createGroup(int replicas, Settings settings, String mappings, EngineFactory engineFactory)
throws IOException {
return createGroup(replicas, settings, mappings, engineFactory, null);
}

Expand Down Expand Up @@ -247,10 +248,18 @@ protected ReplicationGroup(final IndexMetadata indexMetadata) throws IOException
protected ReplicationGroup(final IndexMetadata indexMetadata, Path remotePath) throws IOException {
final ShardRouting primaryRouting = this.createShardRouting("s0", true);
Store remoteStore = null;
if(remotePath != null) {
if (remotePath != null) {
remoteStore = createRemoteStore(remotePath, primaryRouting, indexMetadata);
}
primary = newShard(primaryRouting, indexMetadata, null, getEngineFactory(primaryRouting), () -> {}, retentionLeaseSyncer, remoteStore);
primary = newShard(
primaryRouting,
indexMetadata,
null,
getEngineFactory(primaryRouting),
() -> {},
retentionLeaseSyncer,
remoteStore
);
replicas = new CopyOnWriteArrayList<>();
this.indexMetadata = indexMetadata;
updateAllocationIDsOnPrimary();
Expand Down Expand Up @@ -370,13 +379,13 @@ public void startPrimary() throws IOException {
}

public IndexShard addReplica() throws IOException {
return addReplica((Path)null);
return addReplica((Path) null);
}

public IndexShard addReplica(Path remotePath) throws IOException {
final ShardRouting replicaRouting = createShardRouting("s" + replicaId.incrementAndGet(), false);
Store remoteStore = null;
if(remotePath != null) {
if (remotePath != null) {
remoteStore = createRemoteStore(remotePath, replicaRouting, indexMetadata);
}
final IndexShard replica = newShard(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,9 @@
import org.opensearch.indices.replication.common.ReplicationFailedException;
import org.opensearch.indices.replication.common.ReplicationListener;
import org.opensearch.indices.replication.common.ReplicationState;
import org.opensearch.indices.replication.common.ReplicationType;
import org.opensearch.repositories.IndexId;
import org.opensearch.repositories.RepositoriesService;
import org.opensearch.repositories.Repository;
import org.opensearch.repositories.blobstore.OpenSearchBlobStoreRepositoryIntegTestCase;
import org.opensearch.repositories.fs.FsRepository;
import org.opensearch.snapshots.Snapshot;
import org.opensearch.test.DummyShardLock;
import org.opensearch.test.OpenSearchTestCase;
Expand Down

0 comments on commit e6a5e13

Please sign in to comment.