class InstanceFailureStepDefinitions implements EC2StepFunctions {

    @When("^CPU spike on (\\d+) instances for (\\d+) cores$")
    public InstanceFailureStepDefinitions spikeCPUOnHealthyInstances(int numHosts, int cores) {
        List<EC2InstanceTO> instances = executionStateCache.getInstances();
        if (instances == null || instances.isEmpty()) {
            throw new RuntimeException("No Instances are available");
        }

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

        IntStream.range(0, numHosts)
                .parallel()
                .forEach(
                        i ->
                        {
                            spikeCPUHelper(cores, instances.get(i).getInstanceId(), instances.get(i).getPrivateIpAddress());
                            executionStateCache.addUnHealthyInstance(instances.get(i));
                            executionStateCache.setCpuSpiked(true);
                        });

        return this;
    }

    public  InstanceFailureStepDefinitions();

}