distributedlog-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DL-199) Be able to support filesystem-path like name
Date Fri, 26 May 2017 21:09:04 GMT

    [ https://issues.apache.org/jira/browse/DL-199?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16026847#comment-16026847
] 

ASF GitHub Bot commented on DL-199:
-----------------------------------

Github user sijie commented on a diff in the pull request:

    https://github.com/apache/incubator-distributedlog/pull/130#discussion_r118790221
  
    --- Diff: distributedlog-core/src/main/java/org/apache/distributedlog/util/DLUtils.java
---
    @@ -281,41 +281,89 @@ public static boolean isReservedStreamName(String name) {
         }
     
         /**
    -     * Validate the stream name.
    +     * Validate the log name.
          *
    -     * @param nameOfStream
    -     *          name of stream
    +     * @param logName
    +     *          name of log
          * @throws InvalidStreamNameException
          */
    -    public static void validateName(String nameOfStream)
    +    public static String validateAndNormalizeName(String logName)
                 throws InvalidStreamNameException {
    -        String reason = null;
    -        char chars[] = nameOfStream.toCharArray();
    -        char c;
    -        // validate the stream to see if meet zookeeper path's requirement
    -        for (int i = 0; i < chars.length; i++) {
    -            c = chars[i];
    -
    -            if (c == 0) {
    -                reason = "null character not allowed @" + i;
    -                break;
    -            } else if (c == '/') {
    -                reason = "'/' not allowed @" + i;
    -                break;
    -            } else if (c > '\u0000' && c < '\u001f'
    -                    || c > '\u007f' && c < '\u009F'
    -                    || c > '\ud800' && c < '\uf8ff'
    -                    || c > '\ufff0' && c < '\uffff') {
    -                reason = "invalid charater @" + i;
    -                break;
    -            }
    +        if (isReservedStreamName(logName)) {
    +            throw new InvalidStreamNameException(logName, "Log Name is reserved");
             }
    -        if (null != reason) {
    -            throw new InvalidStreamNameException(nameOfStream, reason);
    +
    +        if (logName.charAt(0) == 47) {
    +            validatePathName(logName);
    +            return logName.substring(1);
    +        } else {
    +            validatePathName("/" + logName);
    +            return logName;
             }
    -        if (isReservedStreamName(nameOfStream)) {
    -            throw new InvalidStreamNameException(nameOfStream,
    -                    "Stream Name is reserved");
    +    }
    +
    +    private static void validatePathName(String logName) throws InvalidStreamNameException
{
    +        if (logName == null) {
    +            throw new InvalidStreamNameException("Log name cannot be null");
    +        } else if (logName.length() == 0) {
    +            throw new InvalidStreamNameException("Log name length must be > 0");
    +        } else if (logName.charAt(0) != 47) {
    +            throw new InvalidStreamNameException("Log name must start with / character");
    +        } else if (logName.length() != 1) {
    +            if (logName.charAt(logName.length() - 1) == 47) {
    +                throw new InvalidStreamNameException("Log name must not end with / character");
    +            } else {
    +                String reason = null;
    +                char lastc = 47;
    +                char[] chars = logName.toCharArray();
    +
    +                for (int i = 1; i < chars.length; ++i) {
    +                    char c = chars[i];
    +                    if (c == 0) {
    +                        reason = "null character not allowed @" + i;
    +                        break;
    +                    }
    +
    +                    if (c == '<' || c == '>') {
    +                        reason = "< or > specified @" + i;
    +                        break;
    +                    }
    +
    +                    if (c == ' ') {
    --- End diff --
    
    I believe it is covered in the last "else if" branch.


> Be able to support filesystem-path like name
> --------------------------------------------
>
>                 Key: DL-199
>                 URL: https://issues.apache.org/jira/browse/DL-199
>             Project: DistributedLog
>          Issue Type: Task
>          Components: distributedlog-core
>            Reporter: Sijie Guo
>            Assignee: Sijie Guo
>             Fix For: 0.5.0
>
>
> In order to support hierachical namespace, we need to be able to support filesystem path
like log name.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message