Skip to content

Commit

Permalink
Remove remaining line length violations in o.e.cluster (#34941)
Browse files Browse the repository at this point in the history
relates #34923, #34884
  • Loading branch information
rjernst committed Oct 30, 2018
1 parent 3489a18 commit ea845eb
Show file tree
Hide file tree
Showing 49 changed files with 796 additions and 529 deletions.
104 changes: 0 additions & 104 deletions buildSrc/src/main/resources/checkstyle_suppressions.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,8 @@ public void postAdded() {
lastObservedState.set(new StoredState(newState));
context.listener.onNewClusterState(newState);
} else {
logger.trace("observer: postAdded - predicate approved state but observing context has changed - ignoring ({})", newState);
logger.trace("observer: postAdded - predicate approved state but observing context has changed - ignoring ({})",
newState);
}
} else {
logger.trace("observer: postAdded - predicate rejected state ({})", newState);
Expand All @@ -240,7 +241,8 @@ public void onTimeout(TimeValue timeout) {
if (context != null) {
clusterApplierService.removeTimeoutListener(this);
long timeSinceStartMS = TimeValue.nsecToMSec(System.nanoTime() - startTimeNS);
logger.trace("observer: timeout notification from cluster service. timeout setting [{}], time since start [{}]", timeOutValue, new TimeValue(timeSinceStartMS));
logger.trace("observer: timeout notification from cluster service. timeout setting [{}], time since start [{}]",
timeOutValue, new TimeValue(timeSinceStartMS));
// update to latest, in case people want to retry
lastObservedState.set(new StoredState(clusterApplierService.state()));
timedOut = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* A task that can update the cluster state.
*/
public abstract class ClusterStateUpdateTask
implements ClusterStateTaskConfig, ClusterStateTaskExecutor<ClusterStateUpdateTask>, ClusterStateTaskListener {
implements ClusterStateTaskConfig, ClusterStateTaskExecutor<ClusterStateUpdateTask>, ClusterStateTaskListener {

private final Priority priority;

Expand All @@ -43,7 +43,7 @@ public ClusterStateUpdateTask(Priority priority) {

@Override
public final ClusterTasksResult<ClusterStateUpdateTask> execute(ClusterState currentState, List<ClusterStateUpdateTask> tasks)
throws Exception {
throws Exception {
ClusterState result = execute(currentState);
return ClusterTasksResult.<ClusterStateUpdateTask>builder().successes(tasks).build(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ private ClusterState applyRequest(ClusterState currentState, PutMappingClusterSt
if (existingMapper != null) {
existingSource = existingMapper.mappingSource();
}
DocumentMapper mergedMapper = mapperService.merge(mappingType, mappingUpdateSource, MergeReason.MAPPING_UPDATE, request.updateAllTypes());
DocumentMapper mergedMapper = mapperService.merge(mappingType, mappingUpdateSource,
MergeReason.MAPPING_UPDATE, request.updateAllTypes());
CompressedXContent updatedSource = mergedMapper.mappingSource();

if (existingSource != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ public ShardIterator indexShards(ClusterState clusterState, String index, String
return shards(clusterState, index, id, routing).shardsIt();
}

public ShardIterator getShards(ClusterState clusterState, String index, String id, @Nullable String routing, @Nullable String preference) {
public ShardIterator getShards(ClusterState clusterState, String index, String id, @Nullable String routing,
@Nullable String preference) {
return preferenceActiveShardIterator(shards(clusterState, index, id, routing), clusterState.nodes().getLocalNodeId(),
clusterState.nodes(), preference, null, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ private void testFilteringByIndexWorks(String[] indices, String[] expected) {
}

public void testLargeClusterStatePublishing() throws Exception {
int estimatedBytesSize = scaledRandomIntBetween(ByteSizeValue.parseBytesSizeValue("10k", "estimatedBytesSize").bytesAsInt(),
ByteSizeValue.parseBytesSizeValue("256k", "estimatedBytesSize").bytesAsInt());
int estimatedBytesSize = scaledRandomIntBetween(
ByteSizeValue.parseBytesSizeValue("10k", "estimatedBytesSize").bytesAsInt(),
ByteSizeValue.parseBytesSizeValue("256k", "estimatedBytesSize").bytesAsInt());
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties");
int counter = 0;
int numberOfFields = 0;
Expand Down Expand Up @@ -274,7 +275,8 @@ public void testIndicesIgnoreUnavailableFalse() throws Exception {
// ignore_unavailable set to false throws exception when allowNoIndices is turned off
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, true, true, false);
try {
client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("fzzbzz").setIndicesOptions(allowNoIndices).get();
client().admin().cluster().prepareState().clear().setMetaData(true)
.setIndices("fzzbzz").setIndicesOptions(allowNoIndices).get();
fail("Expected IndexNotFoundException");
} catch (IndexNotFoundException e) {
assertThat(e.getMessage(), is("no such index"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,22 +133,26 @@ public void testElectOnlyBetweenMasterNodes() throws IOException {
*/
public void testCustomDefaultMapping() throws Exception {
logger.info("--> start master node / non data");
internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true));
internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false)
.put(Node.NODE_MASTER_SETTING.getKey(), true));

logger.info("--> start data node / non master node");
internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), true).put(Node.NODE_MASTER_SETTING.getKey(), false));
internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), true)
.put(Node.NODE_MASTER_SETTING.getKey(), false));

createIndex("test");
assertAcked(client().admin().indices().preparePutMapping("test").setType("_default_").setSource("timestamp", "type=date"));

MappingMetaData defaultMapping = client().admin().cluster().prepareState().get().getState().getMetaData().getIndices().get("test").getMappings().get("_default_");
MappingMetaData defaultMapping = client().admin().cluster().prepareState().get()
.getState().getMetaData().getIndices().get("test").getMappings().get("_default_");
Map<?,?> properties = (Map<?, ?>) defaultMapping.getSourceAsMap().get("properties");
assertThat(properties.get("timestamp"), notNullValue());

assertAcked(client().admin().indices().preparePutMapping("test").setType("_default_").setSource("timestamp", "type=date"));

assertAcked(client().admin().indices().preparePutMapping("test").setType("type1").setSource("foo", "enabled=true"));
MappingMetaData type1Mapping = client().admin().cluster().prepareState().get().getState().getMetaData().getIndices().get("test").getMappings().get("type1");
MappingMetaData type1Mapping = client().admin().cluster().prepareState().get()
.getState().getMetaData().getIndices().get("test").getMappings().get("type1");
properties = (Map<?, ?>) type1Mapping.getSourceAsMap().get("properties");
assertThat(properties.get("timestamp"), notNullValue());
}
Expand Down
6 changes: 4 additions & 2 deletions server/src/test/java/org/elasticsearch/cluster/ack/AckIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,8 @@ public void testIndicesAliasesAcknowledgement() {
public void testIndicesAliasesNoAcknowledgement() {
createIndex("test");

AcknowledgedResponse indicesAliasesResponse = client().admin().indices().prepareAliases().addAlias("test", "alias").setTimeout("0s").get();
AcknowledgedResponse indicesAliasesResponse = client().admin().indices().prepareAliases()
.addAlias("test", "alias").setTimeout("0s").get();
assertThat(indicesAliasesResponse.isAcknowledged(), equalTo(false));
}

Expand Down Expand Up @@ -285,7 +286,8 @@ public void testPutMappingNoAcknowledgement() {
createIndex("test");
ensureGreen();

AcknowledgedResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("test").setSource("field", "type=keyword").setTimeout("0s").get();
AcknowledgedResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("test")
.setSource("field", "type=keyword").setTimeout("0s").get();
assertThat(putMappingResponse.isAcknowledged(), equalTo(false));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,22 @@ public void testExpression_MultiParts() throws Exception {
public void testExpression_CustomFormat() throws Exception {
List<String> results = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{YYYY.MM.dd}}>"));
assertThat(results.size(), equalTo(1));
assertThat(results.get(0), equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC))));
assertThat(results.get(0),
equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC))));
}

public void testExpression_EscapeStatic() throws Exception {
List<String> result = expressionResolver.resolve(context, Arrays.asList("<.mar\\{v\\}el-{now/d}>"));
assertThat(result.size(), equalTo(1));
assertThat(result.get(0), equalTo(".mar{v}el-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC))));
assertThat(result.get(0),
equalTo(".mar{v}el-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC))));
}

public void testExpression_EscapeDateFormat() throws Exception {
List<String> result = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{'\\{year\\}'YYYY}}>"));
assertThat(result.size(), equalTo(1));
assertThat(result.get(0), equalTo(".marvel-" + DateTimeFormat.forPattern("'{year}'YYYY").print(new DateTime(context.getStartTime(), UTC))));
assertThat(result.get(0),
equalTo(".marvel-" + DateTimeFormat.forPattern("'{year}'YYYY").print(new DateTime(context.getStartTime(), UTC))));
}

public void testExpression_MixedArray() throws Exception {
Expand All @@ -116,9 +119,11 @@ public void testExpression_MixedArray() throws Exception {
));
assertThat(result.size(), equalTo(4));
assertThat(result.get(0), equalTo("name1"));
assertThat(result.get(1), equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC))));
assertThat(result.get(1),
equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC))));
assertThat(result.get(2), equalTo("name2"));
assertThat(result.get(3), equalTo(".logstash-" + DateTimeFormat.forPattern("YYYY.MM").print(new DateTime(context.getStartTime(), UTC).withDayOfMonth(1))));
assertThat(result.get(3), equalTo(".logstash-" +
DateTimeFormat.forPattern("YYYY.MM").print(new DateTime(context.getStartTime(), UTC).withDayOfMonth(1))));
}

public void testExpression_CustomTimeZoneInSetting() throws Exception {
Expand All @@ -136,7 +141,8 @@ public void testExpression_CustomTimeZoneInSetting() throws Exception {
DateTime now;
if (hoursOffset >= 0) {
// rounding to next day 00:00
now = DateTime.now(UTC).plusHours(hoursOffset).plusMinutes(minutesOffset).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
now = DateTime.now(UTC).plusHours(hoursOffset).plusMinutes(minutesOffset)
.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
} else {
// rounding to today 00:00
now = DateTime.now(UTC).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
Expand Down Expand Up @@ -167,13 +173,15 @@ public void testExpression_CustomTimeZoneInIndexName() throws Exception {
DateTime now;
if (hoursOffset >= 0) {
// rounding to next day 00:00
now = DateTime.now(UTC).plusHours(hoursOffset).plusMinutes(minutesOffset).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
now = DateTime.now(UTC).plusHours(hoursOffset).plusMinutes(minutesOffset)
.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
} else {
// rounding to today 00:00
now = DateTime.now(UTC).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
}
Context context = new Context(this.context.getState(), this.context.getOptions(), now.getMillis());
List<String> results = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{YYYY.MM.dd|" + timeZone.getID() + "}}>"));
List<String> results = expressionResolver.resolve(context,
Arrays.asList("<.marvel-{now/d{YYYY.MM.dd|" + timeZone.getID() + "}}>"));
assertThat(results.size(), equalTo(1));
logger.info("timezone: [{}], now [{}], name: [{}]", timeZone, now, results.get(0));
assertThat(results.get(0), equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.withZone(timeZone))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public void testIndexAndAliasWithSameName() {
fail("exception should have been thrown");
} catch (IllegalStateException e) {
assertThat(e.getMessage(),
equalTo("index and alias names need to be unique, but the following duplicates were found [index (alias of [index])]"));
equalTo("index and alias names need to be unique, " +
"but the following duplicates were found [index (alias of [index])]"));
}
}

Expand Down Expand Up @@ -165,7 +166,8 @@ public void testResolveIndexRouting() {
metaData.resolveIndexRouting(null, "0", "alias1");
fail("should fail");
} catch (IllegalArgumentException ex) {
assertThat(ex.getMessage(), is("Alias [alias1] has index routing associated with it [1], and was provided with routing value [0], rejecting operation"));
assertThat(ex.getMessage(), is("Alias [alias1] has index routing associated with it [1]," +
" and was provided with routing value [0], rejecting operation"));
}

try {
Expand All @@ -189,7 +191,8 @@ public void testResolveIndexRouting() {
metaData.resolveIndexRouting(null, "1", "alias2");
fail("should fail");
} catch (IllegalArgumentException ex) {
assertThat(ex.getMessage(), is("index/alias [alias2] provided with routing value [1,2] that resolved to several routing values, rejecting operation"));
assertThat(ex.getMessage(), is("index/alias [alias2] provided with routing value [1,2]" +
" that resolved to several routing values, rejecting operation"));
}

try {
Expand Down Expand Up @@ -260,7 +263,8 @@ public void testResolveWriteIndexRouting() {
exception = expectThrows(IllegalArgumentException.class, () -> metaData.resolveWriteIndexRouting(null, "1", "alias2"));
assertThat(exception.getMessage(),
is("index/alias [alias2] provided with routing value [1,2] that resolved to several routing values, rejecting operation"));
exception = expectThrows(IllegalArgumentException.class, () -> metaData.resolveWriteIndexRouting(null, randomFrom("1", null), "alias4"));
exception = expectThrows(IllegalArgumentException.class,
() -> metaData.resolveWriteIndexRouting(null, randomFrom("1", null), "alias4"));
assertThat(exception.getMessage(),
is("index/alias [alias4] provided with routing value [1,2] that resolved to several routing values, rejecting operation"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,8 @@ public void testMatchesConcreteIndicesWildcardAndAliases() {
// when ignoreAliases option is not set, WildcardExpressionResolver resolves the provided
// expressions against the defined indices and aliases
IndicesOptions indicesAndAliasesOptions = IndicesOptions.fromOptions(false, false, true, false, true, false, false);
IndexNameExpressionResolver.Context indicesAndAliasesContext = new IndexNameExpressionResolver.Context(state, indicesAndAliasesOptions);
IndexNameExpressionResolver.Context indicesAndAliasesContext =
new IndexNameExpressionResolver.Context(state, indicesAndAliasesOptions);

// ignoreAliases option is set, WildcardExpressionResolver resolves the provided expressions
// only against the defined indices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ public void testNewIndexRestored() {
.build();
ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY))
.metaData(metaData)
.routingTable(RoutingTable.builder().addAsNewRestore(metaData.index("test"), new SnapshotRecoverySource(new Snapshot("rep1", new SnapshotId("snp1", UUIDs.randomBase64UUID())), Version.CURRENT, "test"), new IntHashSet()).build()).build();
.routingTable(RoutingTable.builder().addAsNewRestore(metaData.index("test"), new SnapshotRecoverySource(
new Snapshot("rep1", new SnapshotId("snp1", UUIDs.randomBase64UUID())), Version.CURRENT, "test"),
new IntHashSet()).build()).build();
for (ShardRouting shard : clusterState.getRoutingNodes().shardsWithState(UNASSIGNED)) {
assertThat(shard.unassignedInfo().getReason(), equalTo(UnassignedInfo.Reason.NEW_INDEX_RESTORED));
}
Expand Down
Loading

0 comments on commit ea845eb

Please sign in to comment.