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

Prepare for v8.0.0 demo release #74

Merged
merged 10 commits into from
Mar 26, 2024
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: Java CI with Maven JDK17
name: Java CI with Maven JDK21

on:
push:
Expand Down
82 changes: 30 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,29 +173,15 @@ your local machine.

## Run the Application on Kubernetes

The steps to run the application on Kubernetes comprises the following:
* Oracle Coherence Operator Helm Chart
The steps to run the application on Kubernetes comprises:

* Use `kubectl` to install the Oracle Coherence Operator
* Use `kubectl` to install the Coherence cluster which comprises 2 roles:
* storage-enabled Coherence servers
* storage-disabled application with Grizzly HTTP Server

> **Note:** If you want to enable Federation when running on Kubernetes, see [Enable Federation on Kubernetes](#enable-federation-on-kubernetes).

1. **Add Helm Repositories**

You must have at least version v2.14.3 of `helm`, but these instructions are written for V3.3.+.
See [here](https://helm.sh/docs/intro/install/) for information on installing helm for your platform.

Run the following to add the required helm repositories:

```bash
$ helm repo add stable https://charts.helm.sh/stable
$ helm repo add coherence https://oracle.github.io/coherence-operator/charts
$ helm repo update
```

> Note: The `helm` commands below are for helm 3.3. Version 2 equivalent commands have also been included.

1. **Create Namespace**

Run the application using the Oracle Coherence Operator in a namespace called `coherence-example`. Create the demonstration namespace:
Expand All @@ -205,7 +191,7 @@ The steps to run the application on Kubernetes comprises the following:
namespace/coherence-example created
```

1. **Build and Push Docker Image**
2. **Build and Push Docker Image**

Ensure that you have Docker running locally and execute the following command which will
used the `jib-maven-plugin` to build a Docker image.
Expand All @@ -214,46 +200,37 @@ The steps to run the application on Kubernetes comprises the following:
mvn clean install -P docker
```

This creates an image named `coherence-demo:6.0.0-SNAPSHOT` which contains everything needed to run the demo.
This creates an image named `coherence-demo:8.0.0-SNAPSHOT` which contains everything needed to run the demo.

> Note: If you are running against a remote Kubernetes cluster, you need to push the Docker
> image to your repository accessible to that cluster. You also need to prefix the image name in the `yaml` files used in the `helm` commands below.
> Find your Docker image id with `docker images` and tag it with your prefix: `docker tag image youname/coherence-demo:6.0.0-SNAPSHOT` and
> them push using `docker push youname/coherence-demo:6.0.0-SNAPSHOT`.

1. **Install the Oracle Coherence Operator**
> Find your Docker image id with `docker images` and tag it with your prefix: `docker tag image youname/coherence-demo:8.0.0-SNAPSHOT` and
> them push using `docker push youname/coherence-demo:8.0.0-SNAPSHOT`.

Install the operator using `helm`:
3. **Install the Oracle Coherence Operator**

```bash
helm install --namespace coherence-example coherence-operator coherence/coherence-operator
```
You must have a supported version of Kubernetes. Please see https://github.com/oracle/coherence-operator for more details.

Confirm the creation of the chart:
Install the operator using `kubectl`. (It will be installed into a new namespace called `coherence`)

```bash
helm ls --namespace coherence-example

NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
coherence-operator coherence-example 1 2021-01-12 15:25:04.409346768 +0800 AWST deployed coherence-operator-3.1.3 3.1.3

kubectl get pods --namespace coherence-example

NAME READY STATUS RESTARTS AGE
coherence-operator-cd9b646d5-p5xk8 1/1 Running 0 2m12s
kubectl apply -f https://github.com/oracle/coherence-operator/releases/download/v3.3.3/coherence-operator.yaml
```

For `helm` version 2.X:
Confirm the creation of the operator:

```bash
helm install --namespace coherence-example --name coherence-operator coherence/coherence-operator

helm ls
kubectl get pods -n coherence
NAME READY STATUS RESTARTS AGE
coherence-operator-controller-manager-55fd645db8-9tnvq 1/1 Running 1 (11m ago) 12m
coherence-operator-controller-manager-55fd645db8-bk46q 1/1 Running 1 (11m ago) 12m
coherence-operator-controller-manager-55fd645db8-rlfv8 1/1 Running 0 12m
```

1. **Install the Coherence Cluster**

The Coherence cluster comprises of 2 roles:
4. **Install the Coherence Cluster**

The Coherence cluster comprises 2 roles:

* storage - contains the storage-enabled tier which stores application data
* http - contains a storage-disabled http server which serves the application
Expand All @@ -271,10 +248,11 @@ The steps to run the application on Kubernetes comprises the following:
The pod primary-cluster-storage-0 must be running and ready as shown:

```bash
NAME READY STATUS RESTARTS AGE
coherence-operator-cd9b646d5-p5xk8 1/1 Running 0 33m
primary-cluster-http-0 1/1 Running 0 3m2s
primary-cluster-storage-0 1/1 Running 0 3m4s
kubectl get pods -n coherence-example
NAME READY STATUS RESTARTS AGE
primary-cluster-http-0 1/1 Running 0 5s
primary-cluster-storage-0 1/1 Running 0 5s
primary-cluster-storage-1 1/1 Running 0 5s
```

If the pod does not show as `Running`, you can use the following command to diagnose and troubleshoot the pod:
Expand All @@ -283,19 +261,19 @@ The steps to run the application on Kubernetes comprises the following:
kubectl describe pod primary-cluster-storage-0 --namespace coherence-example
```

1. **Port Forward the HTTP Port**
5. **Port Forward the HTTP Port**

```bash
kubectl port-forward --namespace coherence-example primary-cluster-http-0 8080:8080
```

1. **Access the Application**</br>
6. **Access the Application**</br>

Use the following URL to access the application home page:

[http://127.0.0.1:8080/application/index.html](http://127.0.0.1:8080/application/index.html)

1. **Scale the Application**
7. **Scale the Application**

When running the application in Kubernetes, the **Add Server** and **Remove Server** options are not available. You need to use `kubectl` to scale the application.

Expand All @@ -314,7 +292,7 @@ The steps to run the application on Kubernetes comprises the following:

Use `kubectl --namespace coherence-example rollout status sts/primary-cluster-storage` to view the progress.

1. **Scale the Application down**
8. **Scale the Application down**

Scale the application to one node by editing `demo-cluster.yaml` and changing
the `replicas` value for the `storage` role to 1. Then apply using
Expand All @@ -329,7 +307,7 @@ The steps to run the application on Kubernetes comprises the following:
> carried out in a safe manner (checking service statusHA values) to ensure no data is lost.
> You can confirm this by checking the number of positions are the same as before the scale-down was initiated.

1. Uninstall the Coherence Cluster
9. Uninstall the Coherence Cluster

Use the following to uninstall the Coherence cluster.

Expand Down
43 changes: 36 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@

<groupId>com.oracle.coherence</groupId>
<artifactId>coherence-demo</artifactId>
<version>7.0.1-SNAPSHOT</version>
<version>8.0.0-SNAPSHOT</version>

<properties>
<!-- The groupId of the Coherence product -->
<coherence.group.id>com.oracle.coherence.ce</coherence.group.id>

<!-- dependency versions -->
<bedrock.version>6.0.1</bedrock.version>
<coherence.version>23.09.2</coherence.version>
<bedrock.version>7.0.3</bedrock.version>
<coherence.version>24.03</coherence.version>
<jakarta.xml.bind.version>3.0.1</jakarta.xml.bind.version>
<copy.rename.maven.plugin.version>1.0.1</copy.rename.maven.plugin.version>
<derby.version>10.17.1.0</derby.version>
<docker.version>${project.version}</docker.version>
<eclipselink.version>3.0.2</eclipselink.version>
<jackson.version>2.14.1</jackson.version>
<eclipselink.version>4.0.2</eclipselink.version>
<jackson.version>2.17.0</jackson.version>
<jackson.databind.version>${jackson.version}</jackson.databind.version>
<jaeger.version>1.8.1</jaeger.version>
<jaxrs.version>3.0.0</jaxrs.version>
Expand All @@ -55,10 +55,11 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<maven.compiler.plugin.version>3.8.1</maven.compiler.plugin.version>
<maven.compiler.plugin.version>3.12.1</maven.compiler.plugin.version>
<maven.dependency.plugin.version>3.1.1</maven.dependency.plugin.version>
<maven.enforcer.plugin.version>1.3.1</maven.enforcer.plugin.version>
<maven.exec.plugin.version>1.6.0</maven.exec.plugin.version>
<maven.jandex.plugin.version>1.2.3</maven.jandex.plugin.version>
<maven.javadoc.plugin.version>3.4.0</maven.javadoc.plugin.version>
<maven.resources.plugin.version>3.1.0</maven.resources.plugin.version>
<maven.replacer.plugin.version>1.5.3</maven.replacer.plugin.version>
Expand Down Expand Up @@ -381,6 +382,34 @@
</arguments>
</configuration>
</plugin>

<plugin>
<groupId>com.oracle.coherence.ce</groupId>
<artifactId>pof-maven-plugin</artifactId>
<version>24.03</version>
<executions>
<execution>
<id>instrument</id>
<goals>
<goal>instrument</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jboss.jandex</groupId>
<artifactId>jandex-maven-plugin</artifactId>
<version>${maven.jandex.plugin.version}</version>
<executions>
<execution>
<id>make-index</id>
<goals>
<goal>jandex</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down Expand Up @@ -524,7 +553,7 @@
<version>${jib.version}</version>
<configuration>
<from>
<image>gcr.io/distroless/java17</image>
<image>openjdk:21-jdk</image>
</from>
<to>
<image>${project.artifactId}</image>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
/**
* Common functionality for resources that start/stop multiple Coherence members.
*/
public class AbstractClusterMemberResource
{
public class AbstractClusterMemberResource {

/**
* Stable internal ID set for odd/even tracking.
*/
Expand All @@ -41,16 +41,13 @@ public class AbstractClusterMemberResource
*
* @return the next available ID
*/
protected synchronized static int getStableId()
{
for (int i = 0, len = Byte.SIZE; i < len; i++)
{
if ((s_UsedIds >> i & 1) == 0)
{
protected static synchronized int getStableId() {
for (int i = 0, len = Byte.SIZE; i < len; i++) {
if ((s_UsedIds >> i & 1) == 0) {
s_UsedIds |= 1 << i;
return i;
}
}
}
return -1;
}

Expand All @@ -60,8 +57,7 @@ protected synchronized static int getStableId()
* @param sMemberId the member ID
* @param nStableId the stable ID
*/
protected synchronized static void associateMemberToStableId(String sMemberId, Integer nStableId)
{
protected static synchronized void associateMemberToStableId(String sMemberId, Integer nStableId) {
MEMBER_TO_STABLE_ID.put(sMemberId, nStableId);
}

Expand All @@ -70,13 +66,11 @@ protected synchronized static void associateMemberToStableId(String sMemberId, I
*
* @param sMemberId the member ID
*/
protected synchronized static void releaseMemberToStableIdAssociation(String sMemberId)
{
protected static synchronized void releaseMemberToStableIdAssociation(String sMemberId) {
int nId = MEMBER_TO_STABLE_ID.remove(sMemberId);
releaseId(nId);
}


/**
* Augment the provided role name by appending {@code Even} or {@code Odd} depending
* on the evenness/oddness of the provided stable ID.
Expand All @@ -85,16 +79,14 @@ protected synchronized static void releaseMemberToStableIdAssociation(String sMe
*
* @return the augmented role name
*/
protected String createRoleName(int nStableId)
{
protected String createRoleName(int nStableId) {
return "CoherenceDemoServer" + ((nStableId & 1) == 1 ? "Odd" : "Even");
}

/**
* Release a stable ID for re-use.
*/
private static void releaseId(int nId)
{
private static void releaseId(int nId) {
s_UsedIds &= ~(1 << nId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
* @author Brian Oliver
*/
@ApplicationPath("application")
public class ApplicationResourceConfig extends ResourceConfig
{
public class ApplicationResourceConfig
extends ResourceConfig {

/**
* Constructs the {@link ApplicationResourceConfig}.
*/
public ApplicationResourceConfig()
{
public ApplicationResourceConfig() {
register(StaticResource.class);
}
}
Loading
Loading