Skip to content

Commit

Permalink
Adjust format by spotlessApply task
Browse files Browse the repository at this point in the history
Signed-off-by: Tianli Feng <[email protected]>
  • Loading branch information
Tianli Feng committed May 11, 2022
1 parent 8af315e commit 8d602f0
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,9 @@ void invariant() {
.filter(m -> m.payload instanceof PublishRequest)
.collect(Collectors.groupingBy(m -> ((PublishRequest) m.payload).getAcceptedState().term()))
.forEach((term, publishMessages) -> {
Set<DiscoveryNode> clusterManagersForTerm = publishMessages.stream().collect(Collectors.groupingBy(m -> m.sourceNode)).keySet();
Set<DiscoveryNode> clusterManagersForTerm = publishMessages.stream()
.collect(Collectors.groupingBy(m -> m.sourceNode))
.keySet();
assertThat("Multiple cluster-managers " + clusterManagersForTerm + " for term " + term, clusterManagersForTerm, hasSize(1));
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ public static void ensureAllArraysAreReleased() throws Exception {
assertBusy(() -> assertTrue(Sets.haveEmptyIntersection(clusterManagerCopy.keySet(), ACQUIRED_ARRAYS.keySet())));
} catch (AssertionError ex) {
clusterManagerCopy.keySet().retainAll(ACQUIRED_ARRAYS.keySet());
ACQUIRED_ARRAYS.keySet().removeAll(clusterManagerCopy.keySet()); // remove all existing cluster-manager copy we will report on
// remove all existing cluster-manager copy we will report on
ACQUIRED_ARRAYS.keySet().removeAll(clusterManagerCopy.keySet());
if (!clusterManagerCopy.isEmpty()) {
Iterator<Object> causes = clusterManagerCopy.values().iterator();
Object firstCause = causes.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,15 @@ public static void ensureAllPagesAreReleased() throws Exception {
final boolean success = waitUntil(() -> Sets.haveEmptyIntersection(clusterManagerCopy.keySet(), ACQUIRED_PAGES.keySet()));
if (!success) {
clusterManagerCopy.keySet().retainAll(ACQUIRED_PAGES.keySet());
ACQUIRED_PAGES.keySet().removeAll(clusterManagerCopy.keySet()); // remove all existing cluster-manager copy we will report on
// remove all existing cluster-manager copy we will report on
ACQUIRED_PAGES.keySet().removeAll(clusterManagerCopy.keySet());
if (!clusterManagerCopy.isEmpty()) {
Iterator<Throwable> causes = clusterManagerCopy.values().iterator();
Throwable firstCause = causes.next();
RuntimeException exception = new RuntimeException(clusterManagerCopy.size() + " pages have not been released", firstCause);
RuntimeException exception = new RuntimeException(
clusterManagerCopy.size() + " pages have not been released",
firstCause
);
while (causes.hasNext()) {
exception.addSuppressed(causes.next());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ public InternalTestCluster(
+ "[{}] (data) nodes and [{}] coord only nodes (min_cluster_manager_nodes are [{}])",
clusterName,
SeedUtils.formatSeed(clusterSeed),
numSharedDedicatedClusterManagerNodes,
numSharedDedicatedClusterManagerNodes,
numSharedDataNodes,
numSharedCoordOnlyNodes,
autoManageClusterManagerNodes ? "auto-managed" : "manual"
Expand Down Expand Up @@ -454,7 +454,8 @@ public InternalTestCluster(
*/
public void setBootstrapClusterManagerNodeIndex(int bootstrapClusterManagerNodeIndex) {
assert autoManageClusterManagerNodes == false || bootstrapClusterManagerNodeIndex == -1
: "bootstrapClusterManagerNodeIndex should be -1 if autoManageClusterManagerNodes is true, but was " + bootstrapClusterManagerNodeIndex;
: "bootstrapClusterManagerNodeIndex should be -1 if autoManageClusterManagerNodes is true, but was "
+ bootstrapClusterManagerNodeIndex;
this.bootstrapClusterManagerNodeIndex = bootstrapClusterManagerNodeIndex;
}

Expand Down Expand Up @@ -686,7 +687,12 @@ public synchronized void ensureAtMostNumDataNodes(int n) throws IOException {
}
}

private Settings getNodeSettings(final int nodeId, final long seed, final Settings extraSettings, final int defaultMinClusterManagerNodes) {
private Settings getNodeSettings(
final int nodeId,
final long seed,
final Settings extraSettings,
final int defaultMinClusterManagerNodes
) {
final Settings settings = getSettings(nodeId, seed, extraSettings);

final String name = buildNodeName(nodeId, settings);
Expand Down Expand Up @@ -1128,7 +1134,9 @@ private synchronized void reset(boolean wipeData) throws IOException {

// start any missing node
assert newSize == numSharedDedicatedClusterManagerNodes + numSharedDataNodes + numSharedCoordOnlyNodes;
final int numberOfClusterManagerNodes = numSharedDedicatedClusterManagerNodes > 0 ? numSharedDedicatedClusterManagerNodes : numSharedDataNodes;
final int numberOfClusterManagerNodes = numSharedDedicatedClusterManagerNodes > 0
? numSharedDedicatedClusterManagerNodes
: numSharedDataNodes;
final int defaultMinClusterManagerNodes = (numberOfClusterManagerNodes / 2) + 1;
final List<NodeAndClient> toStartAndPublish = new ArrayList<>(); // we want to start nodes in one go
final Runnable onTransportServiceStarted = () -> rebuildUnicastHostFiles(toStartAndPublish);
Expand All @@ -1148,8 +1156,8 @@ private synchronized void reset(boolean wipeData) throws IOException {
settings.add(nodeSettings);
}
}
for (int i = numSharedDedicatedClusterManagerNodes + numSharedDataNodes; i < numSharedDedicatedClusterManagerNodes + numSharedDataNodes
+ numSharedCoordOnlyNodes; i++) {
for (int i = numSharedDedicatedClusterManagerNodes + numSharedDataNodes; i < numSharedDedicatedClusterManagerNodes
+ numSharedDataNodes + numSharedCoordOnlyNodes; i++) {
final Builder extraSettings = Settings.builder().put(noRoles());
settings.add(getNodeSettings(i, sharedNodesSeeds[i], extraSettings.build(), defaultMinClusterManagerNodes));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -717,7 +717,9 @@ protected static NetworkDisruption isolateMasterDisruption(NetworkDisruption.Net
return new NetworkDisruption(
new NetworkDisruption.TwoPartitions(
Collections.singleton(clusterManagerNode),
Arrays.stream(internalCluster().getNodeNames()).filter(name -> name.equals(clusterManagerNode) == false).collect(Collectors.toSet())
Arrays.stream(internalCluster().getNodeNames())
.filter(name -> name.equals(clusterManagerNode) == false)
.collect(Collectors.toSet())
),
disruptionType
);
Expand Down Expand Up @@ -953,8 +955,8 @@ private ClusterHealthStatus ensureColor(
// cluster state where it is cluster-manager but where the node that was stopped hasn't been removed yet from the cluster state.
// It will only subsequently publish a second state where the old cluster-manager is removed.
// If the ensureGreen/ensureYellow is timed just right, it will get to execute before the second cluster state update removes
// the old cluster-manager and the condition ensureGreen / ensureYellow will trivially hold if it held before the node was
// shut down. The following "waitForNodes" condition ensures that the node has been removed by the cluster-manager
// the old cluster-manager and the condition ensureGreen / ensureYellow will trivially hold if it held before the node was
// shut down. The following "waitForNodes" condition ensures that the node has been removed by the cluster-manager
// so that the health check applies to the set of nodes we expect to be part of the cluster.
.waitForNodes(Integer.toString(cluster().size()));

Expand Down Expand Up @@ -1112,7 +1114,11 @@ protected void ensureClusterStateConsistency() throws IOException {
if (clusterManagerClusterState.version() == localClusterState.version()
&& clusterManagerId.equals(localClusterState.nodes().getMasterNodeId())) {
try {
assertEquals("cluster state UUID does not match", clusterManagerClusterState.stateUUID(), localClusterState.stateUUID());
assertEquals(
"cluster state UUID does not match",
clusterManagerClusterState.stateUUID(),
localClusterState.stateUUID()
);
// We cannot compare serialization bytes since serialization order of maps is not guaranteed
// We also cannot compare byte array size because CompressedXContent's DeflateCompressor uses
// a synced flush that can affect the size of the compressed byte array
Expand Down

0 comments on commit 8d602f0

Please sign in to comment.