During the development and review process of the disk health indicator we noticed that it was hard to understand. Since we learnt a lot from the first round of development we want to go through the code one more time and restructure it.
server/src/main/java/org/elasticsearch/cluster/routing/RoutingNode.java
void add(ShardRouting shard) {
        addInternal(shard, true);
    }
    void addWithoutValidation(ShardRouting shard) {
        addInternal(shard, false);
    }
    private void addInternal(ShardRouting shard, boolean validate) {
        final ShardRouting existing = shards.putIfAbsent(shard.shardId(), shard);
        if (existing != null) {
            final IllegalStateException e = new IllegalStateException(
                "Trying to add a shard "
                    + shard.shardId()
                    + " to a node ["
                    + nodeId
                    + "] where it already exists. current ["
                    + shards.get(shard.shardId())
                    + "]. new ["
                    + shard
                    + "]"
            );
            assert false : e;
            throw e;
        }
        if (shard.initializing()) {
            initializingShards.add(shard);
        } else if (shard.relocating()) {
            relocatingShards.add(shard);
        } else if (shard.started()) {
            startedShards.add(shard);
        }