From 34a5c2d8db61c1daecf7e10844075f697cafd736 Mon Sep 17 00:00:00 2001 From: Bond Date: Tue, 12 Mar 2024 18:27:22 +0800 Subject: [PATCH 01/12] Added the Open-Telemetry support. --- .../docker/conf/grafana-datasources.yaml | 30 ++++++++++ .../docker/conf/prometheus.yaml | 11 ++++ .../hugegraph-dist/docker/conf/tempo.yaml | 42 ++++++++++++++ .../docker/example/docker-compose-trace.yaml | 56 +++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 hugegraph-server/hugegraph-dist/docker/conf/grafana-datasources.yaml create mode 100644 hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml create mode 100644 hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml create mode 100644 hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml diff --git a/hugegraph-server/hugegraph-dist/docker/conf/grafana-datasources.yaml b/hugegraph-server/hugegraph-dist/docker/conf/grafana-datasources.yaml new file mode 100644 index 0000000000..4a3bc2c4e7 --- /dev/null +++ b/hugegraph-server/hugegraph-dist/docker/conf/grafana-datasources.yaml @@ -0,0 +1,30 @@ +apiVersion: 1 + +datasources: +- name: Prometheus + type: prometheus + uid: prometheus + access: proxy + orgId: 1 + url: http://prometheus:9090 + basicAuth: false + isDefault: false + version: 1 + editable: false + jsonData: + httpMethod: GET +- name: Tempo + type: tempo + access: proxy + orgId: 1 + url: http://tempo:3200 + basicAuth: false + isDefault: true + version: 1 + editable: false + apiVersion: 1 + uid: tempo + jsonData: + httpMethod: GET + serviceMap: + datasourceUid: prometheus diff --git a/hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml b/hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml new file mode 100644 index 0000000000..2ac68598ac --- /dev/null +++ b/hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml @@ -0,0 +1,11 @@ +global: + scrape_interval: 15s + evaluation_interval: 15s + +scrape_configs: + - job_name: 'prometheus' + static_configs: + - targets: [ 'localhost:9090' ] + - job_name: 'tempo' + static_configs: + - targets: [ 'tempo:3200' ] \ No newline at end of file diff --git a/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml b/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml new file mode 100644 index 0000000000..a4b428bf19 --- /dev/null +++ b/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml @@ -0,0 +1,42 @@ +stream_over_http_enabled: true +server: + http_listen_port: 3200 + log_level: info + +distributor: + otlp: + protocols: + http: + grpc: + opencensus: + +ingester: + max_block_duration: 5m # cut the headblock when this much time passes. this is being set for demo purposes and should probably be left alone normally + +compactor: + compaction: + block_retention: 1h # overall Tempo trace retention. set for demo purposes + +metrics_generator: + registry: + external_labels: + source: tempo + cluster: docker-compose + storage: + path: /tmp/tempo/generator/wal + remote_write: + - url: http://prometheus:9090/api/v1/write + send_exemplars: true + +storage: + trace: + backend: local # backend configuration to use + wal: + path: /tmp/tempo/wal # where to store the the wal locally + local: + path: /tmp/tempo/blocks + +overrides: + defaults: + metrics_generator: + processors: [service-graphs, span-metrics] # enables metrics generator diff --git a/hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml b/hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml new file mode 100644 index 0000000000..92f59b0731 --- /dev/null +++ b/hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml @@ -0,0 +1,56 @@ +# +# 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. +# + +version: "3" + +services: + tempo: + image: grafana/tempo:latest + command: [ "-config.file=/etc/tempo.yaml" ] + volumes: + - ../conf/tempo.yaml:/etc/tempo.yaml + - ../data/tempo:/tmp/tempo + ports: + - "3200:3200" # tempo + - "9095:9095" # tempo grpc + - "4317:4317" # otlp grpc + - "4318:4318" # otlp http + + prometheus: + image: prom/prometheus:latest + command: + - --config.file=/etc/prometheus.yaml + - --web.enable-remote-write-receiver + - --enable-feature=exemplar-storage + - --storage.tsdb.path=/tmp/data + volumes: + - ../conf/prometheus.yaml:/etc/prometheus.yaml + - ../data/prometheus:/tmp/data + ports: + - "9090:9090" + + grafana: + image: grafana/grafana:10.2.2 + volumes: + - ../conf/grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml + environment: + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin + - GF_AUTH_DISABLE_LOGIN_FORM=true + - GF_FEATURE_TOGGLES_ENABLE=traceqlEditor traceQLStreaming metricsSummary + ports: + - "3000:3000" From 58b49434d994617b69c3e844e2f8ce2b643f6a35 Mon Sep 17 00:00:00 2001 From: Bond Date: Tue, 12 Mar 2024 18:29:26 +0800 Subject: [PATCH 02/12] Added the Open-Telemetry support. --- .gitignore | 3 ++ .../hugegraph-dist/docker/README.md | 27 ++++++++++++++++++ .../docker/conf/grafana-datasources.yaml | 17 +++++++++++ .../docker/conf/prometheus.yaml | 17 +++++++++++ .../hugegraph-dist/docker/conf/tempo.yaml | 28 ++++++++++++++----- .../assembly/static/bin/start-hugegraph.sh | 25 ++++++++++++++++- .../src/assembly/static/bin/util.sh | 2 +- 7 files changed, 110 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 47bbf40170..a2292f1984 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,6 @@ hs_err_pid* .mtj.tmp/ # blueJ files *.ctxt + +# docker volumes ignore +hugegraph-server/hugegraph-dist/docker/data/ \ No newline at end of file diff --git a/hugegraph-server/hugegraph-dist/docker/README.md b/hugegraph-server/hugegraph-dist/docker/README.md index c47d66f8a7..53daedf1a3 100644 --- a/hugegraph-server/hugegraph-dist/docker/README.md +++ b/hugegraph-server/hugegraph-dist/docker/README.md @@ -81,3 +81,30 @@ If you want to customize the pre-loaded data, please mount the the groovy script - AUTH=true - PASSWORD=123456 ``` +## 4. Running Open-Telemetry-Collector + +1. Start Open-Telemetry-Collector + + ``` + cd hugegraph-server/hugegraph-dist/docker/example + docker-compose -f docker-compose-trace.yaml -p hugegraph-trace up -d + ``` + +2. Active Open-Telemetry-Agent + + ``` + ./start-hugegraph.sh -y true + ``` + +3. Stop Open-Telemetry-Collector + + ``` + cd hugegraph-server/hugegraph-dist/docker/example + docker-compose -f docker-compose-trace.yaml -p hugegraph-trace stop + ``` + +4. References + + - [What is OpenTelemetry](https://opentelemetry.io/docs/what-is-opentelemetry/) + + - [Tempo in Grafana](https://grafana.com/docs/tempo/latest/getting-started/tempo-in-grafana/) \ No newline at end of file diff --git a/hugegraph-server/hugegraph-dist/docker/conf/grafana-datasources.yaml b/hugegraph-server/hugegraph-dist/docker/conf/grafana-datasources.yaml index 4a3bc2c4e7..7154272102 100644 --- a/hugegraph-server/hugegraph-dist/docker/conf/grafana-datasources.yaml +++ b/hugegraph-server/hugegraph-dist/docker/conf/grafana-datasources.yaml @@ -1,3 +1,20 @@ +# +# 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. +# + apiVersion: 1 datasources: diff --git a/hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml b/hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml index 2ac68598ac..ae9cbabad2 100644 --- a/hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml +++ b/hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml @@ -1,3 +1,20 @@ +# +# 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. +# + global: scrape_interval: 15s evaluation_interval: 15s diff --git a/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml b/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml index a4b428bf19..bb10b4e03c 100644 --- a/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml +++ b/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml @@ -1,27 +1,41 @@ +# +# 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. +# + stream_over_http_enabled: true server: http_listen_port: 3200 log_level: info distributor: + receivers: otlp: protocols: http: grpc: - opencensus: - -ingester: - max_block_duration: 5m # cut the headblock when this much time passes. this is being set for demo purposes and should probably be left alone normally compactor: compaction: - block_retention: 1h # overall Tempo trace retention. set for demo purposes + block_retention: 48h # configure total trace retention here metrics_generator: registry: external_labels: source: tempo - cluster: docker-compose + storage: path: /tmp/tempo/generator/wal remote_write: @@ -39,4 +53,4 @@ storage: overrides: defaults: metrics_generator: - processors: [service-graphs, span-metrics] # enables metrics generator + processors: [ service-graphs, span-metrics ] # enables metrics generator \ No newline at end of file diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh index c2e861a1f8..62bfdc18cb 100644 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh @@ -17,6 +17,7 @@ # OPEN_MONITOR="false" OPEN_SECURITY_CHECK="true" +OPEN_TELEMETRY="false" DAEMON="true" #VERBOSE="" GC_OPTION="" @@ -37,12 +38,13 @@ BIN=$(abs_path) TOP="$(cd "$BIN"/../ && pwd)" CONF="$TOP/conf" LOGS="$TOP/logs" +PLUGINS="$TOP/plugins" SCRIPTS="$TOP/scripts" PID_FILE="$BIN/pid" . "$BIN"/util.sh -while getopts "d:g:m:p:s:j:t:v" arg; do +while getopts "d:g:m:p:s:j:t:v:y:" arg; do case ${arg} in d) DAEMON="$OPTARG" ;; g) GC_OPTION="$OPTARG" ;; @@ -53,6 +55,7 @@ while getopts "d:g:m:p:s:j:t:v" arg; do t) SERVER_STARTUP_TIMEOUT_S="$OPTARG" ;; # TODO: should remove it in future (check the usage carefully) v) VERBOSE="verbose" ;; + y) OPEN_TELEMETRY="$OPTARG";; # Note: update usage info when the params changed ?) exit_with_usage_help ;; esac @@ -79,6 +82,26 @@ if [ ! -d "$LOGS" ]; then mkdir -p "$LOGS" fi +ensure_path_writable "$PLUGINS" + +if [ "${OPEN_TELEMETRY}" == "true" ]; then + if [[ ! -e "${PLUGINS}/opentelemetry-javaagent.jar" ]]; then + echo "Downloading opentelemetry-javaagent.jar..." + download "${PLUGINS}" "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.1.0/opentelemetry-javaagent.jar" + fi + + export JAVA_TOOL_OPTIONS="-javaagent:${PLUGINS}/opentelemetry-javaagent.jar" + export OTEL_TRACES_EXPORTER=otlp + export OTEL_METRICS_EXPORTER=none + export OTEL_LOGS_EXPORTER=none + export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc + # 127.0.0.1:4317 is the port of otel-collector running in Docker located in + # 'hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml'. + # Make sure the otel-collector is running before starting HugeGraphServer. + export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:4317 + export OTEL_RESOURCE_ATTRIBUTES=service.name=server +fi + GREMLIN_SERVER_CONF="gremlin-server.yaml" if [[ $PRELOAD == "true" ]]; then GREMLIN_SERVER_CONF="gremlin-server-preload.yaml" diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh index 70baed7ca6..c4e12ee7fd 100755 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh @@ -385,6 +385,6 @@ function kill_process_and_wait() { } function exit_with_usage_help(){ - echo "USAGE: $0 [-d true|false] [-g g1] [-m true|false] [-p true|false] [-s true|false] [-j java_options] [-t timeout]" + echo "USAGE: $0 [-d true|false] [-g g1] [-m true|false] [-p true|false] [-s true|false] [-j java_options] [-t timeout] [-y true|false]" exit 1 } From 98ae1d369fab4d3007578166f49cbd021f047724 Mon Sep 17 00:00:00 2001 From: imbajin Date: Wed, 13 Mar 2024 15:32:57 +0800 Subject: [PATCH 03/12] refactor usage & some typo --- .gitignore | 2 +- .../hugegraph-dist/docker/README.md | 16 +++--- .../docker/conf/prometheus.yaml | 2 +- .../hugegraph-dist/docker/conf/tempo.yaml | 2 +- .../docker/example/docker-compose-trace.yaml | 2 +- .../assembly/static/bin/hugegraph-server.sh | 50 +++++++++++++------ .../assembly/static/bin/start-hugegraph.sh | 47 ++++++----------- .../src/assembly/static/bin/util.sh | 1 + 8 files changed, 62 insertions(+), 60 deletions(-) diff --git a/.gitignore b/.gitignore index a2292f1984..b3afdfd551 100644 --- a/.gitignore +++ b/.gitignore @@ -85,4 +85,4 @@ hs_err_pid* *.ctxt # docker volumes ignore -hugegraph-server/hugegraph-dist/docker/data/ \ No newline at end of file +hugegraph-server/hugegraph-dist/docker/data/ diff --git a/hugegraph-server/hugegraph-dist/docker/README.md b/hugegraph-server/hugegraph-dist/docker/README.md index 53daedf1a3..8e3d81a695 100644 --- a/hugegraph-server/hugegraph-dist/docker/README.md +++ b/hugegraph-server/hugegraph-dist/docker/README.md @@ -4,7 +4,7 @@ > > 1. The docker image of hugegraph is a convenience release, not official distribution artifacts from ASF. You can find more details from [ASF Release Distribution Policy](https://infra.apache.org/release-distribution.html#dockerhub). > -> 2. Recommand to use `release tag`(like `1.2.0`) for the stable version. Use `latest` tag to experience the newest functions in development. +> 2. Recommend to use `release tag`(like `1.2.0`) for the stable version. Use `latest` tag to experience the newest functions in development. ## 1. Deploy @@ -29,9 +29,9 @@ We can use docker to quickly start an inner HugeGraph server with RocksDB in bac ## 2. Create Sample Graph on Server Startup -If you want to **pre-load** some (test) data or graphs in container(by default), you can set the env `PRELOAD=ture` +If you want to **preload** some (test) data or graphs in container(by default), you can set the env `PRELOAD=ture` -If you want to customize the pre-loaded data, please mount the the groovy scripts (not necessary). +If you want to customize the preloaded data, please mount the groovy scripts (not necessary). 1. Using docker run @@ -67,7 +67,7 @@ If you want to customize the pre-loaded data, please mount the the groovy script 2. Using docker compose - Similarly, we can set the envionment variables in the docker-compose.yaml: + Similarly, we can set the environment variables in the docker-compose.yaml: ```yaml version: '3' @@ -85,20 +85,20 @@ If you want to customize the pre-loaded data, please mount the the groovy script 1. Start Open-Telemetry-Collector - ``` + ```bash cd hugegraph-server/hugegraph-dist/docker/example docker-compose -f docker-compose-trace.yaml -p hugegraph-trace up -d ``` 2. Active Open-Telemetry-Agent - ``` + ```bash ./start-hugegraph.sh -y true ``` 3. Stop Open-Telemetry-Collector - ``` + ```bash cd hugegraph-server/hugegraph-dist/docker/example docker-compose -f docker-compose-trace.yaml -p hugegraph-trace stop ``` @@ -107,4 +107,4 @@ If you want to customize the pre-loaded data, please mount the the groovy script - [What is OpenTelemetry](https://opentelemetry.io/docs/what-is-opentelemetry/) - - [Tempo in Grafana](https://grafana.com/docs/tempo/latest/getting-started/tempo-in-grafana/) \ No newline at end of file + - [Tempo in Grafana](https://grafana.com/docs/tempo/latest/getting-started/tempo-in-grafana/) diff --git a/hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml b/hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml index ae9cbabad2..1d935126a7 100644 --- a/hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml +++ b/hugegraph-server/hugegraph-dist/docker/conf/prometheus.yaml @@ -25,4 +25,4 @@ scrape_configs: - targets: [ 'localhost:9090' ] - job_name: 'tempo' static_configs: - - targets: [ 'tempo:3200' ] \ No newline at end of file + - targets: [ 'tempo:3200' ] diff --git a/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml b/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml index bb10b4e03c..90be8ac53d 100644 --- a/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml +++ b/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml @@ -53,4 +53,4 @@ storage: overrides: defaults: metrics_generator: - processors: [ service-graphs, span-metrics ] # enables metrics generator \ No newline at end of file + processors: [ service-graphs, span-metrics ] # enables metrics generator diff --git a/hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml b/hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml index 92f59b0731..eee6fa49de 100644 --- a/hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml +++ b/hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml @@ -20,7 +20,7 @@ version: "3" services: tempo: image: grafana/tempo:latest - command: [ "-config.file=/etc/tempo.yaml" ] + command: ["-config.file=/etc/tempo.yaml"] volumes: - ../conf/tempo.yaml:/etc/tempo.yaml - ../data/tempo:/tmp/tempo diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh index 4a08e4b8ee..c89f8ec5d0 100644 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh @@ -15,6 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + function abs_path() { SOURCE="${BASH_SOURCE[0]}" while [[ -h "$SOURCE" ]]; do @@ -39,24 +40,20 @@ EXT="$TOP/ext" PLUGINS="$TOP/plugins" LOGS="$TOP/logs" OUTPUT=${LOGS}/hugegraph-server.log +GITHUB="https://github.com" export HUGEGRAPH_HOME="$TOP" . "${BIN}"/util.sh -GREMLIN_SERVER_CONF="$1" -REST_SERVER_CONF="$2" -OPEN_SECURITY_CHECK="$3" - -if [[ $# -eq 3 ]]; then - USER_OPTION="" - GC_OPTION="" -elif [[ $# -eq 4 ]]; then - USER_OPTION="$4" - GC_OPTION="" -elif [[ $# -eq 5 ]]; then - USER_OPTION="$4" - GC_OPTION="$5" -fi +# Parse the server arguments in array way +SERVER_ARGS=("$@") +GREMLIN_SERVER_CONF="${SERVER_ARGS[0]:-}" +REST_SERVER_CONF="${SERVER_ARGS[1]:-}" +OPEN_SECURITY_CHECK="${SERVER_ARGS[2]:-}" +# Param will be empty str("") if not set +USER_OPTION="${SERVER_ARGS[3]:-}" +GC_OPTION="${SERVER_ARGS[4]:-}" +OPEN_TELEMETRY="${SERVER_ARGS[5]:-}" ensure_path_writable "$LOGS" ensure_path_writable "$PLUGINS" @@ -64,11 +61,32 @@ ensure_path_writable "$PLUGINS" # The maximum and minimum heap memory that service can use MAX_MEM=$((32 * 1024)) MIN_MEM=$((1 * 512)) +# TODO: upgrade to Java 11 in 1.5.0 MIN_JAVA_VERSION=8 -# download binary file +# Note: Download for HTTPS, could comment out if you don't need it if [[ ! -e "${CONF}/hugegraph-server.keystore" ]]; then - download "${CONF}" "https://github.com/apache/hugegraph-doc/raw/binary-1.0/dist/server/hugegraph-server.keystore" + download "${CONF}" "${GITHUB}/apache/hugegraph-doc/raw/binary-1.0/dist/server/hugegraph-server.keystore" +fi + +if [ "${OPEN_TELEMETRY}" == "true" ]; then + OT_JAR="opentelemetry-javaagent.jar" + if [[ ! -e "${PLUGINS}/${OT_JAR}" ]]; then + echo "Downloading ${OT_JAR}..." + download "${PLUGINS}" \ + "${GITHUB}/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.1.0/${OT_JAR}" + fi + + export JAVA_TOOL_OPTIONS="-javaagent:${PLUGINS}/${OT_JAR}" + export OTEL_TRACES_EXPORTER=otlp + export OTEL_METRICS_EXPORTER=none + export OTEL_LOGS_EXPORTER=none + export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc + # 127.0.0.1:4317 is the port of otel-collector running in Docker located in + # 'hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml'. + # Make sure the otel-collector is running before starting HugeGraphServer. + export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:4317 + export OTEL_RESOURCE_ATTRIBUTES=service.name=server fi # Add the slf4j-log4j12 binding diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh index 62bfdc18cb..f047606b89 100644 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh @@ -15,15 +15,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # + OPEN_MONITOR="false" OPEN_SECURITY_CHECK="true" +# change to "true" to enable telemetry(Trace) by default OPEN_TELEMETRY="false" DAEMON="true" #VERBOSE="" GC_OPTION="" USER_OPTION="" SERVER_STARTUP_TIMEOUT_S=30 -# todo: move abs_path funtion to shell like util.sh + +# TODO: move abs_path function to shell like util.sh function abs_path() { SOURCE="${BASH_SOURCE[0]}" while [[ -h "$SOURCE" ]]; do @@ -38,13 +41,12 @@ BIN=$(abs_path) TOP="$(cd "$BIN"/../ && pwd)" CONF="$TOP/conf" LOGS="$TOP/logs" -PLUGINS="$TOP/plugins" SCRIPTS="$TOP/scripts" PID_FILE="$BIN/pid" . "$BIN"/util.sh -while getopts "d:g:m:p:s:j:t:v:y:" arg; do +while getopts "d:g:m:p:s:j:t:y" arg; do case ${arg} in d) DAEMON="$OPTARG" ;; g) GC_OPTION="$OPTARG" ;; @@ -53,9 +55,8 @@ while getopts "d:g:m:p:s:j:t:v:y:" arg; do s) OPEN_SECURITY_CHECK="$OPTARG" ;; j) USER_OPTION="$OPTARG" ;; t) SERVER_STARTUP_TIMEOUT_S="$OPTARG" ;; - # TODO: should remove it in future (check the usage carefully) - v) VERBOSE="verbose" ;; - y) OPEN_TELEMETRY="$OPTARG";; + # Telemetry is used to collect metrics, traces and logs + y) OPEN_TELEMETRY="$OPTARG" ;; # Note: update usage info when the params changed ?) exit_with_usage_help ;; esac @@ -82,44 +83,26 @@ if [ ! -d "$LOGS" ]; then mkdir -p "$LOGS" fi -ensure_path_writable "$PLUGINS" - -if [ "${OPEN_TELEMETRY}" == "true" ]; then - if [[ ! -e "${PLUGINS}/opentelemetry-javaagent.jar" ]]; then - echo "Downloading opentelemetry-javaagent.jar..." - download "${PLUGINS}" "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.1.0/opentelemetry-javaagent.jar" - fi - - export JAVA_TOOL_OPTIONS="-javaagent:${PLUGINS}/opentelemetry-javaagent.jar" - export OTEL_TRACES_EXPORTER=otlp - export OTEL_METRICS_EXPORTER=none - export OTEL_LOGS_EXPORTER=none - export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc - # 127.0.0.1:4317 is the port of otel-collector running in Docker located in - # 'hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml'. - # Make sure the otel-collector is running before starting HugeGraphServer. - export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:4317 - export OTEL_RESOURCE_ATTRIBUTES=service.name=server -fi - GREMLIN_SERVER_CONF="gremlin-server.yaml" if [[ $PRELOAD == "true" ]]; then GREMLIN_SERVER_CONF="gremlin-server-preload.yaml" - EXAMPLE_SCRPIT="example-preload.groovy" + EXAMPLE_SCRIPT="example-preload.groovy" cp "${CONF}"/gremlin-server.yaml "${CONF}/${GREMLIN_SERVER_CONF}" - cp "${SCRIPTS}"/example.groovy "${SCRIPTS}/${EXAMPLE_SCRPIT}" - sed -i -e "s/empty-sample.groovy/$EXAMPLE_SCRPIT/g" "${CONF}/${GREMLIN_SERVER_CONF}" - sed -i -e '/registerRocksDB/d; /serverStarted/d' "${SCRIPTS}/${EXAMPLE_SCRPIT}" + cp "${SCRIPTS}"/example.groovy "${SCRIPTS}/${EXAMPLE_SCRIPT}" + sed -i -e "s/empty-sample.groovy/$EXAMPLE_SCRIPT/g" "${CONF}/${GREMLIN_SERVER_CONF}" + sed -i -e '/registerRocksDB/d; /serverStarted/d' "${SCRIPTS}/${EXAMPLE_SCRIPT}" fi if [[ $DAEMON == "true" ]]; then echo "Starting HugeGraphServer in daemon mode..." "${BIN}"/hugegraph-server.sh "${CONF}/${GREMLIN_SERVER_CONF}" "${CONF}"/rest-server.properties \ - "${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" >>"${LOGS}"/hugegraph-server.log 2>&1 & + "${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" "${OPEN_TELEMETRY}" \ + >>"${LOGS}"/hugegraph-server.log 2>&1 & else echo "Starting HugeGraphServer in foreground mode..." "${BIN}"/hugegraph-server.sh "${CONF}/${GREMLIN_SERVER_CONF}" "${CONF}"/rest-server.properties \ - "${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" >>"${LOGS}"/hugegraph-server.log 2>&1 + "${OPEN_SECURITY_CHECK}" "${USER_OPTION}" "${GC_OPTION}" "${OPEN_TELEMETRY}" \ + >>"${LOGS}"/hugegraph-server.log 2>&1 fi PID="$!" diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh index c4e12ee7fd..11979b6481 100755 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh @@ -15,6 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # + function command_available() { local cmd=$1 if [[ -x "$(command -v "$cmd")" ]]; then From 888800e9c896f3cd9c629a5d8a8a84301322e7b8 Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 13 Mar 2024 15:59:58 +0800 Subject: [PATCH 04/12] fix: remove -v in start-server.sh --- .../hugegraph-dist/src/assembly/travis/start-server.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-server/hugegraph-dist/src/assembly/travis/start-server.sh b/hugegraph-server/hugegraph-dist/src/assembly/travis/start-server.sh index 40b4e63f13..f92a7ff2fc 100755 --- a/hugegraph-server/hugegraph-dist/src/assembly/travis/start-server.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/travis/start-server.sh @@ -70,4 +70,4 @@ if [ -n "$JACOCO_PORT" ]; then JACOCO_OPTION="-javaagent:${JACOCO_JAR}=includes=*,port=${JACOCO_PORT},destfile=jacoco-it.exec,output=tcpserver" fi -echo -e "pa" | $BIN/init-store.sh && $BIN/start-hugegraph.sh -j "$JACOCO_OPTION" -t 60 -v +echo -e "pa" | $BIN/init-store.sh && $BIN/start-hugegraph.sh -j "$JACOCO_OPTION" -t 60 From 96774dfcfdf160894b5dc9f4347c57585e9b4ec7 Mon Sep 17 00:00:00 2001 From: imbajin Date: Wed, 13 Mar 2024 16:05:40 +0800 Subject: [PATCH 05/12] fix useless "-v" bug --- README.md | 6 ++++-- hugegraph-server/hugegraph-dist/docker/README.md | 2 +- hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml | 2 +- .../hugegraph-dist/src/assembly/travis/start-server.sh | 5 +++-- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9ad381f1fe..64c86a02bd 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,9 @@ ## What is Apache HugeGraph? [HugeGraph](https://hugegraph.apache.org/) is a fast-speed and highly-scalable [graph database](https://en.wikipedia.org/wiki/Graph_database). -Billions of vertices and edges can be easily stored into and queried from HugeGraph due to its excellent OLTP ability. As compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/) framework, various complicated graph queries can be accomplished through [Gremlin](https://tinkerpop.apache.org/gremlin.html)(a powerful graph traversal language). +Billions of vertices and edges can be easily stored into and queried from HugeGraph due to its excellent OLTP ability. +As compliance to [Apache TinkerPop 3](https://tinkerpop.apache.org/) framework, various complicated graph queries can be +achieved through [Gremlin](https://tinkerpop.apache.org/gremlin.html)(a powerful graph traversal language). ## Features @@ -40,7 +42,7 @@ You can visit [doc page](https://hugegraph.apache.org/docs/quickstart/hugegraph- > > 1. The docker image of hugegraph is a convenience release, but not **official distribution** artifacts. You can find more details from [ASF Release Distribution Policy](https://infra.apache.org/release-distribution.html#dockerhub). > -> 2. Recommand to use `release tag`(like `1.2.0`) for the stable version. Use `latest` tag to experience the newest functions in development. +> 2. Recommend to use `release tag`(like `1.2.0`) for the stable version. Use `latest` tag to experience the newest functions in development. ### 2. Download Way diff --git a/hugegraph-server/hugegraph-dist/docker/README.md b/hugegraph-server/hugegraph-dist/docker/README.md index 8e3d81a695..6aaa73c860 100644 --- a/hugegraph-server/hugegraph-dist/docker/README.md +++ b/hugegraph-server/hugegraph-dist/docker/README.md @@ -8,7 +8,7 @@ ## 1. Deploy -We can use docker to quickly start an inner HugeGraph server with RocksDB in background. +We can use docker to quickly start an inner HugeGraph server with RocksDB in the background. 1. Using docker run diff --git a/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml b/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml index 90be8ac53d..433ee3c064 100644 --- a/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml +++ b/hugegraph-server/hugegraph-dist/docker/conf/tempo.yaml @@ -46,7 +46,7 @@ storage: trace: backend: local # backend configuration to use wal: - path: /tmp/tempo/wal # where to store the the wal locally + path: /tmp/tempo/wal # where to store the wal locally local: path: /tmp/tempo/blocks diff --git a/hugegraph-server/hugegraph-dist/src/assembly/travis/start-server.sh b/hugegraph-server/hugegraph-dist/src/assembly/travis/start-server.sh index 40b4e63f13..22af1ae330 100755 --- a/hugegraph-server/hugegraph-dist/src/assembly/travis/start-server.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/travis/start-server.sh @@ -47,7 +47,7 @@ SERIALIZER=${backend_serializer_map[$BACKEND]} sed -i "s/backend=.*/backend=$BACKEND/" $CONF sed -i "s/serializer=.*/serializer=$SERIALIZER/" $CONF -# Set PostgreSQL configurations if needed +# Set PostgresSQL configurations if needed if [ "$BACKEND" == "postgresql" ]; then sed -i '/org.postgresql.Driver/,+2 s/\#//g' $CONF fi @@ -70,4 +70,5 @@ if [ -n "$JACOCO_PORT" ]; then JACOCO_OPTION="-javaagent:${JACOCO_JAR}=includes=*,port=${JACOCO_PORT},destfile=jacoco-it.exec,output=tcpserver" fi -echo -e "pa" | $BIN/init-store.sh && $BIN/start-hugegraph.sh -j "$JACOCO_OPTION" -t 60 -v +echo -e "pa" | $BIN/init-store.sh +$BIN/start-hugegraph.sh -j "$JACOCO_OPTION" -t 60 From 9881eba914c69aae0c027ac13d357dbcd8d2c69a Mon Sep 17 00:00:00 2001 From: VGalaxies Date: Wed, 13 Mar 2024 17:23:10 +0800 Subject: [PATCH 06/12] fix: add colon for -y param in start-hugegraph.sh --- .../hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh index f047606b89..f2c01f8aff 100644 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh @@ -46,7 +46,7 @@ PID_FILE="$BIN/pid" . "$BIN"/util.sh -while getopts "d:g:m:p:s:j:t:y" arg; do +while getopts "d:g:m:p:s:j:t:y:" arg; do case ${arg} in d) DAEMON="$OPTARG" ;; g) GC_OPTION="$OPTARG" ;; From 81a2f735c2b250131d42a94261ad869783be516f Mon Sep 17 00:00:00 2001 From: imbajin Date: Wed, 13 Mar 2024 17:59:27 +0800 Subject: [PATCH 07/12] change java-agent order TODO: also validate hash for it --- .../assembly/static/bin/hugegraph-server.sh | 43 ++++++++++--------- .../assembly/static/bin/start-hugegraph.sh | 2 + 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh index c89f8ec5d0..42a5a17b15 100644 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh @@ -69,26 +69,6 @@ if [[ ! -e "${CONF}/hugegraph-server.keystore" ]]; then download "${CONF}" "${GITHUB}/apache/hugegraph-doc/raw/binary-1.0/dist/server/hugegraph-server.keystore" fi -if [ "${OPEN_TELEMETRY}" == "true" ]; then - OT_JAR="opentelemetry-javaagent.jar" - if [[ ! -e "${PLUGINS}/${OT_JAR}" ]]; then - echo "Downloading ${OT_JAR}..." - download "${PLUGINS}" \ - "${GITHUB}/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.1.0/${OT_JAR}" - fi - - export JAVA_TOOL_OPTIONS="-javaagent:${PLUGINS}/${OT_JAR}" - export OTEL_TRACES_EXPORTER=otlp - export OTEL_METRICS_EXPORTER=none - export OTEL_LOGS_EXPORTER=none - export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc - # 127.0.0.1:4317 is the port of otel-collector running in Docker located in - # 'hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml'. - # Make sure the otel-collector is running before starting HugeGraphServer. - export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:4317 - export OTEL_RESOURCE_ATTRIBUTES=service.name=server -fi - # Add the slf4j-log4j12 binding CP=$(find -L $LIB -name 'log4j-slf4j-impl*.jar' | sort | tr '\n' ':') # Add the jars in lib that start with "hugegraph" @@ -99,7 +79,7 @@ CP="$CP":$(find -L $LIB -name '*.jar' \ \! -name 'log4j-slf4j-impl*.jar' | sort | tr '\n' ':') # Add the jars in ext (at any subdirectory depth) CP="$CP":$(find -L $EXT -name '*.jar' | sort | tr '\n' ':') -# Add the jars in plugins (at any subdirectory depth) +# Add the jars in plugins (at any subdirectory depth), check "javaagent" related jars carefully CP="$CP":$(find -L $PLUGINS -name '*.jar' | sort | tr '\n' ':') # (Cygwin only) Use ; classpath separator and reformat paths for Windows ("C:\foo") @@ -171,6 +151,27 @@ if [[ ${OPEN_SECURITY_CHECK} == "true" ]]; then JVM_OPTIONS="${JVM_OPTIONS} -Djava.security.manager=org.apache.hugegraph.security.HugeSecurityManager" fi +if [ "${OPEN_TELEMETRY}" == "true" ]; then + OT_JAR="opentelemetry-javaagent.jar" + if [[ ! -e "${PLUGINS}/${OT_JAR}" ]]; then + echo "## Downloading ${OT_JAR}..." + download "${PLUGINS}" \ + "${GITHUB}/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.1.0/${OT_JAR}" + fi + + # Note: check carefully if multi "javeagent" params are set + export JAVA_TOOL_OPTIONS="-javaagent:${PLUGINS}/${OT_JAR}" + export OTEL_TRACES_EXPORTER=otlp + export OTEL_METRICS_EXPORTER=none + export OTEL_LOGS_EXPORTER=none + export OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc + # 127.0.0.1:4317 is the port of otel-collector running in Docker located in + # 'hugegraph-server/hugegraph-dist/docker/example/docker-compose-trace.yaml'. + # Make sure the otel-collector is running before starting HugeGraphServer. + export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:4317 + export OTEL_RESOURCE_ATTRIBUTES=service.name=server +fi + # Turn on security check exec ${JAVA} -Dname="HugeGraphServer" ${JVM_OPTIONS} ${JAVA_OPTIONS} -cp ${CLASSPATH}: \ org.apache.hugegraph.dist.HugeGraphServer ${GREMLIN_SERVER_CONF} ${REST_SERVER_CONF} \ diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh index f2c01f8aff..9cb5d0e099 100644 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/start-hugegraph.sh @@ -46,6 +46,7 @@ PID_FILE="$BIN/pid" . "$BIN"/util.sh +# Note: keep ':' in the end of the string to indicate the option needs a value while getopts "d:g:m:p:s:j:t:y:" arg; do case ${arg} in d) DAEMON="$OPTARG" ;; @@ -93,6 +94,7 @@ if [[ $PRELOAD == "true" ]]; then sed -i -e '/registerRocksDB/d; /serverStarted/d' "${SCRIPTS}/${EXAMPLE_SCRIPT}" fi +# TODO: show the output message in hugegraph-server.sh when start the server if [[ $DAEMON == "true" ]]; then echo "Starting HugeGraphServer in daemon mode..." "${BIN}"/hugegraph-server.sh "${CONF}/${GREMLIN_SERVER_CONF}" "${CONF}"/rest-server.properties \ From 4fca283b99d35f36302db15c6f524a6dd0937c86 Mon Sep 17 00:00:00 2001 From: Bond Date: Thu, 14 Mar 2024 16:31:15 +0800 Subject: [PATCH 08/12] Add an MD5 checksum for the opentelemetry-javaagent.jar file. --- .../assembly/static/bin/hugegraph-server.sh | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh index 42a5a17b15..f7051b527b 100644 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh @@ -128,22 +128,22 @@ fi # mention: zgc is only available on ARM-Mac with java > 13 case "$GC_OPTION" in g1|G1|g1gc) - echo "Using G1GC as the default garbage collector" - JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseG1GC -XX:+ParallelRefProcEnabled \ + echo "Using G1GC as the default garbage collector" + JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseG1GC -XX:+ParallelRefProcEnabled \ -XX:InitiatingHeapOccupancyPercent=50 \ -XX:G1RSetUpdatingPauseTimePercent=5" - ;; + ;; zgc|ZGC) - echo "Using ZGC as the default garbage collector (Only support Java 11+)" - JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseZGC -XX:+UnlockExperimentalVMOptions \ + echo "Using ZGC as the default garbage collector (Only support Java 11+)" + JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseZGC -XX:+UnlockExperimentalVMOptions \ -XX:ConcGCThreads=2 -XX:ParallelGCThreads=6 \ -XX:ZCollectionInterval=120 -XX:ZAllocationSpikeTolerance=5 \ -XX:+UnlockDiagnosticVMOptions -XX:-ZProactive" - ;; - "") ;; - *) + ;; +"") ;; +*) echo "Unrecognized gc option: '$GC_OPTION', only support 'G1/ZGC' now" >> ${OUTPUT} - exit 1 + exit 1 esac JVM_OPTIONS="-Dlog4j.configurationFile=${CONF}/log4j2.xml" @@ -153,10 +153,26 @@ fi if [ "${OPEN_TELEMETRY}" == "true" ]; then OT_JAR="opentelemetry-javaagent.jar" - if [[ ! -e "${PLUGINS}/${OT_JAR}" ]]; then - echo "## Downloading ${OT_JAR}..." - download "${PLUGINS}" \ - "${GITHUB}/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.1.0/${OT_JAR}" + OT_JAR_PATH="${PLUGINS}/${OT_JAR}" + + if [[ ! -e "${OT_JAR_PATH}" ]]; then + echo "## Downloading ${OT_JAR}..." + download "${PLUGINS}" \ + "${GITHUB}/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.1.0/${OT_JAR}" + + if [[ ! -e "${OT_JAR_PATH}" ]]; then + echo "## Error: Failed to download ${OT_JAR}." >>${OUTPUT} + exit 1 + fi + fi + + expected_md5="e3bcbbe8ed9b6d840fa4c333b36f369f" + actual_md5=$(md5sum "${OT_JAR_PATH}" | awk '{print $1}') + + if [[ "${expected_md5}" != "${actual_md5}" ]]; then + echo "## Error: MD5 checksum verification failed for ${OT_JAR_PATH}." >>${OUTPUT} + echo "## Tips: Remove the file and try again." >>${OUTPUT} + exit 1 fi # Note: check carefully if multi "javeagent" params are set From cf0099a2aac38147c14ab5d1fa05f9a5f5038c8b Mon Sep 17 00:00:00 2001 From: Bond Date: Thu, 14 Mar 2024 17:56:12 +0800 Subject: [PATCH 09/12] Added a caution for the AGPL --- hugegraph-server/hugegraph-dist/docker/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hugegraph-server/hugegraph-dist/docker/README.md b/hugegraph-server/hugegraph-dist/docker/README.md index 6aaa73c860..91e7194dea 100644 --- a/hugegraph-server/hugegraph-dist/docker/README.md +++ b/hugegraph-server/hugegraph-dist/docker/README.md @@ -83,6 +83,11 @@ If you want to customize the preloaded data, please mount the groovy scripts (no ``` ## 4. Running Open-Telemetry-Collector +> CAUTION: +> +> The docker-compose-trace.yaml file utilizes Grafana and Grafana-Tempo, both of which are licensed under AGPL-3.0, requiring users to disclose their source code. +> +> [GNU AFFERO GENERAL PUBLIC LICENSE](https://www.gnu.org/licenses/agpl-3.0.en.html) 1. Start Open-Telemetry-Collector ```bash From 5e2261ae4d9fd8905e9c42d762b932fc13bb6b16 Mon Sep 17 00:00:00 2001 From: Bond Date: Thu, 14 Mar 2024 18:09:51 +0800 Subject: [PATCH 10/12] Removed a space. --- hugegraph-server/hugegraph-dist/docker/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-server/hugegraph-dist/docker/README.md b/hugegraph-server/hugegraph-dist/docker/README.md index 91e7194dea..7be060f140 100644 --- a/hugegraph-server/hugegraph-dist/docker/README.md +++ b/hugegraph-server/hugegraph-dist/docker/README.md @@ -85,7 +85,7 @@ If you want to customize the preloaded data, please mount the groovy scripts (no > CAUTION: > -> The docker-compose-trace.yaml file utilizes Grafana and Grafana-Tempo, both of which are licensed under AGPL-3.0, requiring users to disclose their source code. +> The docker-compose-trace.yaml file utilizes Grafana and Grafana-Tempo, both of which are licensed under AGPL-3.0, requiring users to disclose their source code. > > [GNU AFFERO GENERAL PUBLIC LICENSE](https://www.gnu.org/licenses/agpl-3.0.en.html) 1. Start Open-Telemetry-Collector From 0e6cf9ec1420f97e258bcae113cbff8e111c2375 Mon Sep 17 00:00:00 2001 From: imbajin Date: Thu, 14 Mar 2024 18:52:19 +0800 Subject: [PATCH 11/12] Apply suggestions from code review --- hugegraph-server/hugegraph-dist/docker/README.md | 3 +-- .../hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hugegraph-server/hugegraph-dist/docker/README.md b/hugegraph-server/hugegraph-dist/docker/README.md index 7be060f140..47e117168b 100644 --- a/hugegraph-server/hugegraph-dist/docker/README.md +++ b/hugegraph-server/hugegraph-dist/docker/README.md @@ -85,9 +85,8 @@ If you want to customize the preloaded data, please mount the groovy scripts (no > CAUTION: > -> The docker-compose-trace.yaml file utilizes Grafana and Grafana-Tempo, both of which are licensed under AGPL-3.0, requiring users to disclose their source code. +> The `docker-compose-trace.yaml` utilizes `Grafana` and `Grafana-Tempo`, both of them are licensed under [AGPL-3.0](https://www.gnu.org/licenses/agpl-3.0.en.html), you should be aware of and use them with caution. Currently, we mainly provide this template for everyone to **test** > -> [GNU AFFERO GENERAL PUBLIC LICENSE](https://www.gnu.org/licenses/agpl-3.0.en.html) 1. Start Open-Telemetry-Collector ```bash diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh index f7051b527b..6762f1a504 100644 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh @@ -166,6 +166,7 @@ if [ "${OPEN_TELEMETRY}" == "true" ]; then fi fi + # Note: remember update it if we change the jar expected_md5="e3bcbbe8ed9b6d840fa4c333b36f369f" actual_md5=$(md5sum "${OT_JAR_PATH}" | awk '{print $1}') From 530fdf55ab21e6536896099a7e9118ecb36cbd0f Mon Sep 17 00:00:00 2001 From: Bond Date: Thu, 14 Mar 2024 19:26:09 +0800 Subject: [PATCH 12/12] reverted some text format --- .../assembly/static/bin/hugegraph-server.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh index 6762f1a504..de2fdd8da4 100644 --- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh +++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/hugegraph-server.sh @@ -128,22 +128,22 @@ fi # mention: zgc is only available on ARM-Mac with java > 13 case "$GC_OPTION" in g1|G1|g1gc) - echo "Using G1GC as the default garbage collector" - JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseG1GC -XX:+ParallelRefProcEnabled \ + echo "Using G1GC as the default garbage collector" + JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseG1GC -XX:+ParallelRefProcEnabled \ -XX:InitiatingHeapOccupancyPercent=50 \ -XX:G1RSetUpdatingPauseTimePercent=5" - ;; + ;; zgc|ZGC) - echo "Using ZGC as the default garbage collector (Only support Java 11+)" - JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseZGC -XX:+UnlockExperimentalVMOptions \ + echo "Using ZGC as the default garbage collector (Only support Java 11+)" + JAVA_OPTIONS="${JAVA_OPTIONS} -XX:+UseZGC -XX:+UnlockExperimentalVMOptions \ -XX:ConcGCThreads=2 -XX:ParallelGCThreads=6 \ -XX:ZCollectionInterval=120 -XX:ZAllocationSpikeTolerance=5 \ -XX:+UnlockDiagnosticVMOptions -XX:-ZProactive" - ;; -"") ;; -*) + ;; + "") ;; + *) echo "Unrecognized gc option: '$GC_OPTION', only support 'G1/ZGC' now" >> ${OUTPUT} - exit 1 + exit 1 esac JVM_OPTIONS="-Dlog4j.configurationFile=${CONF}/log4j2.xml"