diff --git a/.env b/.env index 0997804..1fd17e1 100644 --- a/.env +++ b/.env @@ -11,7 +11,21 @@ PINPOINT_ZOOKEEPER_ADDRESS=zoo1 ### Pinpoint-Hbase PINPOINT_HBASE_NAME=pinpoint-hbase -#config for hbase in external docker +AGENTINFO_TTL=31536000 +AGENTSTATV2_TTL=5184000 +APPSTATAGGRE_TTL=5184000 +APPINDEX_TTL=31536000 +AGENTLIFECYCLE_TTL=5184000 +AGENTEVENT_TTL=5184000 +STRINGMETADATA_TTL=15552000 +APIMETADATA_TTL=31536000 +SQLMETADATA_TTL=15552000 +TRACEV2_TTL=5184000 +APPTRACEINDEX_TTL=5184000 +APPMAPSTATCALLERV2_TTL=5184000 +APPMAPSTATCALLEV2_TTL=5184000 +APPMAPSTATSELFV2_TTL=5184000 +HOSTAPPMAPV2_TTL=5184000 ### Pinpoint-mysql MYSQL_ROOT_PASSWORD=root123 diff --git a/docker-compose.yml b/docker-compose.yml index f1bf954..a086254 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,22 @@ services: image: "pinpointdocker/pinpoint-hbase:${PINPOINT_VERSION}" networks: - pinpoint - + environment: + - AGENTINFO_TTL=${AGENTINFO_TTL} + - AGENTSTATV2_TTL=${AGENTSTATV2_TTL} + - APPSTATAGGRE_TTL=${APPSTATAGGRE_TTL} + - APPINDEX_TTL=${APPINDEX_TTL} + - AGENTLIFECYCLE_TTL=${AGENTLIFECYCLE_TTL} + - AGENTEVENT_TTL=${AGENTEVENT_TTL} + - STRINGMETADATA_TTL=${STRINGMETADATA_TTL} + - APIMETADATA_TTL=${APIMETADATA_TTL} + - SQLMETADATA_TTL=${SQLMETADATA_TTL} + - TRACEV2_TTL=${TRACEV2_TTL} + - APPTRACEINDEX_TTL=${APPTRACEINDEX_TTL} + - APPMAPSTATCALLERV2_TTL=${APPMAPSTATCALLERV2_TTL} + - APPMAPSTATCALLEV2_TTL=${APPMAPSTATCALLEV2_TTL} + - APPMAPSTATSELFV2_TTL=${APPMAPSTATSELFV2_TTL} + - HOSTAPPMAPV2_TTL=${HOSTAPPMAPV2_TTL} volumes: - hbase_data:/home/pinpoint/hbase - /home/pinpoint/zookeeper diff --git a/pinpoint-hbase/Dockerfile b/pinpoint-hbase/Dockerfile index aa988c2..38e50d2 100644 --- a/pinpoint-hbase/Dockerfile +++ b/pinpoint-hbase/Dockerfile @@ -13,10 +13,12 @@ COPY hbase-site.xml hbase-site.xml COPY hbase-env.sh hbase-env.sh COPY /build/scripts/initialize-hbase.sh /usr/local/bin/ COPY /build/scripts/check-table.sh /usr/local/bin/ +COPY /build/scripts/configure-hbase.sh /usr/local/bin RUN apt-get update && apt-get install --no-install-recommends -y curl && apt-get clean \ && chmod a+x /usr/local/bin/initialize-hbase.sh \ && chmod a+x /usr/local/bin/check-table.sh \ + && chmod a+x /usr/local/bin/configure-hbase.sh \ && mkdir -p ${BASE_DIR} \ && cd ${BASE_DIR} \ && curl -fSL "${HBASE_REPOSITORY}/${HBASE_VERSION}/hbase-${HBASE_VERSION}-bin.tar.gz" -o hbase.tar.gz || curl -fSL "${HBASE_SUB_REPOSITORY}/${HBASE_VERSION}/hbase-${HBASE_VERSION}-bin.tar.gz" -o hbase.tar.gz \ diff --git a/pinpoint-hbase/build/scripts/check-table.sh b/pinpoint-hbase/build/scripts/check-table.sh index dde43f7..aa31b4c 100644 --- a/pinpoint-hbase/build/scripts/check-table.sh +++ b/pinpoint-hbase/build/scripts/check-table.sh @@ -3,8 +3,10 @@ if echo -e "exists 'HostApplicationMap_Ver2'" | ${HBASE_HOME}/bin/hbase shell 2>&1 | grep -q "does exist" 2>/dev/null then echo "Tables already exist" + sleep 15 + ${HBASE_HOME}/bin/hbase shell ${BASE_DIR}/hbase-update-ttl.hbase else - sleep 15 + sleep 15 echo "create tables" ${HBASE_HOME}/bin/hbase shell ${BASE_DIR}/hbase-create.hbase fi \ No newline at end of file diff --git a/pinpoint-hbase/build/scripts/configure-hbase.sh b/pinpoint-hbase/build/scripts/configure-hbase.sh new file mode 100644 index 0000000..a97d0ca --- /dev/null +++ b/pinpoint-hbase/build/scripts/configure-hbase.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e +set -x +cp ${BASE_DIR}/hbase-create.hbase ${BASE_DIR}/hbase-update-ttl.hbase + +sed -i "/AgentInfo/s/TTL => .[[:digit:]]*/TTL => ${AGENTINFO_TTL:-31536000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/AgentStatV2/s/TTL => .[[:digit:]]*/TTL => ${AGENTSTATV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/ApplicationStatAggre/s/TTL => .[[:digit:]]*/TTL => ${APPSTATAGGRE_TTL:-5184000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/ApplicationIndex/s/TTL => .[[:digit:]]*/TTL => ${APPINDEX_TTL:-31536000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/AgentLifeCycle/s/TTL => .[[:digit:]]*/TTL => ${AGENTLIFECYCLE_TTL:-5184000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/AgentEvent/s/TTL => .[[:digit:]]*/TTL => ${AGENTEVENT_TTL:-5184000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/StringMetaData/s/TTL => .[[:digit:]]*/TTL => ${STRINGMETADATA_TTL:-15552000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/ApiMetaData/s/TTL => .[[:digit:]]*/TTL => ${APIMETADATA_TTL:-31536000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/SqlMetaData_Ver2/s/TTL => .[[:digit:]]*/TTL => ${SQLMETADATA_TTL:-15552000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/TraceV2/s/TTL => .[[:digit:]]*/TTL => ${TRACEV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/ApplicationTraceIndex/s/TTL => .[[:digit:]]*/TTL => ${APPTRACEINDEX_TTL:-5184000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/ApplicationMapStatisticsCaller_Ver2/s/TTL => .[[:digit:]]*/TTL => ${APPMAPSTATCALLERV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/ApplicationMapStatisticsCallee_Ver2/s/TTL => .[[:digit:]]*/TTL => ${APPMAPSTATCALLEV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/ApplicationMapStatisticsSelf_Ver2/s/TTL => .[[:digit:]]*/TTL => ${APPMAPSTATSELFV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-create.hbase +sed -i "/HostApplicationMap_Ver2/s/TTL => .[[:digit:]]*/TTL => ${HOSTAPPMAPV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-create.hbase + +sed -i "s/create/alter/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/AgentInfo/s/TTL => .[[:digit:]]*/TTL => ${AGENTINFO_TTL:-31536000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/AgentStatV2/s/TTL => .[[:digit:]]*/TTL => ${AGENTSTATV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/ApplicationStatAggre/s/TTL => .[[:digit:]]*/TTL => ${APPSTATAGGRE_TTL:-5184000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/ApplicationIndex/s/TTL => .[[:digit:]]*/TTL => ${APPINDEX_TTL:-31536000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/AgentLifeCycle/s/TTL => .[[:digit:]]*/TTL => ${AGENTLIFECYCLE_TTL:-5184000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/AgentEvent/s/TTL => .[[:digit:]]*/TTL => ${AGENTEVENT_TTL:-5184000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/StringMetaData/s/TTL => .[[:digit:]]*/TTL => ${STRINGMETADATA_TTL:-15552000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/ApiMetaData/s/TTL => .[[:digit:]]*/TTL => ${APIMETADATA_TTL:-31536000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/SqlMetaData_Ver2/s/TTL => .[[:digit:]]*/TTL => ${SQLMETADATA_TTL:-15552000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/TraceV2/s/TTL => .[[:digit:]]*/TTL => ${TRACEV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/ApplicationTraceIndex/s/TTL => .[[:digit:]]*/TTL => ${APPTRACEINDEX_TTL:-5184000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/ApplicationMapStatisticsCaller_Ver2/s/TTL => .[[:digit:]]*/TTL => ${APPMAPSTATCALLERV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/ApplicationMapStatisticsCallee_Ver2/s/TTL => .[[:digit:]]*/TTL => ${APPMAPSTATCALLEV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/ApplicationMapStatisticsSelf_Ver2/s/TTL => .[[:digit:]]*/TTL => ${APPMAPSTATSELFV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-update-ttl.hbase +sed -i "/HostApplicationMap_Ver2/s/TTL => .[[:digit:]]*/TTL => ${HOSTAPPMAPV2_TTL:-5184000}/g" ${BASE_DIR}/hbase-update-ttl.hbase + +exec "$@" diff --git a/pinpoint-hbase/build/scripts/initialize-hbase.sh b/pinpoint-hbase/build/scripts/initialize-hbase.sh index ca72ffd..7b7cd38 100644 --- a/pinpoint-hbase/build/scripts/initialize-hbase.sh +++ b/pinpoint-hbase/build/scripts/initialize-hbase.sh @@ -2,4 +2,5 @@ ${HBASE_HOME}/bin/start-hbase.sh +/usr/local/bin/configure-hbase.sh /usr/local/bin/check-table.sh \ No newline at end of file