Skip to content

Commit 1345dff

Browse files
authored
Fix line length in org.elasticsearch.snapshots (#36646)
Remove the line length suppression for this package and fix offending lines in both main and test relates #34884
1 parent d2ce576 commit 1345dff

File tree

9 files changed

+173
-90
lines changed

9 files changed

+173
-90
lines changed

buildSrc/src/main/resources/checkstyle_suppressions.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@
5656
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]rest[/\\]action[/\\]cat[/\\]RestIndicesAction.java" checks="LineLength" />
5757
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]rest[/\\]action[/\\]cat[/\\]RestShardsAction.java" checks="LineLength" />
5858
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]rest[/\\]action[/\\]cat[/\\]RestThreadPoolAction.java" checks="LineLength" />
59-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]RestoreService.java" checks="LineLength" />
60-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]SnapshotShardFailure.java" checks="LineLength" />
61-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]SnapshotShardsService.java" checks="LineLength" />
62-
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]snapshots[/\\]SnapshotsService.java" checks="LineLength" />
6359
<suppress files="server[/\\]src[/\\]main[/\\]java[/\\]org[/\\]elasticsearch[/\\]threadpool[/\\]ThreadPool.java" checks="LineLength" />
6460
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]aliases[/\\]IndexAliasesIT.java" checks="LineLength" />
6561
<suppress files="server[/\\]src[/\\]test[/\\]java[/\\]org[/\\]elasticsearch[/\\]explain[/\\]ExplainActionIT.java" checks="LineLength" />

server/src/main/java/org/elasticsearch/snapshots/RestoreInfo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
142142
return builder;
143143
}
144144

145-
private static final ObjectParser<RestoreInfo, Void> PARSER = new ObjectParser<>(RestoreInfo.class.getName(), true, RestoreInfo::new);
145+
private static final ObjectParser<RestoreInfo, Void> PARSER = new ObjectParser<>(RestoreInfo.class.getName(),
146+
true, RestoreInfo::new);
146147

