Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java V2 Add java files Resilient Service #5557

Merged
merged 11 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .doc_gen/metadata/cross_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,26 @@ cross_ResilientService:
- Control web server response to requests and health checks by updating &SYSlong; parameters.
category: Scenarios
languages:
Java:
versions:
- sdk_version: 2
github: javav2/usecases/resilient_service
excerpts:
- description: Run the interactive scenario at a command prompt.
snippet_tags:
- javav2.example_code.workflow.ResilientService_Runner
- description: Create a class that wraps &AS; and &EC2; actions.
snippet_tags:
- javav2.example_code.workflow.ResilientService_AutoScaler
- description: Create a class that wraps &ELB; actions.
snippet_tags:
- javav2.example_code.workflow.ResilientService_LoadBalancer
- description: Create a class that uses &DDB; to simulate a recommendation service.
snippet_tags:
- javav2.example_code.workflow.ResilientService_RecommendationService
- description: Create a class that wraps &SYS; actions.
snippet_tags:
- javav2.example_code.workflow.ResilientService_ParameterHelper
Python:
versions:
- sdk_version: 3
Expand Down
63 changes: 63 additions & 0 deletions .doc_gen/metadata/elastic-load-balancing-v2_metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ elastic-load-balancing-v2_Hello:
synopsis: get started using &ELB;.
category: Hello
languages:
Java:
versions:
- sdk_version: 2
github: javav2/usecases/resilient_service
sdkguide:
excerpts:
- description:
snippet_tags:
- javav2.example_code.elbv2.Hello
Python:
versions:
- sdk_version: 3
Expand Down Expand Up @@ -39,6 +48,15 @@ elastic-load-balancing-v2_CreateTargetGroup:
synopsis: create an ELB target group.
category:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/usecases/resilient_service
sdkguide:
excerpts:
- description:
snippet_tags:
- javav2.cross_service.resilient_service.elbv2.CreateTargetGroup
Python:
versions:
- sdk_version: 3
Expand All @@ -57,6 +75,15 @@ elastic-load-balancing-v2_DeleteTargetGroup:
synopsis: delete an ELB target group.
category:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/usecases/resilient_service
sdkguide:
excerpts:
- description:
snippet_tags:
- javav2.cross_service.resilient_service.elbv2.DeleteTargetGroup
Python:
versions:
- sdk_version: 3
Expand All @@ -75,6 +102,15 @@ elastic-load-balancing-v2_CreateLoadBalancer:
synopsis: create an ELB Application Load Balancer.
category:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/usecases/resilient_service
sdkguide:
excerpts:
- description:
snippet_tags:
- javav2.cross_service.resilient_service.elbv2.CreateLoadBalancer
Python:
versions:
- sdk_version: 3
Expand All @@ -93,6 +129,15 @@ elastic-load-balancing-v2_CreateListener:
synopsis: create a listener that forwards requests from an ELB load balancer to a target group.
category:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/usecases/resilient_service
sdkguide:
excerpts:
- description:
snippet_tags:
- javav2.cross_service.resilient_service.elbv2.CreateListener
Python:
versions:
- sdk_version: 3
Expand All @@ -111,6 +156,15 @@ elastic-load-balancing-v2_DeleteLoadBalancer:
synopsis: delete an ELB load balancer.
category:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/usecases/resilient_service
sdkguide:
excerpts:
- description:
snippet_tags:
- javav2.cross_service.resilient_service.elbv2.DeleteLoadBalancer
Python:
versions:
- sdk_version: 3
Expand All @@ -129,6 +183,15 @@ elastic-load-balancing-v2_DescribeTargetHealth:
synopsis: get the health of instances in an ELB target group.
category:
languages:
Java:
versions:
- sdk_version: 2
github: javav2/usecases/resilient_service
sdkguide:
excerpts:
- description:
snippet_tags:
- javav2.cross_service.resilient_service.elbv2.DescribeTargetHealth
Python:
versions:
- sdk_version: 3
Expand Down
36 changes: 13 additions & 23 deletions javav2/usecases/resilient_service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Several components are used to demonstrate the resilience of the example web ser
parameters control web server response to requests and health checks to
simulate failures and demonstrate resiliency.

