Skip to content

Commit 2c4c040

Browse files
refactor(loader): adjust LoadContext to 1.7.0 version (#687)
1 parent 8a936a2 commit 2c4c040

File tree

9 files changed

+240
-248
lines changed

9 files changed

+240
-248
lines changed

.github/workflows/loader-ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
TRAVIS_DIR: hugegraph-loader/assembly/travis
2828
STATIC_DIR: hugegraph-loader/assembly/static
2929
# TODO: replace it with the (latest - n) commit id (n >= 15)
30-
# hugegraph commit date: 2024-12-09
31-
COMMIT_ID: f838897
30+
# hugegraph commit date: 2025-10-30
31+
COMMIT_ID: 5b3d295
3232
DB_USER: root
3333
DB_PASS: root
3434
DB_DATABASE: load_test
@@ -43,13 +43,13 @@ jobs:
4343
fetch-depth: 2
4444

4545
- name: Install JDK 11
46-
uses: actions/setup-java@v3
46+
uses: actions/setup-java@v4
4747
with:
4848
java-version: ${{ matrix.JAVA_VERSION }}
4949
distribution: 'adopt'
5050

5151
- name: Cache Maven packages
52-
uses: actions/cache@v3
52+
uses: actions/cache@v4
5353
with:
5454
path: ~/.m2
5555
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
@@ -81,7 +81,7 @@ jobs:
8181
mvn test -P kafka
8282
8383
- name: Upload coverage to Codecov
84-
uses: codecov/codecov-action@v3
84+
uses: codecov/codecov-action@v4
8585
with:
8686
token: ${{ secrets.CODECOV_TOKEN }}
8787
file: target/jacoco.xml

hugegraph-client/src/main/java/org/apache/hugegraph/api/graphs/GraphsAPI.java

Lines changed: 27 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -136,14 +136,8 @@ public void clear(String graph, boolean clearSchema) {
136136
}
137137

138138
public void clear(String graph, String message) {
139-
clear(null, graph, message);
140-
}
141-
142-
public void clear(String graphSpace, String graph, String message) {
143-
String path = (graphSpace == null)
144-
? joinPath(this.path(), graph, CLEAR)
145-
: joinPath(this.path(), graphSpace, graph, CLEAR);
146-
this.client.delete(path, ImmutableMap.of(CONFIRM_MESSAGE, message));
139+
this.client.delete(joinPath(this.path(), graph, CLEAR),
140+
ImmutableMap.of(CONFIRM_MESSAGE, message));
147141
}
148142

149143
public Map<String, String> update(String name, String nickname) {
@@ -204,85 +198,51 @@ public Map<String, String> reload() {
204198
}
205199

206200
public void mode(String graph, GraphMode mode) {
207-
mode(null, graph, mode);
208-
}
209-
210-
public void mode(String graphSpace, String graph, GraphMode mode) {
211201
// NOTE: Must provide id for PUT. If you use "graph/mode", "/" will
212202
// be encoded to "%2F". So use "mode" here, although inaccurate.
213-
if (graphSpace == null) {
214-
this.client.put(joinPath(this.path(), graph, MODE), null, mode);
215-
return;
216-
}
217-
this.client.put(joinPath(this.path(), graphSpace, graph, MODE), null, mode);
203+
this.client.put(joinPath(this.path(), graph, MODE), null, mode);
218204
}
219205

220-
public void readMode(String graph, GraphReadMode readMode) {
221-
readMode(null, graph, readMode);
206+
public GraphMode mode(String graph) {
207+
RestResult result = this.client.get(joinPath(this.path(), graph), MODE);
208+
@SuppressWarnings("unchecked")
209+
Map<String, String> mode = result.readObject(Map.class);
210+
String value = mode.get(MODE);
211+
if (value == null) {
212+
throw new InvalidResponseException("Invalid response, expect 'mode' in response");
213+
}
214+
try {
215+
return GraphMode.valueOf(value);
216+
} catch (IllegalArgumentException e) {
217+
throw new InvalidResponseException("Invalid GraphMode value '%s'", value);
218+
}
222219
}
223220

224-
225-
public void readMode(String graphSpace, String graph, GraphReadMode readMode) {
221+
public void readMode(String graph, GraphReadMode readMode) {
226222
this.client.checkApiVersion("0.59", "graph read mode");
227223
// NOTE: Must provide id for PUT. If you use "graph/graph_read_mode", "/"
228224
// will be encoded to "%2F". So use "graph_read_mode" here, although
229225
// inaccurate.
230-
if (graphSpace == null) {
231-
this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null, readMode);
232-
return;
233-
}
234-
this.client.put(joinPath(this.path(), graphSpace, graph, GRAPH_READ_MODE), null, readMode);
226+
this.client.put(joinPath(this.path(), graph, GRAPH_READ_MODE), null, readMode);
235227
}
236228

237-
/**
238-
* Get graph mode value from server response
239-
*
240-
* @param graphSpace the graph space name, null for non-graphspace mode
241-
* @param graph the graph name
242-
* @param modeKey the mode key in response (MODE or GRAPH_READ_MODE)
243-
* @param enumClass the enum class type
244-
* @return the mode enum value
245-
*/
246-
private <T extends Enum<T>> T getModeValue(String graphSpace, String graph,
247-
String modeKey, Class<T> enumClass) {
248-
String path = (graphSpace != null)
249-
? joinPath(this.path(), graphSpace, graph)
250-
: joinPath(this.path(), graph);
251-
252-
RestResult result = this.client.get(path, modeKey);
229+
public GraphReadMode readMode(String graph) {
230+
this.client.checkApiVersion("0.59", "graph read mode");
231+
RestResult result = this.client.get(joinPath(this.path(), graph), GRAPH_READ_MODE);
253232
@SuppressWarnings("unchecked")
254-
Map<String, String> map = result.readObject(Map.class);
255-
String value = map.get(modeKey);
256-
233+
Map<String, String> readMode = result.readObject(Map.class);
234+
String value = readMode.get(GRAPH_READ_MODE);
257235
if (value == null) {
258-
throw new InvalidResponseException(
259-
"Invalid response, expect '%s' in response", modeKey);
236+
throw new InvalidResponseException("Invalid response, expect 'graph_read_mode' " +
237+
"in response");
260238
}
261239
try {
262-
return Enum.valueOf(enumClass, value);
240+
return GraphReadMode.valueOf(value);
263241
} catch (IllegalArgumentException e) {
264-
throw new InvalidResponseException(
265-
"Invalid %s value '%s'", enumClass.getSimpleName(), value);
242+
throw new InvalidResponseException("Invalid GraphReadMode value '%s'", value);
266243
}
267244
}
268245

269-
public GraphMode mode(String graphSpace, String graph) {
270-
return getModeValue(graphSpace, graph, MODE, GraphMode.class);
271-
}
272-
273-
public GraphMode mode(String graph) {
274-
return mode(null, graph);
275-
}
276-
277-
public GraphReadMode readMode(String graphSpace, String graph) {
278-
this.client.checkApiVersion("0.59", "graph read mode");
279-
return getModeValue(graphSpace, graph, GRAPH_READ_MODE, GraphReadMode.class);
280-
}
281-
282-
public GraphReadMode readMode(String graph) {
283-
return readMode(null, graph);
284-
}
285-
286246
public String clone(String graph, Map<String, Object> body) {
287247
RestResult result = this.client.post(joinPath(this.path(), graph,
288248
"clone"), body);

hugegraph-client/src/main/java/org/apache/hugegraph/driver/GraphsManager.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ public void clearGraph(String graph, String message) {
9494
this.graphsAPI.clear(graph, message);
9595
}
9696

97-
public void clearGraph(String graphSpace, String graph, String message) {
98-
this.graphsAPI.clear(graphSpace, graph, message);
99-
}
100-
10197
public void update(String graph, String nickname) {
10298
this.graphsAPI.update(graph, nickname);
10399
}
@@ -119,30 +115,14 @@ public void mode(String graph, GraphMode mode) {
119115
this.graphsAPI.mode(graph, mode);
120116
}
121117

122-
public void mode(String graphSpace, String graph, GraphMode mode) {
123-
this.graphsAPI.mode(graphSpace, graph, mode);
124-
}
125-
126118
public GraphMode mode(String graph) {
127119
return this.graphsAPI.mode(graph);
128120
}
129121

130-
public GraphMode mode(String graphSpace, String graph) {
131-
return this.graphsAPI.mode(graphSpace, graph);
132-
}
133-
134-
public void readMode(String graphSpace, String graph, GraphReadMode readMode) {
135-
this.graphsAPI.readMode(graphSpace, graph, readMode);
136-
}
137-
138122
public void readMode(String graph, GraphReadMode readMode) {
139123
this.graphsAPI.readMode(graph, readMode);
140124
}
141125

142-
public GraphReadMode readMode(String graphSpace, String graph) {
143-
return this.graphsAPI.readMode(graphSpace, graph);
144-
}
145-
146126
public GraphReadMode readMode(String graph) {
147127
return this.graphsAPI.readMode(graph);
148128
}

hugegraph-loader/assembly/travis/install-hugegraph-from-source.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ mkdir ${HTTPS_SERVER_DIR}
4141
cp -r apache-hugegraph-*/. ${HTTPS_SERVER_DIR}
4242
cd "$(find apache-hugegraph-* | head -1)"
4343
# start HugeGraphServer with http protocol
44-
bin/init-store.sh || exit 1
44+
sed -i 's|gremlin.graph=org.apache.hugegraph.HugeFactory|gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy|' conf/graphs/hugegraph.properties
45+
sed -i 's|#auth.authenticator=.*|auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator|' conf/rest-server.properties
46+
sed -i 's|#auth.admin_pa=.*|auth.admin_pa=pa|' conf/rest-server.properties
47+
echo -e "pa" | bin/init-store.sh || exit 1
4548
bin/start-hugegraph.sh || exit 1
4649

4750
cd ../${HTTPS_SERVER_DIR}
@@ -53,6 +56,9 @@ sed -i "s/#port: 8182/port: 8282/g" "$GREMLIN_SERVER_CONFIG"
5356
echo "gremlinserver.url=http://127.0.0.1:8282" >> ${REST_SERVER_CONFIG}
5457

5558
# start HugeGraphServer with https protocol
56-
bin/init-store.sh
59+
sed -i 's|gremlin.graph=org.apache.hugegraph.HugeFactory|gremlin.graph=org.apache.hugegraph.auth.HugeFactoryAuthProxy|' conf/graphs/hugegraph.properties
60+
sed -i 's|#auth.authenticator=.*|auth.authenticator=org.apache.hugegraph.auth.StandardAuthenticator|' conf/rest-server.properties
61+
sed -i 's|#auth.admin_pa=.*|auth.admin_pa=pa|' conf/rest-server.properties
62+
echo -e "pa" | bin/init-store.sh || exit 1
5763
bin/start-hugegraph.sh
5864
cd ../

0 commit comments

Comments
 (0)