class MaxShardsPerNodeSysCheck extends AbstractSysNodeCheck {

    static final int ID = 8;
    private static final String DESCRIPTION = ("The amount of shards on the node reached 90 % of the limit of the cluster setting `cluster.max_shards_per_node`. " +
                                               "Creating new tables or partitions which would push the number of shards beyond 100 % of the limit will be rejected.");

    private static final double PERCENTAGE_MAX_SHARDS_PER_NODE_THRESHOLD = 0.90d;

    private final ClusterService clusterService;

    @Inject
    public MaxShardsPerNodeSysCheck(ClusterService clusterService) {
        super(ID, DESCRIPTION, Severity.MEDIUM);
        this.clusterService = clusterService;
    }

    @Override
    public boolean isValid() {<FILL_FUNCTION_BODY>}

    private static Iterable<ShardRouting> shardsForOpenIndices(ClusterState clusterState) {
        var concreteIndices = Arrays.stream(clusterState.metadata().getConcreteAllOpenIndices())
            .filter(index -> !IndexParts.isDangling(index))
            .toArray(String[]::new);
        return clusterState.routingTable().allShards(concreteIndices);
    }
}

        var maxShardLimitPerNode = clusterService.getClusterSettings().get(SETTING_CLUSTER_MAX_SHARDS_PER_NODE).doubleValue();
        var cs = clusterService.state();
        var localNodeId = cs.nodes().getLocalNodeId();
        var numberOfShardsOnLocalNode = 0d;
        for (var shardRouting : shardsForOpenIndices(cs)) {
            if (localNodeId.equals(shardRouting.currentNodeId())) {
                numberOfShardsOnLocalNode++;
            }
        }
        return numberOfShardsOnLocalNode / maxShardLimitPerNode < PERCENTAGE_MAX_SHARDS_PER_NODE_THRESHOLD;
    
<methods>public boolean acknowledged() ,public void acknowledged(boolean) ,public java.lang.String nodeId() ,public java.lang.String rowId() ,public void setNodeId(java.lang.String) <variables>private static final java.lang.String LINK_PATTERN,private static final Function<List<java.lang.String>,java.lang.String> PK_FUNC,private boolean acknowledged,private java.lang.String nodeId,private java.lang.String rowId