You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hugegraph.apache.org by "contrueCT (via GitHub)" <gi...@apache.org> on 2026/03/10 10:02:27 UTC
[PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
contrueCT opened a new pull request, #2966:
URL: https://github.com/apache/hugegraph/pull/2966
<!--
Thank you very much for contributing to Apache HugeGraph, we are happy that you want to help us improve it!
Here are some tips for you:
1. If this is your first time, please read the [contributing guidelines](https://github.com/apache/hugegraph/blob/master/CONTRIBUTING.md)
2. If a PR fix/close an issue, type the message "close xxx" (xxx is the link of related
issue) in the content, GitHub will auto link it (Required)
3. Name the PR title in "Google Commit Format", start with "feat | fix | perf | refactor | doc | chore",
such like: "feat(core): support the PageRank algorithm" or "fix: wrong break in the compute loop" (module is optional)
skip it if you are unsure about which is the best component.
4. One PR address one issue, better not to mix up multiple issues.
5. Put an `x` in the `[ ]` to mark the item as CHECKED. `[x]` (or click it directly after
published)
-->
## Purpose of the PR
- close #2964 <!-- or use "fix #xxx", "xxx" is the ID-link of related issue, e.g: close #1024 -->
<!--
Please explain more context in this section, clarify why the changes are needed.
e.g:
- If you propose a new API, clarify the use case for a new API.
- If you fix a bug, you can clarify why it is a bug, and should be associated with an issue.
-->
## Main Changes
The issue requires GraphSpaceAPI to return a friendly response in standalone mode. During code investigation, I found that ManagerAPI has a similar problem: in standalone mode, manager.graphSpace(name) returns a fake new GraphSpace("DEFAULT"), which causes ManagerAPI.validGraphSpace() to pass incorrectly. As a result, ManagerAPI can still enter logic that is not actually supported in standalone mode, leading to unfriendly errors or behavior that does not match the API semantics. For consistency and correctness, I applied the same standalone-mode guard to ManagerAPI as well.
- Add public isUsePD() accessor to GraphManager to expose PD status
- Add checkPdModeEnabled() helper in API base class
- Call checkPdModeEnabled() in all public methods of GraphSpaceAPI (list/get/create/manage/delete)
- Call checkPdModeEnabled() in all public methods of ManagerAPI (createManager/delete/list/checkRole/getRolesInGs)
- Returns HTTP 400 with message 'GraphSpace management is not supported in standalone mode'
- Add standalone-mode rejection tests in GraphSpaceApiTest and ManagerApiTest
<!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. These change logs are helpful for better and faster reviews.)
For example:
- If you introduce a new feature, please show detailed design here or add the link of design documentation.
- If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
- If there is a discussion in the mailing list, please add the link. -->
## Verifying these changes
<!-- Please pick the proper options below -->
- [ ] Trivial rework / code cleanup without any test coverage. (No Need)
- [ ] Already covered by existing tests, such as *(please modify tests here)*.
- [ ] Need tests and can be verified as follows:
- xxx
## Does this PR potentially affect the following parts?
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] Dependencies ([add/update license](https://hugegraph.apache.org/docs/contribution-guidelines/contribute/#321-check-licenses) info & [regenerate_known_dependencies.sh](../install-dist/scripts/dependency/regenerate_known_dependencies.sh)) <!-- Don't forget to add/update the info in "LICENSE" & "NOTICE" files (both in root & dist module) -->
- [ ] Modify configurations
- [ ] The public API
- [ ] Other affects (typed here)
- [x] Nope
## Documentation Status
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `Doc - TODO` <!-- Your PR changes impact docs and you will update later -->
- [ ] `Doc - Done` <!-- Related docs have been already added or updated -->
- [x] `Doc - No Need` <!-- Your PR changes don't impact/need docs -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2917494522
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/GraphSpaceApiStandaloneTest.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+package org.apache.hugegraph.api;
+
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import jakarta.ws.rs.core.Response;
+
+/**
+ * Tests that GraphSpaceAPI returns a friendly HTTP 400 error in standalone
+ * mode (i.e. when the server is started without PD / hstore backend).
+ * <p>
+ * This class intentionally does NOT have a class-level Assume guard so that
+ * the tests are actually executed in non-hstore CI runs.
+ */
+public class GraphSpaceApiStandaloneTest extends BaseApiTest {
+
+ private static final String PATH = "graphspaces";
+ private static final String STANDALONE_ERROR =
+ "GraphSpace management is not supported in standalone mode";
+
+ @Before
+ public void skipForPdMode() {
+ assumeStandaloneMode();
+ }
+
+ @Test
Review Comment:
‼️ The standalone suite still doesn't cover `/graphspaces/profile`, and `GraphSpaceAPI#listProfile()` remains unguarded on the current head. That means this PR can still pass while one GraphSpace endpoint returns a different standalone behavior than the others. Please add a profile assertion here and guard `listProfile()` the same way as the rest of the GraphSpace endpoints.
```suggestion
@Test
public void testProfileReturnsFriendlyError() {
Response r = this.client().get(PATH + "/profile");
String content = assertResponseStatus(400, r);
Assert.assertTrue(content.contains(STANDALONE_ERROR));
}
@Test
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2917501717
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/space/GraphSpaceAPI.java:
##########
@@ -76,6 +76,7 @@ public class GraphSpaceAPI extends API {
@Produces(APPLICATION_JSON_WITH_CHARSET)
public Object list(@Context GraphManager manager,
@Context SecurityContext sc) {
+ checkPdModeEnabled(manager);
Set<String> spaces = manager.graphSpaces();
return ImmutableMap.of("graphSpaces", spaces);
Review Comment:
GraphSpaceAPI is intended to be disabled in standalone mode, but only some endpoints call checkPdModeEnabled(). The /graphspaces/profile endpoint (listProfile) is still reachable without the guard, so standalone mode can still access GraphSpace-related management data. Consider adding the same checkPdModeEnabled(manager) at the start of listProfile (and any other GraphSpaceAPI endpoints) to fully enforce the standalone restriction.
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/ManagerApiStandaloneTest.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+package org.apache.hugegraph.api;
+
+import java.util.Map;
+
+import org.apache.hugegraph.auth.HugePermission;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import jakarta.ws.rs.core.Response;
+
+/**
+ * Tests that ManagerAPI returns a friendly HTTP 400 error in standalone mode
+ * (i.e. when the server is started without PD / hstore backend).
+ * <p>
+ * This class intentionally does NOT have a class-level Assume guard so that
+ * the tests are actually executed in non-hstore CI runs.
+ */
+public class ManagerApiStandaloneTest extends BaseApiTest {
+
+ private static final String STANDALONE_ERROR =
+ "GraphSpace management is not supported in standalone mode";
+
+ private static String managerPath(String graphSpace) {
+ return String.format("graphspaces/%s/auth/managers", graphSpace);
+ }
+
+ @Before
+ public void skipForPdMode() {
+ assumeStandaloneMode();
+ }
+
+ @Test
+ public void testCreateManagerReturnsFriendlyError() {
+ String body = "{\"user\":\"admin\",\"type\":\"ADMIN\"}";
+ Response r = this.client().post(managerPath("DEFAULT"), body);
+ String content = assertResponseStatus(400, r);
+ Assert.assertTrue(content.contains(STANDALONE_ERROR));
+ }
+
+ @Test
+ public void testDeleteManagerReturnsFriendlyError() {
+ Response r = this.client().delete(managerPath("DEFAULT"),
+ Map.of("user", "admin",
+ "type", HugePermission.ADMIN));
+ String content = assertResponseStatus(400, r);
+ Assert.assertTrue(content.contains(STANDALONE_ERROR));
+ }
+
+ @Test
+ public void testListManagerReturnsFriendlyError() {
+ Response r = this.client().get(managerPath("DEFAULT"),
+ Map.of("type", (Object)HugePermission.ADMIN));
+ String content = assertResponseStatus(400, r);
+ Assert.assertTrue(content.contains(STANDALONE_ERROR));
Review Comment:
This test uses java.util.Map.of(...) for query params, but other API tests in this module consistently use Guava ImmutableMap.of(...). Using ImmutableMap here would avoid the extra (Object) casts needed for type inference and keep parameter-map construction consistent across the test suite.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -280,6 +280,10 @@ private boolean usePD() {
return this.PDExist;
}
+ public boolean isUsePD() {
+ return this.PDExist;
Review Comment:
GraphManager already has a private usePD() helper used internally; adding a separate public isUsePD() with the same implementation duplicates the source of truth and risks divergence over time. Consider either making usePD() public (or package-private) and using it consistently, or having isUsePD() delegate to usePD().
```suggestion
return this.usePD();
```
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/GraphSpaceApiStandaloneTest.java:
##########
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+package org.apache.hugegraph.api;
+
+import java.util.Map;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import jakarta.ws.rs.core.Response;
+
+/**
+ * Tests that GraphSpaceAPI returns a friendly HTTP 400 error in standalone
+ * mode (i.e. when the server is started without PD / hstore backend).
+ * <p>
+ * This class intentionally does NOT have a class-level Assume guard so that
+ * the tests are actually executed in non-hstore CI runs.
+ */
+public class GraphSpaceApiStandaloneTest extends BaseApiTest {
+
+ private static final String PATH = "graphspaces";
+ private static final String STANDALONE_ERROR =
+ "GraphSpace management is not supported in standalone mode";
+
+ @Before
+ public void skipForPdMode() {
+ assumeStandaloneMode();
+ }
+
+ @Test
+ public void testListReturnsFriendlyError() {
+ Response r = this.client().get(PATH);
+ String content = assertResponseStatus(400, r);
+ Assert.assertTrue(content.contains(STANDALONE_ERROR));
+ }
+
+ @Test
+ public void testGetReturnsFriendlyError() {
+ Response r = this.client().get(PATH, "DEFAULT");
+ String content = assertResponseStatus(400, r);
+ Assert.assertTrue(content.contains(STANDALONE_ERROR));
+ }
+
+ @Test
+ public void testCreateReturnsFriendlyError() {
+ String body = "{\"name\":\"test_standalone\",\"nickname\":\"test\","
+ + "\"description\":\"test\",\"cpu_limit\":10,"
+ + "\"memory_limit\":10,\"storage_limit\":10,"
+ + "\"max_graph_number\":10,\"max_role_number\":10,"
+ + "\"auth\":false,\"configs\":{}}";
+ Response r = this.client().post(PATH, body);
+ String content = assertResponseStatus(400, r);
+ Assert.assertTrue(content.contains(STANDALONE_ERROR));
+ }
+
+ @Test
+ public void testManageReturnsFriendlyError() {
+ String body = "{\"action\":\"update\",\"update\":{\"name\":\"DEFAULT\"}}";
+ Response r = this.client().put(PATH, "DEFAULT", body, Map.of());
+ String content = assertResponseStatus(400, r);
Review Comment:
This test uses Map.of() for the (empty) query-params map, while other API tests in this module use ImmutableMap.of(). Consider switching to ImmutableMap.of() for consistency with the rest of the test suite.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "contrueCT (via GitHub)" <gi...@apache.org>.
contrueCT commented on PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#issuecomment-4087535854
@imbajin The latest CI build failed, but it appears unrelated to my changes. Could you please re-run the CI?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936757127
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
Review Comment:
[38;5;198;48;5;233m🧹[39;49m[38;5;15m [39m[38;5;15mMinor[39m[38;5;15m:[39m[38;5;15m [39m[38;5;15mExtract[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mliteral[39m[38;5;15m [39m[38;5;15merror[39m[38;5;15m [39m[38;5;15mmessage[39m[38;5;15m [39m[38;5;15minto[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15mconstant[39m[38;5;15m [39m[38;5;15mto[39m[38;5;15m [39m[38;5;15mavoid[39m[38;5;15m [39m[38;5;15mduplication[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;15mtypos[39m[38;5;204m.[39m[38;5;15m [39m[38;5;15mFor[39m[38;5;15m [39m[38;5;15mexample[39m[38;5;15m:[39m
[38;5;15mprivate[39m[38;5;15m [39m[38;5;81mstatic[39m[38;5;15m [39m[38;5;15mfinal[39m[38;5;15m [39m[38;5;15mString[39m[38;5;15m [39m[38;5;15mSTANDALONE_GRAPHSPACE_ERROR[39m[38;5;15m [39m[38;5;204m=[39m[38;5;15m [39m[38;5;186m"[39m[38;5;186mGraphSpace management is not supported in standalone mode[39m[38;5;186m"[39m[38;5;15m;[39m
[38;5;15mThen[39m[38;5;15m [39m[38;5;15mthrow[39m[38;5;15m [39m[38;5;15mnew[39m[38;5;15m [39m[38;5;15mHugeException[39m[38;5;15m([39m[38;5;15mSTANDALONE_GRAPHSPACE_ERROR[39m[38;5;15m)[39m[38;5;15m;[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;15mupdate[39m[38;5;15m [39m[38;5;15mtests[39m[38;5;15m [39m[38;5;15mto[39m[38;5;15m [39m[38;5;15mreference[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mconstant[39m[38;5;15m [39m[38;5;15mwhere[39m[38;5;15m [39m[38;5;15mpractical[39m[38;5;204m.[39m
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936769177
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
Review Comment:
[38;5;15mConsider[39m[38;5;15m [39m[38;5;15mrenaming[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mcheckPdModeEnabled(GraphManager manager)[39m[38;5;15m`[39m[38;5;15m.[39m[38;5;15m [39m[38;5;15mThe[39m[38;5;15m [39m[38;5;81mcurrent[39m[38;5;15m [39m[38;5;81mname[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;15mnon[39m[38;5;204m-[39m[38;5;15midiomatic[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15mmethod[39m[38;5;15m [39m[38;5;15mthat[39m[38;5;15m [39m[38;5;15mthrows[39m[38;5;15m [39m[38;5;81mon[39m[38;5;15m [39m[38;5;15mfailure[39m[38;5;15m;[39m[38;5;15m [39m[38;5;15mprefer[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15mverb[39m[38;5;15m [39m[38;5;15mthat[39m[38;5;15m [39m[38;5;15mindicates[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m [39m[38;5;15masserts[39m[38;5;204m/[39m[38;5;15mensures[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [3
9m[38;5;81mcondition[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15me[39m[38;5;15m.[39m[38;5;15mg[39m[38;5;15m.[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mensurePdModeEnabled(...)[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mor[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mrequirePdModeEnabled(...)[39m[38;5;15m`[39m[38;5;15m.[39m
[38;5;15mAlso[39m[38;5;15m [39m[38;5;15mconsider[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;81mfollowing[39m[38;5;15m [39m[38;5;15mimprovements[39m[38;5;204m:[39m
[38;5;204m-[39m[38;5;15m [39m[38;5;81mAdd[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15mdefensive[39m[38;5;15m [39m[38;5;81mnull[39m[38;5;204m-[39m[38;5;81mcheck[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mmanager[39m[38;5;15m`[39m[38;5;15m [39m[38;5;15mparameter[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15me[39m[38;5;15m.[39m[38;5;15mg[39m[38;5;15m.[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mE.checkArgumentNotNull(manager, "manager can't be null")[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mto[39m[38;5;15m [39m[38;5;15mavoid[39m[38;5;15m [39m[38;5;15mpotential[39m[38;5;15m [39m[38;5;15mNPEs[39m[38;5;15m.[39m
[38;5;204m-[39m[38;5;15m [39m[38;5;81mAdd[39m[38;5;15m [39m[38;5;15mJavadoc[39m[38;5;15m [39m[38;5;15mdescribing[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mmethod[39m[38;5;186m'[39m[38;5;186ms behaviour and the exception it throws (`HugeException` when PD mode is not enabled).[39m
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
Review Comment:
[38;5;15mThis[39m[38;5;15m [39m[38;5;15mhelper[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;15mdeclared[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mpublic static[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mon[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mwidely[39m[38;5;204m-[39m[38;5;15mused[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mAPI[39m[38;5;15m`[39m[38;5;15m [39m[38;5;15mbase[39m[38;5;15m [39m[38;5;15mclass[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15mwhich[39m[38;5;15m [39m[38;5;15munnecessarily[39m[38;5;15m [39m[38;5;15mexpands[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mpublic[39m[38;5;15m [39m[38;5;15mAPI[39m[38;5;15m [39m[38;5;15msurface[39m[38;5;15m.[39m[38;5;15m [39m[38;5;81mIf[39m[38;5;15m [39m[38;5;15mthis[39m[38;5;15m [39m[38;5;15mmethod[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;81monly[39m[38;5;15m [39m[38;5;15mused[39m[38;5;15m [
39m[38;5;81mby[39m[38;5;15m [39m[38;5;15mAPI[39m[38;5;15m [39m[38;5;15msubclasses[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15mconsider[39m[38;5;15m [39m[38;5;15mreducing[39m[38;5;15m [39m[38;5;15mvisibility[39m[38;5;15m [39m[38;5;15m([39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15mexample[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mprotected[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mor[39m[38;5;15m [39m[38;5;15mpackage[39m[38;5;204m-[39m[38;5;15mprivate[39m[38;5;15m)[39m[38;5;15m [39m[38;5;15mso[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;81mnot[39m[38;5;15m [39m[38;5;15mexposed[39m[38;5;15m [39m[38;5;81mas[39m[38;5;15m [39m[38;5;15mpart[39m[38;5;15m [39m[38;5;81mof[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mpublic[39m[38;5;15m [39m[38;5;15mAPI[39m[38;5;15m.[39m
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
+ if (!manager.usePD()) {
+ throw new HugeException(
+ "GraphSpace management is not supported in standalone mode");
Review Comment:
[38;5;15mThe[39m[38;5;15m [39m[38;5;15merror[39m[38;5;15m [39m[38;5;15mmessage[39m[38;5;15m [39m[38;5;15mstring[39m[38;5;15m [39m[38;5;198;48;5;233m`[39;49m[38;5;186m"[39m[38;5;186mGraphSpace management is not supported in standalone mode[39m[38;5;186m"[39m[38;5;198;48;5;233m`[39;49m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;15mduplicated[39m[38;5;15m [39m[38;5;15mbetween[39m[38;5;15m [39m[38;5;15mthis[39m[38;5;15m [39m[38;5;15mcode[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mtests[39m[38;5;15m [39m[38;5;15m([39m[38;5;15me[39m[38;5;204m.[39m[38;5;15mg[39m[38;5;204m.[39m[38;5;15m [39m[38;5;15mGraphSpaceApiStandaloneTest[39m[38;5;15m [39m[38;5;204m/[39m[38;5;15m [39m[38;5;15mManagerApiStandaloneTest[39m[38;5;15m)[39m[38;5;204m.[39m[38;5;15m [39m[38;5;15mExtract[39m[38;5;15m [39m[38;5;15mthis[39m[38;5;15m [39m[38;5;15mliteral[39m[38;5;15m
[39m[38;5;15minto[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15msingle[39m[38;5;15m [39m[38;5;15mconstant[39m[38;5;15m [39m[38;5;15mto[39m[38;5;15m [39m[38;5;15mavoid[39m[38;5;15m [39m[38;5;15mduplication[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;15mensure[39m[38;5;15m [39m[38;5;15mconsistency[39m[38;5;15m,[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15mexample[39m[38;5;15m:[39m
[38;5;198;48;5;233m`[39;49m[38;5;198;48;5;233m`[39;49m[38;5;198;48;5;233m`[39;49m
[38;5;15mprivate[39m[38;5;15m [39m[38;5;81mstatic[39m[38;5;15m [39m[38;5;15mfinal[39m[38;5;15m [39m[38;5;15mString[39m[38;5;15m [39m[38;5;15mSTANDALONE_ERROR[39m[38;5;15m [39m[38;5;204m=[39m
[38;5;15m [39m[38;5;186m"[39m[38;5;186mGraphSpace management is not supported in standalone mode[39m[38;5;186m"[39m[38;5;15m;[39m
[38;5;198;48;5;233m`[39;49m[38;5;198;48;5;233m`[39;49m[38;5;198;48;5;233m`[39;49m
[38;5;15mIf[39m[38;5;15m [39m[38;5;15mtests[39m[38;5;15m [39m[38;5;15mneed[39m[38;5;15m [39m[38;5;15mto[39m[38;5;15m [39m[38;5;15mreference[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15mconsider[39m[38;5;15m [39m[38;5;15mplacing[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m [39m[38;5;204min[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15mshared[39m[38;5;15m [39m[38;5;15mtest[39m[38;5;204m-[39m[38;5;15mfriendly[39m[38;5;15m [39m[38;5;15mlocation[39m[38;5;15m [39m[38;5;204mor[39m[38;5;15m [39m[38;5;15mmaking[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m [39m[38;5;15mpackage[39m[38;5;204m-[39m[38;5;15mvisible[39m[38;5;204m/[39m[38;5;15mpublic[39m[38;5;15m [39m[38;5;81mas[39m[38;5;15m [39m[38;5;15mappropriate[39m[38;5;204m.[39m
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -276,7 +276,7 @@ private static String serviceId(String graphSpace, Service.ServiceType type,
.replace("_", "-").toLowerCase();
}
- private boolean usePD() {
+ public boolean usePD() {
Review Comment:
[38;5;15mThe[39m[38;5;15m [39m[38;5;15mmethod[39m[38;5;15m [39m[38;5;81mname[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15musePD()[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;15mambiguous[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;81mboolean[39m[38;5;15m [39m[38;5;15mgetter[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mdoes[39m[38;5;15m [39m[38;5;81mnot[39m[38;5;15m [39m[38;5;15mfollow[39m[38;5;15m [39m[38;5;15mstandard[39m[38;5;15m [39m[38;5;15mJava[39m[38;5;15m [39m[38;5;81mboolean[39m[38;5;15m [39m[38;5;15mnaming[39m[38;5;15m [39m[38;5;15mconventions[39m[38;5;15m.[39m[38;5;15m [39m[38;5;15mConsider[39m[38;5;15m [39m[38;5;15mrenaming[39m[38;5;15m [39m[38;5;81mto[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15misPdEnabled()[39m[38;5;15m`[39m[38;5;15m [39m[38;5;15m([39m[38;5;81mor[39m[38;5;15m [39m[38;5;15m`[39m[38;5
;15misUsePD()[39m[38;5;15m`[39m[38;5;15m)[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15mclarity[39m[38;5;15m,[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mreview[39m[38;5;15m [39m[38;5;15mwhether[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m [39m[38;5;15mneeds[39m[38;5;15m [39m[38;5;81mto[39m[38;5;15m [39m[38;5;15mbe[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mpublic[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mor[39m[38;5;15m [39m[38;5;15mcan[39m[38;5;15m [39m[38;5;15mbe[39m[38;5;15m [39m[38;5;15mmade[39m[38;5;15m [39m[38;5;81mless[39m[38;5;15m [39m[38;5;81mvisible[39m[38;5;15m [39m[38;5;81mif[39m[38;5;15m [39m[38;5;15mused[39m[38;5;15m [39m[38;5;81monly[39m[38;5;15m [39m[38;5;15minternally[39m[38;5;15m.[39m
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -748,6 +739,28 @@ public static RestClient analystClient(String graphSpace, String username) {
return analystClient;
}
+ /**
+ * Skips the current test if the server is running in hstore / PD mode.
+ * Treats both {@code "hstore"} and {@code null} (i.e. the property is not
+ * set, which is the default in hstore CI runs) as PD mode.
+ * Call this from a {@code @Before} method in standalone-only test classes.
+ */
+ public static void assumeStandaloneMode() {
+ String backend = System.getProperty("backend");
+ Assume.assumeTrue(
+ "skip standalone tests: backend is '" + backend + "' (hstore/PD mode)",
+ backend != null && !backend.equals("hstore"));
Review Comment:
[38;5;15mThe[39m[38;5;15m [39m[38;5;81mcurrent[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15massumeStandaloneMode()[39m[38;5;15m`[39m[38;5;15m [39m[38;5;15muses[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;81mdouble[39m[38;5;204m-[39m[38;5;15mnegative[39m[38;5;15m [39m[38;5;81min[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;81mcondition[39m[38;5;15m [39m[38;5;15m([39m[38;5;15m`[39m[38;5;15mbackend != null && !backend.equals("hstore")[39m[38;5;15m`[39m[38;5;15m)[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15mwhich[39m[38;5;15m [39m[38;5;15mreduces[39m[38;5;15m [39m[38;5;15mreadability[39m[38;5;15m.[39m[38;5;15m [39m[38;5;81mFor[39m[38;5;15m [39m[38;5;15mclarity[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;81mnull[39m[38;5;204m-[39m[38;5;15msafety[39m[38;5;15m [39m[38;5;15mprefer[39m[38;5;15m [39m[38;5;15man[39m[38;5;15m [39m[38;5;15mexplicit[39m[38;5;15m [39m[38;5;81mbo
olean[39m[38;5;15m [39m[38;5;15mvariable[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mAssume.assumeFalse[39m[38;5;15m`[39m[38;5;15m,[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15mexample[39m[38;5;204m:[39m
[38;5;15m`[39m[38;5;15m``[39m
[38;5;15mboolean isPdMode = backend == null || backend.equals("hstore");[39m
[38;5;15mAssume.assumeFalse([39m
[38;5;15m "skip standalone tests: backend is '" + backend + "' (hstore/PD mode)",[39m
[38;5;15m isPdMode);[39m
[38;5;15m``[39m[38;5;15m`[39m
[38;5;15mThis[39m[38;5;15m [39m[38;5;15mmakes[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mintent[39m[38;5;15m [39m[38;5;15m([39m[38;5;15m`[39m[38;5;15misPdMode[39m[38;5;15m`[39m[38;5;15m)[39m[38;5;15m [39m[38;5;15mexplicit[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mavoids[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;81mdouble[39m[38;5;204m-[39m[38;5;15mnegative[39m[38;5;15m.[39m
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936757831
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -748,6 +739,28 @@ public static RestClient analystClient(String graphSpace, String username) {
return analystClient;
}
+ /**
+ * Skips the current test if the server is running in hstore / PD mode.
+ * Treats both {@code "hstore"} and {@code null} (i.e. the property is not
+ * set, which is the default in hstore CI runs) as PD mode.
+ * Call this from a {@code @Before} method in standalone-only test classes.
+ */
+ public static void assumeStandaloneMode() {
+ String backend = System.getProperty("backend");
Review Comment:
[38;5;15m⚠️[39m[38;5;15m [39m[38;5;15mSuggestion[39m[38;5;204m:[39m[38;5;15m [39m[38;5;15mclarify[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15msimplify[39m[38;5;15m [39m[38;5;15massumeStandaloneMode[39m[38;5;15m([39m[38;5;15m)[39m
[38;5;15mThe[39m[38;5;15m [39m[38;5;81mcurrent[39m[38;5;15m [39m[38;5;81mcondition[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mAssume.assumeTrue(backend != null && !backend.equals("hstore"))[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;81mdouble[39m[38;5;204m-[39m[38;5;15mnegative[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mcan[39m[38;5;15m [39m[38;5;15mbe[39m[38;5;15m [39m[38;5;15mhard[39m[38;5;15m [39m[38;5;81mto[39m[38;5;15m [39m[38;5;81mread[39m[38;5;15m.[39m[38;5;15m [39m[38;5;15mConsider[39m[38;5;15m [39m[38;5;15mexpressing[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;81mskip[39m[38;5;15m [39m[38;5;81mcondition[39m[38;5;15m [39m[38;5;15mexplicitly[39m[38;5;15m [39m[38;5;81mwith[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15massumeFalse[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mavoiding[39
m[38;5;15m [39m[38;5;15mNPEs[39m[38;5;15m.[39m[38;5;15m [39m[38;5;81mFor[39m[38;5;15m [39m[38;5;15mexample[39m[38;5;204m:[39m
[38;5;15mpublic[39m[38;5;15m [39m[38;5;15mstatic[39m[38;5;15m [39m[38;5;15mvoid[39m[38;5;15m [39m[38;5;15massumeStandaloneMode[39m[38;5;15m([39m[38;5;15m)[39m[38;5;15m [39m[38;5;198;48;5;233m{[39;49m
[38;5;15m [39m[38;5;81mString[39m[38;5;15m [39m[38;5;15mbackend[39m[38;5;15m [39m[38;5;204m=[39m[38;5;15m [39m[38;5;81mSystem[39m[38;5;15m.[39m[38;5;15mgetProperty[39m[38;5;15m([39m[38;5;186m"[39m[38;5;186mbackend[39m[38;5;186m"[39m[38;5;15m)[39m[38;5;15m;[39m
[38;5;15m [39m[38;5;81mboolean[39m[38;5;15m [39m[38;5;15misPdMode[39m[38;5;15m [39m[38;5;204m=[39m[38;5;15m [39m[38;5;15mbackend[39m[38;5;15m [39m[38;5;204m==[39m[38;5;15m [39m[38;5;81mnull[39m[38;5;15m [39m[38;5;204m||[39m[38;5;15m [39m[38;5;186m"[39m[38;5;186mhstore[39m[38;5;186m"[39m[38;5;15m.[39m[38;5;15mequals[39m[38;5;15m([39m[38;5;15mbackend[39m[38;5;15m)[39m[38;5;15m;[39m
[38;5;15m [39m[38;5;15mAssume[39m[38;5;15m.[39m[38;5;15massumeFalse[39m[38;5;15m([39m[38;5;186m"[39m[38;5;186mskip standalone tests: backend='[39m[38;5;186m"[39m[38;5;15m [39m[38;5;204m+[39m[38;5;15m [39m[38;5;15mbackend[39m[38;5;15m [39m[38;5;204m+[39m[38;5;15m [39m[38;5;186m"[39m[38;5;186m' (hstore/PD mode)[39m[38;5;186m"[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15misPdMode[39m[38;5;15m)[39m[38;5;15m;[39m
[38;5;198;48;5;233m}[39;49m
[38;5;15mThis[39m[38;5;15m [39m[38;5;15mmakes[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mintent[39m[38;5;15m [39m[38;5;15mclearer[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mavoids[39m[38;5;15m [39m[38;5;81mnull[39m[38;5;15m [39m[38;5;15mchecks[39m[38;5;15m [39m[38;5;81min[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;81mboolean[39m[38;5;15m [39m[38;5;15mexpression[39m[38;5;15m.[39m
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "contrueCT (via GitHub)" <gi...@apache.org>.
contrueCT commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2919588048
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -193,7 +183,8 @@ protected static void waitTaskStatus(int task, Set<String> expectedStatus) {
Assert.fail(String.format("Failed to wait for task %s " +
"due to timeout", task));
}
- } while (!expectedStatus.contains(status));
+ }
+ while (!expectedStatus.contains(status));
Review Comment:
This is not a part of this pr.I am not sure its logic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936782282
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
Review Comment:
⚠️ Method name `checkPdModeEnabled()` is non-idiomatic for a method that throws — Java convention uses imperative names like `ensure*` or `require*` for assertion/guard methods. Consider renaming:
```java
public static void ensurePdModeEnabled(GraphManager manager) {
```
Also missing: a null-check for `manager` and a Javadoc comment explaining what exception is thrown and when.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
Review Comment:
⚠️ Declaring this as `public static` on the widely-used `API` base class unnecessarily expands the public API surface. Since this guard is only called from API subclasses, consider reducing visibility to `protected`:
```java
protected static void checkPdModeEnabled(GraphManager manager) {
```
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
+ if (!manager.usePD()) {
+ throw new HugeException(
+ "GraphSpace management is not supported in standalone mode");
Review Comment:
🧹 The error message `"GraphSpace management is not supported in standalone mode"` is duplicated across production code and tests. Extract it to a constant to avoid typos and make future changes easier:
```java
private static final String PD_MODE_REQUIRED_MSG =
"GraphSpace management is not supported in standalone mode";
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2958443350
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -74,6 +74,8 @@ public class BaseApiTest {
private static final String GRAPH_VERTEX = "/graph/vertices";
private static final String GRAPH_EDGE = "/graph/edges";
private static final String BATCH = "/batch";
+ static final String STANDALONE_ERROR =
+ "GraphSpace management is not supported in standalone mode";
Review Comment:
Should not add an error log in BaseTest
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2911691470
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/space/GraphSpaceAPI.java:
##########
@@ -76,6 +76,7 @@ public class GraphSpaceAPI extends API {
@Produces(APPLICATION_JSON_WITH_CHARSET)
public Object list(@Context GraphManager manager,
@Context SecurityContext sc) {
+ checkPdModeEnabled(manager);
Review Comment:
‼️ `checkPdModeEnabled()` is added to the other GraphSpace endpoints, but `/graphspaces/profile` is still unguarded. In standalone mode this method will continue to return a different result instead of the new 400, so the API contract remains inconsistent. Please add the same guard to `listProfile()` and extend the standalone coverage to hit `/graphspaces/profile` as well.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936778089
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -748,6 +739,28 @@ public static RestClient analystClient(String graphSpace, String username) {
return analystClient;
}
+ /**
+ * Skips the current test if the server is running in hstore / PD mode.
+ * Treats both {@code "hstore"} and {@code null} (i.e. the property is not
+ * set, which is the default in hstore CI runs) as PD mode.
+ * Call this from a {@code @Before} method in standalone-only test classes.
+ */
+ public static void assumeStandaloneMode() {
+ String backend = System.getProperty("backend");
+ Assume.assumeTrue(
+ "skip standalone tests: backend is '" + backend + "' (hstore/PD mode)",
+ backend != null && !backend.equals("hstore"));
Review Comment:
⚠️ `assumeStandaloneMode()` uses a double-negative condition (`backend != null && !backend.equals("hstore")`), which reduces readability. Prefer an explicit boolean variable and `Assume.assumeFalse(...)` for clarity and null-safety:
```java
boolean isPdMode = "hstore".equals(backend);
Assume.assumeFalse("Skip in PD/distributed mode", isPdMode);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936742351
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/ManagerApiTest.java:
##########
@@ -326,15 +322,15 @@ protected List<Map<String, Object>> listUsers(String graphSpace, String graph) {
Response r = this.client().get(userPath, ImmutableMap.of("limit", NO_LIMIT));
String result = assertResponseStatus(200, r);
- Map<String, List<Map<String, Object>>> resultMap =
- JsonUtil.fromJson(result, new TypeReference<Map<String,
- List<Map<String, Object>>>>() {
- });
+ Map<String, List<Map<String, Object>>> resultMap = JsonUtil.fromJson(result,
+ new TypeReference<Map<String, List<Map<String, Object>>>>() {
+ });
Review Comment:
This reformatted block exceeds the 100-character line length enforced by checkstyle (see `style/checkstyle.xml:29-30`). Line 326 is approximately 130+ characters due to deep alignment indentation. Consider breaking the `TypeReference` instantiation onto a separate variable or reducing the alignment depth.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2958159664
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/GraphSpaceApiStandaloneTest.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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.
+ */
+
+package org.apache.hugegraph.api;
+
+import com.google.common.collect.ImmutableMap;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import jakarta.ws.rs.core.Response;
+
+/**
+ * Tests that GraphSpaceAPI returns a friendly HTTP 400 error in standalone
+ * mode (i.e. when the server is started without PD / hstore backend).
+ * <p>
+ * This class intentionally does NOT have a class-level Assume guard so that
+ * the tests are actually executed in non-hstore CI runs.
+ */
+public class GraphSpaceApiStandaloneTest extends BaseApiTest {
+
+ private static final String PATH = "graphspaces";
+ private static final String STANDALONE_ERROR =
+ "GraphSpace management is not supported in standalone mode";
Review Comment:
`STANDALONE_ERROR` is duplicated here and in `ManagerApiStandaloneTest`. To avoid future drift if the server message changes, consider centralizing this string in a shared test constant (e.g., `BaseApiTest`) and referencing it from both standalone-mode test classes.
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/ManagerApiStandaloneTest.java:
##########
@@ -0,0 +1,131 @@
+/*
+ * 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.
+ */
+
+package org.apache.hugegraph.api;
+
+import java.util.Map;
+
+import org.apache.hugegraph.auth.HugePermission;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import jakarta.ws.rs.core.Response;
+
+/**
+ * Tests that ManagerAPI returns a friendly HTTP 400 error in standalone mode
+ * (i.e. when the server is started without PD / hstore backend).
+ * <p>
+ * This class intentionally does NOT have a class-level Assume guard so that
+ * the tests are actually executed in non-hstore CI runs.
+ */
+public class ManagerApiStandaloneTest extends BaseApiTest {
+
+ private static final String STANDALONE_ERROR =
+ "GraphSpace management is not supported in standalone mode";
+
Review Comment:
`STANDALONE_ERROR` is duplicated here and in `GraphSpaceApiStandaloneTest`. To avoid future drift if the server message changes, consider centralizing this string in a shared test constant (e.g., `BaseApiTest`) and referencing it from both standalone-mode test classes.
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -748,6 +739,27 @@ public static RestClient analystClient(String graphSpace, String username) {
return analystClient;
}
+ /**
+ * Skips the current test if the server is running in hstore / PD mode.
+ * Treats both {@code "hstore"} and {@code null} (i.e. the property is not
+ * set, which is the default in hstore CI runs) as PD mode.
+ * Call this from a {@code @Before} method in standalone-only test classes.
+ */
+ public static void assumeStandaloneMode() {
+ String backend = System.getProperty("backend");
+ boolean isPdMode = backend == null || "hstore".equals(backend);
+ Assume.assumeFalse("Skip in PD/distributed mode", isPdMode);
Review Comment:
The Javadoc and assumption message imply `backend == null` is effectively PD/hstore mode. In this test module, `backend` is generally expected to be explicitly set (and other tests treat null as its own “unset/invalid” case). Consider updating the Javadoc and the Assume message to reflect that null means “backend not provided/unknown” (and is skipped for safety), rather than specifically “default in hstore CI runs”.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936755627
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
Review Comment:
[38;5;198;48;5;233m⚠[39;49m[38;5;198;48;5;233m️[39;49m[38;5;15m [39m[38;5;204mSuggestion[39m[38;5;204m:[39m[38;5;15m [39m[38;5;204mrename[39m[38;5;15m [39m[38;5;204mcheckPdModeEnabled[39m[38;5;15m [39m[38;5;204mto[39m[38;5;15m [39m[38;5;204ma[39m[38;5;15m [39m[38;5;204mclearer[39m[38;5;15m [39m[38;5;204mname[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;204madd[39m[38;5;15m [39m[38;5;204mnull-check[39m
[38;5;204mThis[39m[38;5;15m [39m[38;5;204mmethod[39m[38;5;15m [39m[38;5;204mthrows[39m[38;5;15m [39m[38;5;204mwhen[39m[38;5;15m [39m[38;5;204mPD[39m[38;5;15m [39m[38;5;204mmode[39m[38;5;15m [39m[38;5;204mis[39m[38;5;15m [39m[38;5;204mnot[39m[38;5;15m [39m[38;5;204menabled[39m[38;5;204m.[39m[38;5;15m [39m[38;5;204mRename[39m[38;5;15m [39m[38;5;204mto[39m[38;5;15m [39m[38;5;204mmake[39m[38;5;15m [39m[38;5;204mthe[39m[38;5;15m [39m[38;5;204mcontract[39m[38;5;15m [39m[38;5;204mexplicit[39m[38;5;15m [39m[38;5;204m([39m[38;5;204mfor[39m[38;5;15m [39m[38;5;204mexample[39m[38;5;15m [39m[38;5;204mensurePdModeEnabled[39m[38;5;15m [39m[38;5;204mor[39m[38;5;15m [39m[38;5;204mrequirePdModeEnabled[39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;204madd[39m[38;5;15m [39m[38;5;204ma[39m[38;5;15m [39m[38;5;204mnull-check[39m[38;5;15m [39m[38;5;204m+[39m[38;5;15m [39m[38;5
;204mJavadoc[39m[38;5;204m.[39m[38;5;15m [39m[38;5;204mSuggested[39m[38;5;15m [39m[38;5;204mchange[39m[38;5;204m:[39m
[38;5;204mpublic[39m[38;5;15m [39m[38;5;204mstatic[39m[38;5;15m [39m[38;5;204mvoid[39m[38;5;15m [39m[38;5;204mensurePdModeEnabled[39m[38;5;204m([39m[38;5;204mGraphManager[39m[38;5;15m [39m[38;5;204mmanager[39m[38;5;204m)[39m[38;5;15m [39m[38;5;15m{[39m
[38;5;15m [39m[38;5;198;48;5;233mE[39;49m[38;5;198;48;5;233m.[39;49m[38;5;198;48;5;233mc[39;49m[38;5;198;48;5;233mh[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mc[39;49m[38;5;198;48;5;233mk[39;49m[38;5;198;48;5;233mA[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mN[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mN[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233ml[39;49m[38;5;198;48;5;233ml[39;49m[38;5;198;48;5;233m([39;49m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233m,[39;49m[38;5;15m [39m[38;5;198;48;5;233m"[39;49m[38;5;198;48;5;233mG[39;49m[3
8;5;198;48;5;233mr[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233mh[39;49m[38;5;198;48;5;233mM[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mr[39;49m[38;5;15m [39m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233mt[39;49m[38;5;15m [39m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mt[39;49m[38;5;15m [39m[38;5;198;48;5;233mb[39;49m[38;5;198;48;5;233me[39;49m[38;5;15m [39m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233ml[39;49m[38;5;198;48;5;233ml[39;49m[38;5;198;48;5;233m"[39;49m[38;5;198;48;5;233m)[39;49m[38;5;15m;[39m
[38;5;15m [39m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233mf[39;49m[38;5;15m [39m[38;5;198;48;5;233m([39;49m[38;5;198;48;5;233m![39;49m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233m.[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mP[39;49m[38;5;198;48;5;233mD[39;49m[38;5;198;48;5;233m([39;49m[38;5;198;48;5;233m)[39;49m[38;5;198;48;5;233m)[39;49m[38;5;15m [39m[38;5;198;48;5;233m{[39;49m
[38;5;15m [39m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mh[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mw[39;49m[38;5;15m [39m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mw[39;49m[38;5;15m [39m[38;5;198;48;5;233mH[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mE[39;49m[38;5;198;48;5;233mx[39;49m[38;5;198;48;5;233mc[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233m([39;49m[38;5;198;48;5;233m"[39;49m[38;5;198;48;5;233mG[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233mh[39;49m[38;5;198;48;5;233mS[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mc[39;49m[38;5;198;4
8;5;233me[39;49m[38;5;15m [39m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233mt[39;49m[38;5;15m [39m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233ms[39;49m[38;5;15m [39m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mt[39;49m[38;5;15m [39m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233md[39;49m[38;5;15m [39m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233mn[39;49m[38;5;15m [39m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;
5;233md[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233ml[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233me[39;49m[38;5;15m [39m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233md[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233m"[39;49m[38;5;198;48;5;233m)[39;49m[38;5;15m;[39m
[38;5;15m [39m[38;5;15m}[39m
[38;5;198;48;5;233m}[39;49m
[38;5;204mThen[39m[38;5;15m [39m[38;5;204mupdate[39m[38;5;15m [39m[38;5;204mcall[39m[38;5;15m [39m[38;5;204msites[39m[38;5;15m [39m[38;5;204m([39m[38;5;204mGraphSpaceAPI[39m[38;5;204m,[39m[38;5;15m [39m[38;5;204mManagerAPI[39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mto[39m[38;5;15m [39m[38;5;204mcall[39m[38;5;15m [39m[38;5;204mensurePdModeEnabled[39m[38;5;204m([39m[38;5;204mmanager[39m[38;5;204m)[39m[38;5;204m.[39m
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936769177
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
Review Comment:
[38;5;15mConsider[39m[38;5;15m [39m[38;5;15mrenaming[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mcheckPdModeEnabled(GraphManager manager)[39m[38;5;15m`[39m[38;5;15m.[39m[38;5;15m [39m[38;5;15mThe[39m[38;5;15m [39m[38;5;81mcurrent[39m[38;5;15m [39m[38;5;81mname[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;15mnon[39m[38;5;204m-[39m[38;5;15midiomatic[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15mmethod[39m[38;5;15m [39m[38;5;15mthat[39m[38;5;15m [39m[38;5;15mthrows[39m[38;5;15m [39m[38;5;81mon[39m[38;5;15m [39m[38;5;15mfailure[39m[38;5;15m;[39m[38;5;15m [39m[38;5;15mprefer[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15mverb[39m[38;5;15m [39m[38;5;15mthat[39m[38;5;15m [39m[38;5;15mindicates[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m [39m[38;5;15masserts[39m[38;5;204m/[39m[38;5;15mensures[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [3
9m[38;5;81mcondition[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15me[39m[38;5;15m.[39m[38;5;15mg[39m[38;5;15m.[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mensurePdModeEnabled(...)[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mor[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mrequirePdModeEnabled(...)[39m[38;5;15m`[39m[38;5;15m.[39m
[38;5;15mAlso[39m[38;5;15m [39m[38;5;15mconsider[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;81mfollowing[39m[38;5;15m [39m[38;5;15mimprovements[39m[38;5;204m:[39m
[38;5;204m-[39m[38;5;15m [39m[38;5;81mAdd[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15mdefensive[39m[38;5;15m [39m[38;5;81mnull[39m[38;5;204m-[39m[38;5;81mcheck[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mmanager[39m[38;5;15m`[39m[38;5;15m [39m[38;5;15mparameter[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15me[39m[38;5;15m.[39m[38;5;15mg[39m[38;5;15m.[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mE.checkArgumentNotNull(manager, "manager can't be null")[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mto[39m[38;5;15m [39m[38;5;15mavoid[39m[38;5;15m [39m[38;5;15mpotential[39m[38;5;15m [39m[38;5;15mNPEs[39m[38;5;15m.[39m
[38;5;204m-[39m[38;5;15m [39m[38;5;81mAdd[39m[38;5;15m [39m[38;5;15mJavadoc[39m[38;5;15m [39m[38;5;15mdescribing[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mmethod[39m[38;5;186m'[39m[38;5;186ms behaviour and the exception it throws (`HugeException` when PD mode is not enabled).[39m
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
Review Comment:
[38;5;15mThis[39m[38;5;15m [39m[38;5;15mhelper[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;15mdeclared[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mpublic static[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mon[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mwidely[39m[38;5;204m-[39m[38;5;15mused[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mAPI[39m[38;5;15m`[39m[38;5;15m [39m[38;5;15mbase[39m[38;5;15m [39m[38;5;15mclass[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15mwhich[39m[38;5;15m [39m[38;5;15munnecessarily[39m[38;5;15m [39m[38;5;15mexpands[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mpublic[39m[38;5;15m [39m[38;5;15mAPI[39m[38;5;15m [39m[38;5;15msurface[39m[38;5;15m.[39m[38;5;15m [39m[38;5;81mIf[39m[38;5;15m [39m[38;5;15mthis[39m[38;5;15m [39m[38;5;15mmethod[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;81monly[39m[38;5;15m [39m[38;5;15mused[39m[38;5;15m [
39m[38;5;81mby[39m[38;5;15m [39m[38;5;15mAPI[39m[38;5;15m [39m[38;5;15msubclasses[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15mconsider[39m[38;5;15m [39m[38;5;15mreducing[39m[38;5;15m [39m[38;5;15mvisibility[39m[38;5;15m [39m[38;5;15m([39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15mexample[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mprotected[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mor[39m[38;5;15m [39m[38;5;15mpackage[39m[38;5;204m-[39m[38;5;15mprivate[39m[38;5;15m)[39m[38;5;15m [39m[38;5;15mso[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;81mnot[39m[38;5;15m [39m[38;5;15mexposed[39m[38;5;15m [39m[38;5;81mas[39m[38;5;15m [39m[38;5;15mpart[39m[38;5;15m [39m[38;5;81mof[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mpublic[39m[38;5;15m [39m[38;5;15mAPI[39m[38;5;15m.[39m
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
+ if (!manager.usePD()) {
+ throw new HugeException(
+ "GraphSpace management is not supported in standalone mode");
Review Comment:
[38;5;15mThe[39m[38;5;15m [39m[38;5;15merror[39m[38;5;15m [39m[38;5;15mmessage[39m[38;5;15m [39m[38;5;15mstring[39m[38;5;15m [39m[38;5;198;48;5;233m`[39;49m[38;5;186m"[39m[38;5;186mGraphSpace management is not supported in standalone mode[39m[38;5;186m"[39m[38;5;198;48;5;233m`[39;49m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;15mduplicated[39m[38;5;15m [39m[38;5;15mbetween[39m[38;5;15m [39m[38;5;15mthis[39m[38;5;15m [39m[38;5;15mcode[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mtests[39m[38;5;15m [39m[38;5;15m([39m[38;5;15me[39m[38;5;204m.[39m[38;5;15mg[39m[38;5;204m.[39m[38;5;15m [39m[38;5;15mGraphSpaceApiStandaloneTest[39m[38;5;15m [39m[38;5;204m/[39m[38;5;15m [39m[38;5;15mManagerApiStandaloneTest[39m[38;5;15m)[39m[38;5;204m.[39m[38;5;15m [39m[38;5;15mExtract[39m[38;5;15m [39m[38;5;15mthis[39m[38;5;15m [39m[38;5;15mliteral[39m[38;5;15m
[39m[38;5;15minto[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15msingle[39m[38;5;15m [39m[38;5;15mconstant[39m[38;5;15m [39m[38;5;15mto[39m[38;5;15m [39m[38;5;15mavoid[39m[38;5;15m [39m[38;5;15mduplication[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;15mensure[39m[38;5;15m [39m[38;5;15mconsistency[39m[38;5;15m,[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15mexample[39m[38;5;15m:[39m
[38;5;198;48;5;233m`[39;49m[38;5;198;48;5;233m`[39;49m[38;5;198;48;5;233m`[39;49m
[38;5;15mprivate[39m[38;5;15m [39m[38;5;81mstatic[39m[38;5;15m [39m[38;5;15mfinal[39m[38;5;15m [39m[38;5;15mString[39m[38;5;15m [39m[38;5;15mSTANDALONE_ERROR[39m[38;5;15m [39m[38;5;204m=[39m
[38;5;15m [39m[38;5;186m"[39m[38;5;186mGraphSpace management is not supported in standalone mode[39m[38;5;186m"[39m[38;5;15m;[39m
[38;5;198;48;5;233m`[39;49m[38;5;198;48;5;233m`[39;49m[38;5;198;48;5;233m`[39;49m
[38;5;15mIf[39m[38;5;15m [39m[38;5;15mtests[39m[38;5;15m [39m[38;5;15mneed[39m[38;5;15m [39m[38;5;15mto[39m[38;5;15m [39m[38;5;15mreference[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15mconsider[39m[38;5;15m [39m[38;5;15mplacing[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m [39m[38;5;204min[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15mshared[39m[38;5;15m [39m[38;5;15mtest[39m[38;5;204m-[39m[38;5;15mfriendly[39m[38;5;15m [39m[38;5;15mlocation[39m[38;5;15m [39m[38;5;204mor[39m[38;5;15m [39m[38;5;15mmaking[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m [39m[38;5;15mpackage[39m[38;5;204m-[39m[38;5;15mvisible[39m[38;5;204m/[39m[38;5;15mpublic[39m[38;5;15m [39m[38;5;81mas[39m[38;5;15m [39m[38;5;15mappropriate[39m[38;5;204m.[39m
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -276,7 +276,7 @@ private static String serviceId(String graphSpace, Service.ServiceType type,
.replace("_", "-").toLowerCase();
}
- private boolean usePD() {
+ public boolean usePD() {
Review Comment:
[38;5;15mThe[39m[38;5;15m [39m[38;5;15mmethod[39m[38;5;15m [39m[38;5;81mname[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15musePD()[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;15mambiguous[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;81mboolean[39m[38;5;15m [39m[38;5;15mgetter[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mdoes[39m[38;5;15m [39m[38;5;81mnot[39m[38;5;15m [39m[38;5;15mfollow[39m[38;5;15m [39m[38;5;15mstandard[39m[38;5;15m [39m[38;5;15mJava[39m[38;5;15m [39m[38;5;81mboolean[39m[38;5;15m [39m[38;5;15mnaming[39m[38;5;15m [39m[38;5;15mconventions[39m[38;5;15m.[39m[38;5;15m [39m[38;5;15mConsider[39m[38;5;15m [39m[38;5;15mrenaming[39m[38;5;15m [39m[38;5;81mto[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15misPdEnabled()[39m[38;5;15m`[39m[38;5;15m [39m[38;5;15m([39m[38;5;81mor[39m[38;5;15m [39m[38;5;15m`[39m[38;5
;15misUsePD()[39m[38;5;15m`[39m[38;5;15m)[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15mclarity[39m[38;5;15m,[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mreview[39m[38;5;15m [39m[38;5;15mwhether[39m[38;5;15m [39m[38;5;15mit[39m[38;5;15m [39m[38;5;15mneeds[39m[38;5;15m [39m[38;5;81mto[39m[38;5;15m [39m[38;5;15mbe[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mpublic[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mor[39m[38;5;15m [39m[38;5;15mcan[39m[38;5;15m [39m[38;5;15mbe[39m[38;5;15m [39m[38;5;15mmade[39m[38;5;15m [39m[38;5;81mless[39m[38;5;15m [39m[38;5;81mvisible[39m[38;5;15m [39m[38;5;81mif[39m[38;5;15m [39m[38;5;15mused[39m[38;5;15m [39m[38;5;81monly[39m[38;5;15m [39m[38;5;15minternally[39m[38;5;15m.[39m
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -748,6 +739,28 @@ public static RestClient analystClient(String graphSpace, String username) {
return analystClient;
}
+ /**
+ * Skips the current test if the server is running in hstore / PD mode.
+ * Treats both {@code "hstore"} and {@code null} (i.e. the property is not
+ * set, which is the default in hstore CI runs) as PD mode.
+ * Call this from a {@code @Before} method in standalone-only test classes.
+ */
+ public static void assumeStandaloneMode() {
+ String backend = System.getProperty("backend");
+ Assume.assumeTrue(
+ "skip standalone tests: backend is '" + backend + "' (hstore/PD mode)",
+ backend != null && !backend.equals("hstore"));
Review Comment:
[38;5;15mThe[39m[38;5;15m [39m[38;5;81mcurrent[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15massumeStandaloneMode()[39m[38;5;15m`[39m[38;5;15m [39m[38;5;15muses[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;81mdouble[39m[38;5;204m-[39m[38;5;15mnegative[39m[38;5;15m [39m[38;5;81min[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;81mcondition[39m[38;5;15m [39m[38;5;15m([39m[38;5;15m`[39m[38;5;15mbackend != null && !backend.equals("hstore")[39m[38;5;15m`[39m[38;5;15m)[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15mwhich[39m[38;5;15m [39m[38;5;15mreduces[39m[38;5;15m [39m[38;5;15mreadability[39m[38;5;15m.[39m[38;5;15m [39m[38;5;81mFor[39m[38;5;15m [39m[38;5;15mclarity[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;81mnull[39m[38;5;204m-[39m[38;5;15msafety[39m[38;5;15m [39m[38;5;15mprefer[39m[38;5;15m [39m[38;5;15man[39m[38;5;15m [39m[38;5;15mexplicit[39m[38;5;15m [39m[38;5;81mbo
olean[39m[38;5;15m [39m[38;5;15mvariable[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mAssume.assumeFalse[39m[38;5;15m`[39m[38;5;15m,[39m[38;5;15m [39m[38;5;81mfor[39m[38;5;15m [39m[38;5;15mexample[39m[38;5;204m:[39m
[38;5;15m`[39m[38;5;15m``[39m
[38;5;15mboolean isPdMode = backend == null || backend.equals("hstore");[39m
[38;5;15mAssume.assumeFalse([39m
[38;5;15m "skip standalone tests: backend is '" + backend + "' (hstore/PD mode)",[39m
[38;5;15m isPdMode);[39m
[38;5;15m``[39m[38;5;15m`[39m
[38;5;15mThis[39m[38;5;15m [39m[38;5;15mmakes[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mintent[39m[38;5;15m [39m[38;5;15m([39m[38;5;15m`[39m[38;5;15misPdMode[39m[38;5;15m`[39m[38;5;15m)[39m[38;5;15m [39m[38;5;15mexplicit[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mavoids[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;81mdouble[39m[38;5;204m-[39m[38;5;15mnegative[39m[38;5;15m.[39m
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2919474145
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
+ if (!manager.usePD()) {
+ throw new HugeException(
+ "GraphSpace management is not supported in standalone mode");
+ }
+ }
Review Comment:
`checkPdModeEnabled()` is introduced as `public static` on a widely-used API base class, which unnecessarily expands the public surface area. Since it’s an internal guard used by subclasses, consider making it `protected` (or package-private) to avoid exposing it as a public utility.
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -193,7 +183,8 @@ protected static void waitTaskStatus(int task, Set<String> expectedStatus) {
Assert.fail(String.format("Failed to wait for task %s " +
"due to timeout", task));
}
- } while (!expectedStatus.contains(status));
+ }
+ while (!expectedStatus.contains(status));
Review Comment:
This changes the original `do { ... } while (...)` polling into an empty-body `while (...);` loop, and `status` is no longer updated inside the loop. This can spin forever (or at least behave incorrectly) if `status` isn’t already in `expectedStatus`. Restore the polling loop structure so `status` is refreshed each iteration and the loop has a real body.
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -276,7 +276,7 @@ private static String serviceId(String graphSpace, Service.ServiceType type,
.replace("_", "-").toLowerCase();
}
- private boolean usePD() {
+ public boolean usePD() {
Review Comment:
For a public boolean accessor, `usePD()` is a bit ambiguous as a getter name. Consider renaming to a clearer boolean-style accessor (e.g., `isPdEnabled()` / `isUsePD()`), which also matches the PR description and improves readability at call sites.
```suggestion
public boolean isPdEnabled() {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2930146640
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -519,19 +510,20 @@ protected static void initOrClear() {
// isn't hstore
BaseApiTest.clearData();
}
- } else {
+ }
+ else {
Review Comment:
The brace style `}\nelse {` (else on a new line) deviates from the established codebase convention of `} else {` (else on the same line as the closing brace). This is consistently used throughout the codebase (e.g., `API.java:239`, `GraphSpaceAPI.java:129`, and dozens of other files). The same applies to the `}\ncatch` on line 537-538. These appear to be auto-formatter artifacts and should be reverted to match the codebase convention.
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -542,14 +534,15 @@ protected static <T> List<T> readList(String content,
JavaType type = MAPPER.getTypeFactory()
.constructParametricType(List.class, clazz);
return MAPPER.readValue(element.toString(), type);
- } catch (IOException e) {
+ }
+ catch (IOException e) {
Review Comment:
Same issue: `}\ncatch` deviates from the codebase convention of `} catch {` on the same line. See the same convention established throughout the codebase (e.g., `API.java:239`, `GraphsAPI.java:113`).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2911693010
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/ManagerApiTest.java:
##########
@@ -981,4 +981,45 @@ public void testUserWithDifferentRolesInMultipleSpaces() {
Assert.assertTrue("Only graphb1 should remain in spaceb",
graphsList.contains("graphb1") && !graphsList.contains("graphb2"));
}
+
+ @Test
+ public void testStandaloneModeForbidsAllEndpoints() {
+ Assume.assumeFalse("skip this test for hstore (PD mode)",
Review Comment:
⚠️ This standalone test never actually runs. `ManagerApiTest#setUpClass()` has a class-level `Assume.assumeTrue(... hstore ...)`, so JUnit skips the whole class before the method-level `assumeFalse()` is reached here. That means this PR adds no regression coverage for the new standalone behavior. Please move these assertions into a test class that is allowed to run without PD, or relax the class-level guard so this method can execute.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2911593735
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
+ public static void checkPdModeEnabled(GraphManager manager) {
+ if (!manager.isUsePD()) {
+ throw new HugeException(
Review Comment:
`HugeException` is a general internal exception and will typically be mapped to an HTTP 500 response, not 400 as intended and as tested. The tests assert HTTP 400 (`assertResponseStatus(400, r)`), but using `HugeException` directly will likely result in a 500. You should throw the appropriate exception type that maps to HTTP 400 (e.g., `IllegalArgumentException` or a `BadRequestException`), or use an existing API-level exception that carries the desired status code.
```suggestion
throw new IllegalArgumentException(
```
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -280,6 +280,10 @@ private boolean usePD() {
return this.PDExist;
}
+ public boolean isUsePD() {
+ return this.PDExist;
+ }
Review Comment:
The private `usePD()` method and the newly added public `isUsePD()` method have identical implementations. The private method should be removed or replaced by delegating to the public one to avoid duplicated logic.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "contrueCT (via GitHub)" <gi...@apache.org>.
contrueCT commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2912035511
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/ManagerApiTest.java:
##########
@@ -981,4 +981,45 @@ public void testUserWithDifferentRolesInMultipleSpaces() {
Assert.assertTrue("Only graphb1 should remain in spaceb",
graphsList.contains("graphb1") && !graphsList.contains("graphb2"));
}
+
+ @Test
+ public void testStandaloneModeForbidsAllEndpoints() {
+ Assume.assumeFalse("skip this test for hstore (PD mode)",
Review Comment:
OK, I will create a new test class for standalone test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936756643
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -276,7 +276,7 @@ private static String serviceId(String graphSpace, Service.ServiceType type,
.replace("_", "-").toLowerCase();
Review Comment:
[38;5;198;48;5;233m⚠[39;49m[38;5;198;48;5;233m️[39;49m[38;5;15m [39m[38;5;204mSuggestion[39m[38;5;204m:[39m[38;5;15m [39m[38;5;204mrename[39m[38;5;15m [39m[38;5;204mpublic[39m[38;5;15m [39m[38;5;204mboolean[39m[38;5;15m [39m[38;5;204musePD[39m[38;5;204m([39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mto[39m[38;5;15m [39m[38;5;204mfollow[39m[38;5;15m [39m[38;5;204mJava[39m[38;5;15m [39m[38;5;204mboolean[39m[38;5;15m [39m[38;5;204mgetter[39m[38;5;15m [39m[38;5;204mconventions[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;204madd[39m[38;5;15m [39m[38;5;204mJavadoc[39m
[38;5;204mPublicly[39m[38;5;15m [39m[38;5;204mexposing[39m[38;5;15m [39m[38;5;204musePD[39m[38;5;204m([39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mincreases[39m[38;5;15m [39m[38;5;204mthe[39m[38;5;15m [39m[38;5;204mclass[39m[38;5;15m [39m[38;5;204msurface[39m[38;5;204m;[39m[38;5;15m [39m[38;5;204mprefer[39m[38;5;15m [39m[38;5;204ma[39m[38;5;15m [39m[38;5;204mclearer[39m[38;5;15m [39m[38;5;204mname[39m[38;5;15m [39m[38;5;204msuch[39m[38;5;15m [39m[38;5;204mas[39m[38;5;15m [39m[38;5;204misPdEnabled[39m[38;5;204m([39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;204madd[39m[38;5;15m [39m[38;5;204mjavadoc[39m[38;5;15m [39m[38;5;204mdescribing[39m[38;5;15m [39m[38;5;204mPD[39m[38;5;15m [39m[38;5;204msemantics[39m[38;5;204m.[39m[38;5;15m [39m[38;5;204mExample[39m[38;5;204m:[39m
[38;5;245m/** Returns true if placement driver (PD / hstore) is configured/available. */[39m
[38;5;204mpublic[39m[38;5;15m [39m[38;5;204mboolean[39m[38;5;15m [39m[38;5;204misPdEnabled[39m[38;5;204m([39m[38;5;204m)[39m[38;5;15m [39m[38;5;15m{[39m
[38;5;15m [39m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233mn[39;49m[38;5;15m [39m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mh[39;49m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233m.[39;49m[38;5;198;48;5;233mP[39;49m[38;5;198;48;5;233mD[39;49m[38;5;198;48;5;233mE[39;49m[38;5;198;48;5;233mx[39;49m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233mt[39;49m[38;5;15m;[39m
[38;5;15m}[39m
[38;5;204mIf[39m[38;5;15m [39m[38;5;204mcallers[39m[38;5;15m [39m[38;5;204moutside[39m[38;5;15m [39m[38;5;204mcore[39m[38;5;15m [39m[38;5;204mneed[39m[38;5;15m [39m[38;5;204mthe[39m[38;5;15m [39m[38;5;204mcurrent[39m[38;5;15m [39m[38;5;204mname[39m[38;5;204m,[39m[38;5;15m [39m[38;5;204mkeep[39m[38;5;15m [39m[38;5;204musePD[39m[38;5;204m([39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mas[39m[38;5;15m [39m[38;5;204ma[39m[38;5;15m [39m[38;5;204mdeprecated[39m[38;5;15m [39m[38;5;204mdelegate[39m[38;5;15m [39m[38;5;204mthat[39m[38;5;15m [39m[38;5;204mcalls[39m[38;5;15m [39m[38;5;204mthe[39m[38;5;15m [39m[38;5;204mnew[39m[38;5;15m [39m[38;5;204mmethod[39m[38;5;204m.[39m
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2958443350
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -74,6 +74,8 @@ public class BaseApiTest {
private static final String GRAPH_VERTEX = "/graph/vertices";
private static final String GRAPH_EDGE = "/graph/edges";
private static final String BATCH = "/batch";
+ static final String STANDALONE_ERROR =
+ "GraphSpace management is not supported in standalone mode";
Review Comment:
Should not add an error log in BaseTest
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] refactor(server): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin merged PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2930102211
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/ManagerApiStandaloneTest.java:
##########
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+package org.apache.hugegraph.api;
+
+import java.util.Map;
+
+import org.apache.hugegraph.auth.HugePermission;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import jakarta.ws.rs.core.Response;
+
+/**
+ * Tests that ManagerAPI returns a friendly HTTP 400 error in standalone mode
+ * (i.e. when the server is started without PD / hstore backend).
+ * <p>
+ * This class intentionally does NOT have a class-level Assume guard so that
+ * the tests are actually executed in non-hstore CI runs.
+ */
+public class ManagerApiStandaloneTest extends BaseApiTest {
+
+ private static final String STANDALONE_ERROR =
+ "GraphSpace management is not supported in standalone mode";
+
+ private static String managerPath(String graphSpace) {
+ return String.format("graphspaces/%s/auth/managers", graphSpace);
+ }
+
+ @Before
+ public void skipForPdMode() {
+ assumeStandaloneMode();
+ }
+
+ @Test
+ public void testCreateManagerReturnsFriendlyError() {
+ String body = "{\"user\":\"admin\",\"type\":\"ADMIN\"}";
+ Response r = this.client().post(managerPath("DEFAULT"), body);
+ String content = assertResponseStatus(400, r);
+ Assert.assertTrue(content.contains(STANDALONE_ERROR));
+ }
+
+ @Test
+ public void testDeleteManagerReturnsFriendlyError() {
+ Response r = this.client().delete(managerPath("DEFAULT"),
+ Map.of("user", "admin",
+ "type", HugePermission.ADMIN));
+ String content = assertResponseStatus(400, r);
+ Assert.assertTrue(content.contains(STANDALONE_ERROR));
+ }
+
+ @Test
+ public void testListManagerReturnsFriendlyError() {
Review Comment:
⚠️ The new standalone tests only exercise the `ADMIN` branch, so they don't actually lock down the regression described in the PR body. The problematic path was that `validGraphSpace()` could still succeed in standalone mode because `manager.graphSpace(name)` returns a synthetic `DEFAULT` space, and that only happens in the `SPACE` / `SPACE_MEMBER` branches.
ASCII view:
```text
checkPdModeEnabled()
|
+-- ADMIN <- covered here
+-- SPACE <- regression path
\-- SPACE_MEMBER <- regression path
```
Please add at least one standalone test with `type=SPACE` or `type=SPACE_MEMBER` against a non-`DEFAULT` graphspace, so this PR verifies the branch that used to fall through.
```suggestion
@Test
public void testListSpaceManagerReturnsFriendlyError() {
Response r = this.client().get(managerPath("nonexistent"),
Map.of("type", (Object) HugePermission.SPACE));
String content = assertResponseStatus(400, r);
Assert.assertTrue(content.contains(STANDALONE_ERROR));
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936782589
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -276,7 +276,7 @@ private static String serviceId(String graphSpace, Service.ServiceType type,
.replace("_", "-").toLowerCase();
}
- private boolean usePD() {
+ public boolean usePD() {
Review Comment:
⚠️ `usePD()` is an ambiguous name for a public boolean accessor — Java convention for boolean getters is `is*` or `has*`. Consider renaming to `isPdEnabled()` or `isUsePD()` to make the intent clear:
```java
public boolean isPdEnabled() {
return this.PDExist;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2938108173
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -276,7 +276,7 @@ private static String serviceId(String graphSpace, Service.ServiceType type,
.replace("_", "-").toLowerCase();
}
- private boolean usePD() {
+ public boolean isPDEnable() {
return this.PDExist;
}
Review Comment:
The method name `isPDEnable` is grammatically incorrect — the conventional Java naming for a boolean getter would be `isPDEnabled` (past participle). This is a public API method on `GraphManager`, so it's worth getting the name right before it gets more callers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org
Re: [PR] optimize(api): disable GraphSpaceAPI and ManagerAPI in standalone mode [hugegraph]
Posted by "imbajin (via GitHub)" <gi...@apache.org>.
imbajin commented on code in PR #2966:
URL: https://github.com/apache/hugegraph/pull/2966#discussion_r2936755627
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
Review Comment:
[38;5;198;48;5;233m⚠[39;49m[38;5;198;48;5;233m️[39;49m[38;5;15m [39m[38;5;204mSuggestion[39m[38;5;204m:[39m[38;5;15m [39m[38;5;204mrename[39m[38;5;15m [39m[38;5;204mcheckPdModeEnabled[39m[38;5;15m [39m[38;5;204mto[39m[38;5;15m [39m[38;5;204ma[39m[38;5;15m [39m[38;5;204mclearer[39m[38;5;15m [39m[38;5;204mname[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;204madd[39m[38;5;15m [39m[38;5;204mnull-check[39m
[38;5;204mThis[39m[38;5;15m [39m[38;5;204mmethod[39m[38;5;15m [39m[38;5;204mthrows[39m[38;5;15m [39m[38;5;204mwhen[39m[38;5;15m [39m[38;5;204mPD[39m[38;5;15m [39m[38;5;204mmode[39m[38;5;15m [39m[38;5;204mis[39m[38;5;15m [39m[38;5;204mnot[39m[38;5;15m [39m[38;5;204menabled[39m[38;5;204m.[39m[38;5;15m [39m[38;5;204mRename[39m[38;5;15m [39m[38;5;204mto[39m[38;5;15m [39m[38;5;204mmake[39m[38;5;15m [39m[38;5;204mthe[39m[38;5;15m [39m[38;5;204mcontract[39m[38;5;15m [39m[38;5;204mexplicit[39m[38;5;15m [39m[38;5;204m([39m[38;5;204mfor[39m[38;5;15m [39m[38;5;204mexample[39m[38;5;15m [39m[38;5;204mensurePdModeEnabled[39m[38;5;15m [39m[38;5;204mor[39m[38;5;15m [39m[38;5;204mrequirePdModeEnabled[39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;204madd[39m[38;5;15m [39m[38;5;204ma[39m[38;5;15m [39m[38;5;204mnull-check[39m[38;5;15m [39m[38;5;204m+[39m[38;5;15m [39m[38;5
;204mJavadoc[39m[38;5;204m.[39m[38;5;15m [39m[38;5;204mSuggested[39m[38;5;15m [39m[38;5;204mchange[39m[38;5;204m:[39m
[38;5;204mpublic[39m[38;5;15m [39m[38;5;204mstatic[39m[38;5;15m [39m[38;5;204mvoid[39m[38;5;15m [39m[38;5;204mensurePdModeEnabled[39m[38;5;204m([39m[38;5;204mGraphManager[39m[38;5;15m [39m[38;5;204mmanager[39m[38;5;204m)[39m[38;5;15m [39m[38;5;15m{[39m
[38;5;15m [39m[38;5;198;48;5;233mE[39;49m[38;5;198;48;5;233m.[39;49m[38;5;198;48;5;233mc[39;49m[38;5;198;48;5;233mh[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mc[39;49m[38;5;198;48;5;233mk[39;49m[38;5;198;48;5;233mA[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mN[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mN[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233ml[39;49m[38;5;198;48;5;233ml[39;49m[38;5;198;48;5;233m([39;49m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233m,[39;49m[38;5;15m [39m[38;5;198;48;5;233m"[39;49m[38;5;198;48;5;233mG[39;49m[3
8;5;198;48;5;233mr[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233mh[39;49m[38;5;198;48;5;233mM[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mr[39;49m[38;5;15m [39m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233mt[39;49m[38;5;15m [39m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mt[39;49m[38;5;15m [39m[38;5;198;48;5;233mb[39;49m[38;5;198;48;5;233me[39;49m[38;5;15m [39m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233ml[39;49m[38;5;198;48;5;233ml[39;49m[38;5;198;48;5;233m"[39;49m[38;5;198;48;5;233m)[39;49m[38;5;15m;[39m
[38;5;15m [39m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233mf[39;49m[38;5;15m [39m[38;5;198;48;5;233m([39;49m[38;5;198;48;5;233m![39;49m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233m.[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mP[39;49m[38;5;198;48;5;233mD[39;49m[38;5;198;48;5;233m([39;49m[38;5;198;48;5;233m)[39;49m[38;5;198;48;5;233m)[39;49m[38;5;15m [39m[38;5;198;48;5;233m{[39;49m
[38;5;15m [39m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mh[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mw[39;49m[38;5;15m [39m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mw[39;49m[38;5;15m [39m[38;5;198;48;5;233mH[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mE[39;49m[38;5;198;48;5;233mx[39;49m[38;5;198;48;5;233mc[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233m([39;49m[38;5;198;48;5;233m"[39;49m[38;5;198;48;5;233mG[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233mh[39;49m[38;5;198;48;5;233mS[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mc[39;49m[38;5;198;4
8;5;233me[39;49m[38;5;15m [39m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mg[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233mt[39;49m[38;5;15m [39m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233ms[39;49m[38;5;15m [39m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mt[39;49m[38;5;15m [39m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233mp[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233md[39;49m[38;5;15m [39m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233mn[39;49m[38;5;15m [39m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;
5;233md[39;49m[38;5;198;48;5;233ma[39;49m[38;5;198;48;5;233ml[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233mn[39;49m[38;5;198;48;5;233me[39;49m[38;5;15m [39m[38;5;198;48;5;233mm[39;49m[38;5;198;48;5;233mo[39;49m[38;5;198;48;5;233md[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233m"[39;49m[38;5;198;48;5;233m)[39;49m[38;5;15m;[39m
[38;5;15m [39m[38;5;15m}[39m
[38;5;198;48;5;233m}[39;49m
[38;5;204mThen[39m[38;5;15m [39m[38;5;204mupdate[39m[38;5;15m [39m[38;5;204mcall[39m[38;5;15m [39m[38;5;204msites[39m[38;5;15m [39m[38;5;204m([39m[38;5;204mGraphSpaceAPI[39m[38;5;204m,[39m[38;5;15m [39m[38;5;204mManagerAPI[39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mto[39m[38;5;15m [39m[38;5;204mcall[39m[38;5;15m [39m[38;5;204mensurePdModeEnabled[39m[38;5;204m([39m[38;5;204mmanager[39m[38;5;204m)[39m[38;5;204m.[39m
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/core/GraphManager.java:
##########
@@ -276,7 +276,7 @@ private static String serviceId(String graphSpace, Service.ServiceType type,
.replace("_", "-").toLowerCase();
Review Comment:
[38;5;198;48;5;233m⚠[39;49m[38;5;198;48;5;233m️[39;49m[38;5;15m [39m[38;5;204mSuggestion[39m[38;5;204m:[39m[38;5;15m [39m[38;5;204mrename[39m[38;5;15m [39m[38;5;204mpublic[39m[38;5;15m [39m[38;5;204mboolean[39m[38;5;15m [39m[38;5;204musePD[39m[38;5;204m([39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mto[39m[38;5;15m [39m[38;5;204mfollow[39m[38;5;15m [39m[38;5;204mJava[39m[38;5;15m [39m[38;5;204mboolean[39m[38;5;15m [39m[38;5;204mgetter[39m[38;5;15m [39m[38;5;204mconventions[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;204madd[39m[38;5;15m [39m[38;5;204mJavadoc[39m
[38;5;204mPublicly[39m[38;5;15m [39m[38;5;204mexposing[39m[38;5;15m [39m[38;5;204musePD[39m[38;5;204m([39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mincreases[39m[38;5;15m [39m[38;5;204mthe[39m[38;5;15m [39m[38;5;204mclass[39m[38;5;15m [39m[38;5;204msurface[39m[38;5;204m;[39m[38;5;15m [39m[38;5;204mprefer[39m[38;5;15m [39m[38;5;204ma[39m[38;5;15m [39m[38;5;204mclearer[39m[38;5;15m [39m[38;5;204mname[39m[38;5;15m [39m[38;5;204msuch[39m[38;5;15m [39m[38;5;204mas[39m[38;5;15m [39m[38;5;204misPdEnabled[39m[38;5;204m([39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;204madd[39m[38;5;15m [39m[38;5;204mjavadoc[39m[38;5;15m [39m[38;5;204mdescribing[39m[38;5;15m [39m[38;5;204mPD[39m[38;5;15m [39m[38;5;204msemantics[39m[38;5;204m.[39m[38;5;15m [39m[38;5;204mExample[39m[38;5;204m:[39m
[38;5;245m/** Returns true if placement driver (PD / hstore) is configured/available. */[39m
[38;5;204mpublic[39m[38;5;15m [39m[38;5;204mboolean[39m[38;5;15m [39m[38;5;204misPdEnabled[39m[38;5;204m([39m[38;5;204m)[39m[38;5;15m [39m[38;5;15m{[39m
[38;5;15m [39m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233me[39;49m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mu[39;49m[38;5;198;48;5;233mr[39;49m[38;5;198;48;5;233mn[39;49m[38;5;15m [39m[38;5;198;48;5;233mt[39;49m[38;5;198;48;5;233mh[39;49m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233m.[39;49m[38;5;198;48;5;233mP[39;49m[38;5;198;48;5;233mD[39;49m[38;5;198;48;5;233mE[39;49m[38;5;198;48;5;233mx[39;49m[38;5;198;48;5;233mi[39;49m[38;5;198;48;5;233ms[39;49m[38;5;198;48;5;233mt[39;49m[38;5;15m;[39m
[38;5;15m}[39m
[38;5;204mIf[39m[38;5;15m [39m[38;5;204mcallers[39m[38;5;15m [39m[38;5;204moutside[39m[38;5;15m [39m[38;5;204mcore[39m[38;5;15m [39m[38;5;204mneed[39m[38;5;15m [39m[38;5;204mthe[39m[38;5;15m [39m[38;5;204mcurrent[39m[38;5;15m [39m[38;5;204mname[39m[38;5;204m,[39m[38;5;15m [39m[38;5;204mkeep[39m[38;5;15m [39m[38;5;204musePD[39m[38;5;204m([39m[38;5;204m)[39m[38;5;15m [39m[38;5;204mas[39m[38;5;15m [39m[38;5;204ma[39m[38;5;15m [39m[38;5;204mdeprecated[39m[38;5;15m [39m[38;5;204mdelegate[39m[38;5;15m [39m[38;5;204mthat[39m[38;5;15m [39m[38;5;204mcalls[39m[38;5;15m [39m[38;5;204mthe[39m[38;5;15m [39m[38;5;204mnew[39m[38;5;15m [39m[38;5;204mmethod[39m[38;5;204m.[39m
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/API.java:
##########
@@ -241,6 +241,13 @@ public static boolean checkAndParseAction(String action) {
}
}
Review Comment:
[38;5;198;48;5;233m🧹[39;49m[38;5;15m [39m[38;5;15mMinor[39m[38;5;15m:[39m[38;5;15m [39m[38;5;15mExtract[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mliteral[39m[38;5;15m [39m[38;5;15merror[39m[38;5;15m [39m[38;5;15mmessage[39m[38;5;15m [39m[38;5;15minto[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;15mconstant[39m[38;5;15m [39m[38;5;15mto[39m[38;5;15m [39m[38;5;15mavoid[39m[38;5;15m [39m[38;5;15mduplication[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;15mtypos[39m[38;5;204m.[39m[38;5;15m [39m[38;5;15mFor[39m[38;5;15m [39m[38;5;15mexample[39m[38;5;15m:[39m
[38;5;15mprivate[39m[38;5;15m [39m[38;5;81mstatic[39m[38;5;15m [39m[38;5;15mfinal[39m[38;5;15m [39m[38;5;15mString[39m[38;5;15m [39m[38;5;15mSTANDALONE_GRAPHSPACE_ERROR[39m[38;5;15m [39m[38;5;204m=[39m[38;5;15m [39m[38;5;186m"[39m[38;5;186mGraphSpace management is not supported in standalone mode[39m[38;5;186m"[39m[38;5;15m;[39m
[38;5;15mThen[39m[38;5;15m [39m[38;5;15mthrow[39m[38;5;15m [39m[38;5;15mnew[39m[38;5;15m [39m[38;5;15mHugeException[39m[38;5;15m([39m[38;5;15mSTANDALONE_GRAPHSPACE_ERROR[39m[38;5;15m)[39m[38;5;15m;[39m[38;5;15m [39m[38;5;204mand[39m[38;5;15m [39m[38;5;15mupdate[39m[38;5;15m [39m[38;5;15mtests[39m[38;5;15m [39m[38;5;15mto[39m[38;5;15m [39m[38;5;15mreference[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mconstant[39m[38;5;15m [39m[38;5;15mwhere[39m[38;5;15m [39m[38;5;15mpractical[39m[38;5;204m.[39m
##########
hugegraph-server/hugegraph-test/src/main/java/org/apache/hugegraph/api/BaseApiTest.java:
##########
@@ -748,6 +739,28 @@ public static RestClient analystClient(String graphSpace, String username) {
return analystClient;
}
+ /**
+ * Skips the current test if the server is running in hstore / PD mode.
+ * Treats both {@code "hstore"} and {@code null} (i.e. the property is not
+ * set, which is the default in hstore CI runs) as PD mode.
+ * Call this from a {@code @Before} method in standalone-only test classes.
+ */
+ public static void assumeStandaloneMode() {
+ String backend = System.getProperty("backend");
Review Comment:
[38;5;15m⚠️[39m[38;5;15m [39m[38;5;15mSuggestion[39m[38;5;204m:[39m[38;5;15m [39m[38;5;15mclarify[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15msimplify[39m[38;5;15m [39m[38;5;15massumeStandaloneMode[39m[38;5;15m([39m[38;5;15m)[39m
[38;5;15mThe[39m[38;5;15m [39m[38;5;81mcurrent[39m[38;5;15m [39m[38;5;81mcondition[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15mAssume.assumeTrue(backend != null && !backend.equals("hstore"))[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mis[39m[38;5;15m [39m[38;5;15ma[39m[38;5;15m [39m[38;5;81mdouble[39m[38;5;204m-[39m[38;5;15mnegative[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mcan[39m[38;5;15m [39m[38;5;15mbe[39m[38;5;15m [39m[38;5;15mhard[39m[38;5;15m [39m[38;5;81mto[39m[38;5;15m [39m[38;5;81mread[39m[38;5;15m.[39m[38;5;15m [39m[38;5;15mConsider[39m[38;5;15m [39m[38;5;15mexpressing[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;81mskip[39m[38;5;15m [39m[38;5;81mcondition[39m[38;5;15m [39m[38;5;15mexplicitly[39m[38;5;15m [39m[38;5;81mwith[39m[38;5;15m [39m[38;5;15m`[39m[38;5;15massumeFalse[39m[38;5;15m`[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mavoiding[39
m[38;5;15m [39m[38;5;15mNPEs[39m[38;5;15m.[39m[38;5;15m [39m[38;5;81mFor[39m[38;5;15m [39m[38;5;15mexample[39m[38;5;204m:[39m
[38;5;15mpublic[39m[38;5;15m [39m[38;5;15mstatic[39m[38;5;15m [39m[38;5;15mvoid[39m[38;5;15m [39m[38;5;15massumeStandaloneMode[39m[38;5;15m([39m[38;5;15m)[39m[38;5;15m [39m[38;5;198;48;5;233m{[39;49m
[38;5;15m [39m[38;5;81mString[39m[38;5;15m [39m[38;5;15mbackend[39m[38;5;15m [39m[38;5;204m=[39m[38;5;15m [39m[38;5;81mSystem[39m[38;5;15m.[39m[38;5;15mgetProperty[39m[38;5;15m([39m[38;5;186m"[39m[38;5;186mbackend[39m[38;5;186m"[39m[38;5;15m)[39m[38;5;15m;[39m
[38;5;15m [39m[38;5;81mboolean[39m[38;5;15m [39m[38;5;15misPdMode[39m[38;5;15m [39m[38;5;204m=[39m[38;5;15m [39m[38;5;15mbackend[39m[38;5;15m [39m[38;5;204m==[39m[38;5;15m [39m[38;5;81mnull[39m[38;5;15m [39m[38;5;204m||[39m[38;5;15m [39m[38;5;186m"[39m[38;5;186mhstore[39m[38;5;186m"[39m[38;5;15m.[39m[38;5;15mequals[39m[38;5;15m([39m[38;5;15mbackend[39m[38;5;15m)[39m[38;5;15m;[39m
[38;5;15m [39m[38;5;15mAssume[39m[38;5;15m.[39m[38;5;15massumeFalse[39m[38;5;15m([39m[38;5;186m"[39m[38;5;186mskip standalone tests: backend='[39m[38;5;186m"[39m[38;5;15m [39m[38;5;204m+[39m[38;5;15m [39m[38;5;15mbackend[39m[38;5;15m [39m[38;5;204m+[39m[38;5;15m [39m[38;5;186m"[39m[38;5;186m' (hstore/PD mode)[39m[38;5;186m"[39m[38;5;15m,[39m[38;5;15m [39m[38;5;15misPdMode[39m[38;5;15m)[39m[38;5;15m;[39m
[38;5;198;48;5;233m}[39;49m
[38;5;15mThis[39m[38;5;15m [39m[38;5;15mmakes[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;15mintent[39m[38;5;15m [39m[38;5;15mclearer[39m[38;5;15m [39m[38;5;81mand[39m[38;5;15m [39m[38;5;15mavoids[39m[38;5;15m [39m[38;5;81mnull[39m[38;5;15m [39m[38;5;15mchecks[39m[38;5;15m [39m[38;5;81min[39m[38;5;15m [39m[38;5;15mthe[39m[38;5;15m [39m[38;5;81mboolean[39m[38;5;15m [39m[38;5;15mexpression[39m[38;5;15m.[39m
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@hugegraph.apache.org
For additional commands, e-mail: issues-help@hugegraph.apache.org