Skip to content

Commit

Permalink
fix ci
Browse files Browse the repository at this point in the history
Change-Id: Id14191f3c02ad85de67c6ba66535ce5a4b167543
  • Loading branch information
javeme committed Dec 25, 2021
1 parent ea0df91 commit 4792d80
Show file tree
Hide file tree
Showing 13 changed files with 115 additions and 156 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-20.04
env:
TRAVIS_DIR: assembly/travis
COMMIT_ID: 2dd2d7c3fd7cb42cd7338d70a73e04b0c5604487
COMMIT_ID: d213166eb2185cbb6bd8bd5d201b7167e7b98993
steps:
- name: Install JDK 8
uses: actions/setup-java@v2
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Prepare env and service
run: |
$TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID | grep -v "Downloading\|Downloaded"
$TRAVIS_DIR/install-hugegraph-from-source.sh $COMMIT_ID
- name: Run test
run: |
Expand Down
1 change: 0 additions & 1 deletion BCLOUD

This file was deleted.

File renamed without changes.
26 changes: 17 additions & 9 deletions assembly/travis/conf/gremlin-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
scriptEvaluationTimeout: 30000

channelizer: org.apache.tinkerpop.gremlin.server.channel.WsAndHttpChannelizer
# don't set graph at here, this happens after support for dynamically adding graph
graphs: {
hugegraph: conf/hugegraph.properties
}
scriptEngines: {
gremlin-groovy: {
Expand All @@ -17,16 +17,30 @@ scriptEngines: {
org.apache.tinkerpop.gremlin.jsr223.ImportGremlinPlugin: {
classImports: [
java.lang.Math,
com.baidu.hugegraph.backend.id.IdGenerator,
com.baidu.hugegraph.type.define.Directions,
com.baidu.hugegraph.traversal.algorithm.CustomizePathsTraverser,
com.baidu.hugegraph.type.define.NodeRole,
com.baidu.hugegraph.traversal.algorithm.CollectionPathsTraverser,
com.baidu.hugegraph.traversal.algorithm.CountTraverser,
com.baidu.hugegraph.traversal.algorithm.CustomizedCrosspointsTraverser,
com.baidu.hugegraph.traversal.algorithm.CustomizePathsTraverser,
com.baidu.hugegraph.traversal.algorithm.FusiformSimilarityTraverser,
com.baidu.hugegraph.traversal.algorithm.HugeTraverser,
com.baidu.hugegraph.traversal.algorithm.JaccardSimilarTraverser,
com.baidu.hugegraph.traversal.algorithm.KneighborTraverser,
com.baidu.hugegraph.traversal.algorithm.KoutTraverser,
com.baidu.hugegraph.traversal.algorithm.MultiNodeShortestPathTraverser,
com.baidu.hugegraph.traversal.algorithm.NeighborRankTraverser,
com.baidu.hugegraph.traversal.algorithm.PathsTraverser,
com.baidu.hugegraph.traversal.algorithm.PersonalRankTraverser,
com.baidu.hugegraph.traversal.algorithm.SameNeighborTraverser,
com.baidu.hugegraph.traversal.algorithm.ShortestPathTraverser,
com.baidu.hugegraph.traversal.algorithm.SingleSourceShortestPathTraverser,
com.baidu.hugegraph.traversal.algorithm.SubGraphTraverser,
com.baidu.hugegraph.traversal.algorithm.TemplatePathsTraverser,
com.baidu.hugegraph.traversal.algorithm.steps.EdgeStep,
com.baidu.hugegraph.traversal.algorithm.steps.RepeatEdgeStep,
com.baidu.hugegraph.traversal.algorithm.steps.WeightedEdgeStep,
com.baidu.hugegraph.traversal.optimize.Text,
com.baidu.hugegraph.traversal.optimize.TraversalUtil,
com.baidu.hugegraph.util.DateUtil
Expand All @@ -40,12 +54,6 @@ scriptEngines: {
}
}
serializers:
- { className: org.apache.tinkerpop.gremlin.driver.ser.GryoLiteMessageSerializerV1d0,
config: {
serializeResultToString: false,
ioRegistries: [com.baidu.hugegraph.io.HugeGraphIoRegistry]
}
}
- { className: org.apache.tinkerpop.gremlin.driver.ser.GraphBinaryMessageSerializerV1,
config: {
serializeResultToString: false,
Expand All @@ -72,7 +80,7 @@ serializers:
}
metrics: {
consoleReporter: {enabled: false, interval: 180000},
csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},
csvReporter: {enabled: false, interval: 180000, fileName: ./metrics/gremlin-server-metrics.csv},
jmxReporter: {enabled: false},
slf4jReporter: {enabled: false, interval: 180000},
gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
Expand Down
35 changes: 32 additions & 3 deletions assembly/travis/conf/rest-server.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,39 @@ restserver.url=http://127.0.0.1:8080
# gremlin server url, need to be consistent with host and port in gremlin-server.yaml
#gremlinserver.url=http://127.0.0.1:8182

# graphs list with pair NAME:CONF_PATH
graphs=[hugegraph:conf/hugegraph.properties]
graphs=./conf/graphs

# authentication
# The maximum thread ratio for batch writing, only take effect if the batch.max_write_threads is 0
batch.max_write_ratio=80
batch.max_write_threads=0

# authentication configs
# choose 'com.baidu.hugegraph.auth.StandardAuthenticator' or 'com.baidu.hugegraph.auth.ConfigAuthenticator'
auth.authenticator=com.baidu.hugegraph.auth.StandardAuthenticator

# for StandardAuthenticator mode
#auth.graph_store=hugegraph
# auth client config
#auth.remote_url=127.0.0.1:8899,127.0.0.1:8898,127.0.0.1:8897

# for ConfigAuthenticator mode
#auth.admin_token=
#auth.user_tokens=[]

# rpc group configs of multi graph servers
# rpc server configs
rpc.server_host=127.0.0.1
rpc.server_port=8090
#rpc.server_timeout=30

# rpc client configs (like enable to keep cache consistency)
rpc.remote_url=127.0.0.1:8090
#rpc.client_connect_timeout=20
#rpc.client_reconnect_period=10
#rpc.client_read_timeout=40
#rpc.client_retries=3
#rpc.client_load_balancer=consistentHash

# lightweight load balancing (beta)
server.id=server-1
server.role=master
26 changes: 17 additions & 9 deletions assembly/travis/install-hugegraph-from-source.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,34 @@ fi

COMMIT_ID=$1
HUGEGRAPH_GIT_URL="https://github.com/hugegraph/hugegraph.git"
GIT_DIR=hugegraph

# download code and compile
git clone --depth 100 ${HUGEGRAPH_GIT_URL}
cd hugegraph
cd "${GIT_DIR}"
git checkout ${COMMIT_ID}
mvn package -DskipTests
mv hugegraph-*.tar.gz ../

TAR=$(echo hugegraph-*.tar.gz)
tar -zxvf "${TAR}" -C ../
cd ../
rm -rf hugegraph
tar -zxvf hugegraph-*.tar.gz
rm -rf "${GIT_DIR}"

HTTP_SERVER_DIR=$(echo hugegraph-*)
HTTPS_SERVER_DIR="hugegraph_https"
mkdir ${HTTPS_SERVER_DIR}
cp -r hugegraph-*/. ${HTTPS_SERVER_DIR}
cd "$(find hugegraph-* | head -1)"
cp ../$TRAVIS_DIR/conf/* conf

cp -r "${HTTP_SERVER_DIR}" "${HTTPS_SERVER_DIR}"

# config auth options just for http server (must keep '/.')
cp -rf "${TRAVIS_DIR}"/conf/. "${HTTP_SERVER_DIR}"/conf/

# start HugeGraphServer with http protocol
cd "${HTTP_SERVER_DIR}"
echo -e "pa" | bin/init-store.sh || exit 1
bin/start-hugegraph.sh || exit 1

cd ../${HTTPS_SERVER_DIR}
# config options for https server
cd ../"${HTTPS_SERVER_DIR}"
REST_SERVER_CONFIG="conf/rest-server.properties"
GREMLIN_SERVER_CONFIG="conf/gremlin-server.yaml"
sed -i "s?http://127.0.0.1:8080?https://127.0.0.1:8443?g" "$REST_SERVER_CONFIG"
Expand Down
69 changes: 0 additions & 69 deletions assembly/travis/install-hugegraph-from-tar.sh

This file was deleted.

29 changes: 15 additions & 14 deletions src/main/java/com/baidu/hugegraph/api/graphs/GraphsAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@

public class GraphsAPI extends API {

private static final String CONFIRM_MESSAGE = "confirm_message";
private static final String DELIMITER = "/";
private static final String MODE = "mode";
private static final String GRAPH_READ_MODE = "graph_read_mode";
private static final String CLEAR = "clear";

private static final String CONFIRM_MESSAGE = "confirm_message";

public GraphsAPI(RestClient client) {
super(client);
Expand Down Expand Up @@ -80,11 +82,11 @@ public List<String> list() {
}

public void clear(String graph, String message) {
this.client.delete(joinPath(this.path(), graph, "clear"),
this.client.delete(joinPath(this.path(), graph, CLEAR),
ImmutableMap.of(CONFIRM_MESSAGE, message));
}

public void delete(String graph, String message) {
public void drop(String graph, String message) {
this.client.checkApiVersion("0.67", "dynamic graph delete");
this.client.delete(joinPath(this.path(), graph),
ImmutableMap.of(CONFIRM_MESSAGE, message));
Expand All @@ -93,12 +95,11 @@ public void delete(String graph, String message) {
public void mode(String graph, GraphMode mode) {
// NOTE: Must provide id for PUT. If use "graph/mode", "/" will
// be encoded to "%2F". So use "mode" here although inaccurate.
this.client.put(joinPath(this.path(), graph), MODE, mode);
this.client.put(joinPath(this.path(), graph, MODE), null, mode);
}

public GraphMode mode(String graph) {
RestResult result = this.client.get(joinPath(this.path(), graph),
MODE);
RestResult result = this.client.get(joinPath(this.path(), graph), MODE);
@SuppressWarnings("unchecked")
Map<String, String> mode = result.readObject(Map.class);
String value = mode.get(MODE);
Expand All @@ -119,14 +120,14 @@ public void readMode(String graph, GraphReadMode readMode) {
// NOTE: Must provide id for PUT. If use "graph/graph_read_mode", "/"
// will be encoded to "%2F". So use "graph_read_mode" here although
// inaccurate.
this.client.put(joinPath(this.path(), graph),
GRAPH_READ_MODE, readMode);
this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE),
null, readMode);
}

public GraphReadMode readMode(String graph) {
this.client.checkApiVersion("0.59", "graph read mode");
RestResult result = this.client.get(joinPath(this.path(), graph),
GRAPH_READ_MODE);
RestResult result = this.client.get(joinPath(this.path(), graph),
GRAPH_READ_MODE);
@SuppressWarnings("unchecked")
Map<String, String> readMode = result.readObject(Map.class);
String value = readMode.get(GRAPH_READ_MODE);
Expand All @@ -142,11 +143,11 @@ public GraphReadMode readMode(String graph) {
}
}

private static String joinPath(String path, String id) {
return String.join(DELIMITER, path, id);
private static String joinPath(String path, String graph) {
return String.join(DELIMITER, path, graph);
}

private static String joinPath(String path, String id, String action) {
return String.join(DELIMITER, path, id, action);
private static String joinPath(String path, String graph, String action) {
return String.join(DELIMITER, path, graph, action);
}
}
44 changes: 8 additions & 36 deletions src/main/java/com/baidu/hugegraph/driver/GraphsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,11 @@

package com.baidu.hugegraph.driver;

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;

import org.apache.commons.io.FileUtils;

import com.baidu.hugegraph.api.graphs.GraphsAPI;
import com.baidu.hugegraph.client.RestClient;
import com.baidu.hugegraph.rest.ClientException;
import com.baidu.hugegraph.structure.constant.GraphMode;
import com.baidu.hugegraph.structure.constant.GraphReadMode;

Expand All @@ -42,34 +35,13 @@ public GraphsManager(RestClient client) {
this.graphsAPI = new GraphsAPI(client);
}

public Map<String, String> createGraph(String name, String config) {
return this.createGraph(name, null, config);
}

public Map<String, String> createGraph(String name, String cloneGraphName,
String config) {
return this.graphsAPI.create(name, cloneGraphName, config);
}

public Map<String, String> createGraph(String name, File file) {
String config;
try {
config = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
} catch (IOException e) {
throw new ClientException("Failed to read config file: %s", file);
}
return this.createGraph(name, config);
public Map<String, String> createGraph(String name, String configText) {
return this.graphsAPI.create(name, null, configText);
}

public Map<String, String> createGraph(String name, String cloneGraphName,
File file) {
String config;
try {
config = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
} catch (IOException e) {
throw new ClientException("Failed to read config file: %s", file);
}
return this.createGraph(name, cloneGraphName, config);
public Map<String, String> cloneGraph(String name, String cloneGraphName,
String configText) {
return this.graphsAPI.create(name, cloneGraphName, configText);
}

public Map<String, String> getGraph(String graph) {
Expand All @@ -80,12 +52,12 @@ public List<String> listGraph() {
return this.graphsAPI.list();
}

public void clear(String graph, String message) {
public void clearGraph(String graph, String message) {
this.graphsAPI.clear(graph, message);
}

public void remove(String graph, String message) {
this.graphsAPI.delete(graph, message);
public void dropGraph(String graph, String message) {
this.graphsAPI.drop(graph, message);
}

public void mode(String graph, GraphMode mode) {
Expand Down
Loading

0 comments on commit 4792d80

Please sign in to comment.