hadoop-zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jakob Homan (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (ZOOKEEPER-132) Create Enum to replace CreateFlag in ZooKepper.create method
Date Wed, 03 Sep 2008 03:39:44 GMT

    [ 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.


Mime
View raw message