Fix failing internal cluster tests.

Signed-off-by: Rabi Panda <adnapibar@gmail.com>
This commit is contained in:
Rabi Panda 2021-10-05 20:18:02 -07:00
parent d7f2b09bae
commit 34ab4defbe
2 changed files with 8 additions and 1 deletions

View File

@ -204,6 +204,13 @@ public class ClusterApplierService extends AbstractLifecycleComponent implements
return clusterState;
}
/**
* Returns true if the appliedClusterState is not null
*/
public boolean isInitialClusterStateSet() {
return Objects.nonNull(this.state.get());
}
/**
* Adds a high priority applier of updated cluster states.
*/

View File

@ -80,7 +80,7 @@ public final class ShardIndexingPressureSettings {
public static boolean isShardIndexingPressureAttributeEnabled() {
// Null check is required only for bwc tests which start node without initializing cluster service.
// In actual run time, clusterService will never be null.
if (Objects.nonNull(clusterService)) {
if (Objects.nonNull(clusterService) && clusterService.getClusterApplierService().isInitialClusterStateSet()) {
Iterator<DiscoveryNode> nodes = clusterService.state().getNodes().getNodes().valuesIt();
while (nodes.hasNext()) {
if (Boolean.parseBoolean(nodes.next().getAttributes().get(SHARD_INDEXING_PRESSURE_ENABLED_ATTRIBUTE_KEY)) == false) {