Skip to content

Commit d15cb1c

Browse files
committed
improve
1 parent b7dfa21 commit d15cb1c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/rollup/action/RollupShardTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
package org.elasticsearch.xpack.core.rollup.action;
99

10-
import java.util.Map;
11-
1210
import org.elasticsearch.index.shard.ShardId;
1311
import org.elasticsearch.tasks.CancellableTask;
1412
import org.elasticsearch.tasks.TaskId;
1513
import org.elasticsearch.xpack.core.rollup.RollupActionConfig;
1614
import org.elasticsearch.xpack.core.rollup.RollupField;
1715

16+
import java.util.Map;
17+
1818
public class RollupShardTask extends CancellableTask {
1919
private String rollupIndex;
2020
private RollupActionConfig config;

x-pack/plugin/rollup/src/test/java/org/elasticsearch/xpack/rollup/v2/RollupActionSingleNodeTests.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void setup() {
120120
rollupIndex = "rollup-" + sourceIndex;
121121
startTime = randomLongBetween(946769284000L, 1607470084000L); // random date between 2000-2020
122122
docCount = randomIntBetween(10, 9000);
123-
numOfShards = 4;// randomIntBetween(1, 4);
123+
numOfShards = randomIntBetween(1, 4);
124124
numOfReplicas = 0; // Since this is a single node, we cannot have replicas
125125

126126
// Values for keyword dimensions
@@ -356,7 +356,8 @@ public void testCancelRollupIndexer() throws IOException {
356356
IndicesService indexServices = getInstanceFromNode(IndicesService.class);
357357
Index srcIndex = resolveIndex(sourceIndex);
358358
IndexService indexService = indexServices.indexServiceSafe(srcIndex);
359-
IndexShard shard = indexService.getShard(0);
359+
int shardNum = randomIntBetween(0, numOfShards - 1);
360+
IndexShard shard = indexService.getShard(shardNum);
360361
RollupShardStatus status = new RollupShardStatus(shard.shardId());
361362

362363
// re-use source index as temp index for test
@@ -373,7 +374,7 @@ public void testCancelRollupIndexer() throws IOException {
373374
status.setCancelled();
374375

375376
TaskCancelledException exception = expectThrows(TaskCancelledException.class, () -> indexer.execute());
376-
assertThat(exception.getMessage(), equalTo("Shard [" + sourceIndex + "][0] rollup cancelled"));
377+
assertThat(exception.getMessage(), equalTo("Shard [" + sourceIndex + "][" + shardNum + "] rollup cancelled"));
377378
}
378379

379380
public void testRollupBulkFailed() throws IOException {

0 commit comments

Comments
 (0)