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

Change server to runtime or instance #203

Merged
merged 4 commits into from
Aug 16, 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
18 changes: 9 additions & 9 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The application that you will be working with is an `inventory` service, which c

You will use the `@Fallback` annotations from the MicroProfile Fault Tolerance specification to define criteria for when to provide an alternative solution for a failed execution.

You will also see the application metrics for the fault tolerance methods that are automatically enabled when you add the MicroProfile Metrics feature to the server.
You will also see the application metrics for the fault tolerance methods that are automatically enabled when you add the MicroProfile Metrics feature to your Open Liberty.


// =================================================================================================
Expand Down Expand Up @@ -108,12 +108,12 @@ endif::[]

// Following context for the static guide:
ifndef::cloud-hosted[]
You do not need to restart the server. Next, return to your browser and point back to the http://localhost:9080/inventory/systems/localhost[http://localhost:9080/inventory/systems/localhost^] URL. The fallback mechanism is triggered because the `system` service is now in maintenance. You see the cached properties for this localhost.
You do not need to restart the Liberty instance. Next, return to your browser and point back to the http://localhost:9080/inventory/systems/localhost[http://localhost:9080/inventory/systems/localhost^] URL. The fallback mechanism is triggered because the `system` service is now in maintenance. You see the cached properties for this localhost.
endif::[]

// Following context for the cloud-hosted guide:
ifdef::cloud-hosted[]
You do not need to restart the server. Next, run the following curl command:
You do not need to restart the Liberty instance. Next, run the following curl command:
```bash
curl -s http://localhost:9080/inventory/systems/localhost | jq
```
Expand Down Expand Up @@ -177,15 +177,15 @@ include::{common-includes}/devmode-lmp33-start.adoc[]

The MicroProfile Fault Tolerance API is included in the MicroProfile dependency that is specified in your [hotspot file=4]`pom.xml` file. Look for the dependency with the [hotspot=microprofile file=4]`microprofile` artifact ID. This dependency provides a library that allows you to use fault tolerance policies in your microservices.

You can also find the [hotspot=mpFaultTolerance file=3]`mpFaultTolerance` feature in your [hotspot file=3]`src/main/liberty/config/server.xml` server configuration, which turns on MicroProfile Fault Tolerance capabilities in Open Liberty.
You can also find the [hotspot=mpFaultTolerance file=3]`mpFaultTolerance` feature in your [hotspot file=3]`src/main/liberty/config/server.xml` configuration file, which turns on MicroProfile Fault Tolerance capabilities in Open Liberty.

To easily work through this guide, the two provided microservices are set up to run on the same server. To simulate the availability of the services and then to enable fault tolerance, dynamic configuration with MicroProfile Configuration is used so that you can easily take one service or the other down for maintenance. If you want to learn more about setting up dynamic configuration, see https://openliberty.io/guides/microprofile-config.html[Configuring microservices^].
To easily work through this guide, the two provided microservices are set up to run on the same Liberty instance. To simulate the availability of the services and then to enable fault tolerance, dynamic configuration with MicroProfile Configuration is used so that you can easily take one service or the other down for maintenance. If you want to learn more about setting up dynamic configuration, see https://openliberty.io/guides/microprofile-config.html[Configuring microservices^].

The following two steps set up the dynamic configuration on the `system` service and its client. You can move on to the next section, which adds the fallback mechanism on the `inventory` service.

First, the [hotspot file=0]`src/main/java/io/openliberty/guides/system/SystemResource.java` file has the [hotspot=isInMaintenance file=0]`isInMaintenance()` condition, which determines that the system properties are returned only if you set the [hotspot=2 file=1]`io_openliberty_guides_system_inMaintenance` configuration property to `false` in the [hotspot file=1]`CustomConfigSource` file. Otherwise, the service returns a [hotspot=response-status file=0]`Status.SERVICE_UNAVAILABLE` message, which makes it unavailable.

