39
39
import java .util .ArrayList ;
40
40
import java .util .Collection ;
41
41
import java .util .Collections ;
42
- import java .util .HashMap ;
42
+ import java .util .LinkedHashMap ;
43
43
import java .util .List ;
44
44
import java .util .Map ;
45
45
import java .util .concurrent .CountDownLatch ;
@@ -89,7 +89,7 @@ public void testRetentionLeasesSyncedOnAdd() throws Exception {
89
89
.getShardOrNull (new ShardId (resolveIndex ("index" ), 0 ));
90
90
// we will add multiple retention leases and expect to see them synced to all replicas
91
91
final int length = randomIntBetween (1 , 8 );
92
- final Map <String , RetentionLease > currentRetentionLeases = new HashMap <>();
92
+ final Map <String , RetentionLease > currentRetentionLeases = new LinkedHashMap <>();
93
93
for (int i = 0 ; i < length ; i ++) {
94
94
final String id = randomValueOtherThanMany (currentRetentionLeases .keySet ()::contains , () -> randomAlphaOfLength (8 ));
95
95
final long retainingSequenceNumber = randomLongBetween (0 , Long .MAX_VALUE );
@@ -136,7 +136,7 @@ public void testRetentionLeaseSyncedOnRemove() throws Exception {
136
136
.getInstance (IndicesService .class , primaryShardNodeName )
137
137
.getShardOrNull (new ShardId (resolveIndex ("index" ), 0 ));
138
138
final int length = randomIntBetween (1 , 8 );
139
- final Map <String , RetentionLease > currentRetentionLeases = new HashMap <>();
139
+ final Map <String , RetentionLease > currentRetentionLeases = new LinkedHashMap <>();
140
140
for (int i = 0 ; i < length ; i ++) {
141
141
final String id = randomValueOtherThanMany (currentRetentionLeases .keySet ()::contains , () -> randomAlphaOfLength (8 ));
142
142
final long retainingSequenceNumber = randomLongBetween (0 , Long .MAX_VALUE );
@@ -277,7 +277,7 @@ public void testBackgroundRetentionLeaseSync() throws Exception {
277
277
.getShardOrNull (new ShardId (resolveIndex ("index" ), 0 ));
278
278
// we will add multiple retention leases and expect to see them synced to all replicas
279
279
final int length = randomIntBetween (1 , 8 );
280
- final Map <String , RetentionLease > currentRetentionLeases = new HashMap <>(length );
280
+ final Map <String , RetentionLease > currentRetentionLeases = new LinkedHashMap <>(length );
281
281
final List <String > ids = new ArrayList <>(length );
282
282
for (int i = 0 ; i < length ; i ++) {
283
283
final String id = randomValueOtherThanMany (currentRetentionLeases .keySet ()::contains , () -> randomAlphaOfLength (8 ));
@@ -318,15 +318,15 @@ public void testRetentionLeasesSyncOnRecovery() throws Exception {
318
318
internalCluster ().ensureAtLeastNumDataNodes (1 + numberOfReplicas );
319
319
/*
320
320
* We effectively disable the background sync to ensure that the retention leases are not synced in the background so that the only
321
- * source of retention leases on the replicas would be from the commit point and recovery.
321
+ * source of retention leases on the replicas would be from recovery.
322
322
*/
323
- final Settings settings = Settings .builder ()
323
+ final Settings . Builder settings = Settings .builder ()
324
324
.put ("index.number_of_shards" , 1 )
325
325
.put ("index.number_of_replicas" , 0 )
326
- .put (IndexService . RETENTION_LEASE_SYNC_INTERVAL_SETTING .getKey (), TimeValue . timeValueHours ( 24 ) )
327
- .build ( );
326
+ .put (IndexSettings . INDEX_SOFT_DELETES_SETTING .getKey (), true )
327
+ .put ( IndexService . RETENTION_LEASE_SYNC_INTERVAL_SETTING . getKey (), TimeValue . timeValueHours ( 24 ) );
328
328
// when we increase the number of replicas below we want to exclude the replicas from being allocated so that they do not recover
329
- assertAcked (prepareCreate ("index" , 1 ). setSettings ( settings ));
329
+ assertAcked (prepareCreate ("index" , 1 , settings ));
330
330
ensureYellow ("index" );
331
331
final AcknowledgedResponse response = client ().admin ()
332
332
.indices ()
@@ -339,7 +339,7 @@ public void testRetentionLeasesSyncOnRecovery() throws Exception {
339
339
.getInstance (IndicesService .class , primaryShardNodeName )
340
340
.getShardOrNull (new ShardId (resolveIndex ("index" ), 0 ));
341
341
final int length = randomIntBetween (1 , 8 );
342
- final Map <String , RetentionLease > currentRetentionLeases = new HashMap <>();
342
+ final Map <String , RetentionLease > currentRetentionLeases = new LinkedHashMap <>();
343
343
for (int i = 0 ; i < length ; i ++) {
344
344
final String id = randomValueOtherThanMany (currentRetentionLeases .keySet ()::contains , () -> randomAlphaOfLength (8 ));
345
345
final long retainingSequenceNumber = randomLongBetween (0 , Long .MAX_VALUE );
@@ -348,10 +348,6 @@ public void testRetentionLeasesSyncOnRecovery() throws Exception {
348
348
final ActionListener <ReplicationResponse > listener = ActionListener .wrap (r -> latch .countDown (), e -> fail (e .toString ()));
349
349
currentRetentionLeases .put (id , primary .addRetentionLease (id , retainingSequenceNumber , source , listener ));
350
350
latch .await ();
351
- /*
352
- * Now renew the leases; since we do not flush immediately on renewal, this means that the latest retention leases will not be
353
- * in the latest commit point and therefore not transferred during the file-copy phase of recovery.
354
- */
355
351
currentRetentionLeases .put (id , primary .renewRetentionLease (id , retainingSequenceNumber , source ));
356
352
}
357
353
0 commit comments