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

Add external compose for clustering #588

Merged
merged 19 commits into from
Nov 3, 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
38 changes: 37 additions & 1 deletion .github/workflows/build-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,34 @@ on:
branches:
- develop
jobs:
build-activemq-docker-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build image for testing activeqm
id: docker_build_testing_image_activeqm
uses: docker/build-push-action@v5
with:
context: ./clustering/activemq-docker/
file: ./clustering/activemq-docker/Dockerfile
push: false
load: true
tags: kartoza/activemq-docker:manual-build
outputs: type=docker,dest=/tmp/activemq.tar
cache-from: |
type=gha,scope=test
type=gha,scope=prod
cache-to: type=gha,scope=test
target: activemq-prod
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: kartoza-activemq
path: /tmp/activemq.tar
build-docker-image:
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -63,7 +91,7 @@ jobs:

run-scenario-tests:
runs-on: ubuntu-latest
needs: build-docker-image
needs: [ build-docker-image, build-activemq-docker-image]
strategy:
matrix:
scenario:
Expand All @@ -83,6 +111,14 @@ jobs:
- name: Load image
run: |
docker load --input /tmp/geoserver.tar
- name: Download ActiveMQ artifact
uses: actions/download-artifact@v3
with:
name: kartoza-activemq
path: /tmp
- name: Load ActiveMQ image
run: |
docker load --input /tmp/activemq.tar
- name: Run scenario test ${{ matrix.scenario }}
working-directory: scenario_tests/${{ matrix.scenario }}
env:
Expand Down
17 changes: 16 additions & 1 deletion clustering/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Clustering using JMS Plugin
GeoServer supports clustering using JMS cluster plugin or using the ActiveMQ-broker.

## JMS cluster plugin
This setup uses the JMS cluster plugin which uses an embedded broker. A docker-compose.yml
is provided in the clustering folder which simulates the replication using
a shared data directory.
Expand All @@ -20,4 +21,18 @@ This value will be different for (Master-Node)
* `CLUSTER_CONNECTION_MAX_WAIT=500` - Wait time between connection to broker retry (in milliseconds)
* `EXISTING_DATA_DIR` - If you are using an existing data directory, you need to set `CLUSTER_CONFIG_DIR`
otherwise the container is will hang and not start. Additionally, it will check if all the files
needed for clustering exists, otherwise it will fail.
needed for clustering exists, otherwise it will fail.

## ActiveMQ-broker

You can additionally run the clustering using an external broker. To run this
you will need to build the image locally and run the stack:

```bash
```

or run in a single step

```bash
docker compose -f docker-compose-external.yml
```
32 changes: 32 additions & 0 deletions clustering/activemq-docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM bellsoft/liberica-openjdk-alpine:13 AS activemq-prod

LABEL maintainer="Alessio Fabiani <alessio.fabiani@geosolutionsgroup.com>"

ENV ACTIVEMQ_VERSION 5.17.1
ENV ACTIVEMQ apache-activemq-$ACTIVEMQ_VERSION
ENV ACTIVEMQ_HOME /opt/activemq/
ENV ACTIVEMQ_CONF $ACTIVEMQ_HOME/conf/
ENV ACTIVEMQ_LIB $ACTIVEMQ_HOME/lib/optional/


