You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Jakob Homan (JIRA)" <ji...@apache.org> on 2008/09/03 05:21:44 UTC

[jira] Created: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method

Create Enum to replace CreateFlag in ZooKepper.create method
------------------------------------------------------------

                 Key: ZOOKEEPER-132
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-132
             Project: Zookeeper
          Issue Type: Sub-task
          Components: java client
    Affects Versions: 3.0.0
            Reporter: Jakob Homan
            Assignee: Jakob Homan
             Fix For: 3.0.0


Replace the current named constant integer in the craete method with a typesafe enum value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method

Posted by "Jakob Homan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jakob Homan updated ZOOKEEPER-132:
----------------------------------

    Attachment: ZOOKEEPER-132.patch

Patch:
 * Creates an Enum value, CreateMode, which handles the four possible combinations of ephemeral and sequential values.
 * Provides JavaDoc for this new Enum
 * Changes the ZooKeeper .create methods to use this type rather than the previous integer value
 * Converts all the unit tests to use the enum
 * Changes the Jute encoding to use two booleans rather than the bit-packed integer value to transmit the flag.

I think it will help quite a bit to have this create flag be type-safe and spelled out via an enum.  I found it confusing when I started, particularly since 0 (or persistent), was not a named constant.

Jute doesn't support sending enums over the wire.  I played with code to convert the original int back into an enum at the server but decided against it as (a) it was god-awful ugly as enums are poorly implemented and supported in Java and, (b) it is more efficient to use two booleans (two bytes) rather than a full 32-bit integer to essentially send two bits of information over the wire.  This is particularly true since those values are immediately used and discarded at the server.

This is of course, non-b/w compatible and meant for the 3.0 release.  If this looks good, I'll start on similar code for enums/enumsets for file permissions and watcher codes.  I'd like to do them as separate patches, but if it's better to role them all into one, I can do that too.  Thanks.

> Create Enum to replace CreateFlag in ZooKepper.create method
> ------------------------------------------------------------
>
>                 Key: ZOOKEEPER-132
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-132
>             Project: Zookeeper
>          Issue Type: Sub-task
>          Components: java client
>    Affects Versions: 3.0.0
>            Reporter: Jakob Homan
>            Assignee: Jakob Homan
>             Fix For: 3.0.0
>
>         Attachments: ZOOKEEPER-132.patch
>
>
> Replace the current named constant integer in the craete method with a typesafe enum value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method

Posted by "Jakob Homan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jakob Homan updated ZOOKEEPER-132:
----------------------------------

    Status: Patch Available  (was: Open)

> Create Enum to replace CreateFlag in ZooKepper.create method
> ------------------------------------------------------------
>
>                 Key: ZOOKEEPER-132
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-132
>             Project: Zookeeper
>          Issue Type: Sub-task
>          Components: java client
>    Affects Versions: 3.0.0
>            Reporter: Jakob Homan
>            Assignee: Jakob Homan
>             Fix For: 3.0.0
>
>         Attachments: ZOOKEEPER-132.patch
>
>
> Replace the current named constant integer in the craete method with a typesafe enum value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method

Posted by "Jakob Homan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jakob Homan updated ZOOKEEPER-132:
----------------------------------

    Attachment: ZOOKEEPER-132.patch

OK, per Ben's request the patch now:
   * Creates an Enum CreateMode that handles all of the possible znode creation combinations
   * The enum can be converted to/from an int flag for sending over the wire without changing the jute protocol.
   * The enum provides type-safety and clarity for users, and convenience methods for once it gets to the server
   * Unit tests for new enum
   * All the other stuff from above.

Again, if this approach looks good, I'll use it for the other constants that need replacing.
-jg


> Create Enum to replace CreateFlag in ZooKepper.create method
> ------------------------------------------------------------
>
>                 Key: ZOOKEEPER-132
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-132
>             Project: Zookeeper
>          Issue Type: Sub-task
>          Components: java client
>    Affects Versions: 3.0.0
>            Reporter: Jakob Homan
>            Assignee: Jakob Homan
>             Fix For: 3.0.0
>
>         Attachments: ZOOKEEPER-132.patch, ZOOKEEPER-132.patch
>
>
> Replace the current named constant integer in the craete method with a typesafe enum value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Hunt updated ZOOKEEPER-132:
-----------------------------------

    Attachment: ZOOKEEPER-132.patch

