Awareness Allocation logic

I am reading the source code of AwarenessAllocationDecider.java, and try to understand the following piece of code (https://github.com/elastic/elasticsearch/blob/aef461b5b30b6b9ee248e8a5a2e2bb5ab39f6981/server/src/main/java/org/elasticsearch/cluster/routing/allocation/decider/AwarenessAllocationDecider.java#L185)

final int currentNodeCount = shardPerAttribute.get(node.node().getAttributes().get(awarenessAttribute));
final int maximumNodeCount = (shardCount + numberOfAttributes - 1) / numberOfAttributes; // ceil(shardCount/numberOfAttributes)
if (currentNodeCount > maximumNodeCount) {
            return allocation.decision(Decision.NO, NAME,
                    "there are too many copies of the shard allocated to nodes with attribute [%s], there are [%d] total configured " +
                    "shard copies for this shard id and [%d] total attribute values, expected the allocated shard count per " +
                    "attribute [%d] to be less than or equal to the upper bound of the required number of shards per attribute [%d]",
                    awarenessAttribute,
                    shardCount,
                    numberOfAttributes,
                    currentNodeCount,
                    maximumNodeCount);
        }

What is the consideration / purpose to have this check? Does it enforce shards to be almost-evenly stored on each attribute? What happens to unbalanced ES cluster?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.