Commit b2de2a53 authored by Nacho's avatar Nacho
Browse files

Añade HazelCast como método de replicado

Se elimina script en bash, que forzaba la
actualización del catálogo. Se cambia por
HazelCast ya que permite notificar los cambios
sin utilizar multicast, para que en AWS funcione
parent 068e9cfc
Loading
Loading
Loading
Loading
+17 −10
Original line number Diff line number Diff line
@@ -4,9 +4,9 @@ LABEL maintainer="info@redmic.es"

ENV DEBIAN_FRONTEND="noninteractive" \
    GEOSERVER_PLUGINS="css inspire libjpeg-turbo csw wps pyramid vectortiles netcdf gdal importer netcdf-out" \
    GEOSERVER_COMMUNITY_PLUGINS="gwc-s3" \
    GEOSERVER_COMMUNITY_PLUGINS="gwc-s3 hz-cluster" \
    GEOSERVER_MAJOR_VERSION="2.12" \
    GEOSERVER_MINOR_VERSION="4" \
    GEOSERVER_MINOR_VERSION="5" \
    GEOSERVER_DATA_DIR="/var/geoserver/data" \
    GEOSERVER_HOME="/opt/geoserver" \
    GEOSERVER_LOG_DIR="/var/log/geoserver" \
@@ -34,7 +34,13 @@ ENV DEBIAN_FRONTEND="noninteractive" \
     -Djava.library.path=/usr/share/java:/opt/libjpeg-turbo/lib64:/usr/lib/jni" \
    GOOGLE_FONTS="Open%20Sans Roboto Lato Ubuntu" \
    NOTO_FONTS="NotoSans-unhinted NotoSerif-unhinted NotoMono-hinted" \
    GEOSERVER_PORT="8080"
    GEOSERVER_PORT="8080" \
    SYNC_MODE="event" \
    SYNC_DELAY="0" \
    CLUSTER_NAME="geoserver-cluster" \
    CLUSTER_PASSWORD="changeme" \
    SESSION_STICKY="true" \
    HAZELCAST_PORT="5701"

ENV GEOSERVER_VERSION="${GEOSERVER_MAJOR_VERSION}.${GEOSERVER_MINOR_VERSION}" \
    GEOSERVER_LOG_LOCATION="${GEOSERVER_LOG_DIR}/geoserver.log" \
@@ -42,9 +48,11 @@ ENV GEOSERVER_VERSION="${GEOSERVER_MAJOR_VERSION}.${GEOSERVER_MINOR_VERSION}" \

ARG TEMP_PATH=/tmp/resources

RUN mkdir -p ${TEMP_PATH} && \
    mkdir -p ${GEOSERVER_DATA_DIR} && \
    mkdir -p ${GEOSERVER_LOG_DIR}
RUN mkdir -p "${TEMP_PATH}" && \
    mkdir -p "${GEOSERVER_DATA_DIR}" && \
    mkdir -p "${GEOSERVER_LOG_DIR}"

COPY ./scripts /

# Install extra fonts to use with sld font markers
RUN apt-get update && \
@@ -62,7 +70,7 @@ RUN apt-get update && \
        libnetcdf11 \
        libnetcdf-c++4 \
        netcdf-bin \
        dnsutils
        gettext-base

# Copy resources
# Install Google Noto fonts
@@ -98,7 +106,8 @@ RUN FILENAME="geoserver-${GEOSERVER_VERSION}-bin.zip" && \
    rm -rf ${GEOSERVER_HOME}/data_dir/demo && \
    rm -rf ${GEOSERVER_HOME}/data_dir/gwc-layers && \
    rm -rf ${GEOSERVER_HOME}/data_dir/layergroups && \
    rm -rf ${GEOSERVER_HOME}/data_dir/workspaces
    rm -rf ${GEOSERVER_HOME}/data_dir/workspaces && \
    mv -f /web.xml ${GEOSERVER_HOME}/webapps/geoserver/WEB-INF/web.xml


# Install Marlin
@@ -185,8 +194,6 @@ RUN rm -fr ${TEMP_PATH} && \

USER geoserver

COPY ./scripts /

EXPOSE ${GEOSERVER_PORT}