Updated based on latest svn mainline.

> Create Enum to replace CreateFlag in ZooKepper.create method
> ------------------------------------------------------------
>
>                 Key: ZOOKEEPER-132
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-132
>             Project: Zookeeper
>          Issue Type: Sub-task
>          Components: java client
>    Affects Versions: 3.0.0
>            Reporter: Jakob Homan
>            Assignee: Jakob Homan
>             Fix For: 3.0.0
>
>         Attachments: ZOOKEEPER-132.patch, ZOOKEEPER-132.patch, ZOOKEEPER-132.patch
>
>
> Replace the current named constant integer in the craete method with a typesafe enum value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Hunt updated ZOOKEEPER-132:
-----------------------------------

    Hadoop Flags: [Incompatible change, Reviewed]

> Create Enum to replace CreateFlag in ZooKepper.create method
> ------------------------------------------------------------
>
>                 Key: ZOOKEEPER-132
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-132
>             Project: Zookeeper
>          Issue Type: Sub-task
>          Components: java client
>    Affects Versions: 3.0.0
>            Reporter: Jakob Homan
>            Assignee: Jakob Homan
>             Fix For: 3.0.0
>
>         Attachments: ZOOKEEPER-132.patch, ZOOKEEPER-132.patch, ZOOKEEPER-132.patch
>
>
> Replace the current named constant integer in the craete method with a typesafe enum value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method

Posted by "Benjamin Reed (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Benjamin Reed updated ZOOKEEPER-132:
------------------------------------

    Status: Open  (was: Patch Available)

-1 I think the patch is okay except for the protocol change. We would like to keep int flags in the protocol, so that we can add new features without doing a protocol change. Could you use ordinals for getting the flag value: PERSISTENT(0), PERSISTENT_SEQUENTIAL(2),  EPHEMERAL(1), EPHEMERAL_SEQUENTIAL(3)

> Create Enum to replace CreateFlag in ZooKepper.create method
> ------------------------------------------------------------
>
>                 Key: ZOOKEEPER-132
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-132
>             Project: Zookeeper
>          Issue Type: Sub-task
>          Components: java client
>    Affects Versions: 3.0.0
>            Reporter: Jakob Homan
>            Assignee: Jakob Homan
>             Fix For: 3.0.0
>
>         Attachments: ZOOKEEPER-132.patch
>
>
> Replace the current named constant integer in the craete method with a typesafe enum value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Hunt updated ZOOKEEPER-132:
-----------------------------------

      Resolution: Fixed
    Hadoop Flags: [Incompatible change, Reviewed]  (was: [Reviewed, Incompatible change])
          Status: Resolved  (was: Patch Available)

Committed revision 693164.

Note this is marked as incompatible change - client API changed.

> Create Enum to replace CreateFlag in ZooKepper.create method
> ------------------------------------------------------------
>
>                 Key: ZOOKEEPER-132
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-132
>             Project: Zookeeper
>          Issue Type: Sub-task
>          Components: java client
>    Affects Versions: 3.0.0
>            Reporter: Jakob Homan
>            Assignee: Jakob Homan
>             Fix For: 3.0.0
>
>         Attachments: ZOOKEEPER-132.patch, ZOOKEEPER-132.patch, ZOOKEEPER-132.patch
>
>
> Replace the current named constant integer in the craete method with a typesafe enum value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method

Posted by "Jakob Homan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12627893#action_12627893 ] 

jghoman edited comment on ZOOKEEPER-132 at 9/2/08 8:39 PM:
---------------------------------------------------------------

Patch:
 * Creates an Enum value, CreateMode, which handles the four possible combinations of ephemeral and sequential values.
 * Provides JavaDoc for this new Enum
 * Changes the ZooKeeper .create methods to use this type rather than the previous integer value
 * Converts all the unit tests to use the enum
 * Changes the Jute encoding to use two booleans rather than the bit-packed integer value to transmit the flag.

