class InstanceFailureStepDefinitions implements EC2StepFunctions {

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

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

        IntStream.range(0, numInstances)
                .parallel()
                .forEach(
                        i ->
                        {
                            blockPortHelper(portNum, instances.get(i).getInstanceId(), instances.get(i).getPrivateIpAddress());
                            executionStateCache.setBlockPort(true);
                            executionStateCache.addPortNum(portNum);
                            executionStateCache.addUnHealthyInstance(instances.get(i));
                        });

        return this;
    }

    public  InstanceFailureStepDefinitions();

}