Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion buildSrc/src/main/resources/checkstyle_suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]explain[/\\]ExplainActionIT.java" checks="LineLength" />
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]get[/\\]GetActionIT.java" checks="LineLength" />
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indexing[/\\]IndexActionIT.java" checks="LineLength" />
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]indexlifecycle[/\\]IndexLifecycleActionIT.java" checks="LineLength" />
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]monitor[/\\]jvm[/\\]JvmGcMonitorServiceSettingsTests.java" checks="LineLength" />
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]plugins[/\\]PluginsServiceTests.java" checks="LineLength" />
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]recovery[/\\]FullRollingRestartIT.java" checks="LineLength" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
final String node1 = getLocalNodeId(server_1);

logger.info("Creating index [test]");
CreateIndexResponse createIndexResponse = client().admin().indices().create(createIndexRequest("test").settings(settings)).actionGet();
CreateIndexResponse createIndexResponse = client().admin().indices().create(
Copy link
Contributor

@pgomulka pgomulka Dec 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that you break lines on '(' . Was that an intention? Reminds me of my early projects in Lisp :) I am worried that most of other refactoring would be breaking chained methods on '.'
what do you think of breaking on '.'
for instance

client().admin().indices()
.create(reateIndexRequest("test").settings(settings)))
.actionGet();

or even one '.' per each line - although that might have been excessive

Copy link
Member Author

@danielmitterdorfer danielmitterdorfer Dec 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intention was to separate the request creation from the actual call.

createIndexRequest("test").settings(settings)).actionGet();
assertAcked(createIndexResponse);

ClusterState clusterState = client().admin().cluster().prepareState().get().getState();
Expand All @@ -90,7 +91,8 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
// explicitly call reroute, so shards will get relocated to the new node (we delay it in ES in case other nodes join)
client().admin().cluster().prepareReroute().execute().actionGet();

clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus().waitForNodes("2").waitForNoRelocatingShards(true)).actionGet();
clusterHealth = client().admin().cluster().health(
clusterHealthRequest().waitForGreenStatus().waitForNodes("2").waitForNoRelocatingShards(true)).actionGet();
assertThat(clusterHealth.isTimedOut(), equalTo(false));
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(clusterHealth.getNumberOfDataNodes(), equalTo(2));
Expand Down Expand Up @@ -127,7 +129,8 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
// explicitly call reroute, so shards will get relocated to the new node (we delay it in ES in case other nodes join)
client().admin().cluster().prepareReroute().execute().actionGet();

clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus().waitForNodes("3").waitForNoRelocatingShards(true)).actionGet();
clusterHealth = client().admin().cluster().health(
clusterHealthRequest().waitForGreenStatus().waitForNodes("3").waitForNoRelocatingShards(true)).actionGet();
assertThat(clusterHealth.isTimedOut(), equalTo(false));
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(clusterHealth.getNumberOfDataNodes(), equalTo(3));
Expand All @@ -145,7 +148,9 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {
routingNodeEntry2 = clusterState.getRoutingNodes().node(node2);
RoutingNode routingNodeEntry3 = clusterState.getRoutingNodes().node(node3);

assertThat(routingNodeEntry1.numberOfShardsWithState(STARTED) + routingNodeEntry2.numberOfShardsWithState(STARTED) + routingNodeEntry3.numberOfShardsWithState(STARTED), equalTo(22));
assertThat(routingNodeEntry1.numberOfShardsWithState(STARTED) +
routingNodeEntry2.numberOfShardsWithState(STARTED) +
routingNodeEntry3.numberOfShardsWithState(STARTED), equalTo(22));

assertThat(routingNodeEntry1.numberOfShardsWithState(RELOCATING), equalTo(0));
assertThat(routingNodeEntry1.numberOfShardsWithState(STARTED), anyOf(equalTo(7), equalTo(8)));
Expand All @@ -168,7 +173,8 @@ public void testIndexLifecycleActionsWith11Shards1Backup() throws Exception {

client().admin().cluster().prepareReroute().get();

clusterHealth = client().admin().cluster().health(clusterHealthRequest().waitForGreenStatus().waitForNoRelocatingShards(true).waitForNodes("2")).actionGet();
clusterHealth = client().admin().cluster().health(
clusterHealthRequest().waitForGreenStatus().waitForNoRelocatingShards(true).waitForNodes("2")).actionGet();
assertThat(clusterHealth.isTimedOut(), equalTo(false));
assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(clusterHealth.getRelocatingShards(), equalTo(0));
Expand Down Expand Up @@ -211,7 +217,9 @@ private String getLocalNodeId(String name) {
}

private void assertNodesPresent(RoutingNodes routingNodes, String... nodes) {
final Set<String> keySet = StreamSupport.stream(routingNodes.spliterator(), false).map((p) -> (p.nodeId())).collect(Collectors.toSet());
final Set<String> keySet = StreamSupport.stream(routingNodes.spliterator(), false)
.map(RoutingNode::nodeId)
.collect(Collectors.toSet());
assertThat(keySet, containsInAnyOrder(nodes));
}
}