Skip to content

Commit

Permalink
spotless apply and fixing gradle failures
Browse files Browse the repository at this point in the history
Signed-off-by: Himshikha Gupta <[email protected]>
  • Loading branch information
Himshikha Gupta committed May 16, 2024
1 parent 0b70dea commit 2107372
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,46 @@ public class RemoteRoutingTableService implements Closeable {
private final ClusterSettings clusterSettings;
private BlobStoreRepository blobStoreRepository;

public RemoteRoutingTableService(Supplier<RepositoriesService> repositoriesService,
Settings settings,
ClusterSettings clusterSettings) {
public RemoteRoutingTableService(
Supplier<RepositoriesService> repositoriesService,
Settings settings,
ClusterSettings clusterSettings
) {
assert isRemoteRoutingTableEnabled(settings) : "Remote routing table is not enabled";
this.repositoriesService = repositoriesService;
this.settings = settings;
this.clusterSettings = clusterSettings;
}

public List<ClusterMetadataManifest.UploadedIndexMetadata> writeFullRoutingTable(ClusterState clusterState, String previousClusterUUID) {
public List<ClusterMetadataManifest.UploadedIndexMetadata> writeFullRoutingTable(
ClusterState clusterState,
String previousClusterUUID
) {
return null;
}

public List<ClusterMetadataManifest.UploadedIndexMetadata> writeIncrementalMetadata(
ClusterState previousClusterState,
ClusterState clusterState,
ClusterMetadataManifest previousManifest) {
ClusterMetadataManifest previousManifest
) {
return null;
}

public RoutingTable getLatestRoutingTable(String clusterName, String clusterUUID) {
return null;
}

public RoutingTable getIncrementalRoutingTable(ClusterState previousClusterState, ClusterMetadataManifest previousManifest, String clusterName, String clusterUUID) {
public RoutingTable getIncrementalRoutingTable(
ClusterState previousClusterState,
ClusterMetadataManifest previousManifest,
String clusterName,
String clusterUUID
) {
return null;
}

private void deleteStaleRoutingTable(String clusterName, String clusterUUID, int manifestsToRetain) {
}
private void deleteStaleRoutingTable(String clusterName, String clusterUUID, int manifestsToRetain) {}

@Override
public void close() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public class FeatureFlags {
Property.NodeScope
);


private static final List<Setting<Boolean>> ALL_FEATURE_FLAG_SETTINGS = List.of(
REMOTE_STORE_MIGRATION_EXPERIMENTAL_SETTING,
EXTENSIONS_SETTING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,8 @@ public RemoteClusterStateService(
this.remoteStateStats = new RemotePersistenceStats();
this.indexMetadataUploadListeners = indexMetadataUploadListeners;

if(isRemoteRoutingTableEnabled(settings)) {
this.remoteRoutingTableService = new RemoteRoutingTableService(repositoriesService,
settings, clusterSettings);
if (isRemoteRoutingTableEnabled(settings)) {
this.remoteRoutingTableService = new RemoteRoutingTableService(repositoriesService, settings, clusterSettings);
}
}

Expand Down Expand Up @@ -652,7 +651,7 @@ public void close() throws IOException {
if (blobStoreRepository != null) {
IOUtils.close(blobStoreRepository);
}
if(this.remoteRoutingTableService != null) {
if (this.remoteRoutingTableService != null) {
this.remoteRoutingTableService.close();
}
}
Expand All @@ -666,7 +665,7 @@ public void start() {
final Repository repository = repositoriesService.get().repository(remoteStoreRepo);
assert repository instanceof BlobStoreRepository : "Repository should be instance of BlobStoreRepository";
blobStoreRepository = (BlobStoreRepository) repository;
if(this.remoteRoutingTableService != null) {
if (this.remoteRoutingTableService != null) {
this.remoteRoutingTableService.start();
}
}
Expand Down Expand Up @@ -805,7 +804,7 @@ public TimeValue getMetadataManifestUploadTimeout() {
return this.metadataManifestUploadTimeout;
}

//Package private for unit test
// Package private for unit test
RemoteRoutingTableService getRemoteRoutingTableService() {
return this.remoteRoutingTableService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private Set<String> getValidatedRepositoryNames(DiscoveryNode node) {
} else if (node.getAttributes().containsKey(REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY)) {
repositoryNames.add(validateAttributeNonNull(node, REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY));
}
if (node.getAttributes().containsKey(REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY)){
if (node.getAttributes().containsKey(REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY)) {
repositoryNames.add(validateAttributeNonNull(node, REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY));
}

Expand Down Expand Up @@ -203,7 +203,8 @@ public static boolean isRemoteRoutingTableAttributePresent(Settings settings) {
}

public static boolean isRemoteRoutingTableEnabled(Settings settings) {
return FeatureFlags.isEnabled(REMOTE_ROUTING_TABLE_EXPERIMENTAL) && RemoteRoutingTableService.REMOTE_ROUTING_TABLE_ENABLED_SETTING.get(settings)
return FeatureFlags.isEnabled(REMOTE_ROUTING_TABLE_EXPERIMENTAL)
&& RemoteRoutingTableService.REMOTE_ROUTING_TABLE_ENABLED_SETTING.get(settings)
&& isRemoteRoutingTableAttributePresent(settings);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

package org.opensearch.cluster.routing.remote;

import org.junit.After;
import org.junit.Before;
import org.opensearch.common.settings.ClusterSettings;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.util.FeatureFlags;
Expand All @@ -18,12 +16,16 @@
import org.opensearch.repositories.RepositoryMissingException;
import org.opensearch.repositories.blobstore.BlobStoreRepository;
import org.opensearch.test.OpenSearchTestCase;
import org.junit.After;
import org.junit.Before;

import java.util.function.Supplier;

import static org.mockito.Mockito.*;
import static org.opensearch.common.util.FeatureFlags.REMOTE_ROUTING_TABLE_EXPERIMENTAL;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

public class RemoteRoutingTableServiceTests extends OpenSearchTestCase {

Expand Down Expand Up @@ -52,11 +54,7 @@ public void setup() {
Settings nodeSettings = Settings.builder().put(REMOTE_ROUTING_TABLE_EXPERIMENTAL, "true").build();
FeatureFlags.initializeFeatureFlags(nodeSettings);

remoteRoutingTableService = new RemoteRoutingTableService(
repositoriesServiceSupplier,
settings,
clusterSettings
);
remoteRoutingTableService = new RemoteRoutingTableService(repositoriesServiceSupplier, settings, clusterSettings);
}

@After
Expand All @@ -65,7 +63,6 @@ public void teardown() throws Exception {
remoteRoutingTableService.close();
}


public void testFailInitializationWhenRemoteRoutingDisabled() {
final Settings settings = Settings.builder().build();
assertThrows(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
import static org.opensearch.gateway.remote.RemoteClusterStateService.MANIFEST_FILE_PREFIX;
import static org.opensearch.gateway.remote.RemoteClusterStateService.METADATA_FILE_PREFIX;
import static org.opensearch.gateway.remote.RemoteClusterStateService.RETAINED_MANIFESTS;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_CLUSTER_STATE_REPOSITORY_NAME_ATTRIBUTE_KEY;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_SETTINGS_ATTRIBUTE_KEY_PREFIX;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_REPOSITORY_TYPE_ATTRIBUTE_KEY_FORMAT;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.REMOTE_STORE_ROUTING_TABLE_REPOSITORY_NAME_ATTRIBUTE_KEY;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
Expand All @@ -100,7 +104,6 @@
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.opensearch.node.remotestore.RemoteStoreNodeAttribute.*;

public class RemoteClusterStateServiceTests extends OpenSearchTestCase {

Expand Down Expand Up @@ -1224,7 +1227,7 @@ public void testGlobalMetadataUploadWaitTimeSetting() {
}

public void testRemoteRoutingTableNotInitializedWhenDisabled() {
assertNull(remoteClusterStateService.getRemoteRoutingTableService());
assertNull(remoteClusterStateService.getRemoteRoutingTableService());
}

public void testRemoteRoutingTableInitializedWhenEnabled() {
Expand All @@ -1245,7 +1248,8 @@ public void testRemoteRoutingTableInitializedWhenEnabled() {
newSettings,
clusterSettings,
() -> 0L,
threadPool
threadPool,
List.of(new RemoteIndexPathUploader(threadPool, newSettings, repositoriesServiceSupplier, clusterSettings))
);
assertNotNull(remoteClusterStateService.getRemoteRoutingTableService());
}
Expand Down

0 comments on commit 2107372

Please sign in to comment.