@@ -59,8 +59,23 @@ cluster_config() {
5959 envsubst < " ${EXTRA_CONFIG_DIR} /cluster.properties" \
6060 > " ${CLUSTER_CONFIG_DIR} /cluster.properties"
6161 else
62- envsubst < /build_data/cluster.properties \
63- > " ${CLUSTER_CONFIG_DIR} /cluster.properties"
62+ cat > " ${CLUSTER_CONFIG_DIR} /cluster.properties" << EOF
63+ CLUSTER_CONFIG_DIR=${CLUSTER_CONFIG_DIR}
64+ instanceName=${INSTANCE_STRING}
65+ readOnly=${READONLY}
66+ durable=${CLUSTER_DURABILITY}
67+ brokerURL=failover:(${BROKER_URL} )
68+ embeddedBroker=${EMBEDDED_BROKER}
69+ connection.retry=${CLUSTER_CONNECTION_RETRY_COUNT}
70+ toggleMaster=${TOGGLE_MASTER}
71+ xbeanURL=./broker.xml
72+ embeddedBrokerProperties=embedded-broker.properties
73+ topicName=VirtualTopic.geoserver
74+ connection=enabled
75+ toggleSlave=${TOGGLE_SLAVE}
76+ connection.maxwait=${CLUSTER_CONNECTION_MAX_WAIT}
77+ group=geoserver-cluster
78+ EOF
6479 fi
6580 fi
6681
@@ -76,30 +91,98 @@ broker_config() {
7691 envsubst < " ${EXTRA_CONFIG_DIR} /embedded-broker.properties" \
7792 > " ${CLUSTER_CONFIG_DIR} /embedded-broker.properties"
7893 else
79- envsubst < /build_data/embedded-broker.properties \
80- > " ${CLUSTER_CONFIG_DIR} /embedded-broker.properties"
94+ cat > " ${CLUSTER_CONFIG_DIR} /embedded-broker.properties" << EOF
95+ activemq.jmx.useJmx=false
96+ activemq.jmx.port=1098
97+ activemq.jmx.host=localhost
98+ activemq.jmx.createConnector=false
99+ activemq.transportConnectors.server.uri=${BROKER_URL} ?maximumConnections=1000&wireFormat.maxFrameSize=104857600&jms.useAsyncSend=true&transport.daemon=true&trace=true
100+ activemq.transportConnectors.server.discoveryURI=multicast://default
101+ activemq.broker.persistent=true
102+ activemq.base=./
103+ activemq.broker.systemUsage.memoryUsage=128 mb
104+ activemq.broker.systemUsage.storeUsage=1 gb
105+ activemq.broker.systemUsage.tempUsage=128 mb
106+ EOF
81107 fi
82108 fi
83109}
84110
85111broker_xml_config () {
86- rm -f " ${CLUSTER_CONFIG_DIR} /broker.xml"
87-
88- if [[ ! -f " ${CLUSTER_CONFIG_DIR} /broker.xml" ]]; then
89- if [[ -f " ${EXTRA_CONFIG_DIR} /broker.xml" ]]; then
90- envsubst < " ${EXTRA_CONFIG_DIR} /broker.xml" \
91- > " ${CLUSTER_CONFIG_DIR} /broker.xml"
92- else
93- envsubst < /build_data/broker.xml \
94- > " ${CLUSTER_CONFIG_DIR} /broker.xml"
95-
96- if [[ " ${DB_BACKEND} " =~ [Pp][Oo][Ss][Tt][Gg][Rr][Ee][Ss] ]]; then
97- sed -i ' 15,17d' " ${CLUSTER_CONFIG_DIR} /broker.xml"
98- else
99- sed -i ' 19,37d' " ${CLUSTER_CONFIG_DIR} /broker.xml"
100- fi
101- fi
112+ local target=" ${CLUSTER_CONFIG_DIR} /broker.xml"
113+
114+ # Always remove old broker.xml
115+ rm -f " $target "
116+
117+ # Helper: write default broker.xml
118+ write_default_broker_xml () {
119+ cat << EOF
120+ <?xml version="1.0" encoding="UTF-8"?>
121+ <beans xmlns="http://www.springframework.org/schema/beans"
122+ xmlns:amq="http://activemq.apache.org/schema/core"
123+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
124+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
125+ http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
126+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
127+
128+ <broker id="broker" persistent="${activemq.broker.persistent} "
129+ useJmx="true" xmlns="http://activemq.apache.org/schema/core"
130+ dataDirectory="${activemq.base} " tmpDataDirectory="${activemq.base} /tmp"
131+ startAsync="false" start="false" brokerName="${INSTANCE_STRING} ">
132+
133+ <amq:persistenceAdapter>
134+ <jdbcPersistenceAdapter dataDirectory="activemq-data"
135+ dataSource="#postgres-ds" lockKeepAlivePeriod="0"
136+ createTablesOnStartup="true"
137+ brokerName="${INSTANCE_STRING} "/>
138+ <statements useLockCreateWhereClause="true"
139+ tablePrefix="ACTIVEMQ_"
140+ dualCommitEnabled="false"
141+ updateClob="true"
142+ updateBlob="true"
143+ lockKeepAlivePeriod="30000"/>
144+ </amq:persistenceAdapter>
145+
146+ <bean id="postgres-ds" class="org.postgresql.ds.PGPoolingDataSource">
147+ <property name="url" value="jdbc:postgresql://${HOST} :${POSTGRES_PORT} /${POSTGRES_DB} ?${SSL_PARAMETERS} "/>
148+ <property name="user" value="${POSTGRES_USER} "/>
149+ <property name="password" value="${POSTGRES_PASS} "/>
150+ <property name="initialConnections" value="15"/>
151+ <property name="maxConnections" value="30"/>
152+ </bean>
153+
154+ <networkConnectors xmlns="http://activemq.apache.org/schema/core">
155+ <networkConnector uri="static:(tcp://host1:61616,tcp://host2:61616,tcp://host3:61616,tcp://localhost:61616)" />
156+ </networkConnectors>
157+
158+ <transportConnectors>
159+ <transportConnector name="openwire" uri="${activemq.transportConnectors.server.uri} " />
160+ </transportConnectors>
161+ </broker>
162+ </beans>
163+ EOF
164+ }
165+
166+ # Step 1: generate broker.xml
167+ if [[ -f " ${EXTRA_CONFIG_DIR} /broker.xml" ]]; then
168+ envsubst < " ${EXTRA_CONFIG_DIR} /broker.xml" > " $target "
169+ else
170+ write_default_broker_xml > " $target "
102171 fi
172+
173+ # Step 2: post-process broker.xml depending on DB_BACKEND
174+ adjust_broker_xml () {
175+ case " $DB_BACKEND " in
176+ [Pp][Oo][Ss][Tt][Gg][Rr][Ee][Ss])
177+ sed -i ' 15,17d' " $target "
178+ ;;
179+ * )
180+ sed -i ' 19,37d' " $target "
181+ ;;
182+ esac
183+ }
184+
185+ adjust_broker_xml
103186}
104187
105188# ###########################################
0 commit comments