147148
static {
148149
ObjectParser<RestoreInfo, Void> shardsParser = new ObjectParser<>("shards", true, null);

server/src/main/java/org/elasticsearch/snapshots/RestoreService.java

Lines changed: 63 additions & 29 deletions
Large diffs are not rendered by default.

server/src/main/java/org/elasticsearch/snapshots/SnapshotInfo.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -232,16 +232,18 @@ int getSuccessfulShards() {
232232
private final List<SnapshotShardFailure> shardFailures;
233233

234234
public SnapshotInfo(SnapshotId snapshotId, List<String> indices, SnapshotState state) {
235-
this(snapshotId, indices, state, null, null, 0L, 0L, 0, 0, Collections.emptyList(), null);
235+
this(snapshotId, indices, state, null, null, 0L, 0L, 0, 0,
236+
Collections.emptyList(), null);
236237
}
237238

238239
public SnapshotInfo(SnapshotId snapshotId, List<String> indices, SnapshotState state, Version version) {
239-
this(snapshotId, indices, state, null, version, 0L, 0L, 0, 0, Collections.emptyList(), null);
240+
this(snapshotId, indices, state, null, version, 0L, 0L, 0, 0,
241+
Collections.emptyList(), null);
240242
}
241243

242244
public SnapshotInfo(SnapshotId snapshotId, List<String> indices, long startTime, Boolean includeGlobalState) {
243-
this(snapshotId, indices, SnapshotState.IN_PROGRESS, null, Version.CURRENT, startTime, 0L, 0, 0,
244-
Collections.emptyList(), includeGlobalState);
245+
this(snapshotId, indices, SnapshotState.IN_PROGRESS, null, Version.CURRENT, startTime, 0L,
246+
0, 0, Collections.emptyList(), includeGlobalState);
245247
}
246248

247249
public SnapshotInfo(SnapshotId snapshotId, List<String> indices, long startTime, String reason, long endTime,
@@ -306,7 +308,8 @@ public SnapshotInfo(final StreamInput in) throws IOException {
306308
public static SnapshotInfo incompatible(SnapshotId snapshotId) {
307309
return new SnapshotInfo(snapshotId, Collections.emptyList(), SnapshotState.INCOMPATIBLE,
308310
"the snapshot is incompatible with the current version of Elasticsearch and its exact version is unknown",
309-
null, 0L, 0L, 0, 0, Collections.emptyList(), null);
311+
null, 0L, 0L, 0, 0,
312+
Collections.emptyList(), null);
310313
}
311314

312315
/**

server/src/main/java/org/elasticsearch/snapshots/SnapshotShardsService.java

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ public class SnapshotShardsService extends AbstractLifecycleComponent implements
116116
private final UpdateSnapshotStatusAction updateSnapshotStatusHandler;
117117

118118
@Inject
119-
public SnapshotShardsService(Settings settings, ClusterService clusterService, SnapshotsService snapshotsService, ThreadPool threadPool,
120-
TransportService transportService, IndicesService indicesService,
119+
public SnapshotShardsService(Settings settings, ClusterService clusterService, SnapshotsService snapshotsService,
120+
ThreadPool threadPool, TransportService transportService, IndicesService indicesService,
121121
ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
122122
super(settings);
123123
this.indicesService = indicesService;
@@ -188,7 +188,8 @@ public void beforeIndexShardClosed(ShardId shardId, @Nullable IndexShard indexSh
188188
for (Map.Entry<Snapshot, Map<ShardId, IndexShardSnapshotStatus>> snapshotShards : snapshotShardsMap.entrySet()) {
189189
Map<ShardId, IndexShardSnapshotStatus> shards = snapshotShards.getValue();
190190
if (shards.containsKey(shardId)) {
191-
logger.debug("[{}] shard closing, abort snapshotting for snapshot [{}]", shardId, snapshotShards.getKey().getSnapshotId());
191+
logger.debug("[{}] shard closing, abort snapshotting for snapshot [{}]",
192+
shardId, snapshotShards.getKey().getSnapshotId());
192193
shards.get(shardId).abortIfNotCompleted("shard is closing, aborting");
193194
}
194195
}
@@ -337,7 +338,8 @@ public void doRun() {
337338

338339
@Override
339340
public void onFailure(Exception e) {
340-
logger.warn(() -> new ParameterizedMessage("[{}][{}] failed to snapshot shard", shardId, snapshot), e);
341+
logger.warn(() -> new ParameterizedMessage("[{}][{}] failed to snapshot shard",
342+
shardId, snapshot), e);
341343
failure.set(e);
342344
}
343345

@@ -367,7 +369,8 @@ public void onAfter() {
367369
* @param snapshot snapshot
368370
* @param snapshotStatus snapshot status
369371
*/
370-
private void snapshot(final IndexShard indexShard, final Snapshot snapshot, final IndexId indexId, final IndexShardSnapshotStatus snapshotStatus) {
372+
private void snapshot(final IndexShard indexShard, final Snapshot snapshot, final IndexId indexId,
373+
final IndexShardSnapshotStatus snapshotStatus) {
371374
final ShardId shardId = indexShard.shardId();
372375
if (indexShard.routingEntry().primary() == false) {
373376
throw new IndexShardSnapshotFailedException(shardId, "snapshot should be performed only on primary");
@@ -526,7 +529,8 @@ void sendSnapshotShardUpdate(final Snapshot snapshot, final ShardId shardId, fin
526529
*
527530
* @param request update shard status request
528531
*/
529-
private void innerUpdateSnapshotState(final UpdateIndexShardSnapshotStatusRequest request, ActionListener<UpdateIndexShardSnapshotStatusResponse> listener) {
532+
private void innerUpdateSnapshotState(final UpdateIndexShardSnapshotStatusRequest request,
533+
ActionListener<UpdateIndexShardSnapshotStatusResponse> listener) {
530534
logger.trace("received updated snapshot restore state [{}]", request);
531535
clusterService.submitStateUpdateTask(
532536
"update snapshot state",
@@ -549,7 +553,8 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
549553
class SnapshotStateExecutor implements ClusterStateTaskExecutor<UpdateIndexShardSnapshotStatusRequest> {
550554

551555
@Override
552-
public ClusterTasksResult<UpdateIndexShardSnapshotStatusRequest> execute(ClusterState currentState, List<UpdateIndexShardSnapshotStatusRequest> tasks) throws Exception {
556+
public ClusterTasksResult<UpdateIndexShardSnapshotStatusRequest>
557+
execute(ClusterState currentState, List<UpdateIndexShardSnapshotStatusRequest> tasks) throws Exception {
553558
final SnapshotsInProgress snapshots = currentState.custom(SnapshotsInProgress.TYPE);
554559
if (snapshots != null) {
555560
int changedCount = 0;
@@ -560,7 +565,8 @@ public ClusterTasksResult<UpdateIndexShardSnapshotStatusRequest> execute(Cluster
560565

561566
for (UpdateIndexShardSnapshotStatusRequest updateSnapshotState : tasks) {
562567
if (entry.snapshot().equals(updateSnapshotState.snapshot())) {
563-
logger.trace("[{}] Updating shard [{}] with status [{}]", updateSnapshotState.snapshot(), updateSnapshotState.shardId(), updateSnapshotState.status().state());
568+
logger.trace("[{}] Updating shard [{}] with status [{}]", updateSnapshotState.snapshot(),
569+
updateSnapshotState.shardId(), updateSnapshotState.status().state());
564570
if (updated == false) {
565571
shards.putAll(entry.shards());
566572
updated = true;
@@ -588,7 +594,8 @@ public ClusterTasksResult<UpdateIndexShardSnapshotStatusRequest> execute(Cluster
588594
if (changedCount > 0) {
589595
logger.trace("changed cluster state triggered by {} snapshot state updates", changedCount);
590596

591-
final SnapshotsInProgress updatedSnapshots = new SnapshotsInProgress(entries.toArray(new SnapshotsInProgress.Entry[entries.size()]));
597+
final SnapshotsInProgress updatedSnapshots =
598+
new SnapshotsInProgress(entries.toArray(new SnapshotsInProgress.Entry[entries.size()]));
592599
return ClusterTasksResult.<UpdateIndexShardSnapshotStatusRequest>builder().successes(tasks).build(
593600
ClusterState.builder(currentState).putCustom(SnapshotsInProgress.TYPE, updatedSnapshots).build());
594601
}
@@ -606,8 +613,8 @@ private class UpdateSnapshotStatusAction
606613
UpdateSnapshotStatusAction(TransportService transportService, ClusterService clusterService,
607614
ThreadPool threadPool, ActionFilters actionFilters, IndexNameExpressionResolver indexNameExpressionResolver) {
608615
super(
609-
SnapshotShardsService.UPDATE_SNAPSHOT_STATUS_ACTION_NAME, transportService, clusterService, threadPool, actionFilters,
610-
indexNameExpressionResolver, UpdateIndexShardSnapshotStatusRequest::new
616+
SnapshotShardsService.UPDATE_SNAPSHOT_STATUS_ACTION_NAME, transportService, clusterService, threadPool,
617+
actionFilters, indexNameExpressionResolver, UpdateIndexShardSnapshotStatusRequest::new
611618
);
612619
}
613620

@@ -622,7 +629,8 @@ protected UpdateIndexShardSnapshotStatusResponse newResponse() {
622629
}
623630

624631
@Override
625-
protected void masterOperation(UpdateIndexShardSnapshotStatusRequest request, ClusterState state, ActionListener<UpdateIndexShardSnapshotStatusResponse> listener) throws Exception {
632+
protected void masterOperation(UpdateIndexShardSnapshotStatusRequest request, ClusterState state,
633+
ActionListener<UpdateIndexShardSnapshotStatusResponse> listener) throws Exception {
626634
innerUpdateSnapshotState(request, listener);
627635
}
628636

0 commit comments

Comments
 (0)