Skip to content

Commit d4b95ca

Browse files
aroundaboutimbajin
andauthored
feat: support Cassandra with docker-compose in server (#2307)
## Main Changes 1. change the dockerfile, adding the shell to wait for storage backend and use a docker-entrypoint.sh to manage the starting process. 2. delete a deprecated class in gremlin-console.sh (reference: [doc of ScriptExecutor](https://tinkerpop.apache.org/javadocs/3.2.3/full/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptExecutor.html)) 3. add a healthy check in docker-compose 4. add an example folder where we can put all the template docker-compose.yml here 5. add `*swagger-ui*` in gitignore, which appears after you compile the source code locally. --------- Co-authored-by: imbajin <[email protected]>
1 parent 73329ce commit d4b95ca

File tree

11 files changed

+229
-11
lines changed

11 files changed

+229
-11
lines changed

.licenserc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ header: # `header` section is configurations for source codes license header.
9696
- '**/util/StringEncoding.java'
9797
- 'hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherOpProcessor.java'
9898
- 'hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherPlugin.java'
99+
- 'hugegraph-dist/src/assembly/static/bin/wait-storage.sh'
99100
comment: on-failure # on what condition license-eye will comment on the pull request, `on-failure`, `always`, `never`.
100101

101102
# license-location-threshold specifies the index threshold where the license header can be located,

Dockerfile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ COPY --from=build /pkg/apache-hugegraph-incubating-$version/ /hugegraph
3131
LABEL maintainer="HugeGraph Docker Maintainers <[email protected]>"
3232

3333
# TODO: use g1gc or zgc as default
34-
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm"
34+
ENV JAVA_OPTS="-XX:+UnlockExperimentalVMOptions -XX:+UseContainerSupport -XX:MaxRAMPercentage=50 -XshowSettings:vm" \
35+
HUGEGRAPH_HOME="hugegraph"
3536

3637
#COPY . /hugegraph/hugegraph-server
3738
WORKDIR /hugegraph/
@@ -50,11 +51,16 @@ RUN set -x \
5051
# 2. Init HugeGraph Sever
5152
RUN set -e \
5253
&& pwd && cd /hugegraph/ \
53-
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties \
54-
&& ./bin/init-store.sh
54+
&& sed -i "s/^restserver.url.*$/restserver.url=http:\/\/0.0.0.0:8080/g" ./conf/rest-server.properties
55+
56+
# 3. Init docker script
57+
COPY hugegraph-dist/docker/scripts/remote-connect.groovy ./scripts
58+
COPY hugegraph-dist/docker/scripts/detect-storage.groovy ./scripts
59+
COPY hugegraph-dist/docker/docker-entrypoint.sh .
60+
RUN chmod 755 ./docker-entrypoint.sh
5561

5662
EXPOSE 8080
5763
VOLUME /hugegraph
5864

5965
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
60-
CMD ["./bin/start-hugegraph.sh", "-d false -j $JAVA_OPTS -g zgc"]
66+
CMD ["./docker-entrypoint.sh"]

LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,5 +214,6 @@ hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptT
214214
hugegraph-core/src/main/java/org/apache/hugegraph/type/Nameable.java from https://github.com/JanusGraph/janusgraph
215215
hugegraph-core/src/main/java/org/apache/hugegraph/type/define/Cardinality.java from https://github.com/JanusGraph/janusgraph
216216
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java from https://github.com/JanusGraph/janusgraph
217+
hugegraph-dist/src/assembly/static/bin/wait-storage.sh from https://github.com/JanusGraph/janusgraph
217218
hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherOpProcessor.java from https://github.com/opencypher/cypher-for-gremlin
218219
hugegraph-api/src/main/java/org/apache/hugegraph/opencypher/CypherPlugin.java from https://github.com/opencypher/cypher-for-gremlin
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with this
5+
# work for additional information regarding copyright ownership. The ASF
6+
# licenses this file to You under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
# License for the specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
19+
20+
./bin/wait-storage.sh
21+
22+
./bin/init-store.sh
23+
24+
./bin/start-hugegraph.sh -d false -j "$JAVA_OPTS" -g zgc
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
18+
version: "3"
19+
20+
services:
21+
graph:
22+
image: hugegraph/hugegraph
23+
container_name: cas-graph
24+
ports:
25+
- 18080:8080
26+
environment:
27+
hugegraph.backend: cassandra
28+
hugegraph.serializer: cassandra
29+
hugegraph.cassandra.host: cas-cassandra
30+
hugegraph.cassandra.port: 9042
31+
networks:
32+
- ca-network
33+
depends_on:
34+
- cassandra
35+
healthcheck:
36+
test: ["CMD", "bin/gremlin-console.sh", "--" ,"-e", "scripts/remote-connect.groovy"]
37+
interval: 10s
38+
timeout: 30s
39+
retries: 3
40+
41+
cassandra:
42+
image: cassandra:4
43+
container_name: cas-cassandra
44+
ports:
45+
- 7000:7000
46+
- 9042:9042
47+
security_opt:
48+
- seccomp:unconfined
49+
networks:
50+
- ca-network
51+
healthcheck:
52+
test: ["CMD", "cqlsh", "--execute", "describe keyspaces;"]
53+
interval: 10s
54+
timeout: 30s
55+
retries: 5
56+
57+
networks:
58+
ca-network:
59+
60+
volumes:
61+
hugegraph-data:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with this
4+
* work for additional information regarding copyright ownership. The ASF
5+
* licenses this file to You under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*/
17+
18+
import org.apache.hugegraph.HugeFactory
19+
import org.apache.hugegraph.dist.RegisterUtil
20+
21+
// register all the backend to avoid changes if docker needs to support othre backend
22+
RegisterUtil.registerPlugins()
23+
RegisterUtil.registerRocksDB()
24+
RegisterUtil.registerCassandra()
25+
RegisterUtil.registerScyllaDB()
26+
RegisterUtil.registerHBase()
27+
RegisterUtil.registerMysql()
28+
RegisterUtil.registerPalo()
29+
RegisterUtil.registerPostgresql()
30+
31+
graph = HugeFactory.open('./conf/graphs/hugegraph.properties')
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with this
4+
* work for additional information regarding copyright ownership. The ASF
5+
* licenses this file to You under the Apache License, Version 2.0 (the
6+
* "License"); you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
* License for the specific language governing permissions and limitations
15+
* under the License.
16+
*/
17+
18+
:remote connect tinkerpop.server conf/remote.yaml
19+
:> hugegraph

hugegraph-dist/release-docs/LICENSE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ The text of each license is the standard Apache 2.0 license.
220220
hugegraph-core/src/main/java/org/apache/hugegraph/type/Nameable.java from https://github.com/JanusGraph/janusgraph
221221
hugegraph-core/src/main/java/org/apache/hugegraph/type/define/Cardinality.java from https://github.com/JanusGraph/janusgraph
222222
hugegraph-core/src/main/java/org/apache/hugegraph/util/StringEncoding.java from https://github.com/JanusGraph/janusgraph
223+
hugegraph-dist/src/assembly/static/bin/wait-storage.sh from https://github.com/JanusGraph/janusgraph
223224
hugegraph-core/src/main/java/org/apache/hugegraph/traversal/optimize/HugeScriptTraversal.java from https://github.com/apache/tinkerpop
224225
hugegraph-test/src/main/java/org/apache/hugegraph/tinkerpop/ProcessBasicSuite.java from https://github.com/apache/tinkerpop
225226
hugegraph-test/src/main/java/org/apache/hugegraph/tinkerpop/StructureBasicSuite.java from https://github.com/apache/tinkerpop
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed with this
5+
# work for additional information regarding copyright ownership. The ASF
6+
# licenses this file to You under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
# License for the specific language governing permissions and limitations
16+
# under the License.
17+
#
18+
19+
20+
./bin/wait-storage.sh
21+
22+
./bin/init-store.sh
23+
24+
./bin/start-hugegraph.sh -d false -j "$JAVA_OPTS" -g zgc

hugegraph-dist/src/assembly/static/bin/gremlin-console.sh

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,10 @@ PROFILING_ENABLED=false
8484

8585
# Process options
8686
MAIN_CLASS=org.apache.tinkerpop.gremlin.console.Console
87-
while getopts "elpv" opt; do
87+
while getopts "lpv" opt; do
8888
case "$opt" in
89-
e) MAIN_CLASS=org.apache.tinkerpop.gremlin.groovy.jsr223.ScriptExecutor
90-
# Stop processing gremlin-console.sh arguments as soon as the -e switch
91-
# is seen; everything following -e becomes arguments to the
92-
# ScriptExecutor main class. This maintains compatibility with
93-
# older deployments.
94-
break;;
89+
# class ScriptExecutor has been Deprecated.
90+
# reference https://tinkerpop.apache.org/javadocs/3.2.3/full/org/apache/tinkerpop/gremlin/groovy/jsr223/ScriptExecutor.html
9591
l) eval GREMLIN_LOG_LEVEL=\$$OPTIND
9692
OPTIND="$(( $OPTIND + 1 ))"
9793
if [ "$GREMLIN_LOG_LEVEL" = "TRACE" -o \

0 commit comments

Comments
 (0)