Skip to content

Commit b49f1ef

Browse files
committed
iter
1 parent 2ac8a29 commit b49f1ef

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

x-pack/plugin/ccr/src/main/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTask.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public abstract class ShardFollowNodeTask extends AllocatedPersistentTask {
6767

6868
private static final Logger LOGGER = Loggers.getLogger(ShardFollowNodeTask.class);
6969

70+
private final String leaderIndex;
7071
private final ShardFollowTask params;
7172
private final TimeValue retryTimeout;
7273
private final TimeValue idleShardChangesRequestDelay;
@@ -113,6 +114,12 @@ protected boolean removeEldestEntry(final Map.Entry<Long, ElasticsearchException
113114
return size() > params.getMaxConcurrentReadBatches();
114115
}
115116
};
117+
118+
if (params.getLeaderClusterAlias() != null) {
119+
leaderIndex = params.getLeaderClusterAlias() + ":" + params.getLeaderShardId().getIndexName();
120+
} else {
121+
leaderIndex = params.getLeaderShardId().getIndexName();
122+
}
116123
}
117124

118125
void start(
@@ -416,12 +423,6 @@ public ShardId getFollowShardId() {
416423

417424
@Override
418425
public synchronized Status getStatus() {
419-
final String leaderIndex;
420-
if (params.getLeaderClusterAlias() != null) {
421-
leaderIndex = params.getLeaderClusterAlias() + ":" + params.getLeaderShardId().getIndexName();
422-
} else {
423-
leaderIndex = params.getLeaderShardId().getIndexName();
424-
}
425426
final long timeSinceLastFetchMillis;
426427
if (lastFetchTime != -1) {
427428
timeSinceLastFetchMillis = TimeUnit.NANOSECONDS.toMillis(relativeTimeProvider.getAsLong() - lastFetchTime);
@@ -681,12 +682,12 @@ public NavigableMap<Long, ElasticsearchException> fetchExceptions() {
681682

682683
private final long timeSinceLastFetchMillis;
683684

684-
public long timeSinceLastFetch() {
685+
public long timeSinceLastFetchMillis() {
685686
return timeSinceLastFetchMillis;
686687
}
687688

688689
Status(
689-
String leaderIndex,
690+
final String leaderIndex,
690691
final int shardId,
691692
final long leaderGlobalCheckpoint,
692693
final long leaderMaxSeqNo,

x-pack/plugin/ccr/src/test/java/org/elasticsearch/xpack/ccr/action/ShardFollowNodeTaskStatusTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ protected void assertEqualInstances(final ShardFollowNodeTask.Status expectedIns
9090
anyOf(instanceOf(ElasticsearchException.class), instanceOf(IllegalStateException.class)));
9191
assertThat(entry.getValue().getCause().getMessage(), containsString(expected.getCause().getMessage()));
9292
}
93-
assertThat(newInstance.timeSinceLastFetch(), equalTo(expectedInstance.timeSinceLastFetch()));
93+
assertThat(newInstance.timeSinceLastFetchMillis(), equalTo(expectedInstance.timeSinceLastFetchMillis()));
9494
}
9595

9696
@Override

0 commit comments

Comments
 (0)