Skip to content

Commit 4ba8d5c

Browse files
committed
Remove context wrapper
1 parent e3f1886 commit 4ba8d5c

File tree

9 files changed

+28
-101
lines changed

9 files changed

+28
-101
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,22 @@ public synchronized void updateAllocationIdsFromMaster(
249249
}
250250

251251
/**
252-
* Get the sequence number primary context for the shard. This includes the state of the global checkpoint tracker.
252+
* Get the primary context for the shard. This includes the state of the global checkpoint tracker.
253253
*
254-
* @return the sequence number primary context
254+
* @return the primary context
255255
*/
256-
synchronized SeqNoPrimaryContext seqNoPrimaryContext() {
256+
synchronized PrimaryContext primaryContext() {
257257
final ObjectLongMap<String> inSyncLocalCheckpoints = new ObjectLongHashMap<>(this.inSyncLocalCheckpoints);
258258
final ObjectLongMap<String> trackingLocalCheckpoints = new ObjectLongHashMap<>(this.trackingLocalCheckpoints);
259-
return new SeqNoPrimaryContext(inSyncLocalCheckpoints, trackingLocalCheckpoints);
259+
return new PrimaryContext(inSyncLocalCheckpoints, trackingLocalCheckpoints);
260260
}
261261

262262
/**
263263
* Updates the known allocation IDs and the local checkpoints for the corresponding allocations from a primary relocation source.
264264
*
265-
* @param seqNoPrimaryContext the sequence number context
265+
* @param primaryContext the primary context
266266
*/
267-
synchronized void updateAllocationIdsFromPrimaryContext(final SeqNoPrimaryContext seqNoPrimaryContext) {
267+
synchronized void updateAllocationIdsFromPrimaryContext(final PrimaryContext primaryContext) {
268268
/*
269269
* We are gathered here today to witness the relocation handoff transferring knowledge from the relocation source to the relocation
270270
* target. We need to consider the possibility that the version of the cluster state on the relocation source when the primary
@@ -312,7 +312,7 @@ synchronized void updateAllocationIdsFromPrimaryContext(final SeqNoPrimaryContex
312312
*
313313
* In both cases, no calls to update the local checkpoint for such shards will be made. This case is safe too.
314314
*/
315-
for (final ObjectLongCursor<String> cursor : seqNoPrimaryContext.inSyncLocalCheckpoints()) {
315+
for (final ObjectLongCursor<String> cursor : primaryContext.inSyncLocalCheckpoints()) {
316316
updateLocalCheckpoint(cursor.key, cursor.value);
317317
assert cursor.value >= globalCheckpoint
318318
: "local checkpoint [" + cursor.value + "] violates being at least the global checkpoint [" + globalCheckpoint + "]";
@@ -327,7 +327,7 @@ synchronized void updateAllocationIdsFromPrimaryContext(final SeqNoPrimaryContex
327327
}
328328
}
329329

330-
for (final ObjectLongCursor<String> cursor : seqNoPrimaryContext.trackingLocalCheckpoints()) {
330+
for (final ObjectLongCursor<String> cursor : primaryContext.trackingLocalCheckpoints()) {
331331
updateLocalCheckpoint(cursor.key, cursor.value);
332332
}
333333
}

core/src/main/java/org/elasticsearch/index/seqno/SeqNoPrimaryContext.java renamed to core/src/main/java/org/elasticsearch/index/seqno/PrimaryContext.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
* Represents the sequence number component of the primary context. This is the knowledge on the primary of the in-sync and initializing
3333
* shards and their local checkpoints.
3434
*/
35-
public class SeqNoPrimaryContext implements Writeable {
35+
public class PrimaryContext implements Writeable {
3636

3737
private ObjectLongMap<String> inSyncLocalCheckpoints;
3838

@@ -46,12 +46,12 @@ public ObjectLongMap<String> trackingLocalCheckpoints() {
4646
return trackingLocalCheckpoints;
4747
}
4848

49-
public SeqNoPrimaryContext(final ObjectLongMap<String> inSyncLocalCheckpoints, final ObjectLongMap<String> trackingLocalCheckpoints) {
49+
public PrimaryContext(final ObjectLongMap<String> inSyncLocalCheckpoints, final ObjectLongMap<String> trackingLocalCheckpoints) {
5050
this.inSyncLocalCheckpoints = inSyncLocalCheckpoints;
5151
this.trackingLocalCheckpoints = trackingLocalCheckpoints;
5252
}
5353

54-
public SeqNoPrimaryContext(StreamInput in) throws IOException {
54+
public PrimaryContext(final StreamInput in) throws IOException {
5555
inSyncLocalCheckpoints = readMap(in);
5656
trackingLocalCheckpoints = readMap(in);
5757
}

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919

2020
package org.elasticsearch.index.seqno;
2121

22-
import com.carrotsearch.hppc.ObjectLongHashMap;
23-
import com.carrotsearch.hppc.ObjectLongMap;
2422
import org.elasticsearch.index.IndexSettings;
2523
import org.elasticsearch.index.shard.AbstractIndexShardComponent;
2624
import org.elasticsearch.index.shard.ShardId;
@@ -179,10 +177,10 @@ public void updateAllocationIdsFromMaster(final Set<String> activeAllocationIds,
179177
/**
180178
* Updates the known allocation IDs and the local checkpoints for the corresponding allocations from a primary relocation source.
181179
*
182-
* @param seqNoPrimaryContext the sequence number context
180+
* @param primaryContext the sequence number context
183181
*/
184-
public void updateAllocationIdsFromPrimaryContext(final SeqNoPrimaryContext seqNoPrimaryContext) {
185-
globalCheckpointTracker.updateAllocationIdsFromPrimaryContext(seqNoPrimaryContext);
182+
public void updateAllocationIdsFromPrimaryContext(final PrimaryContext primaryContext) {
183+
globalCheckpointTracker.updateAllocationIdsFromPrimaryContext(primaryContext);
186184
}
187185

188186
/**
@@ -195,12 +193,12 @@ public boolean pendingInSync() {
195193
}
196194

197195
/**
198-
* Get the sequence number primary context for the shard. This includes the state of the global checkpoint tracker.
196+
* Get the primary context for the shard. This includes the state of the global checkpoint tracker.
199197
*
200-
* @return the sequence number primary context
198+
* @return the primary context
201199
*/
202-
public SeqNoPrimaryContext seqNoPrimaryContext() {
203-
return globalCheckpointTracker.seqNoPrimaryContext();
200+
public PrimaryContext primaryContext() {
201+
return globalCheckpointTracker.primaryContext();
204202
}
205203

206204
}

core/src/main/java/org/elasticsearch/index/shard/IndexShard.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
import org.elasticsearch.common.util.BigArrays;
5858
import org.elasticsearch.common.util.concurrent.AbstractRunnable;
5959
import org.elasticsearch.common.util.concurrent.AsyncIOProcessor;
60-
import org.elasticsearch.common.util.concurrent.CountDown;
6160
import org.elasticsearch.index.Index;
6261
import org.elasticsearch.index.IndexModule;
6362
import org.elasticsearch.index.IndexNotFoundException;
@@ -96,7 +95,7 @@
9695
import org.elasticsearch.index.refresh.RefreshStats;
9796
import org.elasticsearch.index.search.stats.SearchStats;
9897
import org.elasticsearch.index.search.stats.ShardSearchStats;
99-
import org.elasticsearch.index.seqno.SeqNoPrimaryContext;
98+
import org.elasticsearch.index.seqno.PrimaryContext;
10099
import org.elasticsearch.index.seqno.SeqNoStats;
101100
import org.elasticsearch.index.seqno.SequenceNumbersService;
102101
import org.elasticsearch.index.similarity.SimilarityService;
@@ -531,7 +530,7 @@ public PrimaryContext primaryContext() {
531530
verifyPrimary();
532531
assert shardRouting.relocating() : "primary context can only be obtained from a relocating primary but was " + shardRouting;
533532
assert !shardRouting.isRelocationTarget() : "primary context can only be obtained from relocation source but was " + shardRouting;
534-
return new PrimaryContext(getEngine().seqNoService().seqNoPrimaryContext());
533+
return getEngine().seqNoService().primaryContext();
535534
}
536535

537536
public IndexShardState state() {
@@ -1626,14 +1625,14 @@ public void updateAllocationIdsFromMaster(final Set<String> activeAllocationIds,
16261625
/**
16271626
* Updates the known allocation IDs and the local checkpoints for the corresponding allocations from a primary relocation source.
16281627
*
1629-
* @param seqNoPrimaryContext the sequence number context
1628+
* @param primaryContext the sequence number context
16301629
*/
1631-
public void updateAllocationIdsFromPrimaryContext(final SeqNoPrimaryContext seqNoPrimaryContext) {
1630+
public void updateAllocationIdsFromPrimaryContext(final PrimaryContext primaryContext) {
16321631
verifyPrimary();
16331632
assert shardRouting.isRelocationTarget();
16341633
final Engine engine = getEngineOrNull();
16351634
if (engine != null) {
1636-
engine.seqNoService().updateAllocationIdsFromPrimaryContext(seqNoPrimaryContext);
1635+
engine.seqNoService().updateAllocationIdsFromPrimaryContext(primaryContext);
16371636
}
16381637
}
16391638

core/src/main/java/org/elasticsearch/index/shard/PrimaryContext.java

Lines changed: 0 additions & 70 deletions
This file was deleted.

core/src/main/java/org/elasticsearch/indices/recovery/RecoveryHandoffPrimaryContextRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import org.elasticsearch.common.io.stream.StreamInput;
2323
import org.elasticsearch.common.io.stream.StreamOutput;
24-
import org.elasticsearch.index.shard.PrimaryContext;
24+
import org.elasticsearch.index.seqno.PrimaryContext;
2525
import org.elasticsearch.index.shard.ShardId;
2626
import org.elasticsearch.transport.TransportRequest;
2727

core/src/main/java/org/elasticsearch/indices/recovery/RecoveryTarget.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
import org.elasticsearch.common.util.concurrent.ConcurrentCollections;
4242
import org.elasticsearch.index.engine.Engine;
4343
import org.elasticsearch.index.mapper.MapperException;
44+
import org.elasticsearch.index.seqno.PrimaryContext;
4445
import org.elasticsearch.index.shard.IndexShard;
4546
import org.elasticsearch.index.shard.IndexShardNotRecoveringException;
4647
import org.elasticsearch.index.shard.IndexShardState;
47-
import org.elasticsearch.index.shard.PrimaryContext;
4848
import org.elasticsearch.index.shard.ShardId;
4949
import org.elasticsearch.index.store.Store;
5050
import org.elasticsearch.index.store.StoreFileMetaData;
@@ -381,7 +381,7 @@ public void ensureClusterStateVersion(long clusterStateVersion) {
381381

382382
@Override
383383
public void handoffPrimaryContext(final PrimaryContext primaryContext) {
384-
indexShard.updateAllocationIdsFromPrimaryContext(primaryContext.seqNoPrimaryContext());
384+
indexShard.updateAllocationIdsFromPrimaryContext(primaryContext);
385385
}
386386

387387
@Override

core/src/main/java/org/elasticsearch/indices/recovery/RecoveryTargetHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
package org.elasticsearch.indices.recovery;
2020

2121
import org.elasticsearch.common.bytes.BytesReference;
22-
import org.elasticsearch.index.shard.PrimaryContext;
22+
import org.elasticsearch.index.seqno.PrimaryContext;
2323
import org.elasticsearch.index.store.Store;
2424
import org.elasticsearch.index.store.StoreFileMetaData;
2525
import org.elasticsearch.index.translog.Translog;

core/src/main/java/org/elasticsearch/indices/recovery/RemoteRecoveryTargetHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.elasticsearch.ElasticsearchException;
2424
import org.elasticsearch.cluster.node.DiscoveryNode;
2525
import org.elasticsearch.common.bytes.BytesReference;
26-
import org.elasticsearch.index.shard.PrimaryContext;
26+
import org.elasticsearch.index.seqno.PrimaryContext;
2727
import org.elasticsearch.index.shard.ShardId;
2828
import org.elasticsearch.index.store.Store;
2929
import org.elasticsearch.index.store.StoreFileMetaData;

0 commit comments

Comments
 (0)