SDK for Java 2.x를 사용하는 Application Recovery Controller 예제 - AWS SDK 코드 예제

AWS문서 AWS SDK 예제 리포지토리에 더 많은 SDK 예제가 있습니다. GitHub

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

SDK for Java 2.x를 사용하는 Application Recovery Controller 예제

다음 코드 예제에서는 Application Recovery Controller와 함께 AWS SDK for Java 2.x를 사용하여 작업을 수행하고 일반적인 시나리오를 구현하는 방법을 보여줍니다.

작업은 대규모 프로그램에서 발췌한 코드이며 컨텍스트에 맞춰 실행해야 합니다. 작업은 개별 서비스 함수를 호출하는 방법을 보여주며 관련 시나리오와 크로스 서비스 예제에서 컨텍스트에 맞는 작업을 볼 수 있습니다.

시나리오는 동일한 서비스 내에서 여러 함수를 호출하여 특정 태스크를 수행하는 방법을 보여주는 코드 예시입니다.

각 예제에는 상황에 맞게 코드를 설정하고 실행하는 방법에 대한 지침을 찾을 수 있는 링크가 포함되어 있습니다. GitHub

주제

작업

다음 코드 예제에서는 Application Recovery Controller 라우팅 컨트롤의 상태를 가져오는 방법을 보여줍니다.

SDK for Java 2.x
참고

자세한 내용은 여기를 참조하십시오 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

public static GetRoutingControlStateResponse getRoutingControlState(List<ClusterEndpoint> clusterEndpoints, String routingControlArn) { // As a best practice, we recommend choosing a random cluster endpoint to get or // set routing control states. // For more information, see // https://docs.aws.amazon.com/r53recovery/latest/dg/route53-arc-best-practices.html#route53-arc-best-practices.regional Collections.shuffle(clusterEndpoints); for (ClusterEndpoint clusterEndpoint : clusterEndpoints) { try { System.out.println(clusterEndpoint); Route53RecoveryClusterClient client = Route53RecoveryClusterClient.builder() .endpointOverride(URI.create(clusterEndpoint.endpoint())) .region(Region.of(clusterEndpoint.region())).build(); return client.getRoutingControlState( GetRoutingControlStateRequest.builder() .routingControlArn(routingControlArn).build()); } catch (Exception exception) { System.out.println(exception); } } return null; }

다음 코드 예제에서는 Application Recovery Controller 라우팅 컨트롤의 상태를 업데이트하는 방법을 보여줍니다.

SDK for Java 2.x
참고

자세한 내용은 다음과 같습니다 GitHub. AWS 코드 예제 리포지토리에서 전체 예제를 찾고 설정 및 실행하는 방법을 배워보세요.

public static UpdateRoutingControlStateResponse updateRoutingControlState(List<ClusterEndpoint> clusterEndpoints, String routingControlArn, String routingControlState) { // As a best practice, we recommend choosing a random cluster endpoint to get or // set routing control states. // For more information, see // https://docs.aws.amazon.com/r53recovery/latest/dg/route53-arc-best-practices.html#route53-arc-best-practices.regional Collections.shuffle(clusterEndpoints); for (ClusterEndpoint clusterEndpoint : clusterEndpoints) { try { System.out.println(clusterEndpoint); Route53RecoveryClusterClient client = Route53RecoveryClusterClient.builder() .endpointOverride(URI.create(clusterEndpoint.endpoint())) .region(Region.of(clusterEndpoint.region())) .build(); return client.updateRoutingControlState( UpdateRoutingControlStateRequest.builder() .routingControlArn(routingControlArn).routingControlState(routingControlState).build()); } catch (Exception exception) { System.out.println(exception); } } return null; }