Next, the [hotspot file=2]`src/main/java/io/openliberty/guides/inventory/client/SystemClient.java` file makes a request to the `system` service through the MicroProfile Rest Client API. If you want to learn more about MicroProfile Rest Client, you can follow the https://openliberty.io/guides/microprofile-rest-client.html[Consuming RESTful services with template interfaces^] guide. The `system` service as described in the [hotspot file=0]`SystemResource.java` file may return a [hotspot=response-status file=0]`Status.SERVICE_UNAVAILABLE` message, which is a 503 status code. This code indicates that the server being called is unable to handle the request because of a temporary overload or scheduled maintenance, which would likely be alleviated after some delay. To simulate that the system is unavailable, an [hotspot=IOException file=2]`IOException` is thrown.
Next, the [hotspot file=2]`src/main/java/io/openliberty/guides/inventory/client/SystemClient.java` file makes a request to the `system` service through the MicroProfile Rest Client API. If you want to learn more about MicroProfile Rest Client, you can follow the https://openliberty.io/guides/microprofile-rest-client.html[Consuming RESTful services with template interfaces^] guide. The `system` service as described in the [hotspot file=0]`SystemResource.java` file may return a [hotspot=response-status file=0]`Status.SERVICE_UNAVAILABLE` message, which is a 503 status code. This code indicates that the Liberty instance being called is unable to handle the request because of a temporary overload or scheduled maintenance, which would likely be alleviated after some delay. To simulate that the system is unavailable, an [hotspot=IOException file=2]`IOException` is thrown.

The `InventoryManager` class calls the [hotspot=getProperties file=2]`getProperties()` method in the [hotspot file=2]`SystemClient.java` class. You will look into the `InventoryManager` class in more detail in the next section.

Expand Down Expand Up @@ -259,7 +259,7 @@ include::finish/src/main/liberty/config/server.xml[]

MicroProfile Fault Tolerance integrates with MicroProfile Metrics to provide metrics for the annotated fault tolerance methods. When both the [hotspot=mpFaultTolerance]`mpFaultTolerance` and the [hotspot=mpMetrics]`mpMetrics` features are included in the [hotspot]`server.xml` configuration file, the `@Fallback` fault tolerance annotation provides metrics that count the following things: the total number of annotated method invocations, the total number of failed annotated method invocations, and the total number of the fallback method calls.

The [hotspot=mpMetrics]`mpMetrics` feature requires SSL and the configuration is provided for you. The [hotspot=quickStartSecurity]`quickStartSecurity` configuration element provides basic security to secure the server. When you go to the `/metrics` endpoint, use the credentials that are defined in the server configuration to log in to view the data for the fault tolerance methods.
The [hotspot=mpMetrics]`mpMetrics` feature requires SSL and the configuration is provided for you. The [hotspot=quickStartSecurity]`quickStartSecurity` configuration element provides basic security to secure the Liberty. When you go to the `/metrics` endpoint, use the credentials that are defined in the Liberty's configuration to log in to view the data for the fault tolerance methods.

You can learn more about MicroProfile Metrics in the https://openliberty.io/guides/microprofile-metrics.html[Providing metrics from a microservice^] guide. You can also learn more about the MicroProfile Fault Tolerance and MicroProfile Metrics integration in the https://github.com/eclipse/microprofile-fault-tolerance/releases[MicroProfile Fault Tolerance specification^].

Expand All @@ -272,7 +272,7 @@ include::{common-includes}/devmode-build.adoc[]

// Following context for the static guide:
ifndef::cloud-hosted[]
When the server is running, point your browser to the http://localhost:9080/inventory/systems/localhost[http://localhost:9080/inventory/systems/localhost^] URL. You receive the system properties of your local JVM from the `inventory` service.
When the Liberty instance is running, point your browser to the http://localhost:9080/inventory/systems/localhost[http://localhost:9080/inventory/systems/localhost^] URL. You receive the system properties of your local JVM from the `inventory` service.

Next, point your browser to the `system` service URL, which is located at http://localhost:9080/system/properties[http://localhost:9080/system/properties^], to retrieve the system properties for the specific localhost. Notice that the results from the two URLs are identical because the `inventory` service gets its results from calling the `system` service.

Expand All @@ -282,7 +282,7 @@ endif::[]

// Following context for the cloud-hosted guide:
ifdef::cloud-hosted[]
When the server is running, run the following curl command:
When the Liberty instance is running, run the following curl command:
```bash
curl -s http://localhost:9080/inventory/systems/localhost | jq
```
Expand Down
2 changes: 1 addition & 1 deletion finish/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.7.1</version>
<version>3.8.2</version>
</plugin>
<!-- Plugin to run functional tests -->
<plugin>
Expand Down
2 changes: 1 addition & 1 deletion start/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
<plugin>
<groupId>io.openliberty.tools</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>3.7.1</version>
<version>3.8.2</version>
</plugin>
<!-- Plugin to run functional tests -->
<plugin>
Expand Down
Loading