Each of these components is created and managed with the SDK for Python as part of
Each of these components is created and managed with the SDK for Java as part of
an interactive demo that runs at a command prompt.

### Amazon EC2 Auto Scaling and EC2 instances
Expand Down Expand Up @@ -81,34 +81,24 @@ To access the load balancer endpoint, you must allow inbound traffic
on port 80 from your computer's IP address to your VPC. If this rule doesn't exist, the
example tries to add it. Alternately, you can
[add a rule to the default security group for your VPC](https://docs.aws.amazon.com/vpc/latest/userguide/security-group-rules.html)
and specify your computer's IP address
as a source.
and specify your computer's IP address as a source.

For general prerequisites, see the [README](../../README.md#prerequisites) in the `python` folder.
To complete the tutorial, you need the following:

### Instructions

For general instructions to run the examples, see the
[README](../../README.md#run-the-examples) in the `python` folder.
+ An AWS account
+ A Java IDE (this example uses IntelliJ)
+ Java 17 SDK and Maven

Run this example by running the following command in the folder that contains this README:

```
python runner.py --action all
```
### Instructions

This starts an interactive scenario that walks you through several aspects of creating a
resilient web service and lets you send requests to the load balancer endpoint and verify
instance health along the way.

#### Build and manage a resilient service

You can run the entire example by specifying `--action all`. Alternatively, run each of the sections
separately by specifying actions of `deploy`, `demo`, or `destroy`.
instance health along the way. You can run this example in the Java IDE.

##### Deploy resources

Use the SDK for Python to create the following AWS resources:
Use the SDK for Java to create the following AWS resources:

1. A DynamoDB table that acts as a service that recommends books, movies, and songs.
2. An instance profile and an associated role and policy that grants permission to
Expand Down Expand Up @@ -165,7 +155,7 @@ The scenario takes the following steps:

##### Destroy resources

Use the SDK for Python to clean up all resources created for this example.
Use the SDK for Java to clean up all resources created for this example.

1. Delete the load balancer and target group.
2. Stop all instances and delete the Auto Scaling group.
Expand All @@ -177,9 +167,9 @@ Use the SDK for Python to clean up all resources created for this example.
* [Application Load Balancers user guide](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/introduction.html)
* [Amazon EC2 Auto Scaling user guide](https://docs.aws.amazon.com/autoscaling/ec2/userguide/what-is-amazon-ec2-auto-scaling.html)
* [Amazon Elastic Compute Cloud (Amazon EC2) user guide](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/concepts.html)
* [SDK for Python Elastic Load Balancing v2 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/elbv2.html)
* [SDK for Python Amazon EC2 Auto Scaling reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/autoscaling.html)
* [SDK for Python Amazon EC2 reference](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html)
* [SDK for Java Elastic Load Balancing v2 reference](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/elasticloadbalancingv2/ElasticLoadBalancingV2Client.html)
* [SDK for Java Amazon EC2 Auto Scaling reference](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/autoscaling/AutoScalingClient.html)
* [SDK for Java Amazon EC2 reference](https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/ec2/Ec2Client.html)

---

Expand Down
36 changes: 25 additions & 11 deletions javav2/usecases/resilient_service/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>resilient_service</artifactId>
<artifactId>create_res_usecase</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
Expand All @@ -30,14 +33,34 @@
<groups>IntegrationTest</groups>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>bom</artifactId>
<version>2.20.159</version>
<version>2.21.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -97,10 +120,6 @@
<groupId>software.amazon.awssdk</groupId>
<artifactId>iam</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>dynamodb</artifactId>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>ssm</artifactId>
Expand Down Expand Up @@ -144,11 +163,6 @@
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-commons</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>software.amazon.awssdk</groupId>
<artifactId>elasticloadbalancingv2</artifactId>
<version>2.20.138</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
Expand Down
Loading
Loading