Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
Signed-off-by: Pranshu Shukla <pranshushukla06@gmail.com>
  • Loading branch information
Pranshu-S committed Dec 3, 2024
1 parent 5c9d397 commit b884cfc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -279,7 +277,9 @@ public void testElectClusterManagerRemotePublicationConfigurationNodeJoinCommitF
internalCluster().startDataOnlyNodes(3);

String clusterManagerNode = internalCluster().getClusterManagerName();
List<String> nonClusterManagerNodes = Arrays.stream(internalCluster().getNodeNames()).filter(node -> !node.equals(clusterManagerNode)).collect(Collectors.toList());
List<String> nonClusterManagerNodes = Arrays.stream(internalCluster().getNodeNames())
.filter(node -> !node.equals(clusterManagerNode))
.collect(Collectors.toList());

ensureStableCluster(6);

Expand All @@ -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);
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> restrictedSettings = repository.getRestrictedSystemRepositorySettings()
.stream()
Expand Down

0 comments on commit b884cfc

Please sign in to comment.