ENTRYPOINT ["/docker-entrypoint.sh"]
+3 −0
Original line number Diff line number Diff line
sync_mode=${SYNC_MODE}
sync_delay=${SYNC_DELAY}
session_sticky=${SESSION_STICKY}
 No newline at end of file
+12 −9
Original line number Diff line number Diff line
#!/bin/bash

sleep 15
set -e

if [ -z "$(ls -A ${GEOSERVER_DATA_DIR})" ]
then
	echo "Data dir is empty, creating data folders structure"
    mkdir -p ${GEOSERVER_DATA_DIR}/coverages
    mkdir -p ${GEOSERVER_DATA_DIR}/data
    mkdir -p ${GEOSERVER_DATA_DIR}/gwc-layers
    mkdir -p ${GEOSERVER_DATA_DIR}/layergroups
    mkdir -p ${GEOSERVER_DATA_DIR}/workspaces
    mkdir -p ${GEOSERVER_DATA_DIR}/cluster

	echo "${GEOSERVER_HOME}"
    cp -arv "${GEOSERVER_HOME}/data_dir/"* "${GEOSERVER_DATA_DIR}"

  	echo "Delete data_dir in container"
	rm -rf "${GEOSERVER_HOME}/data_dir"
fi

export JAVA_OPTS="${JAVA_OPTS} ${GEOSERVER_OPTS} -DGEOSERVER_LOG_LOCATION=${GEOSERVER_LOG_LOCATION}"

if [ "${ROLE}" == "master" ]
then
	/manage-slaves.sh & disown
fi
clusterTemplateFilename="cluster"
hazelcastTemplateFilename="hazelcast"

envsubst < /${clusterTemplateFilename}.template > ${GEOSERVER_DATA_DIR}/cluster/${clusterTemplateFilename}.properties
envsubst < /${hazelcastTemplateFilename}.template > ${GEOSERVER_DATA_DIR}/cluster/${hazelcastTemplateFilename}.properties

export JAVA_OPTS="${JAVA_OPTS} ${GEOSERVER_OPTS} -DGEOSERVER_LOG_LOCATION=${GEOSERVER_LOG_LOCATION}"

exec "$@"
+34 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-2.3.xsd"
           xmlns="http://www.hazelcast.com/schema/config"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <group>
    <name>${CLUSTER_NAME}</name>
    <password>${CLUSTER_PASSWORD}</password>
  </group>

  <instanceName>${HOSTNAME}</instanceName>

  <properties>
    <property name="hazelcast.logging.type">log4j</property>
  </properties>

  <network>
    <port auto-increment="true">${HAZELCAST_PORT}</port>
    <join>
      <multicast enabled="false"></multicast>
      <tcp-ip enabled="true">
        <hostname>geoserver</hostname>
      </tcp-ip>
    </join>
  </network>

  <!-- The WPS status map -->
  <map name="wpsExecutionStatusMap">
    <indexes>
      <!-- Add indexes to support the two most common queries -->
      <index ordered="false">executionId</index>
      <index ordered="true">completionTime</index>
    </indexes>
  </map>
</hazelcast>
 No newline at end of file

scripts/manage-slaves.sh

deleted100755 → 0
+0 −34
Original line number Diff line number Diff line
#!/bin/sh

if [ -n "${SWARM_MODE}" ]
then
	servicePrefix="tasks."
else
	servicePrefix=""
fi

sleep "${SLAVES_MANAGEMENT_DELAY}"

while :
do
	echo "Discovering slave instances..."
	nodeIps=$(dig ${servicePrefix}${SLAVE_SERVICE_NAME} +short)
	echo "Nodes of service ${SLAVE_SERVICE_NAME}:"
	echo "${nodeIps}"

	echo "Reloading slave instances..."
	for nodeIp in ${nodeIps}
	do
		echo "Reloading slave instance in ${nodeIp}..."
		curl -XPOST -u "${GEOSERVER_USER}:${GEOSERVER_PASS}" "${nodeIp}:${GEOSERVER_PORT}/geoserver/rest/reload"
		if [ "${?}" -eq "0" ]
		then
			sleep "${SLAVE_MANAGEMENT_TIMEOUT}"
		else
			echo "Failed to reload slave instance in ${nodeIp}"
		fi
	done

	echo "Slave instances reloaded"
	sleep "${SLAVES_MANAGEMENT_INTERVAL}"
done
Loading