diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/DiscoveryDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/DiscoveryDisruptionIT.java index 4938617a312fe..a0305261d3374 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/DiscoveryDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/DiscoveryDisruptionIT.java @@ -32,7 +32,6 @@ package org.opensearch.discovery; -import org.junit.Assert; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.coordination.FailedToCommitClusterStateException; import org.opensearch.cluster.coordination.JoinHelper; @@ -52,15 +51,15 @@ import org.opensearch.test.transport.MockTransportService; import org.opensearch.transport.Transport; import org.opensearch.transport.TransportService; +import org.junit.Assert; +import java.util.Arrays; import java.util.HashSet; +import java.util.List; +import java.util.Random; import java.util.Set; import java.util.concurrent.CountDownLatch; import java.util.stream.Collectors; -import java.util.Random; -import java.util.List; -import java.util.Arrays; - import static org.opensearch.cluster.metadata.IndexMetadata.INDEX_NUMBER_OF_REPLICAS_SETTING; import static org.opensearch.cluster.metadata.IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING; @@ -268,7 +267,6 @@ public void testElectClusterManagerRemotePublicationConfigurationNodeJoinCommitF final String remoteStateRepoName = "remote-state-repo"; final String remoteRoutingTableRepoName = "routing-table-repo"; - Settings remotePublicationSettings = buildRemotePublicationNodeAttributes( remoteStateRepoName, ReloadableFsRepository.TYPE, @@ -279,7 +277,9 @@ public void testElectClusterManagerRemotePublicationConfigurationNodeJoinCommitF internalCluster().startDataOnlyNodes(3); String clusterManagerNode = internalCluster().getClusterManagerName(); - List nonClusterManagerNodes = Arrays.stream(internalCluster().getNodeNames()).filter(node -> !node.equals(clusterManagerNode)).collect(Collectors.toList()); + List nonClusterManagerNodes = Arrays.stream(internalCluster().getNodeNames()) + .filter(node -> !node.equals(clusterManagerNode)) + .collect(Collectors.toList()); ensureStableCluster(6); @@ -288,16 +288,14 @@ public void testElectClusterManagerRemotePublicationConfigurationNodeJoinCommitF clusterManagerNode ); logger.info("Blocking Cluster Manager Commit Request on all nodes"); - nonClusterManagerNodes.forEach( - node -> { - TransportService targetTransportService = internalCluster().getInstance(TransportService.class, node); - clusterManagerTransportService.addOpenSearchFailureException( - targetTransportService, - new FailedToCommitClusterStateException("Blocking Commit"), - PublicationTransportHandler.COMMIT_STATE_ACTION_NAME - ); - } - ); + nonClusterManagerNodes.forEach(node -> { + TransportService targetTransportService = internalCluster().getInstance(TransportService.class, node); + clusterManagerTransportService.addOpenSearchFailureException( + targetTransportService, + new FailedToCommitClusterStateException("Blocking Commit"), + PublicationTransportHandler.COMMIT_STATE_ACTION_NAME + ); + }); logger.info("Starting Node with remote publication settings"); internalCluster().startDataOnlyNodes(1, remotePublicationSettings, Boolean.TRUE); @@ -309,7 +307,10 @@ public void testElectClusterManagerRemotePublicationConfigurationNodeJoinCommitF Random random = new Random(); String randomNode = nonClusterManagerNodes.get(random.nextInt(nonClusterManagerNodes.size())); - RepositoriesMetadata repositoriesMetadata = internalCluster().getInstance(ClusterService.class, randomNode).state().metadata().custom(RepositoriesMetadata.TYPE); + RepositoriesMetadata repositoriesMetadata = internalCluster().getInstance(ClusterService.class, randomNode) + .state() + .metadata() + .custom(RepositoriesMetadata.TYPE); Boolean isRemoteStateRepoConfigured = Boolean.FALSE; Boolean isRemoteRoutingTableRepoConfigured = Boolean.FALSE; diff --git a/server/src/main/java/org/opensearch/node/remotestore/RemoteStoreNodeService.java b/server/src/main/java/org/opensearch/node/remotestore/RemoteStoreNodeService.java index c037cbf2b71c6..10441a74e174c 100644 --- a/server/src/main/java/org/opensearch/node/remotestore/RemoteStoreNodeService.java +++ b/server/src/main/java/org/opensearch/node/remotestore/RemoteStoreNodeService.java @@ -187,8 +187,11 @@ public RepositoriesMetadata updateRepositoriesMetadata(DiscoveryNode joiningNode // the commit operation failed, the cluster-state may have the repository metadata which is not applied into the // repository service. This may lead to assertion failures down the line. if (!repositoriesService.get().isRepositoryPresent(newRepositoryMetadata.name())) { - logger.warn("remote repository [{}] in cluster-state but repository-service but not present " - + "in repository-service, skipping checks", newRepositoryMetadata.name()); + logger.warn( + "remote repository [{}] in cluster-state but repository-service but not present " + + "in repository-service, skipping checks", + newRepositoryMetadata.name() + ); break; } try { diff --git a/server/src/main/java/org/opensearch/repositories/RepositoriesService.java b/server/src/main/java/org/opensearch/repositories/RepositoriesService.java index 13fb6ed8455d7..08008b12d0929 100644 --- a/server/src/main/java/org/opensearch/repositories/RepositoriesService.java +++ b/server/src/main/java/org/opensearch/repositories/RepositoriesService.java @@ -908,7 +908,10 @@ public void ensureValidSystemRepositoryUpdate(RepositoryMetadata newRepositoryMe Settings newRepositoryMetadataSettings = newRepositoryMetadata.settings(); Settings currentRepositoryMetadataSettings = currentRepositoryMetadata.settings(); - assert Objects.nonNull(repository) : String.format("repository [%s] not present in RepositoryService", currentRepositoryMetadata.name()); + assert Objects.nonNull(repository) : String.format( + "repository [%s] not present in RepositoryService", + currentRepositoryMetadata.name() + ); List restrictedSettings = repository.getRestrictedSystemRepositorySettings() .stream()