@@ -92,10 +92,10 @@ public void testRerouteOccursOnDiskPassingHighWatermark() throws Exception {
92
92
clusterInfoService .onMaster ();
93
93
94
94
// prevent any effects from in-flight recoveries, since we are only simulating a 100-byte disk
95
- clusterInfoService .shardSizeFunction = shardRouting -> 0L ;
95
+ clusterInfoService .setShardSizeFunctionAndRefresh ( shardRouting -> 0L ) ;
96
96
97
97
// start with all nodes below the watermark
98
- clusterInfoService .diskUsageFunction = ( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 , between (10 , 100 ));
98
+ clusterInfoService .setDiskUsageFunctionAndRefresh (( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 , between (10 , 100 ) ));
99
99
100
100
final boolean watermarkBytes = randomBoolean (); // we have to consistently use bytes or percentage for the disk watermark settings
101
101
assertAcked (client ().admin ().cluster ().prepareUpdateSettings ().setTransientSettings (Settings .builder ()
@@ -115,8 +115,8 @@ public void testRerouteOccursOnDiskPassingHighWatermark() throws Exception {
115
115
});
116
116
117
117
// move node2 above high watermark
118
- clusterInfoService .diskUsageFunction = (discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 ,
119
- discoveryNode .getId ().equals (nodeIds .get (2 )) ? between (0 , 9 ) : between (10 , 100 ));
118
+ clusterInfoService .setDiskUsageFunctionAndRefresh ( (discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 ,
119
+ discoveryNode .getId ().equals (nodeIds .get (2 )) ? between (0 , 9 ) : between (10 , 100 ))) ;
120
120
121
121
logger .info ("--> waiting for shards to relocate off node [{}]" , nodeIds .get (2 ));
122
122
@@ -128,7 +128,7 @@ public void testRerouteOccursOnDiskPassingHighWatermark() throws Exception {
128
128
});
129
129
130
130
// move all nodes below watermark again
131
- clusterInfoService .diskUsageFunction = ( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 , between (10 , 100 ));
131
+ clusterInfoService .setDiskUsageFunctionAndRefresh (( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 , between (10 , 100 ) ));
132
132
133
133
logger .info ("--> waiting for shards to rebalance back onto node [{}]" , nodeIds .get (2 ));
134
134
@@ -154,10 +154,10 @@ public void testAutomaticReleaseOfIndexBlock() throws Exception {
154
154
clusterInfoService .onMaster ();
155
155
156
156
// prevent any effects from in-flight recoveries, since we are only simulating a 100-byte disk
157
- clusterInfoService .shardSizeFunction = shardRouting -> 0L ;
157
+ clusterInfoService .setShardSizeFunctionAndRefresh ( shardRouting -> 0L ) ;
158
158
159
159
// start with all nodes below the low watermark
160
- clusterInfoService .diskUsageFunction = ( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 , between (15 , 100 ));
160
+ clusterInfoService .setDiskUsageFunctionAndRefresh (( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 , between (15 , 100 ) ));
161
161
162
162
final boolean watermarkBytes = randomBoolean (); // we have to consistently use bytes or percentage for the disk watermark settings
163
163
assertAcked (client ().admin ().cluster ().prepareUpdateSettings ().setTransientSettings (Settings .builder ()
@@ -184,8 +184,8 @@ public void testAutomaticReleaseOfIndexBlock() throws Exception {
184
184
185
185
// Move all nodes above the low watermark so no shard movement can occur, and at least one node above the flood stage watermark so
186
186
// the index is blocked
187
- clusterInfoService .diskUsageFunction = (discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 ,
188
- discoveryNode .getId ().equals (nodeIds .get (2 )) ? between (0 , 4 ) : between (0 , 9 ));
187
+ clusterInfoService .setDiskUsageFunctionAndRefresh ( (discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 ,
188
+ discoveryNode .getId ().equals (nodeIds .get (2 )) ? between (0 , 4 ) : between (0 , 9 ))) ;
189
189
190
190
assertBusy (() -> assertBlocked (
191
191
client ().prepareIndex ().setIndex ("test" ).setType ("doc" ).setId ("1" ).setSource ("foo" , "bar" ),
@@ -201,7 +201,7 @@ public void testAutomaticReleaseOfIndexBlock() throws Exception {
201
201
logger .info ("--> index is confirmed read-only, releasing disk space" );
202
202
203
203
// Move all nodes below the high watermark so that the index is unblocked
204
- clusterInfoService .diskUsageFunction = ( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 , between (10 , 100 ));
204
+ clusterInfoService .setDiskUsageFunctionAndRefresh (( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 , between (10 , 100 ) ));
205
205
206
206
// Attempt to create a new document until DiskUsageMonitor unblocks the index
207
207
assertBusy (() -> {
@@ -230,10 +230,10 @@ public void testOnlyMovesEnoughShardsToDropBelowHighWatermark() throws Exception
230
230
});
231
231
232
232
// shards are 1 byte large
233
- clusterInfoService .shardSizeFunction = shardRouting -> 1L ;
233
+ clusterInfoService .setShardSizeFunctionAndRefresh ( shardRouting -> 1L ) ;
234
234
235
235
// start with all nodes below the watermark
236
- clusterInfoService .diskUsageFunction = ( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 1000L , 1000L );
236
+ clusterInfoService .setDiskUsageFunctionAndRefresh (( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 1000L , 1000L ) );
237
237
238
238
assertAcked (client ().admin ().cluster ().prepareUpdateSettings ().setTransientSettings (Settings .builder ()
239
239
.put (CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING .getKey (), "90%" )
@@ -260,10 +260,10 @@ public void testOnlyMovesEnoughShardsToDropBelowHighWatermark() throws Exception
260
260
.put (CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING .getKey (), EnableAllocationDecider .Rebalance .NONE )));
261
261
262
262
// node2 suddenly has 99 bytes free, less than 10%, but moving one shard is enough to bring it up to 100 bytes free:
263
- clusterInfoService .diskUsageFunction = (discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 1000L ,
263
+ clusterInfoService .setDiskUsageFunctionAndRefresh ( (discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 1000L ,
264
264
discoveryNode .getId ().equals (nodeIds .get (2 ))
265
265
? 101L - masterAppliedClusterState .get ().getRoutingNodes ().node (nodeIds .get (2 )).numberOfOwningShards ()
266
- : 1000L );
266
+ : 1000L )) ;
267
267
268
268
clusterInfoService .refresh ();
269
269
@@ -302,13 +302,13 @@ public void testDoesNotExceedLowWatermarkWhenRebalancing() throws Exception {
302
302
.put (CLUSTER_ROUTING_ALLOCATION_DISK_FLOOD_STAGE_WATERMARK_SETTING .getKey (), "100%" )));
303
303
304
304
// shards are 1 byte large
305
- clusterInfoService .shardSizeFunction = shardRouting -> 1L ;
305
+ clusterInfoService .setShardSizeFunctionAndRefresh ( shardRouting -> 1L ) ;
306
306
307
307
// node 2 only has space for one shard
308
- clusterInfoService .diskUsageFunction = (discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 1000L ,
308
+ clusterInfoService .setDiskUsageFunctionAndRefresh ( (discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 1000L ,
309
309
discoveryNode .getId ().equals (nodeIds .get (2 ))
310
310
? 150L - masterAppliedClusterState .get ().getRoutingNodes ().node (nodeIds .get (2 )).numberOfOwningShards ()
311
- : 1000L );
311
+ : 1000L )) ;
312
312
313
313
assertAcked (prepareCreate ("test" ).setSettings (Settings .builder ()
314
314
.put ("number_of_shards" , 6 )
@@ -352,10 +352,10 @@ public void testMovesShardsOffSpecificDataPathAboveWatermark() throws Exception
352
352
final MockInternalClusterInfoService clusterInfoService = getMockInternalClusterInfoService ();
353
353
354
354
// prevent any effects from in-flight recoveries, since we are only simulating a 100-byte disk
355
- clusterInfoService .shardSizeFunction = shardRouting -> 0L ;
355
+ clusterInfoService .setShardSizeFunctionAndRefresh ( shardRouting -> 0L ) ;
356
356
357
357
// start with all paths below the watermark
358
- clusterInfoService .diskUsageFunction = ( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 , between (10 , 100 ));
358
+ clusterInfoService .setDiskUsageFunctionAndRefresh (( discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100 , between (10 , 100 ) ));
359
359
360
360
assertAcked (client ().admin ().cluster ().prepareUpdateSettings ().setTransientSettings (Settings .builder ()
361
361
.put (CLUSTER_ROUTING_ALLOCATION_LOW_DISK_WATERMARK_SETTING .getKey (), "90%" )
@@ -381,15 +381,13 @@ public void testMovesShardsOffSpecificDataPathAboveWatermark() throws Exception
381
381
&& shardStats .getDataPath ().startsWith (pathOverWatermark .toString ()) == false ).count ();
382
382
logger .info ("--> shards on good path: [{}]" , shardsOnGoodPath );
383
383
384
- // one of the paths on node0 suddenly exceeds the high watermark
385
- clusterInfoService .diskUsageFunction = (discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100L ,
386
- fsInfoPath .getPath ().startsWith (pathOverWatermark .toString ()) ? between (0 , 9 ) : between (10 , 100 ));
387
-
388
384
// disable rebalancing, or else we might move shards back onto the over-full path since we're not faking that
389
385
assertAcked (client ().admin ().cluster ().prepareUpdateSettings ().setTransientSettings (Settings .builder ()
390
386
.put (CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING .getKey (), EnableAllocationDecider .Rebalance .NONE )));
391
387
392
- clusterInfoService .refresh ();
388
+ // one of the paths on node0 suddenly exceeds the high watermark
389
+ clusterInfoService .setDiskUsageFunctionAndRefresh ((discoveryNode , fsInfoPath ) -> setDiskUsage (fsInfoPath , 100L ,
390
+ fsInfoPath .getPath ().startsWith (pathOverWatermark .toString ()) ? between (0 , 9 ) : between (10 , 100 )));
393
391
394
392
logger .info ("--> waiting for shards to relocate off path [{}]" , pathOverWatermark );
395
393
0 commit comments