[
https://issues.apache.org/jira/browse/CURATOR-569?focusedWorklogId=433143&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-433143
]
ASF GitHub Bot logged work on CURATOR-569:
------------------------------------------
Author: ASF GitHub Bot
Created on: 14/May/20 13:51
Start Date: 14/May/20 13:51
Worklog Time Spent: 10m
Work Description: Randgalt commented on a change in pull request #366:
URL: https://github.com/apache/curator/pull/366#discussion_r425153209
##########
File path:
curator-framework/src/main/java/org/apache/curator/framework/imps/ProtectedUtils.java
##########
@@ -0,0 +1,95 @@
+/**
+ * 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.curator.framework.imps;
+
+import java.util.UUID;
+
+import org.apache.curator.framework.api.CreateBuilderMain;
+
+/**
+ * Utility class to handle ZNode names when using {@link
CreateBuilderMain#withProtection()}
+ */
+public final class ProtectedUtils {
+
+ private ProtectedUtils() {
+ throw new RuntimeException("Protected Utils is a helper class");
+ }
+
+ /**
+ * First 3 characters in the prefix on ZNode names when using {@link
CreateBuilderMain#withProtection()}
+ */
+ public static final String PROTECTED_PREFIX = "_c_";
+
+ /**
+ * Last character used in the prefix on ZNode names when using {@link
CreateBuilderMain#withProtection()}
+ */
+ public static final char PROTECTED_SEPARATOR = '-';
+
+ /**
+ * Prefix length on ZNode name when using {@link #withProtection()}
+ */
+ public static final int PROTECTED_PREFIX_WITH_UUID_LENGTH =
+ PROTECTED_PREFIX.length()
+ + 36 // UUID canonical text representation produced by {@link
UUID#toString()}
+ + 1; // Separator length
+
+ /**
+ * Provides a prefix to be appended to a ZNode name when protected. The
method assumes that the provided string
+ * adjusts to the required format
+ *
+ * @param protectedId canonical text representation of a UUID
+ * @return string that concatenates {@value #PROTECTED_PREFIX}, the given
id and {@value #PROTECTED_SEPARATOR}
+ */
+ static String getProtectedPrefix(final String protectedId)
Review comment:
I think you're making a huge assumption there. We really don't know how
clients will use the library - I've been very surprised over the years.
Further, I've had to go to great lengths to get around stuff that's hidden in
ZooKeeper. Remember, this is Java, nothing is truly hidden. You can access
anything via reflection.
tbh - I'd also like to see a method: `public static String
extractProtectId(String znodeName)`. Let's give people as many tools as
possible.
----------------------------------------------------------------
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 433143)
Time Spent: 1h 10m (was: 1h)
> API TO HANDLE PROTECTED MODE ZNODE NAMES
> ----------------------------------------
>
> Key: CURATOR-569
> URL: https://issues.apache.org/jira/browse/CURATOR-569
> Project: Apache Curator
> Issue Type: Improvement
> Components: Framework
> Reporter: Chevaris
> Priority: Major
> Time Spent: 1h 10m
> Remaining Estimate: 0h
>
> Curator provides protectedMode to handle with some corner cases with
> ephemeral nodes. When protectedMode is used, Curator appends a prefix to
> provided name composed by a String concatenating:
> * "_c_"
> * Canonical text representation of a random generated UUID
> * "-"
> Purpose of this ticket is:
> * Improve Javadoc to fully specify the prefix used with protected Mode
> * Provide method that allows to identify if a ZNode name has the protected
> prefix
> * Provide method that allows to separate the prefix name from the provided
> name on Curator Framework when creating the node
--
This message was sent by Atlassian Jira
(v8.3.4#803005)