class InstanceFailureStepDefinitions implements EC2StepFunctions {

    @When("^start (service|process) \"([^\"]*)\" on (\\d+) instance$")
    public InstanceFailureStepDefinitions startProcessOnHealthyInstances(String serviceOrProcessType, String processName, int numHosts) {
        List<EC2InstanceTO> instances = executionStateCache.getInstances();

        if (instances == null || instances.isEmpty()) {
            throw new RuntimeException("No Instances are available");
        }

        executionStateCache.addProcessName(processName);

        if (numHosts > instances.size()) {
            numHosts = instances.size();
        }

        IntStream.range(0, numHosts)
                .parallel()
                .forEach(
                        i ->
                        {
                            String ip = instances.get(i).getPrivateIpAddress();
                            String id = instances.get(i).getInstanceId();
                            logger.info("starting process on: " + id + " @ " + ip);
                            scriptExecutor.executeStartProcess(ip, processName);
                        });
        return this;
    }

    public  InstanceFailureStepDefinitions();

}