Search in sources :

Example 1 with SafeCommitInfo

use of org.elasticsearch.index.engine.SafeCommitInfo in project crate by crate.

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_SETTING.getKey(), true).put(IndexSettings.INDEX_SOFT_DELETES_RETENTION_LEASE_PERIOD_SETTING.getKey(), TimeValue.timeValueMillis(randomLongBetween(1, TimeValue.timeValueHours(12).millis())).getStringRep()).build();
    } else {
        settings = Settings.builder().put(IndexSettings.INDEX_SOFT_DELETES_SETTING.getKey(), true).build();
    }
    // 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.elasticsearch.index.shard.ShardId) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting) ShardId(org.elasticsearch.index.shard.ShardId) SafeCommitInfo(org.elasticsearch.index.engine.SafeCommitInfo) Tuple(io.crate.common.collections.Tuple) IndexSettingsModule(org.elasticsearch.test.IndexSettingsModule) UNASSIGNED_SEQ_NO(org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO) Set(java.util.Set) IndexShardRoutingTable(org.elasticsearch.cluster.routing.IndexShardRoutingTable) Test(org.junit.Test) Collectors(java.util.stream.Collectors) AtomicLong(java.util.concurrent.atomic.AtomicLong) ReplicationResponse(org.elasticsearch.action.support.replication.ReplicationResponse) Stream(java.util.stream.Stream) Settings(org.elasticsearch.common.settings.Settings) Matchers.equalTo(org.hamcrest.Matchers.equalTo) IndexSettings(org.elasticsearch.index.IndexSettings) TimeValue(io.crate.common.unit.TimeValue) Matchers.hasSize(org.hamcrest.Matchers.hasSize) AllocationId(org.elasticsearch.cluster.routing.AllocationId) Collections(java.util.Collections) ActionListener(org.elasticsearch.action.ActionListener) Before(org.junit.Before) IndexShardRoutingTable(org.elasticsearch.cluster.routing.IndexShardRoutingTable) AtomicLong(java.util.concurrent.atomic.AtomicLong) AllocationId(org.elasticsearch.cluster.routing.AllocationId) Before(org.junit.Before)

Aggregations

Tuple (io.crate.common.collections.Tuple)1 TimeValue (io.crate.common.unit.TimeValue)1 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 ActionListener (org.elasticsearch.action.ActionListener)1 ReplicationResponse (org.elasticsearch.action.support.replication.ReplicationResponse)1 AllocationId (org.elasticsearch.cluster.routing.AllocationId)1 IndexShardRoutingTable (org.elasticsearch.cluster.routing.IndexShardRoutingTable)1 ShardRouting (org.elasticsearch.cluster.routing.ShardRouting)1 Settings (org.elasticsearch.common.settings.Settings)1 IndexSettings (org.elasticsearch.index.IndexSettings)1 SafeCommitInfo (org.elasticsearch.index.engine.SafeCommitInfo)1 UNASSIGNED_SEQ_NO (org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO)1 ShardId (org.elasticsearch.index.shard.ShardId)1 IndexSettingsModule (org.elasticsearch.test.IndexSettingsModule)1 Matchers.equalTo (org.hamcrest.Matchers.equalTo)1 Matchers.hasSize (org.hamcrest.Matchers.hasSize)1