software.amazon.awssdk.services.neptunegraph.waiters.DefaultNeptuneGraphAsyncWaiter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neptunegraph Show documentation
Show all versions of neptunegraph Show documentation
The AWS Java SDK for Neptune Graph module holds the client classes that are used for
communicating with Neptune Graph.
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.neptunegraph.waiters;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.function.Consumer;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.annotations.SdkInternalApi;
import software.amazon.awssdk.annotations.ThreadSafe;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.awscore.exception.AwsServiceException;
import software.amazon.awssdk.core.ApiName;
import software.amazon.awssdk.core.internal.waiters.WaiterAttribute;
import software.amazon.awssdk.core.retry.backoff.BackoffStrategy;
import software.amazon.awssdk.core.retry.backoff.FixedDelayBackoffStrategy;
import software.amazon.awssdk.core.waiters.AsyncWaiter;
import software.amazon.awssdk.core.waiters.WaiterAcceptor;
import software.amazon.awssdk.core.waiters.WaiterOverrideConfiguration;
import software.amazon.awssdk.core.waiters.WaiterResponse;
import software.amazon.awssdk.services.neptunegraph.NeptuneGraphAsyncClient;
import software.amazon.awssdk.services.neptunegraph.model.GetGraphRequest;
import software.amazon.awssdk.services.neptunegraph.model.GetGraphResponse;
import software.amazon.awssdk.services.neptunegraph.model.GetGraphSnapshotRequest;
import software.amazon.awssdk.services.neptunegraph.model.GetGraphSnapshotResponse;
import software.amazon.awssdk.services.neptunegraph.model.GetImportTaskRequest;
import software.amazon.awssdk.services.neptunegraph.model.GetImportTaskResponse;
import software.amazon.awssdk.services.neptunegraph.model.GetPrivateGraphEndpointRequest;
import software.amazon.awssdk.services.neptunegraph.model.GetPrivateGraphEndpointResponse;
import software.amazon.awssdk.services.neptunegraph.model.NeptuneGraphRequest;
import software.amazon.awssdk.services.neptunegraph.waiters.internal.WaitersRuntime;
import software.amazon.awssdk.utils.AttributeMap;
import software.amazon.awssdk.utils.SdkAutoCloseable;
import software.amazon.awssdk.utils.ThreadFactoryBuilder;
@Generated("software.amazon.awssdk:codegen")
@SdkInternalApi
@ThreadSafe
final class DefaultNeptuneGraphAsyncWaiter implements NeptuneGraphAsyncWaiter {
private static final WaiterAttribute CLIENT_ATTRIBUTE = new WaiterAttribute<>(SdkAutoCloseable.class);
private static final WaiterAttribute SCHEDULED_EXECUTOR_SERVICE_ATTRIBUTE = new WaiterAttribute<>(
ScheduledExecutorService.class);
private final NeptuneGraphAsyncClient client;
private final AttributeMap managedResources;
private final AsyncWaiter graphAvailableWaiter;
private final AsyncWaiter graphDeletedWaiter;
private final AsyncWaiter graphSnapshotAvailableWaiter;
private final AsyncWaiter graphSnapshotDeletedWaiter;
private final AsyncWaiter importTaskCancelledWaiter;
private final AsyncWaiter importTaskSuccessfulWaiter;
private final AsyncWaiter privateGraphEndpointAvailableWaiter;
private final AsyncWaiter privateGraphEndpointDeletedWaiter;
private final ScheduledExecutorService executorService;
private DefaultNeptuneGraphAsyncWaiter(DefaultBuilder builder) {
AttributeMap.Builder attributeMapBuilder = AttributeMap.builder();
if (builder.client == null) {
this.client = NeptuneGraphAsyncClient.builder().build();
attributeMapBuilder.put(CLIENT_ATTRIBUTE, this.client);
} else {
this.client = builder.client;
}
if (builder.executorService == null) {
this.executorService = Executors.newScheduledThreadPool(1,
new ThreadFactoryBuilder().threadNamePrefix("waiters-ScheduledExecutor").build());
attributeMapBuilder.put(SCHEDULED_EXECUTOR_SERVICE_ATTRIBUTE, this.executorService);
} else {
this.executorService = builder.executorService;
}
managedResources = attributeMapBuilder.build();
this.graphAvailableWaiter = AsyncWaiter.builder(GetGraphResponse.class).acceptors(graphAvailableWaiterAcceptors())
.overrideConfiguration(graphAvailableWaiterConfig(builder.overrideConfiguration))
.scheduledExecutorService(executorService).build();
this.graphDeletedWaiter = AsyncWaiter.builder(GetGraphResponse.class).acceptors(graphDeletedWaiterAcceptors())
.overrideConfiguration(graphDeletedWaiterConfig(builder.overrideConfiguration))
.scheduledExecutorService(executorService).build();
this.graphSnapshotAvailableWaiter = AsyncWaiter.builder(GetGraphSnapshotResponse.class)
.acceptors(graphSnapshotAvailableWaiterAcceptors())
.overrideConfiguration(graphSnapshotAvailableWaiterConfig(builder.overrideConfiguration))
.scheduledExecutorService(executorService).build();
this.graphSnapshotDeletedWaiter = AsyncWaiter.builder(GetGraphSnapshotResponse.class)
.acceptors(graphSnapshotDeletedWaiterAcceptors())
.overrideConfiguration(graphSnapshotDeletedWaiterConfig(builder.overrideConfiguration))
.scheduledExecutorService(executorService).build();
this.importTaskCancelledWaiter = AsyncWaiter.builder(GetImportTaskResponse.class)
.acceptors(importTaskCancelledWaiterAcceptors())
.overrideConfiguration(importTaskCancelledWaiterConfig(builder.overrideConfiguration))
.scheduledExecutorService(executorService).build();
this.importTaskSuccessfulWaiter = AsyncWaiter.builder(GetImportTaskResponse.class)
.acceptors(importTaskSuccessfulWaiterAcceptors())
.overrideConfiguration(importTaskSuccessfulWaiterConfig(builder.overrideConfiguration))
.scheduledExecutorService(executorService).build();
this.privateGraphEndpointAvailableWaiter = AsyncWaiter.builder(GetPrivateGraphEndpointResponse.class)
.acceptors(privateGraphEndpointAvailableWaiterAcceptors())
.overrideConfiguration(privateGraphEndpointAvailableWaiterConfig(builder.overrideConfiguration))
.scheduledExecutorService(executorService).build();
this.privateGraphEndpointDeletedWaiter = AsyncWaiter.builder(GetPrivateGraphEndpointResponse.class)
.acceptors(privateGraphEndpointDeletedWaiterAcceptors())
.overrideConfiguration(privateGraphEndpointDeletedWaiterConfig(builder.overrideConfiguration))
.scheduledExecutorService(executorService).build();
}
private static String errorCode(Throwable error) {
if (error instanceof AwsServiceException) {
return ((AwsServiceException) error).awsErrorDetails().errorCode();
}
return null;
}
@Override
public CompletableFuture> waitUntilGraphAvailable(GetGraphRequest getGraphRequest) {
return graphAvailableWaiter.runAsync(() -> client.getGraph(applyWaitersUserAgent(getGraphRequest)));
}
@Override
public CompletableFuture> waitUntilGraphAvailable(GetGraphRequest getGraphRequest,
WaiterOverrideConfiguration overrideConfig) {
return graphAvailableWaiter.runAsync(() -> client.getGraph(applyWaitersUserAgent(getGraphRequest)),
graphAvailableWaiterConfig(overrideConfig));
}
@Override
public CompletableFuture> waitUntilGraphDeleted(GetGraphRequest getGraphRequest) {
return graphDeletedWaiter.runAsync(() -> client.getGraph(applyWaitersUserAgent(getGraphRequest)));
}
@Override
public CompletableFuture> waitUntilGraphDeleted(GetGraphRequest getGraphRequest,
WaiterOverrideConfiguration overrideConfig) {
return graphDeletedWaiter.runAsync(() -> client.getGraph(applyWaitersUserAgent(getGraphRequest)),
graphDeletedWaiterConfig(overrideConfig));
}
@Override
public CompletableFuture> waitUntilGraphSnapshotAvailable(
GetGraphSnapshotRequest getGraphSnapshotRequest) {
return graphSnapshotAvailableWaiter.runAsync(() -> client
.getGraphSnapshot(applyWaitersUserAgent(getGraphSnapshotRequest)));
}
@Override
public CompletableFuture> waitUntilGraphSnapshotAvailable(
GetGraphSnapshotRequest getGraphSnapshotRequest, WaiterOverrideConfiguration overrideConfig) {
return graphSnapshotAvailableWaiter.runAsync(
() -> client.getGraphSnapshot(applyWaitersUserAgent(getGraphSnapshotRequest)),
graphSnapshotAvailableWaiterConfig(overrideConfig));
}
@Override
public CompletableFuture> waitUntilGraphSnapshotDeleted(
GetGraphSnapshotRequest getGraphSnapshotRequest) {
return graphSnapshotDeletedWaiter.runAsync(() -> client.getGraphSnapshot(applyWaitersUserAgent(getGraphSnapshotRequest)));
}
@Override
public CompletableFuture> waitUntilGraphSnapshotDeleted(
GetGraphSnapshotRequest getGraphSnapshotRequest, WaiterOverrideConfiguration overrideConfig) {
return graphSnapshotDeletedWaiter.runAsync(() -> client.getGraphSnapshot(applyWaitersUserAgent(getGraphSnapshotRequest)),
graphSnapshotDeletedWaiterConfig(overrideConfig));
}
@Override
public CompletableFuture> waitUntilImportTaskCancelled(
GetImportTaskRequest getImportTaskRequest) {
return importTaskCancelledWaiter.runAsync(() -> client.getImportTask(applyWaitersUserAgent(getImportTaskRequest)));
}
@Override
public CompletableFuture> waitUntilImportTaskCancelled(
GetImportTaskRequest getImportTaskRequest, WaiterOverrideConfiguration overrideConfig) {
return importTaskCancelledWaiter.runAsync(() -> client.getImportTask(applyWaitersUserAgent(getImportTaskRequest)),
importTaskCancelledWaiterConfig(overrideConfig));
}
@Override
public CompletableFuture> waitUntilImportTaskSuccessful(
GetImportTaskRequest getImportTaskRequest) {
return importTaskSuccessfulWaiter.runAsync(() -> client.getImportTask(applyWaitersUserAgent(getImportTaskRequest)));
}
@Override
public CompletableFuture> waitUntilImportTaskSuccessful(
GetImportTaskRequest getImportTaskRequest, WaiterOverrideConfiguration overrideConfig) {
return importTaskSuccessfulWaiter.runAsync(() -> client.getImportTask(applyWaitersUserAgent(getImportTaskRequest)),
importTaskSuccessfulWaiterConfig(overrideConfig));
}
@Override
public CompletableFuture> waitUntilPrivateGraphEndpointAvailable(
GetPrivateGraphEndpointRequest getPrivateGraphEndpointRequest) {
return privateGraphEndpointAvailableWaiter.runAsync(() -> client
.getPrivateGraphEndpoint(applyWaitersUserAgent(getPrivateGraphEndpointRequest)));
}
@Override
public CompletableFuture> waitUntilPrivateGraphEndpointAvailable(
GetPrivateGraphEndpointRequest getPrivateGraphEndpointRequest, WaiterOverrideConfiguration overrideConfig) {
return privateGraphEndpointAvailableWaiter.runAsync(
() -> client.getPrivateGraphEndpoint(applyWaitersUserAgent(getPrivateGraphEndpointRequest)),
privateGraphEndpointAvailableWaiterConfig(overrideConfig));
}
@Override
public CompletableFuture> waitUntilPrivateGraphEndpointDeleted(
GetPrivateGraphEndpointRequest getPrivateGraphEndpointRequest) {
return privateGraphEndpointDeletedWaiter.runAsync(() -> client
.getPrivateGraphEndpoint(applyWaitersUserAgent(getPrivateGraphEndpointRequest)));
}
@Override
public CompletableFuture> waitUntilPrivateGraphEndpointDeleted(
GetPrivateGraphEndpointRequest getPrivateGraphEndpointRequest, WaiterOverrideConfiguration overrideConfig) {
return privateGraphEndpointDeletedWaiter.runAsync(
() -> client.getPrivateGraphEndpoint(applyWaitersUserAgent(getPrivateGraphEndpointRequest)),
privateGraphEndpointDeletedWaiterConfig(overrideConfig));
}
private static List> graphAvailableWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "DELETING");
}));
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "FAILED");
}));
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "AVAILABLE");
}));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> graphDeletedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").compare("!=", input.constant("DELETING")).value(), true);
}));
result.add(WaiterAcceptor.successOnExceptionAcceptor(error -> Objects.equals(errorCode(error),
"ResourceNotFoundException")));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> graphSnapshotAvailableWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "DELETING");
}));
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "FAILED");
}));
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "AVAILABLE");
}));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> graphSnapshotDeletedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").compare("!=", input.constant("DELETING")).value(), true);
}));
result.add(WaiterAcceptor.successOnExceptionAcceptor(error -> Objects.equals(errorCode(error),
"ResourceNotFoundException")));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> importTaskCancelledWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").compare("!=", input.constant("CANCELLING")).value(), true);
}));
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "CANCELLED");
}));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> importTaskSuccessfulWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "CANCELLING");
}));
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "CANCELLED");
}));
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "ROLLING_BACK");
}));
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "FAILED");
}));
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "SUCCEEDED");
}));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> privateGraphEndpointAvailableWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "DELETING");
}));
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "FAILED");
}));
result.add(WaiterAcceptor.successOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").value(), "AVAILABLE");
}));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static List> privateGraphEndpointDeletedWaiterAcceptors() {
List> result = new ArrayList<>();
result.add(WaiterAcceptor.errorOnResponseAcceptor(response -> {
WaitersRuntime.Value input = new WaitersRuntime.Value(response);
return Objects.equals(input.field("status").compare("!=", input.constant("DELETING")).value(), true);
}));
result.add(WaiterAcceptor.successOnExceptionAcceptor(error -> Objects.equals(errorCode(error),
"ResourceNotFoundException")));
result.addAll(WaitersRuntime.DEFAULT_ACCEPTORS);
return result;
}
private static WaiterOverrideConfiguration graphAvailableWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(480);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(60)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration graphDeletedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(60);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(60)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration graphSnapshotAvailableWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(120);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(60)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration graphSnapshotDeletedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(60);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(60)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration importTaskCancelledWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(60);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(60)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration importTaskSuccessfulWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(480);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(60)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration privateGraphEndpointAvailableWaiterConfig(
WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(180);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(10)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
private static WaiterOverrideConfiguration privateGraphEndpointDeletedWaiterConfig(WaiterOverrideConfiguration overrideConfig) {
Optional optionalOverrideConfig = Optional.ofNullable(overrideConfig);
int maxAttempts = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::maxAttempts).orElse(180);
BackoffStrategy backoffStrategy = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::backoffStrategy).orElse(
FixedDelayBackoffStrategy.create(Duration.ofSeconds(10)));
Duration waitTimeout = optionalOverrideConfig.flatMap(WaiterOverrideConfiguration::waitTimeout).orElse(null);
return WaiterOverrideConfiguration.builder().maxAttempts(maxAttempts).backoffStrategy(backoffStrategy)
.waitTimeout(waitTimeout).build();
}
@Override
public void close() {
managedResources.close();
}
public static NeptuneGraphAsyncWaiter.Builder builder() {
return new DefaultBuilder();
}
private T applyWaitersUserAgent(T request) {
Consumer userAgentApplier = b -> b.addApiName(ApiName.builder()
.version("waiter").name("hll").build());
AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration()
.map(c -> c.toBuilder().applyMutation(userAgentApplier).build())
.orElse((AwsRequestOverrideConfiguration.builder().applyMutation(userAgentApplier).build()));
return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build();
}
public static final class DefaultBuilder implements NeptuneGraphAsyncWaiter.Builder {
private NeptuneGraphAsyncClient client;
private WaiterOverrideConfiguration overrideConfiguration;
private ScheduledExecutorService executorService;
private DefaultBuilder() {
}
@Override
public NeptuneGraphAsyncWaiter.Builder scheduledExecutorService(ScheduledExecutorService executorService) {
this.executorService = executorService;
return this;
}
@Override
public NeptuneGraphAsyncWaiter.Builder overrideConfiguration(WaiterOverrideConfiguration overrideConfiguration) {
this.overrideConfiguration = overrideConfiguration;
return this;
}
@Override
public NeptuneGraphAsyncWaiter.Builder client(NeptuneGraphAsyncClient client) {
this.client = client;
return this;
}
public NeptuneGraphAsyncWaiter build() {
return new DefaultNeptuneGraphAsyncWaiter(this);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy