Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.4.0
    • Labels:
      None
    • Hadoop Flags:
      Reviewed
    • Release Note:
      A skeleton script that shows how to setup znode watches and how to react to events using the Python client libraries.

      Description

      When adding some zookeeper-based functionality to a python script I had to figure everything out without guidance, which while doable, would have been a lot easier with an example. I extracted a skeleton program structure out with hopes its useful to others (maybe add as an example in the source or wiki?).

      This script does an aget() and sets a watch, and hopefully illustrates what's going on, and where to plug in your application code that gets run when the znode changes.

      There are probably some bugs, which if we fix now and provide a well-reviewed example hopefully others will not run into the same mistakes.

      1. ZOOKEEPER-765.patch
        7 kB
        Andrei Savu
      2. ZOOKEEPER-765.patch
        7 kB
        Andrei Savu
      3. zk.py
        4 kB
        Travis Crawford

        Issue Links

          Activity

          Jeff Hammerbacher made changes -
          Link This issue is related to ZOOKEEPER-395 [ ZOOKEEPER-395 ]
          Mahadev konar made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Hide
          Hudson added a comment -

          Integrated in ZooKeeper-trunk #888 (See http://hudson.zones.apache.org/hudson/job/ZooKeeper-trunk/888/)
          ZOOKEEPER-765. Add python example script (Travis and Andrei via mahadev)

          Show
          Hudson added a comment - Integrated in ZooKeeper-trunk #888 (See http://hudson.zones.apache.org/hudson/job/ZooKeeper-trunk/888/ ) ZOOKEEPER-765 . Add python example script (Travis and Andrei via mahadev)
          Mahadev konar made changes -
          Status Patch Available [ 10002 ] Resolved [ 5 ]
          Hadoop Flags [Reviewed]
          Release Note Travis Crawford wrote a skeleton script that shows how to setup znode watches and how to react to events using the Python client libraries. A skeleton script that shows how to setup znode watches and how to react to events using the Python client libraries.
          Resolution Fixed [ 1 ]
          Hide
          Mahadev konar added a comment -

          +1 the patch looks good. I just committed this.

          thanks travis and andrei!

          Show
          Mahadev konar added a comment - +1 the patch looks good. I just committed this. thanks travis and andrei!
          Hide
          Hadoop QA added a comment -

          +1 overall. Here are the results of testing the latest attachment
          http://issues.apache.org/jira/secure/attachment/12449429/ZOOKEEPER-765.patch
          against trunk revision 963957.

          +1 @author. The patch does not contain any @author tags.

          +0 tests included. The patch appears to be a documentation patch that doesn't require tests.

          +1 javadoc. The javadoc tool did not generate any warning messages.

          +1 javac. The applied patch does not increase the total number of javac compiler warnings.

          +1 findbugs. The patch does not introduce any new Findbugs warnings.

          +1 release audit. The applied patch does not increase the total number of release audit warnings.

          +1 core tests. The patch passed core unit tests.

          +1 contrib tests. The patch passed contrib unit tests.

          Test results: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h7.grid.sp2.yahoo.net/96/testReport/
          Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h7.grid.sp2.yahoo.net/96/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
          Console output: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h7.grid.sp2.yahoo.net/96/console

          This message is automatically generated.

          Show
          Hadoop QA added a comment - +1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12449429/ZOOKEEPER-765.patch against trunk revision 963957. +1 @author. The patch does not contain any @author tags. +0 tests included. The patch appears to be a documentation patch that doesn't require tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed core unit tests. +1 contrib tests. The patch passed contrib unit tests. Test results: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h7.grid.sp2.yahoo.net/96/testReport/ Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h7.grid.sp2.yahoo.net/96/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h7.grid.sp2.yahoo.net/96/console This message is automatically generated.
          Andrei Savu made changes -
          Status Open [ 1 ] Patch Available [ 10002 ]
          Andrei Savu made changes -
          Attachment ZOOKEEPER-765.patch [ 12449429 ]
          Hide
          Andrei Savu added a comment -

          Added license files and a reference to Henry's queue implementation hosted on Github.

          Show
          Andrei Savu added a comment - Added license files and a reference to Henry's queue implementation hosted on Github.
          Patrick Hunt made changes -
          Status Patch Available [ 10002 ] Open [ 1 ]
          Hide
          Patrick Hunt added a comment -

          Andrei, you need to add apache license headers to the files (*.py in this case), see any python script already in SVN for an example of this.

          Show
          Patrick Hunt added a comment - Andrei, you need to add apache license headers to the files (*.py in this case), see any python script already in SVN for an example of this.
          Hide
          Andrei Savu added a comment -

          I think Henry's queue should also be part of this patch: http://github.com/henryr/pyzk-recipes What do you think?

          Show
          Andrei Savu added a comment - I think Henry's queue should also be part of this patch: http://github.com/henryr/pyzk-recipes What do you think?
          Hide
          Hadoop QA added a comment -

          -1 overall. Here are the results of testing the latest attachment
          http://issues.apache.org/jira/secure/attachment/12449092/ZOOKEEPER-765.patch
          against trunk revision 961026.

          +1 @author. The patch does not contain any @author tags.

          +0 tests included. The patch appears to be a documentation patch that doesn't require tests.

          +1 javadoc. The javadoc tool did not generate any warning messages.

          +1 javac. The applied patch does not increase the total number of javac compiler warnings.

          +1 findbugs. The patch does not introduce any new Findbugs warnings.

          -1 release audit. The applied patch generated 19 release audit warnings (more than the trunk's current 17 warnings).

          +1 core tests. The patch passed core unit tests.

          +1 contrib tests. The patch passed contrib unit tests.

          Test results: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/138/testReport/
          Release audit warnings: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/138/artifact/trunk/patchprocess/releaseAuditDiffWarnings.txt
          Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/138/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html
          Console output: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/138/console

          This message is automatically generated.

          Show
          Hadoop QA added a comment - -1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12449092/ZOOKEEPER-765.patch against trunk revision 961026. +1 @author. The patch does not contain any @author tags. +0 tests included. The patch appears to be a documentation patch that doesn't require tests. +1 javadoc. The javadoc tool did not generate any warning messages. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 findbugs. The patch does not introduce any new Findbugs warnings. -1 release audit. The applied patch generated 19 release audit warnings (more than the trunk's current 17 warnings). +1 core tests. The patch passed core unit tests. +1 contrib tests. The patch passed contrib unit tests. Test results: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/138/testReport/ Release audit warnings: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/138/artifact/trunk/patchprocess/releaseAuditDiffWarnings.txt Findbugs warnings: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/138/artifact/trunk/build/test/findbugs/newPatchFindbugsWarnings.html Console output: http://hudson.zones.apache.org/hudson/job/Zookeeper-Patch-h1.grid.sp2.yahoo.net/138/console This message is automatically generated.
          Andrei Savu made changes -
          Status Open [ 1 ] Patch Available [ 10002 ]
          Release Note Travis Crawford wrote a skeleton script that shows how to setup znode watches and how to react to events using the Python client libraries.
          Assignee Travis Crawford [ traviscrawford ] Andrei Savu [ savu.andrei ]
          Andrei Savu made changes -
          Attachment ZOOKEEPER-765.patch [ 12449092 ]
          Hide
          Andrei Savu added a comment -

          I have created a patch containing the script Travis wrote. I have also fixed some typos and added more comments that explain how to play with it.

          I have also added a reference to zk-smoketest [1] because that's another good example that shows how to use the python ZooKeeper client library.

          [1] http://github.com/phunt/zk-smoketest

          Show
          Andrei Savu added a comment - I have created a patch containing the script Travis wrote. I have also fixed some typos and added more comments that explain how to play with it. I have also added a reference to zk-smoketest [1] because that's another good example that shows how to use the python ZooKeeper client library. [1] http://github.com/phunt/zk-smoketest
          Hide
          Patrick Hunt added a comment -

          Hi Travis, thanks for the contrib! Could you (re) submit this as a patch against trunk? Then click "submit patch" on the left hand side. This will trigger some automated workflow, and also notify the commiters that they should review/comment/commit your contribution. You can see more detail on the contrib process here:
          http://wiki.apache.org/hadoop/ZooKeeper/HowToContribute

          I suspect that you would want to put this file into src/contrib/zkpython/src/examples/. Perhaps rename the example to be more descriptive of it's content (type of example).

          Thanks!

          Show
          Patrick Hunt added a comment - Hi Travis, thanks for the contrib! Could you (re) submit this as a patch against trunk? Then click "submit patch" on the left hand side. This will trigger some automated workflow, and also notify the commiters that they should review/comment/commit your contribution. You can see more detail on the contrib process here: http://wiki.apache.org/hadoop/ZooKeeper/HowToContribute I suspect that you would want to put this file into src/contrib/zkpython/src/examples/. Perhaps rename the example to be more descriptive of it's content (type of example). Thanks!
          Patrick Hunt made changes -
          Assignee Travis Crawford [ traviscrawford ]
          Fix Version/s 3.4.0 [ 12314469 ]
          Component/s contrib-bindings [ 12312860 ]
          Travis Crawford made changes -
          Field Original Value New Value
          Attachment zk.py [ 12443656 ]
          Travis Crawford created issue -

            People

            • Assignee:
              Andrei Savu
              Reporter:
              Travis Crawford
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development