You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@zookeeper.apache.org by Wendy Smoak <ws...@gmail.com> on 2014/11/01 00:13:41 UTC

Re: Command Line arguments for ZooKeeper Java example

On Fri, Oct 31, 2014 at 3:02 PM, Wendy Smoak <ws...@gmail.com> wrote:

> Is it this one? http://zookeeper.apache.org/doc/trunk/javaExample.html

Assuming it was... have a look at this:

   https://github.com/wsmoak/zookeeper/tree/master/simple-watch

I'm not entirely sure about a couple of things, but at least it runs
and behaves as described.

Hope that helps!  And just ask if something doesn't work or doesn't make sense.

-Wendy

Re: Command Line arguments for ZooKeeper Java example

Posted by Wendy Smoak <ws...@gmail.com>.
On Sat, Nov 1, 2014 at 11:25 AM, Wendy Smoak <ws...@gmail.com> wrote:
> So that you can see the start, stop, and restart behavior, I updated
> this to use a trivial 'program' (bash script) that counts up 1, 2, 3,
> with a five second delay.

... and, here it is again with a Maven build:

https://github.com/wsmoak/zookeeper/tree/master/simple-watch-mvn

(If you're at a Windows command line, I imagine you'll need to give it
a different "program" to run as the bash script won't work.  Change
the exec plugin config to do that, or ask if you get stuck.)

-Wendy

Re: Command Line arguments for ZooKeeper Java example

Posted by Wendy Smoak <ws...@gmail.com>.
So that you can see the start, stop, and restart behavior, I updated
this to use a trivial 'program' (bash script) that counts up 1, 2, 3,
with a five second delay.

https://github.com/wsmoak/zookeeper/tree/master/simple-watch

Here is what it might look like:

(In the command line interface)
[zk: localhost:2181(CONNECTED) 16] create /stuff my_data
Created /stuff
[zk: localhost:2181(CONNECTED) 17] set /stuff other_data
[zk: localhost:2181(CONNECTED) 18] delete /stuff

(running the watcher example)
2014-11-01 11:05:43,908 [myid:] - INFO
[main-SendThread(localhost:2181):ClientCnxn$SendThread@1346] - Session
establishment complete on server localhost/127.0.0.1:2181, sessionid =
0x1496bca44fe0002, negotiated timeout = 4000
Starting child
1
2
3
4
Stopping child
Starting child
1
2
3
Killing process

-Wendy

Re: Command Line arguments for ZooKeeper Java example

Posted by Wendy Smoak <ws...@gmail.com>.
If you look at
https://github.com/wsmoak/zookeeper/blob/master/simple-watch/run.sh
you can see the minimal set of things I had to add to the CLASSPATH.

zookeeper-3.5.0-alpha.jar
slf4j-api-1.7.5.jar
slf4j-log4j12-1.7.5.jar
log4j-1.2.16.jar

The logging jars were not needed to compile the project, but they are
needed to run it.

The next thing you might run into is a complaint about configuring
Log4j.  There is a sample config file in the conf/ directory of the
ZooKeeper .tar.gz distribution.

-Wendy

Re:Re: Command Line arguments for ZooKeeper Java example

Posted by Tom <bi...@163.com>.
Have you added the slf4j on your classpath?

-Todd






At 2014-11-01 07:28:36, "Yogesh Patil" <pa...@gmail.com> wrote:
>Hi Wendy,
>thank you for taking an effort to try and making it work.
>
>As I tried earlier, I used eclipse IDE and gave following arguments in run
>config:
>localhost /stuff output.txt ls
>
>so encountered following error.
>
>Exception in thread "main" java.lang.NoClassDefFoundError:
>org/slf4j/LoggerFactory
>at org.apache.zookeeper.ZooKeeper.<clinit>(ZooKeeper.java:94)
>at Executor.<init>(Executor.java:38)
>at Executor.main(Executor.java:59)
>
>
>
>On Fri, Oct 31, 2014 at 7:13 PM, Wendy Smoak <ws...@gmail.com> wrote:
>
>> On Fri, Oct 31, 2014 at 3:02 PM, Wendy Smoak <ws...@gmail.com> wrote:
>>
>> > Is it this one? http://zookeeper.apache.org/doc/trunk/javaExample.html
>>
>> Assuming it was... have a look at this:
>>
>>    https://github.com/wsmoak/zookeeper/tree/master/simple-watch
>>
>> I'm not entirely sure about a couple of things, but at least it runs
>> and behaves as described.
>>
>> Hope that helps!  And just ask if something doesn't work or doesn't make
>> sense.
>>
>> -Wendy
>>

Re: Command Line arguments for ZooKeeper Java example

Posted by Yogesh Patil <pa...@gmail.com>.
Hi Wendy,
thank you for taking an effort to try and making it work.

As I tried earlier, I used eclipse IDE and gave following arguments in run
config:
localhost /stuff output.txt ls

so encountered following error.

Exception in thread "main" java.lang.NoClassDefFoundError:
org/slf4j/LoggerFactory
at org.apache.zookeeper.ZooKeeper.<clinit>(ZooKeeper.java:94)
at Executor.<init>(Executor.java:38)
at Executor.main(Executor.java:59)



On Fri, Oct 31, 2014 at 7:13 PM, Wendy Smoak <ws...@gmail.com> wrote:

> On Fri, Oct 31, 2014 at 3:02 PM, Wendy Smoak <ws...@gmail.com> wrote:
>
> > Is it this one? http://zookeeper.apache.org/doc/trunk/javaExample.html
>
> Assuming it was... have a look at this:
>
>    https://github.com/wsmoak/zookeeper/tree/master/simple-watch
>
> I'm not entirely sure about a couple of things, but at least it runs
> and behaves as described.
>
> Hope that helps!  And just ask if something doesn't work or doesn't make
> sense.
>
> -Wendy
>