class RecoveryAfterNodesSysCheck extends AbstractSysNodeCheck {

    private final ClusterService clusterService;
    private final Settings settings;

    static final int ID = 2;
    private static final String DESCRIPTION = "The cluster setting 'gateway.recover_after_data_nodes' " +
                                              "(or the deprecated `gateway.recovery_after_nodes` setting) " +
                                              "is not configured or it is set to a value that seems low in " +
                                              "relation to the the maximum/expected number of (data) nodes " +
                                              "in the cluster.";

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

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

    private static boolean validate(int afterNodes, int expectedNodes, int actualNodes) {
        return actualNodes == 1
               || (expectedNodes / 2) < afterNodes && afterNodes <= expectedNodes;
    }

}

        int actualNodes = clusterService.state().nodes().getDataNodes().size();
        int afterNodes = GatewayService.RECOVER_AFTER_DATA_NODES_SETTING.get(settings);
        int expectedNodes = GatewayService.EXPECTED_DATA_NODES_SETTING.get(settings);
        if (afterNodes == -1 || expectedNodes == -1) {
            // fallback to deprecated settings for BWC
            actualNodes = clusterService.state().nodes().getSize();
            afterNodes = GatewayService.RECOVER_AFTER_NODES_SETTING.get(settings);
            expectedNodes = GatewayService.EXPECTED_NODES_SETTING.get(settings);
        }

        return validate(afterNodes, expectedNodes, actualNodes);
    
<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