Skip to content

Commit b6e6cc3

Browse files
committed
Restore logger specific to GlobalCheckpointTracker
This commit restores having a logger that is specific to GlobalCheckpointTracker so that its logging levels can be configured separately from SequenceNumbersService.
1 parent d71aa16 commit b6e6cc3

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

core/src/main/java/org/elasticsearch/index/seqno/GlobalCheckpointTracker.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import com.carrotsearch.hppc.cursors.ObjectLongCursor;
2525
import org.apache.logging.log4j.Logger;
2626
import org.elasticsearch.index.IndexSettings;
27+
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
28+
import org.elasticsearch.index.shard.ShardId;
2729

2830
import java.util.HashSet;
2931
import java.util.Locale;
@@ -40,7 +42,7 @@
4042
* <p>
4143
* The global checkpoint is maintained by the primary shard and is replicated to all the replicas (via {@link GlobalCheckpointSyncAction}).
4244
*/
43-
public class GlobalCheckpointTracker {
45+
public class GlobalCheckpointTracker extends AbstractIndexShardComponent {
4446

4547
/*
4648
* This map holds the last known local checkpoint for every active shard and initializing shard copies that has been brought up to speed
@@ -62,22 +64,20 @@ public class GlobalCheckpointTracker {
6264
*/
6365
private long globalCheckpoint;
6466

65-
private final Logger logger;
66-
6767
/**
6868
* Initialize the global checkpoint service. The specified global checkpoint should be set to the last known global checkpoint, or
6969
* {@link SequenceNumbersService#UNASSIGNED_SEQ_NO}.
7070
*
71+
* @param shardId the shard ID
7172
* @param indexSettings the index settings
7273
* @param globalCheckpoint the last known global checkpoint for this shard, or {@link SequenceNumbersService#UNASSIGNED_SEQ_NO}
73-
* @param logger a component logger
7474
*/
75-
GlobalCheckpointTracker(final IndexSettings indexSettings, final long globalCheckpoint, final Logger logger) {
75+
GlobalCheckpointTracker(final ShardId shardId, final IndexSettings indexSettings, final long globalCheckpoint) {
76+
super(shardId, indexSettings);
7677
assert globalCheckpoint >= UNASSIGNED_SEQ_NO : "illegal initial global checkpoint: " + globalCheckpoint;
7778
inSyncLocalCheckpoints = new ObjectLongHashMap<>(1 + indexSettings.getNumberOfReplicas());
7879
assignedAllocationIds = new HashSet<>(1 + indexSettings.getNumberOfReplicas());
7980
this.globalCheckpoint = globalCheckpoint;
80-
this.logger = logger;
8181
}
8282

8383
/**

core/src/main/java/org/elasticsearch/index/seqno/SequenceNumbersService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public SequenceNumbersService(
6363
final long globalCheckpoint) {
6464
super(shardId, indexSettings);
6565
localCheckpointTracker = new LocalCheckpointTracker(indexSettings, maxSeqNo, localCheckpoint);
66-
globalCheckpointTracker = new GlobalCheckpointTracker(indexSettings, globalCheckpoint, logger);
66+
globalCheckpointTracker = new GlobalCheckpointTracker(shardId, indexSettings, globalCheckpoint);
6767
}
6868

6969
/**

core/src/test/java/org/elasticsearch/index/seqno/GlobalCheckpointTests.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
import org.elasticsearch.common.settings.Settings;
2222
import org.elasticsearch.common.util.set.Sets;
23+
import org.elasticsearch.index.shard.ShardId;
2324
import org.elasticsearch.test.ESTestCase;
2425
import org.elasticsearch.test.IndexSettingsModule;
2526
import org.junit.Before;
@@ -48,7 +49,10 @@ public class GlobalCheckpointTests extends ESTestCase {
4849
public void setUp() throws Exception {
4950
super.setUp();
5051
tracker =
51-
new GlobalCheckpointTracker(IndexSettingsModule.newIndexSettings("test", Settings.EMPTY), UNASSIGNED_SEQ_NO, logger);
52+
new GlobalCheckpointTracker(
53+
new ShardId("test", "_na_", 0),
54+
IndexSettingsModule.newIndexSettings("test", Settings.EMPTY),
55+
UNASSIGNED_SEQ_NO);
5256
}
5357

5458
public void testEmptyShards() {

0 commit comments

Comments
 (0)