@Override public String apply(Machine machine) { return new ToShortMachineFormat().apply(machine).toString(); } }
@Override public boolean test(Machine machine) { return machine.getMembershipStatus().isEvictable(); } }
/** * Creates a {@link MembershipStatus} that marks a machine as being * non-functional (i.e. inactive) and in need of service. The * {@link Machine} should be replaced and should not be terminated (it is * kept alive for troubleshooting). * * @return */ public static MembershipStatus awaitingService() { return new MembershipStatus(false, false); }
@Override public boolean test(Machine machine) { return isAllocated().test(machine) && machine.getMembershipStatus().isActive(); } }
/** * Returns all <i>started</i> {@link Machine}s in the pool. See * {@link Machine#isStarted()}. * * @return */ public List<Machine> getStartedMachines() { return getMachines().stream().filter(Machine.isStarted()).collect(Collectors.toList()); }
@Override public boolean test(Machine machine) { return machine.getMachineState() == this.state; } }
/** * A {@link Predicate} that returns <code>true</code> when passed a * {@link Machine} that has been started by the underlying infrastructure * (machine state is {@link MachineState#PENDING} or * {@link MachineState#RUNNING}). * * @see MachineState */ public static Predicate<Machine> isStarted() { return new StartedMachinePredicate(); }
/** * Factory method for the {@link ToShortMachineFormat} {@link Function}. * * @return */ public static Function<Machine, Machine> toShortFormat() { return new ToShortMachineFormat(); }
/** * Returns a {@link Predicate} that returns <code>true</code> when passed a * {@link Machine} in a given {@link MachineState}. * * @param state * The {@link MachineState} for which this {@link Predicate} will * return <code>true</code>. * @return */ public static Predicate<? super Machine> inState(MachineState state) { return new MachineWithState(state); }
/** * Returns a {@link Predicate} that returns <code>true</code> when passed a * {@link Machine} that is an active pool member -- it has been allocated * from the underlying infrastructure ({@link MachineState#REQUESTED}, * {@link MachineState#PENDING} or {@link MachineState#RUNNING}) and is an * active pool member ({@link MembershipStatus#isActive()}). * * @return */ public static Predicate<Machine> isActiveMember() { return new ActiveMemberPredicate(); }
/** * Factory method for the {@link ToShortMachineString} {@link Function}. * * @return */ public static Function<Machine, String> toShortString() { return new ToShortMachineString(); }
/** * Creates a {@link Builder} object for generating {@link Machine} * instances. * * @return */ public static Builder builder() { return new Builder(); }
/** * Returns a {@link Predicate} that returns <code>true</code> when passed a * {@link Machine} that has been allocated from the underlying * infrastructure (machine state {@link MachineState#REQUESTED}, * {@link MachineState#PENDING} or {@link MachineState#RUNNING}). * * @return */ public static Predicate<Machine> isAllocated() { return new AllocatedMachinePredicate(); }
/** * Returns a {@link Predicate} that returns <code>true</code> for any * {@link Machine} with an evictable {@link MembershipStatus}. * * @return */ public static Predicate<Machine> isEvictable() { return new EvictableMemberPredicate(); }
@Override public Machine apply(Machine machine) { return machine.withMetadata(null); } }
/** * Creates a copy of this {@link Machine} with a different value for the * metadata field. * * @param metadata * Metadata to set for the {@link Machine} copy, or * <code>null</code> if no metadata is desired. * @return A copy */ public Machine withMetadata(JsonObject metadata) { return new Machine(this.id, this.machineState, this.membershipStatus, this.serviceState, this.cloudProvider, this.region, this.machineSize, this.requestTime, this.launchTime, this.publicIps, this.privateIps, metadata); }
/** * Creates a {@link MembershipStatus} that marks a machine as being * non-functional (i.e. inactive) and in need of replacement. The * {@link Machine} should be replaced and can be terminated. * * @return */ public static MembershipStatus disposable() { return new MembershipStatus(false, true); }
@Override public boolean test(Machine machine) { return allocatedStates.contains(machine.getMachineState()); } }
/** * Creates a default {@link MembershipStatus} that marks a machine both * active and evictable. * * @return */ public static MembershipStatus defaultStatus() { return new MembershipStatus(true, true); }
/** * Creates a {@link MembershipStatus} that marks a machine as blessed (or a * permanent pool member that cannot be evicted). * * @return */ public static MembershipStatus blessed() { return new MembershipStatus(true, false); }