You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by vg...@apache.org on 2024/01/29 15:25:36 UTC

(incubator-hugegraph) branch pd-store updated (46cb612eb -> ec3779c70)

This is an automated email from the ASF dual-hosted git repository.

vgalaxies pushed a change to branch pd-store
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git


    from 46cb612eb fix(pd-store): partially fix hstore backend core tests failure (#2424)
     new 70150ad44 fix(chore): remove zgc in dockerfile for ARM env (#2421)
     new ec3779c70 chore(server): update swagger info for default server profile (#2423)

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 hugegraph-server/Dockerfile                        | 19 +++++++------
 .../apache/hugegraph/api/profile/ProfileAPI.java   |  6 ++++-
 .../hugegraph-dist/docker/docker-entrypoint.sh     | 31 +++++++++++++---------
 .../src/assembly/static/bin/enable-auth.sh         | 26 +++++++++---------
 .../src/assembly/static/bin/hugegraph-server.sh    |  1 +
 .../hugegraph-dist/src/assembly/static/bin/util.sh |  3 +++
 6 files changed, 51 insertions(+), 35 deletions(-)


(incubator-hugegraph) 01/02: fix(chore): remove zgc in dockerfile for ARM env (#2421)

Posted by vg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vgalaxies pushed a commit to branch pd-store
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git

commit 70150ad4487470f150a1b202747975dd578387fd
Author: Dandelion <49...@users.noreply.github.com>
AuthorDate: Fri Jan 26 16:48:41 2024 +0800

    fix(chore): remove zgc in dockerfile for ARM env (#2421)
    
    * remove zgc
    
    * Apply suggestions from code review
    
    Co-authored-by: imbajin <ji...@apache.org>
    
    * add comment for hugegraph-server.sh
    
    * fix enable-auth.sh
    
    * init store in entrypoint
    
    * use flag file to skip re-init
    
    * delete tar.gz
    
    * simply dockerfile
    
    * mvn optimize
    
    * simply dockerfile
    
    * add init log in docker
    
    ---------
    
    Co-authored-by: imbajin <ji...@apache.org>
---
 hugegraph-server/Dockerfile                        | 19 +++++++------
 .../hugegraph-dist/docker/docker-entrypoint.sh     | 31 +++++++++++++---------
 .../src/assembly/static/bin/enable-auth.sh         | 26 +++++++++---------
 .../src/assembly/static/bin/hugegraph-server.sh    |  1 +
 .../hugegraph-dist/src/assembly/static/bin/util.sh |  3 +++
 5 files changed, 46 insertions(+), 34 deletions(-)

diff --git a/hugegraph-server/Dockerfile b/hugegraph-server/Dockerfile
index 45a725786..8eef58c5f 100644
--- a/hugegraph-server/Dockerfile
+++ b/hugegraph-server/Dockerfile
@@ -23,13 +23,13 @@ COPY . /pkg
 WORKDIR /pkg
 ARG MAVEN_ARGS
 
-RUN mvn package $MAVEN_ARGS -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true && pwd && ls -l
+RUN mvn package $MAVEN_ARGS -e -B -ntp -DskipTests -Dmaven.javadoc.skip=true && pwd && ls -l && rm ./hugegraph-server/*.tar.gz
 
 # 2nd stage: runtime env
+# Note: ZGC (The Z Garbage Collector) is only supported on ARM-Mac with java > 13 
 FROM openjdk:11-slim
-# TODO: get the version from the pom.xml
-ENV version=1.2.0
-COPY --from=build /pkg/hugegraph-server/apache-hugegraph-incubating-$version/ /hugegraph-server
+
+COPY --from=build /pkg/hugegraph-server/apache-hugegraph-incubating-*/ /hugegraph-server/
 LABEL maintainer="HugeGraph Docker Maintainers <de...@hugegraph.apache.org>"
 
 # TODO: use g1gc or zgc as default
@@ -39,7 +39,7 @@ ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:Max
 #COPY . /hugegraph/hugegraph-server
 WORKDIR /hugegraph-server/
 
-# 1. Install environment
+# 1. Install environment and init HugeGraph Sever
 RUN set -x \
     && apt-get -q update \
     && apt-get -q install -y --no-install-recommends --no-install-suggests \
@@ -48,15 +48,14 @@ RUN set -x \
        curl \
        lsof \
        vim \
+       cron \
     && apt-get clean \
-    && rm -rf /var/lib/apt/lists/*
-
-# 2. Init HugeGraph Sever
-RUN set -e \
+    && rm -rf /var/lib/apt/lists/* \
+    && service cron start \
     && pwd && cd /hugegraph-server/ \
     && sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties
 
-# 3. Init docker script
+# 2. Init docker script
 COPY hugegraph-server/hugegraph-dist/docker/scripts/remote-connect.groovy ./scripts
 COPY hugegraph-server/hugegraph-dist/docker/scripts/detect-storage.groovy ./scripts
 COPY hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh .
diff --git a/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh b/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh
index 716dbf8c9..aa503f356 100644
--- a/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh
+++ b/hugegraph-server/hugegraph-dist/docker/docker-entrypoint.sh
@@ -16,24 +16,31 @@
 # under the License.
 #
 
-# wait for storage like cassandra
-./bin/wait-storage.sh
+# create a folder to save the docker-related file
+DOCKER_FOLDER='./docker'
+mkdir -p $DOCKER_FOLDER
 
-# set auth if needed 
-if [[ $AUTH == "true" ]]; then
-    # set password if use do not provide
+INIT_FLAG_FILE="init_complete"
+
+if [ ! -f "${DOCKER_FOLDER}/${INIT_FLAG_FILE}" ]; then
+    # wait for storage backend
+    ./bin/wait-storage.sh
     if [ -z "$PASSWORD" ]; then
-        echo "you have not set the password, we will use the default password"
-        PASSWORD="hugegraph"
+        echo "init hugegraph with non-auth mode"
+        ./bin/init-store.sh
+    else
+        echo "init hugegraph with auth mode"
+        ./bin/enable-auth.sh
+        echo "$PASSWORD" | ./bin/init-store.sh
     fi
-    echo "init hugegraph with auth"
-    ./bin/enable-auth.sh
-    echo "$PASSWORD" | ./bin/init-store.sh
+    # create a flag file to avoid re-init when restarting
+    touch ${DOCKER_FOLDER}/${INIT_FLAG_FILE}
 else
-    ./bin/init-store.sh
+    echo "Hugegraph Initialization already done. Skipping re-init..."
 fi
 
 # start hugegraph
-./bin/start-hugegraph.sh -j "$JAVA_OPTS" -g zgc
+# remove "-g zgc" now, which is only available on ARM-Mac with java > 13 
+./bin/start-hugegraph.sh -j "$JAVA_OPTS" 
 
 tail -f /dev/null
diff --git a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/enable-auth.sh b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/enable-auth.sh
index 924bf58f7..2f975872c 100644
--- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/enable-auth.sh
+++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/enable-auth.sh
@@ -36,19 +36,21 @@ GRAPH_CONF="hugegraph.properties"
 
 # make a backup
 BAK_CONF="$TOP/conf-bak"
-mkdir -p "$BAK_CONF"
-cp "${CONF}/${GREMLIN_SERVER_CONF}" "${BAK_CONF}/${GREMLIN_SERVER_CONF}.bak"
-cp "${CONF}/${REST_SERVER_CONF}" "${BAK_CONF}/${REST_SERVER_CONF}.bak"
-cp "${CONF}/graphs/${GRAPH_CONF}" "${BAK_CONF}/${GRAPH_CONF}.bak"
+if [ ! -d "$BAK_CONF" ]; then
+    mkdir -p "$BAK_CONF"
+    cp "${CONF}/${GREMLIN_SERVER_CONF}" "${BAK_CONF}/${GREMLIN_SERVER_CONF}.bak"
+    cp "${CONF}/${REST_SERVER_CONF}" "${BAK_CONF}/${REST_SERVER_CONF}.bak"
+    cp "${CONF}/graphs/${GRAPH_CONF}" "${BAK_CONF}/${GRAPH_CONF}.bak"
 
 
-sed -i -e '$a\authentication: {' \
-       -e '$a\  authenticator: org.apache.hugegraph.auth.StandardAuthenticator,' \
-       -e '$a\  authenticationHandler: org.apache.hugegraph.auth.WsAndHttpBasicAuthHandler,' \
-       -e '$a\  config: {tokens: conf/rest-server.properties}' \
-       -e '$a\}' ${CONF}/${GREMLIN_SERVER_CONF}
+    sed -i -e '$a\authentication: {' \
+        -e '$a\  authenticator: org.apache.hugegraph.auth.StandardAuthenticator,' \
+        -e '$a\  authenticationHandler: org.apache.hugegraph.auth.WsAndHttpBasicAuthHandler,' \
+        -e '$a\  config: {tokens: conf/rest-server.properties}' \
+        -e '$a\}' ${CONF}/${GREMLIN_SERVER_CONF}
 
-sed -i -e '$a\auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator' \
-       -e '$a\auth.graph_store=hugegraph' ${CONF}/${REST_SERVER_CONF}
+    sed -i -e '$a\auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator' \
+        -e '$a\auth.graph_store=hugegraph' ${CONF}/${REST_SERVER_CONF}
 
-sed -i 's/gremlin.graph=org.apache.hugegraph.HugeFactory/gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy/g' ${CONF}/graphs/${GRAPH_CONF}
+    sed -i 's/gremlin.graph=org.apache.hugegraph.HugeFactory/gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy/g' ${CONF}/graphs/${GRAPH_CONF}
+fi
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 a64398683..24b10a8e9 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
@@ -127,6 +127,7 @@ if [[ $JAVA_VERSION -gt 9 ]]; then
 fi
 
 # Using G1GC as the default garbage collector (Recommended for large memory machines)
+# 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"
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 47d18e995..5f7489e60 100755
--- a/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh
+++ b/hugegraph-server/hugegraph-dist/src/assembly/static/bin/util.sh
@@ -139,6 +139,9 @@ function wait_for_startup() {
         process_status "$server_name" "$pid" >/dev/null
         if [ $? -eq 1 ]; then
             echo "Starting $server_name failed"
+            if [ -e "$error_file_name" ]; then
+                rm "$error_file_name"
+            fi
             return 1
         fi
 


(incubator-hugegraph) 02/02: chore(server): update swagger info for default server profile (#2423)

Posted by vg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

vgalaxies pushed a commit to branch pd-store
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git

commit ec3779c709a209bf8224077c9167212f44e38dbb
Author: SunnyBoy-WYH <48...@users.noreply.github.com>
AuthorDate: Sun Jan 28 14:03:38 2024 +0800

    chore(server): update swagger info for default server profile (#2423)
---
 .../src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java
index c28b4878b..5ba53792a 100644
--- a/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java
+++ b/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/ProfileAPI.java
@@ -34,6 +34,8 @@ import jakarta.ws.rs.core.Context;
 import jakarta.ws.rs.core.MediaType;
 
 import org.apache.commons.lang3.StringUtils;
+import org.apache.hugegraph.config.HugeConfig;
+import org.apache.hugegraph.config.ServerOptions;
 import org.apache.tinkerpop.shaded.jackson.annotation.JsonProperty;
 import org.glassfish.jersey.model.Parameter.Source;
 import org.glassfish.jersey.server.model.Parameter;
@@ -55,6 +57,7 @@ public class ProfileAPI {
     private static final String SERVICE = "hugegraph";
     private static final String DOC = "https://hugegraph.apache.org/docs/";
     private static final String API_DOC = DOC + "clients/";
+    private static final String SWAGGER_UI = "/swagger-ui/index.html";
 
     private static String SERVER_PROFILES = null;
     private static String API_PROFILES = null;
@@ -62,7 +65,7 @@ public class ProfileAPI {
     @GET
     @Timed
     @Produces(MediaType.APPLICATION_JSON)
-    public String getProfile(@Context Application application) {
+    public String getProfile(@Context HugeConfig conf, @Context Application application) {
         // May init multi times by multi threads, but no effect on the results
         if (SERVER_PROFILES != null) {
             return SERVER_PROFILES;
@@ -73,6 +76,7 @@ public class ProfileAPI {
         profiles.put("version", CoreVersion.VERSION.toString());
         profiles.put("doc", DOC);
         profiles.put("api_doc", API_DOC);
+        profiles.put("swagger_ui", conf.get(ServerOptions.REST_SERVER_URL) + SWAGGER_UI);
         Set<String> apis = new TreeSet<>();
         for (Class<?> clazz : application.getClasses()) {
             if (!isAnnotatedPathClass(clazz)) {