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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]