Class ComputeRequirementHelper

java.lang.Object
co.yellowdog.platform.clients.compute.ComputeRequirementHelper

public class ComputeRequirementHelper extends Object
Helper class to make it easier to write consumers of the ComputeClient.

This class provides a number of methods that return a Future allowing consumers to simply wait for the required state of a compute requirement before continuing on. For example:

// build the compute requirement
ComputeRequirement requirement = ComputeRequirement.builder()
        {... configure requirement ...}
        .build();

// submit the requirement to YellowDog Compute and replace it with the returned instance
requirement = client.computeClient().submitComputeRequirement(requirement);

// create an instance of the helper class for this specific requirement
ComputeRequirementHelper helper = client.computeClient().getComputeRequirementHelper(requirement);

// wait for the requirement status to change to RUNNING, i.e. all provisioned instances are now running
requirement = helper.whenRequirementStatusIs(ComputeRequirementStatus.RUNNING).get();

{... continue actions now that all instances are running ...}
  • Method Details

    • whenRequirementMatches

      public Future<ComputeRequirement> whenRequirementMatches(@NonNull @NonNull Predicate<ComputeRequirement> predicate)
      Returns a Future that is completed when the specified predicate evaluates to true.
      Parameters:
      predicate - The predicate to test for each compute requirement changed event received
      Returns:
      A Future containing the matching compute requirement
    • whenRequirementStatusIs

      public Future<ComputeRequirement> whenRequirementStatusIs(@NonNull @NonNull ComputeRequirementStatus status)
      Returns a Future that is completed when the compute requirement status matches the specified status.
      Parameters:
      status - the compute requirement status to wait for
      Returns:
      A Future containing the matching compute requirement