RUN apk add --update curl && \
rm -rf /var/cache/apk/* && \
mkdir -p /opt && \
curl -s -S https://archive.apache.org/dist/activemq/$ACTIVEMQ_VERSION/$ACTIVEMQ-bin.tar.gz | tar -xvz -C /opt && \
mv /opt/$ACTIVEMQ $ACTIVEMQ_HOME && \
addgroup -S activemq && \
adduser -S -H -G activemq -h $ACTIVEMQ_HOME activemq && \
chown -R activemq:activemq $ACTIVEMQ_HOME && \
chown -h activemq:activemq $ACTIVEMQ_HOME

ADD setup-jars.sh /setup-jars.sh
RUN chmod +x /*.sh;/setup-jars.sh

COPY activemq.xml $ACTIVEMQ_CONF/activemq.xml

# EXPOSE 1883 5672 8161 61613 61614 61616

USER activemq
WORKDIR $ACTIVEMQ_HOME

CMD ["/bin/sh", "-c", "bin/activemq console"]
169 changes: 169 additions & 0 deletions clustering/activemq-docker/activemq.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- START SNIPPET: example -->
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

<!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>

<bean id="postgres-ds" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<property name="dataSourceClassName" value="org.postgresql.ds.PGSimpleDataSource" />
<property name="maximumPoolSize" value="20" />
<property name="connectionTimeout" value="30000" />
<property name="validationTimeout" value="10000" />
<property name="idleTimeout" value="300000" />
<property name="connectionInitSql" value="SELECT 1" />
<property name="connectionTestQuery" value="SELECT 1" />
<property name="dataSourceProperties" >
<props>
<prop key="portNumber">${POSTGRES_PORT}</prop>
<prop key="databaseName">${POSTGRES_DB}</prop>
<prop key="serverName">${HOST}</prop>
<prop key="user">${POSTGRES_USER}</prop>
<prop key="password">${POSTGRES_PASS}</prop>
<prop key="sslMode">${SSL_MODE}</prop>
<!-- <prop key="sslRootCert">rds.root.cert.url</prop> -->
<prop key="logUnclosedConnections">true</prop>
</props>
</property>
</bean>

<!--
The <broker> element is used to configure the ActiveMQ broker.
-->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}"
offlineDurableSubscriberTimeout="300000" offlineDurableSubscriberTaskSchedule="300000">

<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic="VirtualTopic.geoserver" expireMessagesPeriod="30">
<!--The constantPendingMessageLimitStrategy is used to prevent
slow topic consumers to block producers and affect other consumers
by limiting the number of messages that are retained
For more information, see:

http://activemq.apache.org/slow-consumer-handling.html

<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000"/>
</pendingMessageLimitStrategy>
-->
<!--
Tell the dead letter strategy not to process expired messages
so that they will just be discarded instead of being sent to
the DLQ
-->
<deadLetterStrategy>
<!-- <sharedDeadLetterStrategy processExpired="false" /> -->
<discarding/>
</deadLetterStrategy>
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy>

<!--
The managementContext is used to configure how ActiveMQ is exposed in
JMX. By default, ActiveMQ uses the MBean server that is started by
the JVM. For more information, see:

http://activemq.apache.org/jmx.html
-->
<managementContext>
<managementContext createConnector="false"/>
</managementContext>

<!--
Configure message persistence for the broker. The default persistence
mechanism is the KahaDB store (identified by the kahaDB tag).
For more information, see:

http://activemq.apache.org/persistence.html
-->
<persistenceAdapter>
<!-- <kahaDB directory="${activemq.data}/kahadb"/> -->
<jdbcPersistenceAdapter dataSource="#postgres-ds" lockKeepAlivePeriod="5000">
<locker>
<lease-database-locker lockAcquireSleepInterval="10000"/>
</locker>
</jdbcPersistenceAdapter>
</persistenceAdapter>

<!--
The systemUsage controls the maximum amount of space the broker will
use before disabling caching and/or slowing down producers. For more information, see:
http://activemq.apache.org/producer-flow-control.html
-->
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage percentOfJvmHeap="70" />
</memoryUsage>
<storeUsage>
<storeUsage limit="100 gb"/>
</storeUsage>
<tempUsage>
<tempUsage limit="50 gb"/>
</tempUsage>
</systemUsage>
</systemUsage>

<networkConnectors xmlns="http://activemq.apache.org/schema/core">
<networkConnector uri="${ACTIVEMQ_SERVER_DISCOVERYURI}" />
</networkConnectors>

<!--
The transport connectors expose ActiveMQ over a given protocol to
clients and other brokers. For more information, see:

http://activemq.apache.org/configuring-transports.html
-->
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<transportConnector name="openwire" uri="${ACTIVEMQ_SERVER_URI}" discoveryUri="${ACTIVEMQ_SERVER_DISCOVERYURI}" />
<!-- <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> -->
<!-- <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> -->
<!-- <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> -->
<!-- <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/> -->
</transportConnectors>

<!-- destroy the spring context on shutdown to stop jetty -->
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
</shutdownHooks>

</broker>

<!--
Enable web consoles, REST and Ajax APIs and demos
The web consoles requires by default login, you can disable this in the jetty.xml file

Take a look at ${ACTIVEMQ_HOME}/conf/jetty.xml for more details
-->
<import resource="jetty.xml"/>

</beans>
<!-- END SNIPPET: example -->
12 changes: 12 additions & 0 deletions clustering/activemq-docker/setup-jars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

wget -c --tries=2 https://repo1.maven.org/maven2/org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar \
-O "${ACTIVEMQ_LIB}"/slf4j-api-1.7.21.jar
wget -c --tries=2 https://repo1.maven.org/maven2/org/postgresql/postgresql/42.4.0/postgresql-42.4.0.jar \
-O "${ACTIVEMQ_LIB}"/postgresql-42.4.0.jar
wget -c --tries=2 https://repo1.maven.org/maven2/org/osgi/org.osgi.compendium/4.3.1/org.osgi.compendium-4.3.1.jar \
-O "${ACTIVEMQ_LIB}"/org.osgi.compendium-4.3.1.jar
wget -c --tries=2 https://repo1.maven.org/maven2/org/apache/servicemix/bundles/org.apache.servicemix.bundles.commons-dbcp/1.4_3/org.apache.servicemix.bundles.commons-dbcp-1.4_3-sources.jar \
-O "${ACTIVEMQ_LIB}"/org.apache.servicemix.bundles.commons-dbcp-1.4_3-sources.jar
wget -c --tries=2 https://repo1.maven.org/maven2/com/zaxxer/HikariCP/2.7.2/HikariCP-2.7.2.jar \
-O "${ACTIVEMQ_LIB}"/HikariCP-2.7.2.jar
Loading
Loading