From 9e5f1eebbe573edded254e7d51316de3bb67d7ec Mon Sep 17 00:00:00 2001 From: dandelion Date: Sat, 9 Sep 2023 12:27:16 +0800 Subject: [PATCH 1/8] feat: support Cassandra(Docker) as backend (compose with HugeGraph)(#840) --- .gitignore | 2 + Dockerfile | 5 +- .../example/docker-compose-cassandra.yml | 44 +++++++++++++++ .../assembly/static/bin/docker-entrypoint.sh | 24 ++++++++ .../assembly/static/bin/gremlin-console.sh | 10 +--- .../src/assembly/static/bin/wait-storage.sh | 55 +++++++++++++++++++ .../static/scripts/remote-connect.groovy | 19 +++++++ .../static/scripts/try-storage.groovy | 14 +++++ 8 files changed, 163 insertions(+), 10 deletions(-) create mode 100644 hugegraph-dist/docker/example/docker-compose-cassandra.yml create mode 100644 hugegraph-dist/src/assembly/static/bin/docker-entrypoint.sh create mode 100644 hugegraph-dist/src/assembly/static/bin/wait-storage.sh create mode 100644 hugegraph-dist/src/assembly/static/scripts/remote-connect.groovy create mode 100644 hugegraph-dist/src/assembly/static/scripts/try-storage.groovy diff --git a/.gitignore b/.gitignore index 47bbf40170..9dfe436992 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,5 @@ hs_err_pid* .mtj.tmp/ # blueJ files *.ctxt + +*swagger-ui* diff --git a/Dockerfile b/Dockerfile index e096f3430a..4e11b36e13 100644 --- a/Dockerfile +++ b/Dockerfile @@ -50,11 +50,10 @@ RUN set -x \ # 2. Init HugeGraph Sever RUN set -e \ && pwd && cd /hugegraph/ \ - && sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties \ - && ./bin/init-store.sh + && sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties EXPOSE 8080 VOLUME /hugegraph ENTRYPOINT ["/usr/bin/dumb-init", "--"] -CMD ["./bin/start-hugegraph.sh", "-d false -j $JAVA_OPTS -g zgc"] +CMD ["./bin/docker-entrypoint.sh"] diff --git a/hugegraph-dist/docker/example/docker-compose-cassandra.yml b/hugegraph-dist/docker/example/docker-compose-cassandra.yml new file mode 100644 index 0000000000..0dfe7b3305 --- /dev/null +++ b/hugegraph-dist/docker/example/docker-compose-cassandra.yml @@ -0,0 +1,44 @@ +version: "3" + +services: + graph: + image: hugegraph/hugegraph + container_name: ca-graph + ports: + - 18080:8080 + environment: + hugegraph.backend: cassandra + hugegraph.serializer: cassandra + hugegraph.cassandra.host: ca-cassandra + hugegraph.cassandra.port: 9042 + networks: + - ca-network + depends_on: + - cassandra + healthcheck: + test: ["CMD", "bin/gremlin-console.sh", "--" ,"-e", "scripts/remote-connect.groovy"] + interval: 10s + timeout: 30s + retries: 3 + + cassandra: + image: cassandra:3.11 + container_name: ca-cassandra + ports: + - 7000:7000 + - 9042:9042 + security_opt: + - seccomp:unconfined + networks: + - ca-network + healthcheck: + test: ["CMD", "cqlsh", "--execute", "describe keyspaces;"] + interval: 10s + timeout: 30s + retries: 5 + +networks: + ca-network: + +volumes: + hugegraph-data: diff --git a/hugegraph-dist/src/assembly/static/bin/docker-entrypoint.sh b/hugegraph-dist/src/assembly/static/bin/docker-entrypoint.sh new file mode 100644 index 0000000000..e1fad4a9ff --- /dev/null +++ b/hugegraph-dist/src/assembly/static/bin/docker-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# 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. +# + + +./bin/wait-storage.sh + +./bin/init-store.sh + +./bin/start-hugegraph.sh -d false -j "$JAVA_OPTS" -g zgc diff --git a/hugegraph-dist/src/assembly/static/bin/gremlin-console.sh b/hugegraph-dist/src/assembly/static/bin/gremlin-console.sh index b8a0fadbd2..edcdc0c403 100755 --- a/hugegraph-dist/src/assembly/static/bin/gremlin-console.sh +++ b/hugegraph-dist/src/assembly/static/bin/gremlin-console.sh @@ -84,14 +84,10 @@ PROFILING_ENABLED=false # Process options MAIN_CLASS=org.apache.tinkerpop.gremlin.console.Console -while getopts "elpv" opt; do +while getopts "lpv" opt; do case "$opt" in - e) MAIN_CLASS=org.apache.tinkerpop.gremlin.groovy.jsr223.ScriptExecutor - # Stop processing gremlin-console.sh arguments as soon as the -e switch - # is seen; everything following -e becomes arguments to the - # ScriptExecutor main class. This maintains compatibility with - # older deployments. - break;; + # class ScriptExecutor has been Deprecated. + # reference https://tinkerpop.apache.org/javadocs/3.2.3/full/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptExecutor.html l) eval GREMLIN_LOG_LEVEL=\$$OPTIND OPTIND="$(( $OPTIND + 1 ))" if [ "$GREMLIN_LOG_LEVEL" = "TRACE" -o \ diff --git a/hugegraph-dist/src/assembly/static/bin/wait-storage.sh b/hugegraph-dist/src/assembly/static/bin/wait-storage.sh new file mode 100644 index 0000000000..552e2b427e --- /dev/null +++ b/hugegraph-dist/src/assembly/static/bin/wait-storage.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# 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. +# + +function abs_path() { + SOURCE="${BASH_SOURCE[0]}" + while [[ -h "$SOURCE" ]]; do + DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" + done + cd -P "$(dirname "$SOURCE")" && pwd +} + +BIN=$(abs_path) +TOP="$(cd "$BIN"/../ && pwd)" +GRAPH_PROP="$TOP/conf/graphs/hugegraph.properties" +HUGE_STORAGE_TIMEOUT_S=60 +TRY_STORAGE="$TOP/scripts/try-storage.groovy" + +. "$BIN"/util.sh + +# apply config from env +while IFS=' ' read -r envvar_key envvar_val; do + if [[ "${envvar_key}" =~ hugegraph\. ]] && [[ ! -z ${envvar_val} ]]; then + envvar_key=${envvar_key#"hugegraph."} + if grep -q -E "^\s*${envvar_key}\s*=\.*" ${GRAPH_PROP}; then + sed -ri "s#^(\s*${envvar_key}\s*=).*#\\1${envvar_val}#" ${GRAPH_PROP} + else + echo "${envvar_key}=${envvar_val}" >> ${GRAPH_PROP} + fi + else + continue + fi +done < <(env | sort -r | awk -F= '{ st = index($0, "="); print $1 " " substr($0, st+1) }') + +# wait for storage +if ! [ -z "${HUGE_STORAGE_TIMEOUT_S:-}" ]; then + timeout "${HUGE_STORAGE_TIMEOUT_S}s" bash -c \ + "until bin/gremlin-console.sh -- -e $TRY_STORAGE > /dev/null 2>&1; do echo \"waiting for storage...\"; sleep 5; done" +fi diff --git a/hugegraph-dist/src/assembly/static/scripts/remote-connect.groovy b/hugegraph-dist/src/assembly/static/scripts/remote-connect.groovy new file mode 100644 index 0000000000..e352cdc7e9 --- /dev/null +++ b/hugegraph-dist/src/assembly/static/scripts/remote-connect.groovy @@ -0,0 +1,19 @@ +/* + * 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. + */ + +:remote connect tinkerpop.server conf/remote.yaml +:> hugegraph diff --git a/hugegraph-dist/src/assembly/static/scripts/try-storage.groovy b/hugegraph-dist/src/assembly/static/scripts/try-storage.groovy new file mode 100644 index 0000000000..9b344131f2 --- /dev/null +++ b/hugegraph-dist/src/assembly/static/scripts/try-storage.groovy @@ -0,0 +1,14 @@ +import org.apache.hugegraph.HugeFactory +import org.apache.hugegraph.dist.RegisterUtil + +// register all the backend to avoid changes if docker needs to support othre backend +RegisterUtil.registerPlugins() +RegisterUtil.registerRocksDB() +RegisterUtil.registerCassandra() +RegisterUtil.registerScyllaDB() +RegisterUtil.registerHBase() +RegisterUtil.registerMysql() +RegisterUtil.registerPalo() +RegisterUtil.registerPostgresql() + +graph = HugeFactory.open('./conf/graphs/hugegraph.properties') From 3be461ba73c158c8c308b259e35cde0d67e7e500 Mon Sep 17 00:00:00 2001 From: Dandelion <49650772+aroundabout@users.noreply.github.com> Date: Sat, 9 Sep 2023 19:43:36 +0800 Subject: [PATCH 2/8] Update hugegraph-dist/docker/example/docker-compose-cassandra.yml Co-authored-by: imbajin --- hugegraph-dist/docker/example/docker-compose-cassandra.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-dist/docker/example/docker-compose-cassandra.yml b/hugegraph-dist/docker/example/docker-compose-cassandra.yml index 0dfe7b3305..e4acfec803 100644 --- a/hugegraph-dist/docker/example/docker-compose-cassandra.yml +++ b/hugegraph-dist/docker/example/docker-compose-cassandra.yml @@ -3,7 +3,7 @@ version: "3" services: graph: image: hugegraph/hugegraph - container_name: ca-graph + container_name: cas-graph ports: - 18080:8080 environment: From 137d004348e546cdc08ee8d5cf0e6bd30f0cc9a4 Mon Sep 17 00:00:00 2001 From: dandelion Date: Sun, 10 Sep 2023 22:58:29 +0800 Subject: [PATCH 3/8] Update hugegraph-dist/docker/example/docker-compose-cassandra.yml --- .gitignore | 2 -- Dockerfile | 13 ++++++-- hugegraph-dist/docker/docker-entrypoint.sh | 24 ++++++++++++++ .../example/docker-compose-cassandra.yml | 19 +++++++++++- .../scripts/remote-connect.groovy | 0 .../docker/scripts/try-storage.groovy | 31 +++++++++++++++++++ .../src/assembly/static/bin/wait-storage.sh | 2 +- .../static/scripts/try-storage.groovy | 14 --------- 8 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 hugegraph-dist/docker/docker-entrypoint.sh rename hugegraph-dist/{src/assembly/static => docker}/scripts/remote-connect.groovy (100%) create mode 100644 hugegraph-dist/docker/scripts/try-storage.groovy delete mode 100644 hugegraph-dist/src/assembly/static/scripts/try-storage.groovy diff --git a/.gitignore b/.gitignore index 9dfe436992..47bbf40170 100644 --- a/.gitignore +++ b/.gitignore @@ -83,5 +83,3 @@ hs_err_pid* .mtj.tmp/ # blueJ files *.ctxt - -*swagger-ui* diff --git a/Dockerfile b/Dockerfile index 4e11b36e13..ecbe3110e7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -31,7 +31,8 @@ COPY --from=build /pkg/apache-hugegraph-incubating-$version/ /hugegraph LABEL maintainer="HugeGraph Docker Maintainers " # TODO: use g1gc or zgc as default -ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm" +ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm" \ + HUGEGRAPH_HOME="hugegraph" #COPY . /hugegraph/hugegraph-server WORKDIR /hugegraph/ @@ -50,10 +51,16 @@ RUN set -x \ # 2. Init HugeGraph Sever RUN set -e \ && pwd && cd /hugegraph/ \ - && sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties + && sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties + +# 3. Init docker script +COPY hugegraph-dist/docker/scripts/remote-connect.groovy ./scripts +COPY hugegraph-dist/docker/scripts/try-storage.groovy ./scripts +COPY hugegraph-dist/docker/docker-entrypoint.sh . +RUN chmod 755 ./docker-entrypoint.sh EXPOSE 8080 VOLUME /hugegraph ENTRYPOINT ["/usr/bin/dumb-init", "--"] -CMD ["./bin/docker-entrypoint.sh"] +CMD ["./docker-entrypoint.sh"] diff --git a/hugegraph-dist/docker/docker-entrypoint.sh b/hugegraph-dist/docker/docker-entrypoint.sh new file mode 100644 index 0000000000..e1fad4a9ff --- /dev/null +++ b/hugegraph-dist/docker/docker-entrypoint.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# 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. +# + + +./bin/wait-storage.sh + +./bin/init-store.sh + +./bin/start-hugegraph.sh -d false -j "$JAVA_OPTS" -g zgc diff --git a/hugegraph-dist/docker/example/docker-compose-cassandra.yml b/hugegraph-dist/docker/example/docker-compose-cassandra.yml index e4acfec803..e31e0f1a51 100644 --- a/hugegraph-dist/docker/example/docker-compose-cassandra.yml +++ b/hugegraph-dist/docker/example/docker-compose-cassandra.yml @@ -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. +# + version: "3" services: @@ -22,7 +39,7 @@ services: retries: 3 cassandra: - image: cassandra:3.11 + image: cassandra:4 container_name: ca-cassandra ports: - 7000:7000 diff --git a/hugegraph-dist/src/assembly/static/scripts/remote-connect.groovy b/hugegraph-dist/docker/scripts/remote-connect.groovy similarity index 100% rename from hugegraph-dist/src/assembly/static/scripts/remote-connect.groovy rename to hugegraph-dist/docker/scripts/remote-connect.groovy diff --git a/hugegraph-dist/docker/scripts/try-storage.groovy b/hugegraph-dist/docker/scripts/try-storage.groovy new file mode 100644 index 0000000000..df57ade988 --- /dev/null +++ b/hugegraph-dist/docker/scripts/try-storage.groovy @@ -0,0 +1,31 @@ +/* + * 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. + */ + +import org.apache.hugegraph.HugeFactory +import org.apache.hugegraph.dist.RegisterUtil + +// register all the backend to avoid changes if docker needs to support othre backend +RegisterUtil.registerPlugins() +RegisterUtil.registerRocksDB() +RegisterUtil.registerCassandra() +RegisterUtil.registerScyllaDB() +RegisterUtil.registerHBase() +RegisterUtil.registerMysql() +RegisterUtil.registerPalo() +RegisterUtil.registerPostgresql() + +graph = HugeFactory.open('./conf/graphs/hugegraph.properties') diff --git a/hugegraph-dist/src/assembly/static/bin/wait-storage.sh b/hugegraph-dist/src/assembly/static/bin/wait-storage.sh index 552e2b427e..9d987992dd 100644 --- a/hugegraph-dist/src/assembly/static/bin/wait-storage.sh +++ b/hugegraph-dist/src/assembly/static/bin/wait-storage.sh @@ -29,7 +29,7 @@ function abs_path() { BIN=$(abs_path) TOP="$(cd "$BIN"/../ && pwd)" GRAPH_PROP="$TOP/conf/graphs/hugegraph.properties" -HUGE_STORAGE_TIMEOUT_S=60 +HUGE_STORAGE_TIMEOUT_S=120 TRY_STORAGE="$TOP/scripts/try-storage.groovy" . "$BIN"/util.sh diff --git a/hugegraph-dist/src/assembly/static/scripts/try-storage.groovy b/hugegraph-dist/src/assembly/static/scripts/try-storage.groovy deleted file mode 100644 index 9b344131f2..0000000000 --- a/hugegraph-dist/src/assembly/static/scripts/try-storage.groovy +++ /dev/null @@ -1,14 +0,0 @@ -import org.apache.hugegraph.HugeFactory -import org.apache.hugegraph.dist.RegisterUtil - -// register all the backend to avoid changes if docker needs to support othre backend -RegisterUtil.registerPlugins() -RegisterUtil.registerRocksDB() -RegisterUtil.registerCassandra() -RegisterUtil.registerScyllaDB() -RegisterUtil.registerHBase() -RegisterUtil.registerMysql() -RegisterUtil.registerPalo() -RegisterUtil.registerPostgresql() - -graph = HugeFactory.open('./conf/graphs/hugegraph.properties') From 2fdd40f282b365e66064a7113790fa15c87b2030 Mon Sep 17 00:00:00 2001 From: Dandelion <49650772+aroundabout@users.noreply.github.com> Date: Tue, 19 Sep 2023 20:03:30 +0800 Subject: [PATCH 4/8] Update hugegraph-dist/docker/example/docker-compose-cassandra.yml --- hugegraph-dist/docker/example/docker-compose-cassandra.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-dist/docker/example/docker-compose-cassandra.yml b/hugegraph-dist/docker/example/docker-compose-cassandra.yml index e31e0f1a51..5ce8451ddb 100644 --- a/hugegraph-dist/docker/example/docker-compose-cassandra.yml +++ b/hugegraph-dist/docker/example/docker-compose-cassandra.yml @@ -26,7 +26,7 @@ services: environment: hugegraph.backend: cassandra hugegraph.serializer: cassandra - hugegraph.cassandra.host: ca-cassandra + hugegraph.cassandra.host: cas-cassandra hugegraph.cassandra.port: 9042 networks: - ca-network From ffa1779a62be6996847b0a390c1c81f30daff95f Mon Sep 17 00:00:00 2001 From: Dandelion <49650772+aroundabout@users.noreply.github.com> Date: Tue, 19 Sep 2023 20:04:04 +0800 Subject: [PATCH 5/8] Update hugegraph-dist/docker/example/docker-compose-cassandra.yml --- hugegraph-dist/docker/example/docker-compose-cassandra.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hugegraph-dist/docker/example/docker-compose-cassandra.yml b/hugegraph-dist/docker/example/docker-compose-cassandra.yml index 5ce8451ddb..3682b02f92 100644 --- a/hugegraph-dist/docker/example/docker-compose-cassandra.yml +++ b/hugegraph-dist/docker/example/docker-compose-cassandra.yml @@ -40,7 +40,7 @@ services: cassandra: image: cassandra:4 - container_name: ca-cassandra + container_name: cas-cassandra ports: - 7000:7000 - 9042:9042 From d92450877be7fcdffe65c4374fc671d78f438cb3 Mon Sep 17 00:00:00 2001 From: Dandelion Date: Fri, 13 Oct 2023 19:02:40 +0800 Subject: [PATCH 6/8] change detect script's filename --- Dockerfile | 2 +- .../scripts/{try-storage.groovy => detect-storage.groovy} | 0 hugegraph-dist/src/assembly/static/bin/wait-storage.sh | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename hugegraph-dist/docker/scripts/{try-storage.groovy => detect-storage.groovy} (100%) diff --git a/Dockerfile b/Dockerfile index ecbe3110e7..7dcbf2131f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -55,7 +55,7 @@ RUN set -e \ # 3. Init docker script COPY hugegraph-dist/docker/scripts/remote-connect.groovy ./scripts -COPY hugegraph-dist/docker/scripts/try-storage.groovy ./scripts +COPY hugegraph-dist/docker/scripts/detect-storage.groovy ./scripts COPY hugegraph-dist/docker/docker-entrypoint.sh . RUN chmod 755 ./docker-entrypoint.sh diff --git a/hugegraph-dist/docker/scripts/try-storage.groovy b/hugegraph-dist/docker/scripts/detect-storage.groovy similarity index 100% rename from hugegraph-dist/docker/scripts/try-storage.groovy rename to hugegraph-dist/docker/scripts/detect-storage.groovy diff --git a/hugegraph-dist/src/assembly/static/bin/wait-storage.sh b/hugegraph-dist/src/assembly/static/bin/wait-storage.sh index 9d987992dd..62e33ee7c2 100644 --- a/hugegraph-dist/src/assembly/static/bin/wait-storage.sh +++ b/hugegraph-dist/src/assembly/static/bin/wait-storage.sh @@ -30,7 +30,7 @@ BIN=$(abs_path) TOP="$(cd "$BIN"/../ && pwd)" GRAPH_PROP="$TOP/conf/graphs/hugegraph.properties" HUGE_STORAGE_TIMEOUT_S=120 -TRY_STORAGE="$TOP/scripts/try-storage.groovy" +TRY_STORAGE="$TOP/scripts/detect-storage.groovy" . "$BIN"/util.sh From 5e4c8e60c8fc0f396cf0982e295e48129cc7f99a Mon Sep 17 00:00:00 2001 From: Dandelion Date: Sun, 15 Oct 2023 19:43:47 +0800 Subject: [PATCH 7/8] change var name in wait storage script --- .../src/assembly/static/bin/wait-storage.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/hugegraph-dist/src/assembly/static/bin/wait-storage.sh b/hugegraph-dist/src/assembly/static/bin/wait-storage.sh index 62e33ee7c2..c98b68388b 100644 --- a/hugegraph-dist/src/assembly/static/bin/wait-storage.sh +++ b/hugegraph-dist/src/assembly/static/bin/wait-storage.sh @@ -28,9 +28,9 @@ function abs_path() { BIN=$(abs_path) TOP="$(cd "$BIN"/../ && pwd)" -GRAPH_PROP="$TOP/conf/graphs/hugegraph.properties" -HUGE_STORAGE_TIMEOUT_S=120 -TRY_STORAGE="$TOP/scripts/detect-storage.groovy" +GRAPH_CONF="$TOP/conf/graphs/hugegraph.properties" +WAIT_STORAGE_TIMEOUT_S=120 +DETECT_STORAGE="$TOP/scripts/detect-storage.groovy" . "$BIN"/util.sh @@ -38,10 +38,10 @@ TRY_STORAGE="$TOP/scripts/detect-storage.groovy" while IFS=' ' read -r envvar_key envvar_val; do if [[ "${envvar_key}" =~ hugegraph\. ]] && [[ ! -z ${envvar_val} ]]; then envvar_key=${envvar_key#"hugegraph."} - if grep -q -E "^\s*${envvar_key}\s*=\.*" ${GRAPH_PROP}; then - sed -ri "s#^(\s*${envvar_key}\s*=).*#\\1${envvar_val}#" ${GRAPH_PROP} + if grep -q -E "^\s*${envvar_key}\s*=\.*" ${GRAPH_CONF}; then + sed -ri "s#^(\s*${envvar_key}\s*=).*#\\1${envvar_val}#" ${GRAPH_CONF} else - echo "${envvar_key}=${envvar_val}" >> ${GRAPH_PROP} + echo "${envvar_key}=${envvar_val}" >> ${GRAPH_CONF} fi else continue @@ -49,7 +49,7 @@ while IFS=' ' read -r envvar_key envvar_val; do done < <(env | sort -r | awk -F= '{ st = index($0, "="); print $1 " " substr($0, st+1) }') # wait for storage -if ! [ -z "${HUGE_STORAGE_TIMEOUT_S:-}" ]; then - timeout "${HUGE_STORAGE_TIMEOUT_S}s" bash -c \ - "until bin/gremlin-console.sh -- -e $TRY_STORAGE > /dev/null 2>&1; do echo \"waiting for storage...\"; sleep 5; done" +if ! [ -z "${WAIT_STORAGE_TIMEOUT_S:-}" ]; then + timeout "${WAIT_STORAGE_TIMEOUT_S}s" bash -c \ + "until bin/gremlin-console.sh -- -e $DETECT_STORAGE > /dev/null 2>&1; do echo \"waiting for storage...\"; sleep 5; done" fi From da46a0f066e97a6e67087c4732f6922259cc021f Mon Sep 17 00:00:00 2001 From: Dandelion Date: Sun, 22 Oct 2023 18:49:00 +0800 Subject: [PATCH 8/8] fix: some reference url and 3rd-party file license --- .licenserc.yaml | 1 + LICENSE | 1 + hugegraph-dist/release-docs/LICENSE | 1 + .../src/assembly/static/bin/wait-storage.sh | 19 +++++++++---------- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.licenserc.yaml b/.licenserc.yaml index 334d89b51e..db7af8d8d1 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -96,6 +96,7 @@ header: # `header` section is configurations for source codes license header. - '**/util/StringEncoding.java' - 'hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherOpProcessor.java' - 'hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherPlugin.java' + - 'hugegraph-dist/src/assembly/static/bin/wait-storage.sh' comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`. # license-location-threshold specifies the index threshold where the license header can be located, diff --git a/LICENSE b/LICENSE index ad08080e31..cea0b74f43 100644 --- a/LICENSE +++ b/LICENSE @@ -214,5 +214,6 @@ hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptT hugegraph-core/src/main/java/org/apache/hugegraph/type/Nameable.java from https://github.com/JanusGraph/janusgraph hugegraph-core/src/main/java/org/apache/hugegraph/type/define/Cardinality.java from https://github.com/JanusGraph/janusgraph hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java from https://github.com/JanusGraph/janusgraph +hugegraph-dist/src/assembly/static/bin/wait-storage.sh from https://github.com/JanusGraph/janusgraph hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherOpProcessor.java from https://github.com/opencypher/cypher-for-gremlin hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherPlugin.java from https://github.com/opencypher/cypher-for-gremlin diff --git a/hugegraph-dist/release-docs/LICENSE b/hugegraph-dist/release-docs/LICENSE index f1cc9686c8..25c50c2fbb 100644 --- a/hugegraph-dist/release-docs/LICENSE +++ b/hugegraph-dist/release-docs/LICENSE @@ -220,6 +220,7 @@ The text of each license is the standard Apache 2.0 license. hugegraph-core/src/main/java/org/apache/hugegraph/type/Nameable.java from https://github.com/JanusGraph/janusgraph hugegraph-core/src/main/java/org/apache/hugegraph/type/define/Cardinality.java from https://github.com/JanusGraph/janusgraph hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java from https://github.com/JanusGraph/janusgraph +hugegraph-dist/src/assembly/static/bin/wait-storage.sh from https://github.com/JanusGraph/janusgraph hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptTraversal.java from https://github.com/apache/tinkerpop hugegraph-test/src/main/java/org/apache/hugegraph/tinkerpop/ProcessBasicSuite.java from https://github.com/apache/tinkerpop hugegraph-test/src/main/java/org/apache/hugegraph/tinkerpop/StructureBasicSuite.java from https://github.com/apache/tinkerpop diff --git a/hugegraph-dist/src/assembly/static/bin/wait-storage.sh b/hugegraph-dist/src/assembly/static/bin/wait-storage.sh index c98b68388b..3a98e8c56e 100644 --- a/hugegraph-dist/src/assembly/static/bin/wait-storage.sh +++ b/hugegraph-dist/src/assembly/static/bin/wait-storage.sh @@ -1,19 +1,18 @@ #!/bin/bash # -# 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. +# Copyright 2023 JanusGraph Authors +# +# Licensed 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 +# 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. +# 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. # function abs_path() {