Skip to content

Commit ea845eb

Browse files
committed
Remove remaining line length violations in o.e.cluster (#34941)
relates #34923, #34884
1 parent 3489a18 commit ea845eb

File tree

49 files changed

+796
-529
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+796
-529
lines changed

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 104 deletions
Large diffs are not rendered by default.

server/src/main/java/org/elasticsearch/cluster/ClusterStateObserver.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ public void postAdded() {
216216
lastObservedState.set(new StoredState(newState));
217217
context.listener.onNewClusterState(newState);
218218
} else {
219-
logger.trace("observer: postAdded - predicate approved state but observing context has changed - ignoring ({})", newState);
219+
logger.trace("observer: postAdded - predicate approved state but observing context has changed - ignoring ({})",
220+
newState);
220221
}
221222
} else {
222223
logger.trace("observer: postAdded - predicate rejected state ({})", newState);
@@ -240,7 +241,8 @@ public void onTimeout(TimeValue timeout) {
240241
if (context != null) {
241242
clusterApplierService.removeTimeoutListener(this);
242243
long timeSinceStartMS = TimeValue.nsecToMSec(System.nanoTime() - startTimeNS);
243-
logger.trace("observer: timeout notification from cluster service. timeout setting [{}], time since start [{}]", timeOutValue, new TimeValue(timeSinceStartMS));
244+
logger.trace("observer: timeout notification from cluster service. timeout setting [{}], time since start [{}]",
245+
timeOutValue, new TimeValue(timeSinceStartMS));
244246
// update to latest, in case people want to retry
245247
lastObservedState.set(new StoredState(clusterApplierService.state()));
246248
timedOut = true;

server/src/main/java/org/elasticsearch/cluster/ClusterStateUpdateTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* A task that can update the cluster state.
3030
*/
3131
public abstract class ClusterStateUpdateTask
32-
implements ClusterStateTaskConfig, ClusterStateTaskExecutor<ClusterStateUpdateTask>, ClusterStateTaskListener {
32+
implements ClusterStateTaskConfig, ClusterStateTaskExecutor<ClusterStateUpdateTask>, ClusterStateTaskListener {
3333

3434
private final Priority priority;
3535

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

4444
@Override
4545
public final ClusterTasksResult<ClusterStateUpdateTask> execute(ClusterState currentState, List<ClusterStateUpdateTask> tasks)
46-
throws Exception {
46+
throws Exception {
4747
ClusterState result = execute(currentState);
4848
return ClusterTasksResult.<ClusterStateUpdateTask>builder().successes(tasks).build(result);
4949
}

server/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,8 @@ private ClusterState applyRequest(ClusterState currentState, PutMappingClusterSt
310310
if (existingMapper != null) {
311311
existingSource = existingMapper.mappingSource();
312312
}
313-
DocumentMapper mergedMapper = mapperService.merge(mappingType, mappingUpdateSource, MergeReason.MAPPING_UPDATE, request.updateAllTypes());
313+
DocumentMapper mergedMapper = mapperService.merge(mappingType, mappingUpdateSource,
314+
MergeReason.MAPPING_UPDATE, request.updateAllTypes());
314315
CompressedXContent updatedSource = mergedMapper.mappingSource();
315316

316317
if (existingSource != null) {

server/src/main/java/org/elasticsearch/cluster/routing/OperationRouting.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public ShardIterator indexShards(ClusterState clusterState, String index, String
7979
return shards(clusterState, index, id, routing).shardsIt();
8080
}
8181

82-
public ShardIterator getShards(ClusterState clusterState, String index, String id, @Nullable String routing, @Nullable String preference) {
82+
public ShardIterator getShards(ClusterState clusterState, String index, String id, @Nullable String routing,
83+
@Nullable String preference) {
8384
return preferenceActiveShardIterator(shards(clusterState, index, id, routing), clusterState.nodes().getLocalNodeId(),
8485
clusterState.nodes(), preference, null, null);
8586
}

server/src/test/java/org/elasticsearch/cluster/SimpleClusterStateIT.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ private void testFilteringByIndexWorks(String[] indices, String[] expected) {
191191
}
192192

193193
public void testLargeClusterStatePublishing() throws Exception {
194-
int estimatedBytesSize = scaledRandomIntBetween(ByteSizeValue.parseBytesSizeValue("10k", "estimatedBytesSize").bytesAsInt(),
195-
ByteSizeValue.parseBytesSizeValue("256k", "estimatedBytesSize").bytesAsInt());
194+
int estimatedBytesSize = scaledRandomIntBetween(
195+
ByteSizeValue.parseBytesSizeValue("10k", "estimatedBytesSize").bytesAsInt(),
196+
ByteSizeValue.parseBytesSizeValue("256k", "estimatedBytesSize").bytesAsInt());
196197
XContentBuilder mapping = XContentFactory.jsonBuilder().startObject().startObject("type").startObject("properties");
197198
int counter = 0;
198199
int numberOfFields = 0;
@@ -274,7 +275,8 @@ public void testIndicesIgnoreUnavailableFalse() throws Exception {
274275
// ignore_unavailable set to false throws exception when allowNoIndices is turned off
275276
IndicesOptions allowNoIndices = IndicesOptions.fromOptions(false, true, true, false);
276277
try {
277-
client().admin().cluster().prepareState().clear().setMetaData(true).setIndices("fzzbzz").setIndicesOptions(allowNoIndices).get();
278+
client().admin().cluster().prepareState().clear().setMetaData(true)
279+
.setIndices("fzzbzz").setIndicesOptions(allowNoIndices).get();
278280
fail("Expected IndexNotFoundException");
279281
} catch (IndexNotFoundException e) {
280282
assertThat(e.getMessage(), is("no such index"));

server/src/test/java/org/elasticsearch/cluster/SpecificMasterNodesIT.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,22 +133,26 @@ public void testElectOnlyBetweenMasterNodes() throws IOException {
133133
*/
134134
public void testCustomDefaultMapping() throws Exception {
135135
logger.info("--> start master node / non data");
136-
internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true));
136+
internalCluster().startNode(Settings.builder().put(Node.NODE_DATA_SETTING.getKey(), false)
137+
.put(Node.NODE_MASTER_SETTING.getKey(), true));
137138

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

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

144-
MappingMetaData defaultMapping = client().admin().cluster().prepareState().get().getState().getMetaData().getIndices().get("test").getMappings().get("_default_");
146+
MappingMetaData defaultMapping = client().admin().cluster().prepareState().get()
147+
.getState().getMetaData().getIndices().get("test").getMappings().get("_default_");
145148
Map<?,?> properties = (Map<?, ?>) defaultMapping.getSourceAsMap().get("properties");
146149
assertThat(properties.get("timestamp"), notNullValue());
147150

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

150153
assertAcked(client().admin().indices().preparePutMapping("test").setType("type1").setSource("foo", "enabled=true"));
151-
MappingMetaData type1Mapping = client().admin().cluster().prepareState().get().getState().getMetaData().getIndices().get("test").getMappings().get("type1");
154+
MappingMetaData type1Mapping = client().admin().cluster().prepareState().get()
155+
.getState().getMetaData().getIndices().get("test").getMappings().get("type1");
152156
properties = (Map<?, ?>) type1Mapping.getSourceAsMap().get("properties");
153157
assertThat(properties.get("timestamp"), notNullValue());
154158
}

server/src/test/java/org/elasticsearch/cluster/ack/AckIT.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ public void testIndicesAliasesAcknowledgement() {
232232
public void testIndicesAliasesNoAcknowledgement() {
233233
createIndex("test");
234234

235-
AcknowledgedResponse indicesAliasesResponse = client().admin().indices().prepareAliases().addAlias("test", "alias").setTimeout("0s").get();
235+
AcknowledgedResponse indicesAliasesResponse = client().admin().indices().prepareAliases()
236+
.addAlias("test", "alias").setTimeout("0s").get();
236237
assertThat(indicesAliasesResponse.isAcknowledged(), equalTo(false));
237238
}
238239

@@ -285,7 +286,8 @@ public void testPutMappingNoAcknowledgement() {
285286
createIndex("test");
286287
ensureGreen();
287288

288-
AcknowledgedResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("test").setSource("field", "type=keyword").setTimeout("0s").get();
289+
AcknowledgedResponse putMappingResponse = client().admin().indices().preparePutMapping("test").setType("test")
290+
.setSource("field", "type=keyword").setTimeout("0s").get();
289291
assertThat(putMappingResponse.isAcknowledged(), equalTo(false));
290292
}
291293

server/src/test/java/org/elasticsearch/cluster/metadata/DateMathExpressionResolverTests.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,22 @@ public void testExpression_MultiParts() throws Exception {
9595
public void testExpression_CustomFormat() throws Exception {
9696
List<String> results = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{YYYY.MM.dd}}>"));
9797
assertThat(results.size(), equalTo(1));
98-
assertThat(results.get(0), equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC))));
98+
assertThat(results.get(0),
99+
equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC))));
99100
}
100101

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

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

113116
public void testExpression_MixedArray() throws Exception {
@@ -116,9 +119,11 @@ public void testExpression_MixedArray() throws Exception {
116119
));
117120
assertThat(result.size(), equalTo(4));
118121
assertThat(result.get(0), equalTo("name1"));
119-
assertThat(result.get(1), equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC))));
122+
assertThat(result.get(1),
123+
equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(new DateTime(context.getStartTime(), UTC))));
120124
assertThat(result.get(2), equalTo("name2"));
121-
assertThat(result.get(3), equalTo(".logstash-" + DateTimeFormat.forPattern("YYYY.MM").print(new DateTime(context.getStartTime(), UTC).withDayOfMonth(1))));
125+
assertThat(result.get(3), equalTo(".logstash-" +
126+
DateTimeFormat.forPattern("YYYY.MM").print(new DateTime(context.getStartTime(), UTC).withDayOfMonth(1))));
122127
}
123128

124129
public void testExpression_CustomTimeZoneInSetting() throws Exception {
@@ -136,7 +141,8 @@ public void testExpression_CustomTimeZoneInSetting() throws Exception {
136141
DateTime now;
137142
if (hoursOffset >= 0) {
138143
// rounding to next day 00:00
139-
now = DateTime.now(UTC).plusHours(hoursOffset).plusMinutes(minutesOffset).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
144+
now = DateTime.now(UTC).plusHours(hoursOffset).plusMinutes(minutesOffset)
145+
.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
140146
} else {
141147
// rounding to today 00:00
142148
now = DateTime.now(UTC).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
@@ -167,13 +173,15 @@ public void testExpression_CustomTimeZoneInIndexName() throws Exception {
167173
DateTime now;
168174
if (hoursOffset >= 0) {
169175
// rounding to next day 00:00
170-
now = DateTime.now(UTC).plusHours(hoursOffset).plusMinutes(minutesOffset).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
176+
now = DateTime.now(UTC).plusHours(hoursOffset).plusMinutes(minutesOffset)
177+
.withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
171178
} else {
172179
// rounding to today 00:00
173180
now = DateTime.now(UTC).withHourOfDay(0).withMinuteOfHour(0).withSecondOfMinute(0);
174181
}
175182
Context context = new Context(this.context.getState(), this.context.getOptions(), now.getMillis());
176-
List<String> results = expressionResolver.resolve(context, Arrays.asList("<.marvel-{now/d{YYYY.MM.dd|" + timeZone.getID() + "}}>"));
183+
List<String> results = expressionResolver.resolve(context,
184+
Arrays.asList("<.marvel-{now/d{YYYY.MM.dd|" + timeZone.getID() + "}}>"));
177185
assertThat(results.size(), equalTo(1));
178186
logger.info("timezone: [{}], now [{}], name: [{}]", timeZone, now, results.get(0));
179187
assertThat(results.get(0), equalTo(".marvel-" + DateTimeFormat.forPattern("YYYY.MM.dd").print(now.withZone(timeZone))));

server/src/test/java/org/elasticsearch/cluster/metadata/MetaDataTests.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ public void testIndexAndAliasWithSameName() {
6262
fail("exception should have been thrown");
6363
} catch (IllegalStateException e) {
6464
assertThat(e.getMessage(),
65-
equalTo("index and alias names need to be unique, but the following duplicates were found [index (alias of [index])]"));
65+
equalTo("index and alias names need to be unique, " +
66+
"but the following duplicates were found [index (alias of [index])]"));
6667
}
6768
}
6869

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

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

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

0 commit comments

Comments
 (0)