SDK for Java 2.x を使用した Application Recovery Controller の例 - AWS SDK コードサンプル

Doc AWS SDK Examples リポジトリには、他にも SDK の例があります。 AWS 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; }
  • API の詳細については、「 API リファレンスGetRoutingControlState」の「」を参照してください。 AWS SDK for Java 2.x

次のコード例は、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; }
  • API の詳細については、「 API リファレンスUpdateRoutingControlState」の「」を参照してください。 AWS SDK for Java 2.x