I think it will help quite a bit to have this create flag be type-safe and spelled out via an enum.  I found it confusing when I started, particularly since 0 (or persistent), was not a named constant.

Jute doesn't support sending enums over the wire.  I played with code to convert the original int back into an enum at the server but decided against it as (a) it was god-awful ugly code as enums are poorly implemented and supported in Java and, (b) it is more efficient to use two booleans (two bytes) rather than a full 32-bit integer to essentially send two bits of information over the wire.  This is particularly true since those values are immediately used and discarded at the server.  They are file creation flags, but by the time they get to the server, it's simpler just pull out the two values via getter methods.

This is of course, non-b/w compatible and meant for the 3.0 release.  If this looks good, I'll start on similar code for enums/enumsets for file permissions and watcher codes.  I'd like to do them as separate patches, but if it's better to role them all into one, I can do that too.  Thanks.

      was (Author: jghoman):
    Patch:
 * Creates an Enum value, CreateMode, which handles the four possible combinations of ephemeral and sequential values.
 * Provides JavaDoc for this new Enum
 * Changes the ZooKeeper .create methods to use this type rather than the previous integer value
 * Converts all the unit tests to use the enum
 * Changes the Jute encoding to use two booleans rather than the bit-packed integer value to transmit the flag.

I think it will help quite a bit to have this create flag be type-safe and spelled out via an enum.  I found it confusing when I started, particularly since 0 (or persistent), was not a named constant.

Jute doesn't support sending enums over the wire.  I played with code to convert the original int back into an enum at the server but decided against it as (a) it was god-awful ugly as enums are poorly implemented and supported in Java and, (b) it is more efficient to use two booleans (two bytes) rather than a full 32-bit integer to essentially send two bits of information over the wire.  This is particularly true since those values are immediately used and discarded at the server.

This is of course, non-b/w compatible and meant for the 3.0 release.  If this looks good, I'll start on similar code for enums/enumsets for file permissions and watcher codes.  I'd like to do them as separate patches, but if it's better to role them all into one, I can do that too.  Thanks.
  
> Create Enum to replace CreateFlag in ZooKepper.create method
> ------------------------------------------------------------
>
>                 Key: ZOOKEEPER-132
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-132
>             Project: Zookeeper
>          Issue Type: Sub-task
>          Components: java client
>    Affects Versions: 3.0.0
>            Reporter: Jakob Homan
>            Assignee: Jakob Homan
>             Fix For: 3.0.0
>
>         Attachments: ZOOKEEPER-132.patch
>
>
> Replace the current named constant integer in the craete method with a typesafe enum value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12629760#action_12629760 ] 

Hudson commented on ZOOKEEPER-132:
----------------------------------

Integrated in ZooKeeper-trunk #79 (See [http://hudson.zones.apache.org/hudson/job/ZooKeeper-trunk/79/])

> Create Enum to replace CreateFlag in ZooKepper.create method
> ------------------------------------------------------------
>
>                 Key: ZOOKEEPER-132
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-132
>             Project: Zookeeper
>          Issue Type: Sub-task
>          Components: java client
>    Affects Versions: 3.0.0
>            Reporter: Jakob Homan
>            Assignee: Jakob Homan
>             Fix For: 3.0.0
>
>         Attachments: ZOOKEEPER-132.patch, ZOOKEEPER-132.patch, ZOOKEEPER-132.patch
>
>
> Replace the current named constant integer in the craete method with a typesafe enum value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method

Posted by "Jakob Homan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-132?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jakob Homan updated ZOOKEEPER-132:
----------------------------------

    Status: Patch Available  (was: Open)

Re-did orignal patch per Ben's suggestion.

> Create Enum to replace CreateFlag in ZooKepper.create method
> ------------------------------------------------------------
>
>                 Key: ZOOKEEPER-132
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-132
>             Project: Zookeeper
>          Issue Type: Sub-task
>          Components: java client
>    Affects Versions: 3.0.0
>            Reporter: Jakob Homan
>            Assignee: Jakob Homan
>             Fix For: 3.0.0
>
>         Attachments: ZOOKEEPER-132.patch, ZOOKEEPER-132.patch
>
>
> Replace the current named constant integer in the craete method with a typesafe enum value.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.