class InstanceFailureStepDefinitions implements EC2StepFunctions {

    @When("^block DynamoDB on (\\d+) instances$")
    public InstanceFailureStepDefinitions blockDynamoDb(int numInstances) {
        List<EC2InstanceTO> instances = executionStateCache.getInstances();
        if (instances == null || instances.isEmpty()) {
            throw new RuntimeException("No Instances are vailable");
        }

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

        IntStream.range(0, numInstances)
                .parallel()
                .forEach(
                        i ->
                        {
                            EC2InstanceTO ec2SInstance = ec2Raider.getEC2InstanceById(instances.get(i).getInstanceId());
                            String ip = ec2SInstance.getPrivateIpAddress();
                            scriptExecutor.executeBlockDynamoDB(ip);
                            executionStateCache.setBlockDynamoDB(true);
                            executionStateCache.addUnHealthyInstance(ec2SInstance);
                        });

        return this;
    }

    public  InstanceFailureStepDefinitions();

}