imbajin commented on code in PR #3331:
URL: https://github.com/apache/hugegraph/pull/3331#discussion_r4266415653
##########
hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/profile/GraphsAPI.java:
##########
@@ -693,6 +701,59 @@ public Map<String, GraphMode> mode(@Context GraphManager
manager,
return ImmutableMap.of("mode", g.mode());
}
+ @GET
+ @Timed
+ @Path("{name}/mode/owners")
+ @Produces(APPLICATION_JSON_WITH_CHARSET)
+ @RolesAllowed({"space", "$owner=$name"})
+ public Map<String, Object> loadingMode(@Context GraphManager manager,
+ @PathParam("graphspace") String
graphSpace,
+ @PathParam("name") String name) {
+ return graph(manager, graphSpace, name).loadingMode();
+ }
+
+ @PUT
+ @Timed
+ @Path("{name}/mode/owners")
+ @Consumes(APPLICATION_JSON)
+ @Produces(APPLICATION_JSON_WITH_CHARSET)
+ @RolesAllowed({"space", "$owner=$name"})
+ public Map<String, Object> loadingMode(@Context GraphManager manager,
+ @PathParam("graphspace") String
graphSpace,
+ @PathParam("name") String name,
+ JsonLoadingOwner owner,
+ @Context SecurityContext
securityContext) {
+ E.checkArgument(owner != null && owner.epoch != null, "Loading owner
body and epoch are required");
+ if ("recover".equals(owner.action)) {
+ if (securityContext == null ||
!securityContext.isUserInRole("admin")) {
+ throw new ForbiddenException("Loading recovery requires
administrator permission");
+ }
+ E.checkArgument(CONFIRM_RECOVER.equals(owner.confirm),
+ "Stop and drain all related imports, then confirm
with '%s'", CONFIRM_RECOVER);
+ E.checkArgument(owner.revision != null && owner.revision >= 0,
+ "Current loading state revision is required for
recovery");
+ }
+ try {
+ HugeGraph graph = graph(manager, graphSpace, name);
+ if ("recover".equals(owner.action)) {
+ return graph.recoverLoadingMode(owner.instance, owner.epoch,
owner.revision);
+ }
+ return graph.loadingMode(owner.action, owner.instance,
owner.epoch, owner.token, "");
Review Comment:
Fixed: acquire and release now pass the authenticated request principal
explicitly, including graphs that are not wrapped by an auth proxy. A native
HugeFactory memory graph regression reproduces the old cross-caller release and
verifies that the other caller receives a conflict while the original owner
remains active. HTTP/PD deployment coverage remains tracked separately.
##########
hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/StandardHugeGraph.java:
##########
@@ -438,13 +438,29 @@ private void closeTx() {
@Override
public GraphMode mode() {
- return this.mode;
+ return this.loadingMode.mode();
}
@Override
public void mode(GraphMode mode) {
+ this.loadingMode.mode(mode);
LOG.info("Graph {} will work in {} mode", this, mode);
- this.mode = mode;
+ }
+
+ @Override
+ public Map<String, Object> loadingMode() {
+ return this.loadingMode.capability();
+ }
+
+ @Override
+ public Map<String, Object> loadingMode(String action, String instance,
long epoch,
+ String token, String principal) {
+ return this.loadingMode.update(action, instance, epoch, token,
principal);
+ }
+
+ @Override
+ public Map<String, Object> recoverLoadingMode(String instance, long epoch,
long revision) {
+ return this.loadingMode.recover(instance, epoch, revision);
Review Comment:
Added success audit events inside LoadingMode's synchronized transitions,
recording instance, before/after mode, epoch and owner counts (including
cleared owners on recovery). Tokens and principal values are excluded.
Repeated, stale or rejected operations do not emit a successful transition;
focused log regressions verify these boundaries.
--
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]