Search in sources :

Example 1 with SafeCommitInfo

use of org.opensearch.index.engine.SafeCommitInfo in project OpenSearch by opensearch-project.

the class PeerRecoveryRetentionLeaseExpiryTests method setUpReplicationTracker.

@Before
public void setUpReplicationTracker() throws InterruptedException {
    final AllocationId primaryAllocationId = AllocationId.newInitializing();
    currentTimeMillis = new AtomicLong(randomLongBetween(0, 1024));
    if (randomBoolean()) {
        settings = Settings.builder().put(IndexSettings.INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING.getKey(), TimeValue.timeValueMillis(randomLongBetween(1, TimeValue.timeValueHours(12).millis()))).build();
    } else {
        settings = Settings.EMPTY;
    }
    // must be set in each test
    safeCommitInfo = null;
    final long primaryTerm = randomLongBetween(1, Long.MAX_VALUE);
    replicationTracker = new ReplicationTracker(new ShardId("test", "_na", 0), primaryAllocationId.getId(), IndexSettingsModule.newIndexSettings("test", settings), primaryTerm, UNASSIGNED_SEQ_NO, value -> {
    }, currentTimeMillis::get, (leases, listener) -> {
    }, () -> safeCommitInfo);
    replicationTracker.updateFromMaster(1L, Collections.singleton(primaryAllocationId.getId()), routingTable(Collections.emptySet(), primaryAllocationId));
    replicationTracker.activatePrimaryMode(SequenceNumbers.NO_OPS_PERFORMED);
    final AllocationId replicaAllocationId = AllocationId.newInitializing();
    final IndexShardRoutingTable routingTableWithReplica = routingTable(Collections.singleton(replicaAllocationId), primaryAllocationId);
    replicationTracker.updateFromMaster(2L, Collections.singleton(primaryAllocationId.getId()), routingTableWithReplica);
    replicationTracker.addPeerRecoveryRetentionLease(routingTableWithReplica.getByAllocationId(replicaAllocationId.getId()).currentNodeId(), randomCheckpoint(), EMPTY_LISTENER);
    replicationTracker.initiateTracking(replicaAllocationId.getId());
    replicationTracker.markAllocationIdAsInSync(replicaAllocationId.getId(), randomCheckpoint());
}
Also used : ShardId(org.opensearch.index.shard.ShardId) IndexShardRoutingTable(org.opensearch.cluster.routing.IndexShardRoutingTable) TimeValue(org.opensearch.common.unit.TimeValue) NO_OPS_PERFORMED(org.opensearch.index.seqno.SequenceNumbers.NO_OPS_PERFORMED) AllocationId(org.opensearch.cluster.routing.AllocationId) Set(java.util.Set) Settings(org.opensearch.common.settings.Settings) Collectors(java.util.stream.Collectors) Tuple(org.opensearch.common.collect.Tuple) ShardRouting(org.opensearch.cluster.routing.ShardRouting) ShardId(org.opensearch.index.shard.ShardId) AtomicLong(java.util.concurrent.atomic.AtomicLong) UNASSIGNED_SEQ_NO(org.opensearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO) Stream(java.util.stream.Stream) Matchers.equalTo(org.hamcrest.Matchers.equalTo) IndexSettings(org.opensearch.index.IndexSettings) ReplicationResponse(org.opensearch.action.support.replication.ReplicationResponse) Matchers.hasSize(org.hamcrest.Matchers.hasSize) ActionListener(org.opensearch.action.ActionListener) SafeCommitInfo(org.opensearch.index.engine.SafeCommitInfo) Collections(java.util.Collections) IndexSettingsModule(org.opensearch.test.IndexSettingsModule) Before(org.junit.Before) IndexShardRoutingTable(org.opensearch.cluster.routing.IndexShardRoutingTable) AtomicLong(java.util.concurrent.atomic.AtomicLong) AllocationId(org.opensearch.cluster.routing.AllocationId) Before(org.junit.Before)

Aggregations

Collections (java.util.Collections)1 Set (java.util.Set)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 Matchers.equalTo (org.hamcrest.Matchers.equalTo)1 Matchers.hasSize (org.hamcrest.Matchers.hasSize)1 Before (org.junit.Before)1 ActionListener (org.opensearch.action.ActionListener)1 ReplicationResponse (org.opensearch.action.support.replication.ReplicationResponse)1 AllocationId (org.opensearch.cluster.routing.AllocationId)1 IndexShardRoutingTable (org.opensearch.cluster.routing.IndexShardRoutingTable)1 ShardRouting (org.opensearch.cluster.routing.ShardRouting)1 Tuple (org.opensearch.common.collect.Tuple)1 Settings (org.opensearch.common.settings.Settings)1 TimeValue (org.opensearch.common.unit.TimeValue)1 IndexSettings (org.opensearch.index.IndexSettings)1 SafeCommitInfo (org.opensearch.index.engine.SafeCommitInfo)1 NO_OPS_PERFORMED (org.opensearch.index.seqno.SequenceNumbers.NO_OPS_PERFORMED)1 UNASSIGNED_SEQ_NO (org.opensearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO)1