/** * Creates a new waiter with the given strategies. * @param terminationStrategy The termination strategy to use. * @param delayStrategy The delay strategy to use. */ public BmcGenericWaiter(TerminationStrategy terminationStrategy, DelayStrategy delayStrategy) { WaiterConfiguration waiterConfig = new WaiterConfiguration(terminationStrategy, delayStrategy); this.waiter = new GenericWaiter(waiterConfig); }
@Override public boolean shouldTerminate(WaitContext context) { return context.getAttemptsMade() < maxAttempts; } }
@Override public RESPONSE call() throws Exception { return execute(requestSupplier, functionCall, terminationPredicate, allow404); } };
/** * Creates a new {@link Waiter} using the provided configuration. * * @param request the request to send * @param terminationStrategy the {@link TerminationStrategy} to use * @param delayStrategy the {@link DelayStrategy} to use * @return a new {@code Waiter} instance */ public com.oracle.bmc.waiter.Waiter<GetWorkRequestRequest, GetWorkRequestResponse> forWorkRequest( GetWorkRequestRequest request, com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, com.oracle.bmc.waiter.DelayStrategy delayStrategy) { return forWorkRequest( com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), request); }
private static GetDataGuardAssociationResponse waitAndGetDataGuardAssociationResponse( DatabaseWaiters waiter, String databaseId, DataGuardAssociation dataGuardAssociation) throws Exception { return waiter.forDataGuardAssociation( GetDataGuardAssociationRequest.builder() .dataGuardAssociationId(dataGuardAssociation.getId()) .databaseId(databaseId) .build(), DataGuardAssociation.LifecycleState.Available, new MaxTimeTerminationStrategy(minutesToMillis(MAX_WAIT_IN_MINS)), new ExponentialBackoffDelayStrategy( minutesToMillis(DELAY_INTERVAL_IN_MINS))) .execute(); }
@Override public boolean shouldTerminate(WaitContext context) { final long endTime = context.getStartTime() + maxTimeInMillis; final long currentTime = context.getCurrentTime(); return endTime <= currentTime; }
/** * Create a new termination strategy that allows up to the specified number of time units to have elapsed before terminating. * @param maxTime number of time units * @param timeUnit time unit * @return termination strategy */ public static MaxTimeTerminationStrategy ofTimeUnit( final long maxTime, final TimeUnit timeUnit) { return new MaxTimeTerminationStrategy(timeUnit.toMillis(maxTime)); }
/** * Create a new termination strategy that allows up to the specified number of milliseconds to have elapsed before terminating. * @param maxTimeInMillis number of milliseconds * @return termination strategy */ public static MaxTimeTerminationStrategy ofMillis(final long maxTimeInMillis) { return ofTimeUnit(maxTimeInMillis, TimeUnit.MILLISECONDS); }
/** * Creates a new waiter using the given strategies. If any of the args are * null, the default strategy listed in this class will be used. * * @param terminationStrategy * The termination strategy. * @param delayStrategy * The delay strategy. * @return A new waiter instance. */ public static BmcGenericWaiter newWaiter( @Nullable TerminationStrategy terminationStrategy, @Nullable DelayStrategy delayStrategy) { TerminationStrategy terminationStrategyToUse = terminationStrategy != null ? terminationStrategy : DEFAULT_POLLING_TERMINATION_STRATEGY; DelayStrategy delayStrategyToUse = delayStrategy != null ? delayStrategy : DEFAULT_POLLING_DELAY_STRATEGY; return new BmcGenericWaiter(terminationStrategyToUse, delayStrategyToUse); }
/** * Creates a new {@link Waiter} using the provided configuration. * * @param request the request to send * @param terminationStrategy the {@link TerminationStrategy} to use * @param delayStrategy the {@link DelayStrategy} to use * @return a new {@code Waiter} instance */ public com.oracle.bmc.waiter.Waiter<GetWorkRequestRequest, GetWorkRequestResponse> forWorkRequest( GetWorkRequestRequest request, com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, com.oracle.bmc.waiter.DelayStrategy delayStrategy) { return forWorkRequest( com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), request); }
/** * Create a new termination strategy that allows up to the specified number of minutes to have elapsed before terminating. * @param maxTimeInMinutes number of minutes * @return termination strategy */ public static MaxTimeTerminationStrategy ofMinutes(final long maxTimeInMinutes) { return ofTimeUnit(maxTimeInMinutes, TimeUnit.MINUTES); } }
@Override public long nextDelay(WaitContext context) { long delay = (long) Math.pow(2, context.getAttemptsMade()); delay *= 1000; if (delay <= 0) { return maxDelayInMillis; } return Math.min(delay, maxDelayInMillis); } }
/** * Creates a new {@link Waiter} using the provided configuration. * * @param request the request to send * @param terminationStrategy the {@link TerminationStrategy} to use * @param delayStrategy the {@link DelayStrategy} to use * @return a new {@code Waiter} instance */ public com.oracle.bmc.waiter.Waiter<GetWorkRequestRequest, GetWorkRequestResponse> forWorkRequest( GetWorkRequestRequest request, com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, com.oracle.bmc.waiter.DelayStrategy delayStrategy) { return forWorkRequest( com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), request); }
/** * Create a new termination strategy that allows up to the specified number of seconds to have elapsed before terminating. * @param maxTimeInSeconds number of seconds * @return termination strategy */ public static MaxTimeTerminationStrategy ofSeconds(final long maxTimeInSeconds) { return ofTimeUnit(maxTimeInSeconds, TimeUnit.SECONDS); }
/** * Creates a new {@link Waiter} using the provided configuration. * * @param request the request to send * @param terminationStrategy the {@link TerminationStrategy} to use * @param delayStrategy the {@link DelayStrategy} to use * @return a new {@code Waiter} instance */ public com.oracle.bmc.waiter.Waiter<GetWorkRequestRequest, GetWorkRequestResponse> forWorkRequest( GetWorkRequestRequest request, com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, com.oracle.bmc.waiter.DelayStrategy delayStrategy) { return forWorkRequest( com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), request); }
/** * Creates a new {@link Waiter} using the provided configuration. * * @param request the request to send * @param targetState the desired state to wait for * @param terminationStrategy the {@link TerminationStrategy} to use * @param delayStrategy the {@link DelayStrategy} to use * @return a new {@code Waiter} instance */ public com.oracle.bmc.waiter.Waiter<GetVolumeRequest, GetVolumeResponse> forVolume( GetVolumeRequest request, com.oracle.bmc.core.model.Volume.LifecycleState targetState, com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, com.oracle.bmc.waiter.DelayStrategy delayStrategy) { org.apache.commons.lang3.Validate.notNull(targetState, "The targetState cannot be null"); return forVolume( com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), request, targetState); }
/** * Creates a new {@link Waiter} using the provided configuration. * * @param request the request to send * @param targetState the desired state to wait for * @param terminationStrategy the {@link TerminationStrategy} to use * @param delayStrategy the {@link DelayStrategy} to use * @return a new {@code Waiter} instance */ public com.oracle.bmc.waiter.Waiter<GetSenderRequest, GetSenderResponse> forSender( GetSenderRequest request, com.oracle.bmc.email.model.Sender.LifecycleState targetState, com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, com.oracle.bmc.waiter.DelayStrategy delayStrategy) { org.apache.commons.lang3.Validate.notNull(targetState, "The targetState cannot be null"); return forSender( com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), request, targetState); }
/** * Creates a new {@link Waiter} using the provided configuration. * * @param request the request to send * @param targetState the desired state to wait for * @param terminationStrategy the {@link TerminationStrategy} to use * @param delayStrategy the {@link DelayStrategy} to use * @return a new {@code Waiter} instance */ public com.oracle.bmc.waiter.Waiter<GetUserRequest, GetUserResponse> forUser( GetUserRequest request, com.oracle.bmc.identity.model.User.LifecycleState targetState, com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, com.oracle.bmc.waiter.DelayStrategy delayStrategy) { org.apache.commons.lang3.Validate.notNull(targetState, "The targetState cannot be null"); return forUser( com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), request, targetState); }
/** * Creates a new {@link Waiter} using the provided configuration. * * @param request the request to send * @param targetState the desired state to wait for * @param terminationStrategy the {@link TerminationStrategy} to use * @param delayStrategy the {@link DelayStrategy} to use * @return a new {@code Waiter} instance */ public com.oracle.bmc.waiter.Waiter<GetVcnRequest, GetVcnResponse> forVcn( GetVcnRequest request, com.oracle.bmc.core.model.Vcn.LifecycleState targetState, com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, com.oracle.bmc.waiter.DelayStrategy delayStrategy) { org.apache.commons.lang3.Validate.notNull(targetState, "The targetState cannot be null"); return forVcn( com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), request, targetState); }
/** * Creates a new {@link Waiter} using the provided configuration. * * @param request the request to send * @param targetState the desired state to wait for * @param terminationStrategy the {@link TerminationStrategy} to use * @param delayStrategy the {@link DelayStrategy} to use * @return a new {@code Waiter} instance */ public com.oracle.bmc.waiter.Waiter<GetBootVolumeRequest, GetBootVolumeResponse> forBootVolume( GetBootVolumeRequest request, com.oracle.bmc.core.model.BootVolume.LifecycleState targetState, com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, com.oracle.bmc.waiter.DelayStrategy delayStrategy) { org.apache.commons.lang3.Validate.notNull(targetState, "The targetState cannot be null"); return forBootVolume( com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), request, targetState); }