pkuwm commented on a change in pull request #1190:
URL: https://github.com/apache/helix/pull/1190#discussion_r462829238
##########
File path:
helix-rest/src/main/java/org/apache/helix/rest/server/resources/zookeeper/ZooKeeperAccessor.java
##########
@@ -94,6 +96,8 @@ public Response get(@PathParam("path") String path,
@QueryParam("command") Strin
return getChildren(_zkBaseDataAccessor, path);
case getStat:
return getStat(_zkBaseDataAccessor, path);
+ case delete:
Review comment:
Would this go to a "DELETE" HTTP verb?
##########
File path:
helix-rest/src/main/java/org/apache/helix/rest/server/resources/zookeeper/ZooKeeperAccessor.java
##########
@@ -192,7 +196,29 @@ private Response getStat(BaseDataAccessor<byte[]>
zkBaseDataAccessor, String pat
.entity(String.format("The ZNode at path %s does not exist!",
path)).build());
}
Map<String, String> result = ZKUtil.fromStatToMap(stat);
- result.put("path", path);
+ result.put(PATH_STR, path);
+ return JSONRepresentation(result);
+ }
+
+ /**
+ * Delete the ZNode at the given path if exists.
+ * @param zkBaseDataAccessor
+ * @param path
+ * @return The delete result and the operated path.
+ */
+ private Response delete(BaseDataAccessor zkBaseDataAccessor, String path) {
+ // TODO: Remove this restriction once we have audit and ACL for the API
calls.
+ // TODO: This method is added pre-maturely to support removing the live
instance of a zombie
+ // TODO: instance. It is risky to allow all deleting requests before audit
and ACL are done.
+ Stat stat = zkBaseDataAccessor.getStat(path, AccessOption.PERSISTENT);
+ if (stat != null && stat.getEphemeralOwner() <= 0) {
+ throw new
WebApplicationException(Response.status(Response.Status.FORBIDDEN)
+ .entity(String.format("Deleting a non ephemeral node is not
allowed", path)).build());
Review comment:
Missing `%s`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]