[jira] [Assigned] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread John Fang (JIRA)

 [ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

John Fang reassigned STORM-1257:


Assignee: John Fang  (was: Basti Liu)

> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117114#comment-15117114
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50827653
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread wuchong
Github user wuchong commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50827653
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117112#comment-15117112
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50827587
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
--- End diff --

duplicately here


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread wuchong
Github user wuchong commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50827587
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
--- End diff --

duplicately here


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: port org.apache.storm.zookeeper to java

2016-01-26 Thread hustfxj
GitHub user hustfxj opened a pull request:

https://github.com/apache/storm/pull/1047

port org.apache.storm.zookeeper to java

1.  Port "org.apache.storm.zookeeper" to java at 
"org.apache.storm.zookeeper.Zookeeper".
2.  Update all the callings to the config functions.
3.  Deleted most functions in zookeeper.clj except a few: mk-client 
(because of "watcher" which is derived by clojure in some .clj files).
4.  add the package "Callback", where callback functions put. I am merging 
clusters and timer which involves lots of callback functions. I put them into 
package "Callback".

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/hustfxj/storm zookeeper

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/storm/pull/1047.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1047


commit 70f74971561d3a7e152ed558f7b4b1bca0c96185
Author: xiaojian.fxj 
Date:   2016-01-26T09:02:07Z

port zookeeper.clj to java

commit 39e11c05fde872a5bb7e0ac3ddfe5fd55b0d8fd3
Author: xiaojian.fxj 
Date:   2016-01-26T09:04:36Z

fry

commit d66ae23ec4e0aa49a285025acac9406c500e2c62
Author: xiaojian.fxj 
Date:   2016-01-26T09:12:47Z

forget some dependencies




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: port org.apache.storm.zookeeper to java

2016-01-26 Thread hustfxj
Github user hustfxj closed the pull request at:

https://github.com/apache/storm/pull/1045


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread hustfxj
Github user hustfxj commented on the pull request:

https://github.com/apache/storm/pull/1047#issuecomment-174924218
  
test


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread John Fang (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15116987#comment-15116987
 ] 

John Fang commented on STORM-1257:
--

please look at https://github.com/apache/storm/pull/1047


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: Basti Liu
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15116988#comment-15116988
 ] 

ASF GitHub Bot commented on STORM-1257:
---

Github user hustfxj commented on the pull request:

https://github.com/apache/storm/pull/1047#issuecomment-174924218
  
test


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


Re: DRPC server not working

2016-01-26 Thread researcher cs
yes i tried in local and worked well
and about /etc/hosts . i'm feeling that this file has a mistake , i made
alot of changes in this file and didn't remember what was default

In nimbus log file when it connected zookeeper i got
2016-01-27 01:41:00 c.n.c.f.i.CuratorFrameworkImpl [INFO] Starting
2016-01-27 01:41:00 o.a.z.ZooKeeper [INFO] Initiating client connection,
connectString=localhost:2181 sessionTimeout=2
watcher=com.netflix.curator.ConnectionState@2fa423d2
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Opening socket connection to
server localhost/127.0.1.1:2181. Will not attempt to authenticate using
SASL (unknown error)
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Socket connection established
to localhost/127.0.1.1:2181, initiating session
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Session establishment complete
on server localhost/127.0.1.1:2181, sessionid = 0x152804f3a3a0002,
negotiated timeout = 2
2016-01-27 01:41:00 b.s.zookeeper [INFO] Zookeeper state update:
:connected:none
2016-01-27 01:41:00 o.a.z.ZooKeeper [INFO] Session: 0x152804f3a3a0002 closed
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] EventThread shut down
2016-01-27 01:41:00 c.n.c.f.i.CuratorFrameworkImpl [INFO] Starting
2016-01-27 01:41:00 o.a.z.ZooKeeper [INFO] Initiating client connection,
connectString=localhost:2181/storm sessionTimeout=2
watcher=com.netflix.curator.ConnectionState@2ee8b0bf
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Opening socket connection to
server user-Lenovo-G50-70/127.0.0.1:2181. Will not attempt to authenticate
using SASL (unknown error)
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Socket connection established
to user-Lenovo-G50-70/127.0.0.1:2181, initiating session
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Session establishment complete
on server user-Lenovo-G50-70/127.0.0.1:2181, sessionid = 0x152804f3a3a0003,
negotiated timeout = 2

and i set for drpc.server : localhost
storm.zookeeper.server : localhost
nimbus.host : localhost

in my /etc/hosts
127.0.0.1  user-Lenovo-G50-70  localhost
127.0.1.1  localhost

 is that right ?


On Wed, Jan 27, 2016 at 6:12 AM, Erik Weathers <
eweath...@groupon.com.invalid> wrote:

> You said: "except the statement of drpc server trying to connect"
>
> Maybe you are confused about what "b.s.d.drpc [INFO] Starting Distributed
> RPC servers..." implies?
> That is just saying that the server is being started.   It's a server, not
> a client, so it's basic operation is *not* to connect to some other thing.
> It's up and waiting for you to tell it to do stuff.
>
> Have you gotten the Local-mode version of DRPC working?
>
>-
>
> https://storm.apache.org/documentation/Distributed-RPC.html#local-mode-drpc
>
> Not sure what you're asking with regards to DNS and /etc/hosts, those seem
> unrelated to your basic issue.
>
> - Erik
>
> On Tue, Jan 26, 2016 at 6:58 PM, researcher cs 
> wrote:
>
> > There is no error except the statement of drpc server trying to connect
> . I
> > guess I have problem with Dns . if you have any idea about this pleaes
> help
> >
> >
> > I want to submit topology with single machine
> > Only on my laptop without any other devices as a first step so
> >  What this file /etc/hosts should contains ?
> > As I set in drpc.server : localhost
> > Storm.zookeeper. server: localhost
> > Nimbus.host:localhost
> >
> > As this file contains 127.0.1.1 and 127.0.0.1 and my IP address ?
> >
> > What should I use and what should I hash it to not using it ?
> >
> >
> >
> > On Wednesday, January 27, 2016, Erik Weathers
> > 
> > wrote:
> >
> > > What does the client code that is supposed to make the DRPC connection
> > > telling you?  i.e., you should see some exception or log about not
> > > establishing the connection, right?
> > >
> > > Alternatively, perhaps the connections aren't persistent and there's no
> > > actual problem?
> > >
> > > - Erik
> > >
> > > On Tue, Jan 26, 2016 at 4:55 PM, researcher cs <
> > prog.researc...@gmail.com
> > > >
> > > wrote:
> > >
> > > >  thanks for replying , i read the documentation before , i imported
> > > project
> > > > supposed to work well but not working with me
> > > > i checked port by lsof -i gave me all ports i connected it for storm
> > > > java  10675   root   20u  IPv4  98126  0t0  TCP *:52022
> > (LISTEN)
> > > > java  10675   root   26u  IPv4  98131  0t0  TCP *:2181
> (LISTEN)
> > > > java  10675   root   27u  IPv4 101944  0t0  TCP
> > > > localhost:2181->user-Lenovo-G50-70:38150 (ESTABLISHED)
> > > > java  10675   root   29u  IPv4  98974  0t0  TCP
> > > > user-Lenovo-G50-70:2181->user-Lenovo-G50-70:50526 (ESTABLISHED)
> > > > java  10675   root   30u  IPv4  99105  0t0  TCP
> > > > localhost:2181->user-Lenovo-G50-70:38165 (ESTABLISHED)
> > > > java  10715   root   90u  IPv4  98953  0t0  TCP
> > > > user-Lenovo-G50-70:38150->localhost:2181 (ESTABLISHED)
> > > > java  

Re: DRPC server not working

2016-01-26 Thread Erik Weathers
Your mail client is wrapping the log lines prematurely, I have a really
really hard time reading wrapped lines, I'd look into fixing that if I were
you.  Here they are unwrapped:

2016-01-27 01:41:00 c.n.c.f.i.CuratorFrameworkImpl [INFO] Starting
2016-01-27 01:41:00 o.a.z.ZooKeeper [INFO] Initiating client connection,
connectString=localhost:2181 sessionTimeout=2
watcher=com.netflix.curator.ConnectionState@2fa423d2
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Opening socket connection to
server localhost/127.0.1.1:2181. Will not attempt to authenticate using
SASL (unknown error)
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Socket connection established
to localhost/127.0.1.1:2181, initiating session
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Session establishment complete
on server localhost/127.0.1.1:2181, sessionid = 0x152804f3a3a0002,
negotiated timeout = 2
2016-01-27 01:41:00 b.s.zookeeper [INFO] Zookeeper state update:
:connected:none
2016-01-27 01:41:00 o.a.z.ZooKeeper [INFO] Session: 0x152804f3a3a0002 closed
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] EventThread shut down
2016-01-27 01:41:00 c.n.c.f.i.CuratorFrameworkImpl [INFO] Starting
2016-01-27 01:41:00 o.a.z.ZooKeeper [INFO] Initiating client connection,
connectString=localhost:2181/storm sessionTimeout=2
watcher=com.netflix.curator.ConnectionState@2ee8b0bf
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Opening socket connection to
server user-Lenovo-G50-70/127.0.0.1:2181. Will not attempt to authenticate
using SASL (unknown error)
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Socket connection established
to user-Lenovo-G50-70/127.0.0.1:2181, initiating session
2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Session establishment complete
on server user-Lenovo-G50-70/127.0.0.1:2181, sessionid = 0x152804f3a3a0003,
negotiated timeout = 2

None of those indicate a problem, they look pretty standard to me.

Please spend a bit more time zeroing in on what the actual problem is so
that the members of the list(s) can provide help.

- Erik

On Tue, Jan 26, 2016 at 10:15 PM, researcher cs 
wrote:

> yes i tried in local and worked well
> and about /etc/hosts . i'm feeling that this file has a mistake , i made
> alot of changes in this file and didn't remember what was default
>
> In nimbus log file when it connected zookeeper i got
> 2016-01-27 01:41:00 c.n.c.f.i.CuratorFrameworkImpl [INFO] Starting
> 2016-01-27 01:41:00 o.a.z.ZooKeeper [INFO] Initiating client connection,
> connectString=localhost:2181 sessionTimeout=2
> watcher=com.netflix.curator.ConnectionState@2fa423d2
> 2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Opening socket connection to
> server localhost/127.0.1.1:2181. Will not attempt to authenticate using
> SASL (unknown error)
> 2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Socket connection established
> to localhost/127.0.1.1:2181, initiating session
> 2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Session establishment complete
> on server localhost/127.0.1.1:2181, sessionid = 0x152804f3a3a0002,
> negotiated timeout = 2
> 2016-01-27 01:41:00 b.s.zookeeper [INFO] Zookeeper state update:
> :connected:none
> 2016-01-27 01:41:00 o.a.z.ZooKeeper [INFO] Session: 0x152804f3a3a0002
> closed
> 2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] EventThread shut down
> 2016-01-27 01:41:00 c.n.c.f.i.CuratorFrameworkImpl [INFO] Starting
> 2016-01-27 01:41:00 o.a.z.ZooKeeper [INFO] Initiating client connection,
> connectString=localhost:2181/storm sessionTimeout=2
> watcher=com.netflix.curator.ConnectionState@2ee8b0bf
> 2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Opening socket connection to
> server user-Lenovo-G50-70/127.0.0.1:2181. Will not attempt to authenticate
> using SASL (unknown error)
> 2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Socket connection established
> to user-Lenovo-G50-70/127.0.0.1:2181, initiating session
> 2016-01-27 01:41:00 o.a.z.ClientCnxn [INFO] Session establishment complete
> on server user-Lenovo-G50-70/127.0.0.1:2181, sessionid =
> 0x152804f3a3a0003,
> negotiated timeout = 2
>
> and i set for drpc.server : localhost
> storm.zookeeper.server : localhost
> nimbus.host : localhost
>
> in my /etc/hosts
> 127.0.0.1  user-Lenovo-G50-70  localhost
> 127.0.1.1  localhost
>
>  is that right ?
>
>
> On Wed, Jan 27, 2016 at 6:12 AM, Erik Weathers <
> eweath...@groupon.com.invalid> wrote:
>
> > You said: "except the statement of drpc server trying to connect"
> >
> > Maybe you are confused about what "b.s.d.drpc [INFO] Starting Distributed
> > RPC servers..." implies?
> > That is just saying that the server is being started.   It's a server,
> not
> > a client, so it's basic operation is *not* to connect to some other
> thing.
> > It's up and waiting for you to tell it to do stuff.
> >
> > Have you gotten the Local-mode version of DRPC working?
> >
> >-
> >
> >
> https://storm.apache.org/documentation/Distributed-RPC.html#local-mode-drpc
> >
> > Not sure what you're asking with 

Re: DRPC server not working

2016-01-26 Thread Erik Weathers
You said: "except the statement of drpc server trying to connect"

Maybe you are confused about what "b.s.d.drpc [INFO] Starting Distributed
RPC servers..." implies?
That is just saying that the server is being started.   It's a server, not
a client, so it's basic operation is *not* to connect to some other thing.
It's up and waiting for you to tell it to do stuff.

Have you gotten the Local-mode version of DRPC working?

   -
   https://storm.apache.org/documentation/Distributed-RPC.html#local-mode-drpc

Not sure what you're asking with regards to DNS and /etc/hosts, those seem
unrelated to your basic issue.

- Erik

On Tue, Jan 26, 2016 at 6:58 PM, researcher cs 
wrote:

> There is no error except the statement of drpc server trying to connect . I
> guess I have problem with Dns . if you have any idea about this pleaes help
>
>
> I want to submit topology with single machine
> Only on my laptop without any other devices as a first step so
>  What this file /etc/hosts should contains ?
> As I set in drpc.server : localhost
> Storm.zookeeper. server: localhost
> Nimbus.host:localhost
>
> As this file contains 127.0.1.1 and 127.0.0.1 and my IP address ?
>
> What should I use and what should I hash it to not using it ?
>
>
>
> On Wednesday, January 27, 2016, Erik Weathers
> 
> wrote:
>
> > What does the client code that is supposed to make the DRPC connection
> > telling you?  i.e., you should see some exception or log about not
> > establishing the connection, right?
> >
> > Alternatively, perhaps the connections aren't persistent and there's no
> > actual problem?
> >
> > - Erik
> >
> > On Tue, Jan 26, 2016 at 4:55 PM, researcher cs <
> prog.researc...@gmail.com
> > >
> > wrote:
> >
> > >  thanks for replying , i read the documentation before , i imported
> > project
> > > supposed to work well but not working with me
> > > i checked port by lsof -i gave me all ports i connected it for storm
> > > java  10675   root   20u  IPv4  98126  0t0  TCP *:52022
> (LISTEN)
> > > java  10675   root   26u  IPv4  98131  0t0  TCP *:2181 (LISTEN)
> > > java  10675   root   27u  IPv4 101944  0t0  TCP
> > > localhost:2181->user-Lenovo-G50-70:38150 (ESTABLISHED)
> > > java  10675   root   29u  IPv4  98974  0t0  TCP
> > > user-Lenovo-G50-70:2181->user-Lenovo-G50-70:50526 (ESTABLISHED)
> > > java  10675   root   30u  IPv4  99105  0t0  TCP
> > > localhost:2181->user-Lenovo-G50-70:38165 (ESTABLISHED)
> > > java  10715   root   90u  IPv4  98953  0t0  TCP
> > > user-Lenovo-G50-70:38150->localhost:2181 (ESTABLISHED)
> > > java  10715   root   91u  IPv4  98245  0t0  TCP *:6627 (LISTEN)
> > > java  10792   root   90u  IPv4  99973  0t0  TCP
> > > user-Lenovo-G50-70:50526->user-Lenovo-G50-70:2181 (ESTABLISHED)
> > > java  10864   root   82u  IPv4 102425  0t0  TCP *:3772 (LISTEN)
> > > java  10864   root   84u  IPv4 102429  0t0  TCP *:3773 (LISTEN)
> > > java  10864   root   92u  IPv4 102197  0t0  TCP
> > > user-Lenovo-G50-70:3773->user-Lenovo-G50-70:50825 (ESTABLISHED)
> > > java  10928   root   81u  IPv4 102070  0t0  TCP *:http-alt
> > (LISTEN)
> > > java  11087   root   81u  IPv4 100091  0t0  TCP
> > > user-Lenovo-G50-70:50825->user-Lenovo-G50-70:3773 (ESTABLISHED)
> > > java  11087   root   91u  IPv4 102196  0t0  TCP
> > > user-Lenovo-G50-70:38165->localhost:2181 (ESTABLISHED)
> > > java  11087   root   94u  IPv4 102561  0t0  TCP *:7660 (LISTEN)
> > >
> > >
> > > here you can see that 3772 not established
> > >
> > > On Wed, Jan 27, 2016 at 2:47 AM, Erik Weathers <
> > > eweath...@groupon.com.invalid> wrote:
> > >
> > > > hey,
> > > >
> > > > The DRPC server is up and listening on port 3772.   Why do you expect
> > > > established connections?
> > > >
> > > > I'm not familiar with using Storm's DRPC feature, but I'm sure you
> need
> > > to
> > > > write code that interacts with the DRPC server, and you've made no
> > > mention
> > > > of doing so in your email.  I'd start here:
> > > >
> > > >- https://storm.apache.org/documentation/Distributed-RPC.html
> > > >
> > > > - Erik
> > > >
> > > > On Tue, Jan 26, 2016 at 4:29 PM, researcher cs <
> > > prog.researc...@gmail.com >
> > > > wrote:
> > > >
> > > > > I set in the code
> > > > > conf.put(Config.DRPC_SERVERS, dprcServers);
> > > > > conf.put(Config.DRPC_PORT, 3772);
> > > > > but when i submit topolgoy i found at the end of the file
> > > > >  b.s.d.drpc [INFO] Starting Distributed RPC servers...
> > > > >
> > > > > i checked port 3772 by
> > > > >
> > > > > sudo netstat -ap | grep 3772
> > > > >
> > > > > i got
> > > > >
> > > > > tcp 00 *:3772*:* LISTEN  10864/java
> > > > > unix  3  [ ] STREAM CONNECTED 13772
> > > > > 587/dbus-daemon /var/run/dbus/system_bus_socket
> > > > >
> > > > >
> > > > > why it's not 

[jira] [Commented] (STORM-1342) support multiple logviewers per host for container-isolated worker logs

2016-01-26 Thread Erik Weathers (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1342?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15118650#comment-15118650
 ] 

Erik Weathers commented on STORM-1342:
--

STORM-1494 is adding support for the supervisor logs to be linked from the 
Nimbus UI.  So this will likely be another area to adjust when (if!?) this is 
fixed.

> support multiple logviewers per host for container-isolated worker logs
> ---
>
> Key: STORM-1342
> URL: https://issues.apache.org/jira/browse/STORM-1342
> Project: Apache Storm
>  Issue Type: Improvement
>  Components: storm-core
>Reporter: Erik Weathers
>Priority: Minor
>
> h3. Storm-on-Mesos Worker Logs are in varying directories
> When using [storm-on-mesos|https://github.com/mesos/storm] with cgroups, each 
> topology's workers are isolated into separate containers.  By default the 
> worker logs will be saved into container-specific sandbox directories.  These 
> directories are also topology-specific by definition, because, as just 
> stated, the containers are specific to each topology.
> h3. Problem: Storm supports 1-and-only-1 Logviewer per Worker Host
> A challenge with this different way of running Storm is that the [Storm 
> logviewer|https://github.com/apache/storm/blob/768a85926373355c15cc139fd86268916abc6850/docs/_posts/2013-12-08-storm090-released.md#log-viewer-ui]
>  runs as a single instance on each worker host.   This doesn't play well with 
> having the topology worker logs in separate per-topology containers.  The one 
> logviewer doesn't know about the various sandbox directories that the Storm 
> Workers are writing to.  And if we just spawned new logviewers for each 
> container, the problem is that the Storm UI only knows about 1 global port 
> the logviewer, so you cannot just direct.
> These problems are documented (or linked to) from [Issue #6 in the 
> storm-on-mesos project|https://github.com/mesos/storm/issues/6]
> h3. Possible Solutions I can envision
> # configure the Storm workers to write to log directories that exist on the 
> raw host outside of the container sandbox, and run a single logviewer on a 
> host, which serves up the contents of that directory.
> #* violates one of the basic reasons for using containers: isolation.
> #* also prevents allow a standard use case for Mesos: running more than 1 
> instance of a Mesos Framework (e.g., "Storm Cluster") at once on same Mesos 
> Cluster. e.g., for Blue-Green deployments.
> #* a variation on this proposal is to somehow expose the sandbox dirs of all 
> storm containers to this singleton logviewer process (still has above 
> problems)
> # launch a separate logviewers in each container, and somehow register those 
> logviewers with Storm such that Storm knows for a given host which logviewer 
> port is assigned to a given topology.
> #* this is the proposed solution
> h3. Storm Changes for the Proposed Solution
> Nimbus or ZooKeeper could serve as a registrar, recording the association 
> between a slot (host + worker port) and the logviewer port that is serving 
> the workers logs. And the Storm-on-Mesos framework could update this registry 
> when launching a new worker.  (This proposal definitely calls for thorough 
> vetting and thinking.)
> h3. Storm-on-Mesos Framework Changes for the Proposed Solution
> Along with the interaction with the "registrar" proposed above, the 
> storm-on-mesos framework can be enhanced to launch multiple logviewers on a 
> given worker host, where each logviewer is dedicated to serving the worker 
> logs from a specific topology's container/sandbox directory.  This would be 
> done by launching a logviewer process within the topology's container, and 
> assigning it an arbitrary listening port that has been determined dynamically 
> through mesos (which treats ports as one of the schedulable resource 
> primitives of a worker host).  [Code implementing this 
> logviewer-port-allocation logic already 
> exists|https://github.com/mesos/storm/commit/af8c49beac04b530c33c1401c829caaa8e368a35],
>  but [that specific portion of the code was 
> reverted|https://github.com/mesos/storm/commit/dc3eee0f0e9c06f6da7b2fe697a8e4fc05b5227e]
>  because of the issues that inspired this ticket.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1494) Storm UI - Add link to supervisor log

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15118597#comment-15118597
 ] 

ASF GitHub Bot commented on STORM-1494:
---

Github user ptgoetz commented on the pull request:

https://github.com/apache/storm/pull/1049#issuecomment-175378568
  
+1  

For now I'd say it should be applied to the 1.x branch. Master should be 
considered as well, since the .clj files involved haven't really come into play 
yet, in terms of migration.


> Storm UI - Add link to supervisor log
> -
>
> Key: STORM-1494
> URL: https://issues.apache.org/jira/browse/STORM-1494
> Project: Apache Storm
>  Issue Type: Sub-task
>Reporter: P. Taylor Goetz
>Assignee: Yegor Tokmakov
>  Labels: newbie
>
> The UI currently has links to the nimbus and worker logs, but not the 
> supervisor logs.
> If nimbus nodes are separate from supervisor nodes, and there are no 
> topologies deployed, it is impossible to view the supervisor logs.
> The easiest fix is probably to hyperlink the hostname in the supervisor 
> summary table. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: STORM-1494 Link to supervisor logs form UI

2016-01-26 Thread ptgoetz
Github user ptgoetz commented on the pull request:

https://github.com/apache/storm/pull/1049#issuecomment-175378568
  
+1  

For now I'd say it should be applied to the 1.x branch. Master should be 
considered as well, since the .clj files involved haven't really come into play 
yet, in terms of migration.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: port org.apache.storm.zookeeper to java

2016-01-26 Thread hustfxj
GitHub user hustfxj opened a pull request:

https://github.com/apache/storm/pull/1045

port org.apache.storm.zookeeper to java 

1. Port "org.apache.storm.zookeeper" to java at 
"org.apache.storm.zookeeper.Zookeeper".
2. Update all the callings to the config functions.
3. Deleted most functions in zookeeper.clj except a few: mk-client (because 
of "watcher" which is derived by clojure in some .clj files).
4. add the package "Callback", where  callback functions put. I am merging 
clusters and timer which involves lots of callback functions. I put them into 
package "Callback".

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/hustfxj/storm xiaojian.fxj

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/storm/pull/1045.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1045


commit 6ce984128fd92e42ae7018d6b27be753e7dfa30d
Author: zhuol 
Date:   2016-01-13T19:55:47Z

[STORM-1227] Init commit for config.clj function translation to java

commit 0b90a63d5ac7075524e9fabc7a49bda47b41b946
Author: zhuol 
Date:   2016-01-13T22:45:39Z

To continue update callers to read-storm-config

commit cb4cdf6910b9bc8bc9077d5ad0750707d14e5cb2
Author: zhuol 
Date:   2016-01-14T19:44:12Z

mock read-storm-config in drpc_test

commit f350f1ae9aaa44ea8f931c5e48eef5051d79770d
Author: zhuol 
Date:   2016-01-14T20:34:43Z

Update all the callings to read-storm-config and add the import for 
ConfigUtils

commit 3d2796d2fbd7ae182d7414db985cf7de167fcd82
Author: zhuol 
Date:   2016-01-14T21:25:47Z

Update callings to supervisor-isupervisor-dir

commit 635488db5e0670f1e4348fab5e3fd7d3970c5e63
Author: zhuol 
Date:   2016-01-15T18:50:00Z

Updated to callings for supervisor-stormjar-path

commit 99189a6016d24aff485b9206323ad68988d32be1
Author: zhuol 
Date:   2016-01-15T19:10:20Z

Updated to supervisor-storm-resources-path

commit 310128d9469f2151851d4e44710593b6ebcbac59
Author: zhuol 
Date:   2016-01-15T19:33:52Z

updated to nimbus-topo-history-state

commit ba70bf1cfe72aeabec104d8ea664f087b719a08c
Author: zhuol 
Date:   2016-01-15T20:28:04Z

Updated to read-supervisor-storm-conf

commit 0dbdcf39bf411a4ee5abac5e740c07e8813ea025
Author: zhuol 
Date:   2016-01-17T22:37:35Z

Updates workerRoot, worker user, path, state, set. To do a few left.

commit 7c3fec6502ab23855a0b31dbb93debe7e22e73ff
Author: zhuol 
Date:   2016-01-19T17:23:26Z

Updated callings before get-topo-logs-users

commit 13ab1515c503ad3eefe10871b5972d4bce60fde6
Author: zhuol 
Date:   2016-01-19T17:38:05Z

Updated all callings

commit fd37de911ad73cf1a6f0d5500d0c1532a7ece209
Author: zhuol 
Date:   2016-01-19T22:54:10Z

Updated for all the rest that we can do

commit b4847b76f0222344a51987fce1c8180616a4c279
Author: zhuol 
Date:   2016-01-19T23:33:51Z

Manual test

commit b7374d2bb4cf49111936ec1cbd2a4f4f22661100
Author: zhuol 
Date:   2016-01-20T15:54:30Z

Cleanup the comments

commit b9e640afd181e48a3ae2fe726318ce94d8836e59
Author: zhuol 
Date:   2016-01-20T22:37:22Z

Address comments. To continue.

commit 24807720244147b626d2b2fa7e5eb2d5bf9c8e21
Author: zhuol 
Date:   2016-01-20T22:52:09Z

Minor

commit c495266022e47800b74ac8cb0ea73b1d0434669e
Author: zhuol 
Date:   2016-01-20T23:18:11Z

address read-default-config

commit df51368d6d24af12fbde351e77be330736514f24
Author: zhuol 
Date:   2016-01-20T23:38:37Z

use URLEncoder.encode UTF-8

commit 95ee614aaacb2dfa3bad983f8d14d0522d7e63f1
Author: xiaojian.fxj 
Date:   2016-01-21T02:51:03Z

Merge branch '1227' of https://github.com/zhuoliu/storm

commit b821c9352489be0acfdd24a5287b493ee402772b
Author: xiaojian.fxj 
Date:   2016-01-25T06:00:00Z

merge timer and Zookeeper

commit 5edfa3fa85a1d5ebc1df5cb2ed9c558827acdcb7
Author: xiaojian.fxj 
Date:   2016-01-25T09:26:22Z

merge zookeeper.clj

commit 9f93daeb09bf9f13e1110901cbeed04c92663e9a
Author: xiaojian.fxj 
Date:   2016-01-25T09:26:59Z

Merge branch 'master' of github.com:apache/storm

commit a20fbb60d7e942aca5a8e01c5b7661936a61ce70
Author: xiaojian.fxj 
Date:   2016-01-25T09:27:49Z

Merge branch 'master' into xiaojian.fxj

commit b0b518c7540349d53af102192708c51d75a50053
Author: xiaojian.fxj 
Date:  

[jira] [Commented] (STORM-1501) launch worker process exception will cause supervisor process exited

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1501?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15116908#comment-15116908
 ] 

ASF GitHub Bot commented on STORM-1501:
---

GitHub user caofangkun opened a pull request:

https://github.com/apache/storm/pull/1046

[STORM-1501] launch worker process exception will cause supervisor process 
exited


[util.clj/async-loop](https://github.com/apache/storm/blob/master/storm-core/src/clj/org/apache/storm/util.clj#L474)
 default kill-fn will kill current process  

when supervisor use 
[util.clj/launch-process](https://github.com/apache/storm/blob/master/storm-core/src/clj/org/apache/storm/util.clj#L546)
 to launch worker process , if exeception occurs , supervisor process will exit.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/caofangkun/apache-storm storm-1501-1

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/storm/pull/1046.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1046


commit 21ef59cadbe4204a0152cef5cf58dffcd928a469
Author: caofangkun 
Date:   2016-01-26T08:04:53Z

[STORM-1501] launch worker process exception will cause supervisor process 
exited




>  launch worker process exception will cause supervisor process exited
> -
>
> Key: STORM-1501
> URL: https://issues.apache.org/jira/browse/STORM-1501
> Project: Apache Storm
>  Issue Type: Bug
>  Components: storm-core
>Affects Versions: 2.0.0
>Reporter: caofangkun
>Assignee: caofangkun
>Priority: Trivial
>
> [util.clj/async-loop | 
> https://github.com/apache/storm/blob/master/storm-core/src/clj/org/apache/storm/util.clj#L474]
>  default kill-fn will kill current process  
> when supervisor use [util.clj/launch-process | 
> https://github.com/apache/storm/blob/master/storm-core/src/clj/org/apache/storm/util.clj#L546]
>  to launch worker process , if exeception occurs , supervisor process will 
> exit.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1501] launch worker process exception w...

2016-01-26 Thread caofangkun
GitHub user caofangkun opened a pull request:

https://github.com/apache/storm/pull/1046

[STORM-1501] launch worker process exception will cause supervisor process 
exited


[util.clj/async-loop](https://github.com/apache/storm/blob/master/storm-core/src/clj/org/apache/storm/util.clj#L474)
 default kill-fn will kill current process  

when supervisor use 
[util.clj/launch-process](https://github.com/apache/storm/blob/master/storm-core/src/clj/org/apache/storm/util.clj#L546)
 to launch worker process , if exeception occurs , supervisor process will exit.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/caofangkun/apache-storm storm-1501-1

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/storm/pull/1046.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1046


commit 21ef59cadbe4204a0152cef5cf58dffcd928a469
Author: caofangkun 
Date:   2016-01-26T08:04:53Z

[STORM-1501] launch worker process exception will cause supervisor process 
exited




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on the pull request:

https://github.com/apache/storm/pull/1047#issuecomment-175044569
  
Looks like you missed a reference to in-process-zookeeper (from the CI)
```
Exception in thread "main" java.lang.RuntimeException: No such var: 
org.apache.storm.zookeeper/mk-inprocess-zookeeper, 
compiling:(org/apache/storm/transactional_test.clj:105:5)
```


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117278#comment-15117278
 ] 

ASF GitHub Bot commented on STORM-1257:
---

Github user revans2 commented on the pull request:

https://github.com/apache/storm/pull/1047#issuecomment-175044569
  
Looks like you missed a reference to in-process-zookeeper (from the CI)
```
Exception in thread "main" java.lang.RuntimeException: No such var: 
org.apache.storm.zookeeper/mk-inprocess-zookeeper, 
compiling:(org/apache/storm/transactional_test.clj:105:5)
```


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50841330
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/callback/DefaultWatcherCallBack.java ---
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.callback;
+
+import org.apache.storm.zookeeper.ZkEventTypes;
+import org.apache.storm.zookeeper.ZkKeeperStates;
+import org.apache.zookeeper.Watcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DefaultWatcherCallBack implements WatcherCallBack {
+
+private static Logger LOG = 
LoggerFactory.getLogger(DefaultWatcherCallBack.class);
+
+@Override
+public void execute(Watcher.Event.KeeperState state, 
Watcher.Event.EventType type, String path) {
+LOG.info("Zookeeper state update:" + 
ZkKeeperStates.getStateName(state) + "," + ZkEventTypes.getStateName(type) + 
"," + path);
--- End diff --

This is new code that didn't exist in storm proper.  I think it would be 
cleaner to have this be a debug message instead of an info message.  Also could 
you use "{}" substitution instead of +?

```
LOG.info("Zookeeper state update: {}, {}, {}", 
ZkKeeperStates.getStateName(state),  ZkEventTypes.getStateName(type), path);
``` 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117290#comment-15117290
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50841330
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/callback/DefaultWatcherCallBack.java ---
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.callback;
+
+import org.apache.storm.zookeeper.ZkEventTypes;
+import org.apache.storm.zookeeper.ZkKeeperStates;
+import org.apache.zookeeper.Watcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DefaultWatcherCallBack implements WatcherCallBack {
+
+private static Logger LOG = 
LoggerFactory.getLogger(DefaultWatcherCallBack.class);
+
+@Override
+public void execute(Watcher.Event.KeeperState state, 
Watcher.Event.EventType type, String path) {
+LOG.info("Zookeeper state update:" + 
ZkKeeperStates.getStateName(state) + "," + ZkEventTypes.getStateName(type) + 
"," + path);
--- End diff --

This is new code that didn't exist in storm proper.  I think it would be 
cleaner to have this be a debug message instead of an info message.  Also could 
you use "{}" substitution instead of +?

```
LOG.info("Zookeeper state update: {}, {}, {}", 
ZkKeeperStates.getStateName(state),  ZkEventTypes.getStateName(type), path);
``` 


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1483) add storm-mongodb connector

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117299#comment-15117299
 ] 

ASF GitHub Bot commented on STORM-1483:
---

Github user vesense commented on the pull request:

https://github.com/apache/storm/pull/1038#issuecomment-175048700
  
I fixed some issues. Work is going on for `upsert`.
And I will file a new JIRA for the next phase including `MongoMapState`.


> add storm-mongodb connector
> ---
>
> Key: STORM-1483
> URL: https://issues.apache.org/jira/browse/STORM-1483
> Project: Apache Storm
>  Issue Type: Improvement
>Reporter: Xin Wang
>Assignee: Xin Wang
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1483] add storm-mongodb connector

2016-01-26 Thread vesense
Github user vesense commented on a diff in the pull request:

https://github.com/apache/storm/pull/1038#discussion_r50841871
  
--- Diff: 
external/storm-mongodb/src/main/java/org/apache/storm/mongodb/common/MongoDBClient.java
 ---
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.mongodb.common;
+
+import java.util.List;
+
+import org.bson.Document;
+import org.bson.conversions.Bson;
+
+import com.mongodb.MongoClient;
+import com.mongodb.MongoClientURI;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+
+public class MongoDBClient {
+
+private MongoClient client;
+private MongoCollection collection;
+
+public MongoDBClient(String url, String collectionName) {
+//Creates a MongoURI from the given string.
+MongoClientURI uri = new MongoClientURI(url);
+//Creates a MongoClient described by a URI.
+this.client = new MongoClient(uri);
+//Gets a Database.
+MongoDatabase db = client.getDatabase(uri.getDatabase());
+//Gets a collection.
+this.collection = db.getCollection(collectionName);
+}
+
+public void insert(Document document) {
+collection.insertOne(document);
+}
+
+public void insert(List documents) {
+//This method is equivalent to a call to the bulkWrite method.
+collection.insertMany(documents);
+}
+
+public void update(Bson filter, Bson update) {
+//Update all documents in the collection 
--- End diff --

OK


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: [STORM-1483] add storm-mongodb connector

2016-01-26 Thread vesense
Github user vesense commented on the pull request:

https://github.com/apache/storm/pull/1038#issuecomment-175048700
  
I fixed some issues. Work is going on for `upsert`.
And I will file a new JIRA for the next phase including `MongoMapState`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: [STORM-1483] add storm-mongodb connector

2016-01-26 Thread vesense
Github user vesense commented on a diff in the pull request:

https://github.com/apache/storm/pull/1038#discussion_r50841890
  
--- Diff: 
external/storm-mongodb/src/main/java/org/apache/storm/mongodb/trident/state/MongoState.java
 ---
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.mongodb.trident.state;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.Validate;
+import org.apache.storm.mongodb.common.MongoDBClient;
+import org.apache.storm.mongodb.common.mapper.MongoMapper;
+import org.apache.storm.trident.operation.TridentCollector;
+import org.apache.storm.trident.state.State;
+import org.apache.storm.trident.tuple.TridentTuple;
+import org.bson.Document;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
+
+public class MongoState implements State {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(MongoState.class);
+
+private Options options;
+private MongoDBClient mongoClient;
+private Map map;
+
+protected MongoState(Map map, int partitionIndex, int numPartitions, 
Options options) {
--- End diff --

OK


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1483) add storm-mongodb connector

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117301#comment-15117301
 ] 

ASF GitHub Bot commented on STORM-1483:
---

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

https://github.com/apache/storm/pull/1038#discussion_r50841890
  
--- Diff: 
external/storm-mongodb/src/main/java/org/apache/storm/mongodb/trident/state/MongoState.java
 ---
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.mongodb.trident.state;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.Validate;
+import org.apache.storm.mongodb.common.MongoDBClient;
+import org.apache.storm.mongodb.common.mapper.MongoMapper;
+import org.apache.storm.trident.operation.TridentCollector;
+import org.apache.storm.trident.state.State;
+import org.apache.storm.trident.tuple.TridentTuple;
+import org.bson.Document;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
+
+public class MongoState implements State {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(MongoState.class);
+
+private Options options;
+private MongoDBClient mongoClient;
+private Map map;
+
+protected MongoState(Map map, int partitionIndex, int numPartitions, 
Options options) {
--- End diff --

OK


> add storm-mongodb connector
> ---
>
> Key: STORM-1483
> URL: https://issues.apache.org/jira/browse/STORM-1483
> Project: Apache Storm
>  Issue Type: Improvement
>Reporter: Xin Wang
>Assignee: Xin Wang
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1483) add storm-mongodb connector

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117300#comment-15117300
 ] 

ASF GitHub Bot commented on STORM-1483:
---

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

https://github.com/apache/storm/pull/1038#discussion_r50841871
  
--- Diff: 
external/storm-mongodb/src/main/java/org/apache/storm/mongodb/common/MongoDBClient.java
 ---
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.mongodb.common;
+
+import java.util.List;
+
+import org.bson.Document;
+import org.bson.conversions.Bson;
+
+import com.mongodb.MongoClient;
+import com.mongodb.MongoClientURI;
+import com.mongodb.client.MongoCollection;
+import com.mongodb.client.MongoDatabase;
+
+public class MongoDBClient {
+
+private MongoClient client;
+private MongoCollection collection;
+
+public MongoDBClient(String url, String collectionName) {
+//Creates a MongoURI from the given string.
+MongoClientURI uri = new MongoClientURI(url);
+//Creates a MongoClient described by a URI.
+this.client = new MongoClient(uri);
+//Gets a Database.
+MongoDatabase db = client.getDatabase(uri.getDatabase());
+//Gets a collection.
+this.collection = db.getCollection(collectionName);
+}
+
+public void insert(Document document) {
+collection.insertOne(document);
+}
+
+public void insert(List documents) {
+//This method is equivalent to a call to the bulkWrite method.
+collection.insertMany(documents);
+}
+
+public void update(Bson filter, Bson update) {
+//Update all documents in the collection 
--- End diff --

OK


> add storm-mongodb connector
> ---
>
> Key: STORM-1483
> URL: https://issues.apache.org/jira/browse/STORM-1483
> Project: Apache Storm
>  Issue Type: Improvement
>Reporter: Xin Wang
>Assignee: Xin Wang
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50842461
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
+this.leaderLatchListener = leaderLatchListener;
+}
+
+@Override
+public void prepare(Map conf) {
+LOG.info("no-op for zookeeper implementation");
--- End diff --

Could this be a comment instead of a log message?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117310#comment-15117310
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50842461
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
+this.leaderLatchListener = leaderLatchListener;
+}
+
+@Override
+public void prepare(Map conf) {
+LOG.info("no-op for zookeeper implementation");
--- End diff --

Could this be a comment instead of a log message?


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117302#comment-15117302
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50842034
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1382,5 +1382,43 @@ public static TopologyInfo getTopologyInfo(String 
name, String asUser, Map storm
 public static int toPositive(int number) {
 return number & Integer.MAX_VALUE;
 }
+
+public static RuntimeException wrapInRuntime(Exception e){
+if (e instanceof RuntimeException){
+return (RuntimeException)e;
+}else {
+return new RuntimeException(e);
+}
+}
+
+public static List tokenizePath(String path) {
+String[] toks = path.split(File.separator);
+java.util.ArrayList rtn = new ArrayList();
+for (String str : toks) {
+if (!str.isEmpty()) {
+rtn.add(str);
+}
+}
+return rtn;
+}
+
+public static String toksToPath(List toks) {
+StringBuffer buff = new StringBuffer();
+buff.append(File.separator);
+int size = toks.size();
+for (int i = 0; i < size; i++) {
+buff.append(toks.get(i));
+if (i < (size - 1)) {
+buff.append(File.separator);
+}
+
+}
+return buff.toString();
+}
+
+public static String normalizePath(String path) {
+String rtn = toksToPath(tokenizePath(path));
+return rtn;
+}
--- End diff --

Can we please move tokenizePath, toksToPath, and normalizePath to 
Zookeeper.java?  and change them from using File.separator, to use "/".  The 
issue is that they are specific to zookeeper so need the "/", without it on 
windows it will not work.  They should never have been in util.clj to begin 
with.  I'll update the util.clj JIRA to indicate this too.


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50842866
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/ZkEventTypes.java 
---
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.zookeeper.Watcher;
+
+import java.util.HashMap;
+
+public class ZkEventTypes {
+
+private static HashMap map;
+
+static {
+map = new HashMap();
+
+map.put(Watcher.Event.EventType.None, ":none");
+map.put(Watcher.Event.EventType.NodeCreated, ":node-created");
+map.put(Watcher.Event.EventType.NodeDeleted, ":node-deleted");
+map.put(Watcher.Event.EventType.NodeDataChanged, 
":node-data-changed");
+map.put(Watcher.Event.EventType.NodeChildrenChanged, 
":node-children-changed");
+
+}
+
+public static String getStateName(Watcher.Event.EventType type) {
--- End diff --

I would rather see this called getTypeName instead of getStateName.  Of 
even just getName.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117312#comment-15117312
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50842866
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/ZkEventTypes.java 
---
@@ -0,0 +1,43 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.zookeeper.Watcher;
+
+import java.util.HashMap;
+
+public class ZkEventTypes {
+
+private static HashMap map;
+
+static {
+map = new HashMap();
+
+map.put(Watcher.Event.EventType.None, ":none");
+map.put(Watcher.Event.EventType.NodeCreated, ":node-created");
+map.put(Watcher.Event.EventType.NodeDeleted, ":node-deleted");
+map.put(Watcher.Event.EventType.NodeDataChanged, 
":node-data-changed");
+map.put(Watcher.Event.EventType.NodeChildrenChanged, 
":node-children-changed");
+
+}
+
+public static String getStateName(Watcher.Event.EventType type) {
--- End diff --

I would rather see this called getTypeName instead of getStateName.  Of 
even just getName.


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117315#comment-15117315
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50843248
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/callback/DefaultWatcherCallBack.java ---
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.callback;
+
+import org.apache.storm.zookeeper.ZkEventTypes;
+import org.apache.storm.zookeeper.ZkKeeperStates;
+import org.apache.zookeeper.Watcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DefaultWatcherCallBack implements WatcherCallBack {
+
+private static Logger LOG = 
LoggerFactory.getLogger(DefaultWatcherCallBack.class);
+
+@Override
+public void execute(Watcher.Event.KeeperState state, 
Watcher.Event.EventType type, String path) {
+LOG.info("Zookeeper state update:" + 
ZkKeeperStates.getStateName(state) + "," + ZkEventTypes.getStateName(type) + 
"," + path);
--- End diff --

Never mind about making it debug.  I missed original implementation.  I 
still would like to use the "{}" substitution though.


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50844220
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
--- End diff --

Could you please file a follow up JIRA to 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117325#comment-15117325
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50844220
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50845596
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117349#comment-15117349
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50845596
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1483] add storm-mongodb connector

2016-01-26 Thread vesense
Github user vesense commented on a diff in the pull request:

https://github.com/apache/storm/pull/1038#discussion_r50846026
  
--- Diff: 
external/storm-mongodb/src/main/java/org/apache/storm/mongodb/bolt/MongoUpdateBolt.java
 ---
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.mongodb.bolt;
+
+import org.apache.commons.lang.Validate;
+import org.apache.storm.mongodb.common.QueryFilterCreator;
+import org.apache.storm.mongodb.common.mapper.MongoMapper;
+import org.apache.storm.topology.OutputFieldsDeclarer;
+import org.apache.storm.tuple.Tuple;
+import org.bson.Document;
+import org.bson.conversions.Bson;
+
+/**
+ * Basic bolt for updating from MongoDB.
+ *
+ * Note: Each MongoUpdateBolt defined in a topology is tied to a specific 
collection.
+ *
+ */
+public class MongoUpdateBolt extends AbstractMongoBolt {
--- End diff --

Since `MongoUpdateBolt` uses `QueryFilterCreator` for creating a Mongo 
query Filter, maybe it's more clear to the user. @arunmahadevan 's advice is 
also make sence. I'd like to listen to other people's opinions.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1483) add storm-mongodb connector

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117351#comment-15117351
 ] 

ASF GitHub Bot commented on STORM-1483:
---

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

https://github.com/apache/storm/pull/1038#discussion_r50846026
  
--- Diff: 
external/storm-mongodb/src/main/java/org/apache/storm/mongodb/bolt/MongoUpdateBolt.java
 ---
@@ -0,0 +1,69 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.mongodb.bolt;
+
+import org.apache.commons.lang.Validate;
+import org.apache.storm.mongodb.common.QueryFilterCreator;
+import org.apache.storm.mongodb.common.mapper.MongoMapper;
+import org.apache.storm.topology.OutputFieldsDeclarer;
+import org.apache.storm.tuple.Tuple;
+import org.bson.Document;
+import org.bson.conversions.Bson;
+
+/**
+ * Basic bolt for updating from MongoDB.
+ *
+ * Note: Each MongoUpdateBolt defined in a topology is tied to a specific 
collection.
+ *
+ */
+public class MongoUpdateBolt extends AbstractMongoBolt {
--- End diff --

Since `MongoUpdateBolt` uses `QueryFilterCreator` for creating a Mongo 
query Filter, maybe it's more clear to the user. @arunmahadevan 's advice is 
also make sence. I'd like to listen to other people's opinions.


> add storm-mongodb connector
> ---
>
> Key: STORM-1483
> URL: https://issues.apache.org/jira/browse/STORM-1483
> Project: Apache Storm
>  Issue Type: Improvement
>Reporter: Xin Wang
>Assignee: Xin Wang
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50843248
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/callback/DefaultWatcherCallBack.java ---
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.callback;
+
+import org.apache.storm.zookeeper.ZkEventTypes;
+import org.apache.storm.zookeeper.ZkKeeperStates;
+import org.apache.zookeeper.Watcher;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DefaultWatcherCallBack implements WatcherCallBack {
+
+private static Logger LOG = 
LoggerFactory.getLogger(DefaultWatcherCallBack.class);
+
+@Override
+public void execute(Watcher.Event.KeeperState state, 
Watcher.Event.EventType type, String path) {
+LOG.info("Zookeeper state update:" + 
ZkKeeperStates.getStateName(state) + "," + ZkEventTypes.getStateName(type) + 
"," + path);
--- End diff --

Never mind about making it debug.  I missed original implementation.  I 
still would like to use the "{}" substitution though.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50847048
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117360#comment-15117360
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50847048
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[jira] [Commented] (STORM-1483) add storm-mongodb connector

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117361#comment-15117361
 ] 

ASF GitHub Bot commented on STORM-1483:
---

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

https://github.com/apache/storm/pull/1038#discussion_r50847058
  
--- Diff: 
external/storm-mongodb/src/main/java/org/apache/storm/mongodb/trident/state/MongoState.java
 ---
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.mongodb.trident.state;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.Validate;
+import org.apache.storm.mongodb.common.MongoDBClient;
+import org.apache.storm.mongodb.common.mapper.MongoMapper;
+import org.apache.storm.trident.operation.TridentCollector;
+import org.apache.storm.trident.state.State;
+import org.apache.storm.trident.tuple.TridentTuple;
+import org.bson.Document;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
+
+public class MongoState implements State {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(MongoState.class);
+
+private Options options;
+private MongoDBClient mongoClient;
+private Map map;
+
+protected MongoState(Map map, int partitionIndex, int numPartitions, 
Options options) {
+this.options = options;
+this.map = map;
+}
+
+public static class Options implements Serializable {
+private String url;
+private String collectionName;
+private MongoMapper mapper;
+
+public Options withUrl(String url) {
+this.url = url;
+return this;
+}
+
+public Options withCollectionName(String collectionName) {
+this.collectionName = collectionName;
+return this;
+}
+
+public Options withMapper(MongoMapper mapper) {
+this.mapper = mapper;
+return this;
+}
+}
+
+protected void prepare() {
+Validate.notEmpty(options.url, "url can not be blank or null");
+Validate.notEmpty(options.collectionName, "collectionName can not 
be blank or null");
+Validate.notNull(options.mapper, "MongoMapper can not be null");
+
+this.mongoClient = new MongoDBClient(options.url, 
options.collectionName);
+}
+
+@Override
+public void beginCommit(Long txid) {
+LOG.debug("beginCommit is noop.");
+}
+
+@Override
+public void commit(Long txid) {
+LOG.debug("commit is noop.");
+}
+
+public void updateState(List tuples, TridentCollector 
collector) {
+List documents = Lists.newArrayList();
+for (TridentTuple tuple : tuples) {
+Document document = options.mapper.toDocument(tuple);
+documents.add(document);
+}
+this.mongoClient.insert(documents);
--- End diff --

The `MongoStateUpdater` is something like `JdbcUpdater`, just for inserting 
data to a database. 
But what you state is also meaningful. I'll think about it


> add storm-mongodb connector
> ---
>
> Key: STORM-1483
> URL: https://issues.apache.org/jira/browse/STORM-1483
> Project: Apache Storm
>  Issue Type: Improvement
>Reporter: Xin Wang
>Assignee: Xin Wang
>




--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50847581
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117364#comment-15117364
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50847581
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50847904
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117367#comment-15117367
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50847904
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1483] add storm-mongodb connector

2016-01-26 Thread vesense
Github user vesense commented on a diff in the pull request:

https://github.com/apache/storm/pull/1038#discussion_r50847058
  
--- Diff: 
external/storm-mongodb/src/main/java/org/apache/storm/mongodb/trident/state/MongoState.java
 ---
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.mongodb.trident.state;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.Validate;
+import org.apache.storm.mongodb.common.MongoDBClient;
+import org.apache.storm.mongodb.common.mapper.MongoMapper;
+import org.apache.storm.trident.operation.TridentCollector;
+import org.apache.storm.trident.state.State;
+import org.apache.storm.trident.tuple.TridentTuple;
+import org.bson.Document;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
+
+public class MongoState implements State {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(MongoState.class);
+
+private Options options;
+private MongoDBClient mongoClient;
+private Map map;
+
+protected MongoState(Map map, int partitionIndex, int numPartitions, 
Options options) {
+this.options = options;
+this.map = map;
+}
+
+public static class Options implements Serializable {
+private String url;
+private String collectionName;
+private MongoMapper mapper;
+
+public Options withUrl(String url) {
+this.url = url;
+return this;
+}
+
+public Options withCollectionName(String collectionName) {
+this.collectionName = collectionName;
+return this;
+}
+
+public Options withMapper(MongoMapper mapper) {
+this.mapper = mapper;
+return this;
+}
+}
+
+protected void prepare() {
+Validate.notEmpty(options.url, "url can not be blank or null");
+Validate.notEmpty(options.collectionName, "collectionName can not 
be blank or null");
+Validate.notNull(options.mapper, "MongoMapper can not be null");
+
+this.mongoClient = new MongoDBClient(options.url, 
options.collectionName);
+}
+
+@Override
+public void beginCommit(Long txid) {
+LOG.debug("beginCommit is noop.");
+}
+
+@Override
+public void commit(Long txid) {
+LOG.debug("commit is noop.");
+}
+
+public void updateState(List tuples, TridentCollector 
collector) {
+List documents = Lists.newArrayList();
+for (TridentTuple tuple : tuples) {
+Document document = options.mapper.toDocument(tuple);
+documents.add(document);
+}
+this.mongoClient.insert(documents);
--- End diff --

The `MongoStateUpdater` is something like `JdbcUpdater`, just for inserting 
data to a database. 
But what you state is also meaningful. I'll think about it


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117368#comment-15117368
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50848116
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50848116
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread redsanket
Github user redsanket commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50848126
  
--- Diff: 
storm-core/src/clj/org/apache/storm/cluster_state/zookeeper_state_factory.clj 
---
@@ -143,15 +144,15 @@
 (stateChanged
   [this client newState]
   (.stateChanged listener client 
newState)))]
- (zk/add-listener zk-reader curator-listener)))
+ (Zookeeper/addListener zk-reader curator-listener)))
 
  (sync-path
[this path]
-   (zk/sync-path zk-writer path))
+   (Zookeeper/syncPath zk-writer path))
 
   (delete-node-blobstore
 [this path nimbus-host-port-info]
-(zk/delete-node-blobstore zk-writer path nimbus-host-port-info))
+(Zookeeper/deleteDodeBlobstore zk-writer path 
nimbus-host-port-info))
--- End diff --

must be deleteNodeBlobstore instead of deleteDodeBlobstore "spelling"


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117369#comment-15117369
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50848126
  
--- Diff: 
storm-core/src/clj/org/apache/storm/cluster_state/zookeeper_state_factory.clj 
---
@@ -143,15 +144,15 @@
 (stateChanged
   [this client newState]
   (.stateChanged listener client 
newState)))]
- (zk/add-listener zk-reader curator-listener)))
+ (Zookeeper/addListener zk-reader curator-listener)))
 
  (sync-path
[this path]
-   (zk/sync-path zk-writer path))
+   (Zookeeper/syncPath zk-writer path))
 
   (delete-node-blobstore
 [this path nimbus-host-port-info]
-(zk/delete-node-blobstore zk-writer path nimbus-host-port-info))
+(Zookeeper/deleteDodeBlobstore zk-writer path 
nimbus-host-port-info))
--- End diff --

must be deleteNodeBlobstore instead of deleteDodeBlobstore "spelling"


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread redsanket
Github user redsanket commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50848343
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117370#comment-15117370
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50848343
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+   

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50848452
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117372#comment-15117372
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50848452
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread redsanket
Github user redsanket commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50848528
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117374#comment-15117374
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50848528
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+   

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50849208
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117384#comment-15117384
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50849322
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50849322
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117382#comment-15117382
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50849208
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50849583
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50849882
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117388#comment-15117388
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50849882
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50850102
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117396#comment-15117396
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50850244
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50850244
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117393#comment-15117393
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50850102
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117385#comment-15117385
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50849583
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50850528
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117399#comment-15117399
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50850528
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50851022
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50842034
  
--- Diff: storm-core/src/jvm/org/apache/storm/utils/Utils.java ---
@@ -1382,5 +1382,43 @@ public static TopologyInfo getTopologyInfo(String 
name, String asUser, Map storm
 public static int toPositive(int number) {
 return number & Integer.MAX_VALUE;
 }
+
+public static RuntimeException wrapInRuntime(Exception e){
+if (e instanceof RuntimeException){
+return (RuntimeException)e;
+}else {
+return new RuntimeException(e);
+}
+}
+
+public static List tokenizePath(String path) {
+String[] toks = path.split(File.separator);
+java.util.ArrayList rtn = new ArrayList();
+for (String str : toks) {
+if (!str.isEmpty()) {
+rtn.add(str);
+}
+}
+return rtn;
+}
+
+public static String toksToPath(List toks) {
+StringBuffer buff = new StringBuffer();
+buff.append(File.separator);
+int size = toks.size();
+for (int i = 0; i < size; i++) {
+buff.append(toks.get(i));
+if (i < (size - 1)) {
+buff.append(File.separator);
+}
+
+}
+return buff.toString();
+}
+
+public static String normalizePath(String path) {
+String rtn = toksToPath(tokenizePath(path));
+return rtn;
+}
--- End diff --

Can we please move tokenizePath, toksToPath, and normalizePath to 
Zookeeper.java?  and change them from using File.separator, to use "/".  The 
issue is that they are specific to zookeeper so need the "/", without it on 
windows it will not work.  They should never have been in util.clj to begin 
with.  I'll update the util.clj JIRA to indicate this too.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117407#comment-15117407
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50851363
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50851676
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
+this.leaderLatchListener = leaderLatchListener;
+}
+
+@Override
+public void prepare(Map conf) {
+LOG.info("no-op for zookeeper implementation");
--- End diff --

Never mind I see in the code it does the same thing.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1379) Removed Redundant Structure

2016-01-26 Thread darion yaphet (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117415#comment-15117415
 ] 

darion yaphet commented on STORM-1379:
--

Hi Rebert 

Actually I have create a pull request at github 
https://github.com/apache/storm/pull/932 but maybe not very successfully .

Thank you for you great work :)

> Removed Redundant Structure
> ---
>
> Key: STORM-1379
> URL: https://issues.apache.org/jira/browse/STORM-1379
> Project: Apache Storm
>  Issue Type: Improvement
>  Components: storm-kafka
>Affects Versions: 0.10.0, 0.9.4, 0.9.5, 0.9.6
> Environment: CentOS 6  JDK1.7.0_75
>Reporter: darion yaphet
>Assignee: darion yaphet
>Priority: Minor
> Fix For: 1.0.0
>
> Attachments: STORM-1379.patch
>
>
> Storm KafkaSpout have a static class MessageAndRealOffset which is same with 
> Kafka API 's  kafka.message.MessageAndOffset . So I have remove 
> MessageAndRealOffset and replace with MessageAndOffset :)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117413#comment-15117413
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50851676
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
+this.leaderLatchListener = leaderLatchListener;
+}
+
+@Override
+public void prepare(Map conf) {
+LOG.info("no-op for zookeeper implementation");
--- End diff --

Never mind I see in the code it does the same thing.


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: Storm 1379 Removed Redundant Structure

2016-01-26 Thread darionyaphet
Github user darionyaphet commented on the pull request:

https://github.com/apache/storm/pull/932#issuecomment-175084269
  
This issue have merged 
[STORM-1379](https://issues.apache.org/jira/browse/STORM-1379)  and close this 
pull request :)


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117416#comment-15117416
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50851802
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
--- End diff --

I think this was supposed to be the leaderlockPath, that was not set.


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: Storm 1379 Removed Redundant Structure

2016-01-26 Thread darionyaphet
Github user darionyaphet closed the pull request at:

https://github.com/apache/storm/pull/932


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50851943
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
--- End diff --

Can we please mark all of these member variables as final?  None of them 
are ever supposed to change and it would have caught the leaderlockPath not 
being set.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117403#comment-15117403
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50851022
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ 

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117418#comment-15117418
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50851943
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
--- End diff --

Can we please mark all of these member variables as final?  None of them 
are ever supposed to change and it would have caught the leaderlockPath not 
being set.


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50852541
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
+this.leaderLatchListener = leaderLatchListener;
+}
+
+@Override
+public void prepare(Map conf) {
+LOG.info("no-op for zookeeper implementation");
+}
+
+@Override
+public void addToLeaderLockQueue() {
+// if this latch is already closed, we need to create new instance.
+try {
+if 
(LeaderLatch.State.CLOSED.equals(leaderLatch.get().getState())) {
+leaderLatch.set(new LeaderLatch(zk, leaderlockPath));
+
leaderLatchListener.set(Zookeeper.leaderLatchListenerImpl(conf, zk, 
leaderLatch.get()));
+}
+// Only if the latch is not already started we invoke start
+if 
(LeaderLatch.State.LATENT.equals(leaderLatch.get().getState())) {
+leaderLatch.get().addListener(leaderLatchListener.get());
+leaderLatch.get().start();
+LOG.info("Queued up for leader lock.");
+} else {
+LOG.info("Node already in queue for leader lock.");
+}
+} catch (Exception e) {
+LOG.warn("failed to add LeaderLatchListener", e);
+}
--- End diff --

The previous code never caught an exception, and especially did not eat it. 
 Please either update the Interface to support Exceptions or wrap it in a 
RuntimeException and rethrow it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117430#comment-15117430
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50852541
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
+this.leaderLatchListener = leaderLatchListener;
+}
+
+@Override
+public void prepare(Map conf) {
+LOG.info("no-op for zookeeper implementation");
+}
+
+@Override
+public void addToLeaderLockQueue() {
+// if this latch is already closed, we need to create new instance.
+try {
+if 
(LeaderLatch.State.CLOSED.equals(leaderLatch.get().getState())) {
+leaderLatch.set(new LeaderLatch(zk, leaderlockPath));
+
leaderLatchListener.set(Zookeeper.leaderLatchListenerImpl(conf, zk, 
leaderLatch.get()));
+}
+// Only if the latch is not already started we invoke start
+if 
(LeaderLatch.State.LATENT.equals(leaderLatch.get().getState())) {
+leaderLatch.get().addListener(leaderLatchListener.get());
+leaderLatch.get().start();
+LOG.info("Queued up for leader lock.");
+} else {
+LOG.info("Node already in queue for leader lock.");
+}
+} catch (Exception e) {
+LOG.warn("failed to add LeaderLatchListener", e);
+}
--- End diff --

The previous code never caught an exception, and especially did not eat it. 
 Please either update the Interface to support Exceptions or wrap it in a 
RuntimeException and rethrow it.


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50851363
  
--- Diff: storm-core/src/jvm/org/apache/storm/zookeeper/Zookeeper.java ---
@@ -0,0 +1,355 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import clojure.lang.PersistentArrayMap;
+import clojure.lang.RT;
+import org.apache.commons.lang.StringUtils;
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.api.CuratorEvent;
+import org.apache.curator.framework.api.CuratorEventType;
+import org.apache.curator.framework.api.CuratorListener;
+import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.storm.Config;
+import org.apache.storm.callback.DefaultWatcherCallBack;
+import org.apache.storm.callback.WatcherCallBack;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.apache.storm.utils.ZookeeperAuthInfo;
+import org.apache.zookeeper.KeeperException;
+import org.apache.zookeeper.WatchedEvent;
+import org.apache.zookeeper.data.ACL;
+import org.apache.zookeeper.data.Stat;
+import org.apache.zookeeper.server.NIOServerCnxnFactory;
+import org.apache.zookeeper.server.ZooKeeperServer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.BindException;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+public class Zookeeper {
+
+private static Logger LOG = LoggerFactory.getLogger(Zookeeper.class);
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack());
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, Map authConf) {
+return mkClient(conf, servers, port, "", new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, Map authConf) {
+return mkClient(conf, servers, port, root, new 
DefaultWatcherCallBack(), authConf);
+}
+
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher, Map authConf) 
{
+CuratorFramework fk;
+if (authConf != null) {
+fk = Utils.newCurator(conf, servers, port, root, new 
ZookeeperAuthInfo(authConf));
+} else {
+fk = Utils.newCurator(conf, servers, port, root);
+}
+
+fk.getCuratorListenable().addListener(new CuratorListener() {
+@Override
+public void eventReceived(CuratorFramework _fk, CuratorEvent 
e) throws Exception {
+if (e.getType().equals(CuratorEventType.WATCHED)) {
+WatchedEvent event = e.getWatchedEvent();
+
+watcher.execute(event.getState(), event.getType(), 
event.getPath());
+}
+
+}
+});
+fk.start();
+return fk;
+}
+
+/**
+ * connect ZK, register Watch/unhandle Watch
+ *
+ * @return
+ */
+public static CuratorFramework mkClient(Map conf, List 
servers, Object port, String root, final WatcherCallBack watcher) {
+
+return mkClient(conf, servers, port, root, watcher, 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50851802
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
--- End diff --

I think this was supposed to be the leaderlockPath, that was not set.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117422#comment-15117422
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50852249
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
+this.leaderLatchListener = leaderLatchListener;
+}
+
+@Override
+public void prepare(Map conf) {
+LOG.info("no-op for zookeeper implementation");
+}
+
+@Override
+public void addToLeaderLockQueue() {
+// if this latch is already closed, we need to create new instance.
+try {
+if 
(LeaderLatch.State.CLOSED.equals(leaderLatch.get().getState())) {
+leaderLatch.set(new LeaderLatch(zk, leaderlockPath));
+
leaderLatchListener.set(Zookeeper.leaderLatchListenerImpl(conf, zk, 
leaderLatch.get()));
--- End diff --

missing
`LOG.info("LeaderLatch was in closed state. Resetted the leaderLatch and 
listeners.");`


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50852249
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
+this.leaderLatchListener = leaderLatchListener;
+}
+
+@Override
+public void prepare(Map conf) {
+LOG.info("no-op for zookeeper implementation");
+}
+
+@Override
+public void addToLeaderLockQueue() {
+// if this latch is already closed, we need to create new instance.
+try {
+if 
(LeaderLatch.State.CLOSED.equals(leaderLatch.get().getState())) {
+leaderLatch.set(new LeaderLatch(zk, leaderlockPath));
+
leaderLatchListener.set(Zookeeper.leaderLatchListenerImpl(conf, zk, 
leaderLatch.get()));
--- End diff --

missing
`LOG.info("LeaderLatch was in closed state. Resetted the leaderLatch and 
listeners.");`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1379) Removed Redundant Structure

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117419#comment-15117419
 ] 

ASF GitHub Bot commented on STORM-1379:
---

Github user darionyaphet commented on the pull request:

https://github.com/apache/storm/pull/932#issuecomment-175084269
  
This issue have merged 
[STORM-1379](https://issues.apache.org/jira/browse/STORM-1379)  and close this 
pull request :)


> Removed Redundant Structure
> ---
>
> Key: STORM-1379
> URL: https://issues.apache.org/jira/browse/STORM-1379
> Project: Apache Storm
>  Issue Type: Improvement
>  Components: storm-kafka
>Affects Versions: 0.10.0, 0.9.4, 0.9.5, 0.9.6
> Environment: CentOS 6  JDK1.7.0_75
>Reporter: darion yaphet
>Assignee: darion yaphet
>Priority: Minor
> Fix For: 1.0.0
>
> Attachments: STORM-1379.patch
>
>
> Storm KafkaSpout have a static class MessageAndRealOffset which is same with 
> Kafka API 's  kafka.message.MessageAndOffset . So I have remove 
> MessageAndRealOffset and replace with MessageAndOffset :)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50854133
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
+this.leaderLatchListener = leaderLatchListener;
+}
+
+@Override
+public void prepare(Map conf) {
+LOG.info("no-op for zookeeper implementation");
+}
+
+@Override
+public void addToLeaderLockQueue() {
+// if this latch is already closed, we need to create new instance.
+try {
+if 
(LeaderLatch.State.CLOSED.equals(leaderLatch.get().getState())) {
+leaderLatch.set(new LeaderLatch(zk, leaderlockPath));
+
leaderLatchListener.set(Zookeeper.leaderLatchListenerImpl(conf, zk, 
leaderLatch.get()));
+}
+// Only if the latch is not already started we invoke start
+if 
(LeaderLatch.State.LATENT.equals(leaderLatch.get().getState())) {
+leaderLatch.get().addListener(leaderLatchListener.get());
+leaderLatch.get().start();
+LOG.info("Queued up for leader lock.");
+} else {
+LOG.info("Node already in queue for leader lock.");
+}
+} catch (Exception e) {
+LOG.warn("failed to add LeaderLatchListener", e);
+}
+
+}
+
+@Override
+// Only started latches can be closed.
+public void removeFromLeaderLockQueue() {
+if 
(LeaderLatch.State.STARTED.equals(leaderLatch.get().getState())) {
+try {
+leaderLatch.get().close();
+LOG.info("Removed from leader lock queue.");
+} catch (IOException e) {
+LOG.warn("failed to  close leaderLatch!!");
+}
+
+} else {
+LOG.info("leader latch is not started so no 
removeFromLeaderLockQueue needed.");
+}
+}
+
+@Override
+public boolean isLeader() throws Exception {
+return leaderLatch.get().hasLeadership();
+}
+
+@Override
+public NimbusInfo getLeader() {
+try {
+return Zookeeper.toNimbusInfo(leaderLatch.get().getLeader());
+} catch (Exception e) {
+  

[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117447#comment-15117447
 ] 

ASF GitHub Bot commented on STORM-1257:
---

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

https://github.com/apache/storm/pull/1047#discussion_r50853930
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
+this.leaderLatchListener = leaderLatchListener;
+}
+
+@Override
+public void prepare(Map conf) {
+LOG.info("no-op for zookeeper implementation");
+}
+
+@Override
+public void addToLeaderLockQueue() {
+// if this latch is already closed, we need to create new instance.
+try {
+if 
(LeaderLatch.State.CLOSED.equals(leaderLatch.get().getState())) {
+leaderLatch.set(new LeaderLatch(zk, leaderlockPath));
+
leaderLatchListener.set(Zookeeper.leaderLatchListenerImpl(conf, zk, 
leaderLatch.get()));
+}
+// Only if the latch is not already started we invoke start
+if 
(LeaderLatch.State.LATENT.equals(leaderLatch.get().getState())) {
+leaderLatch.get().addListener(leaderLatchListener.get());
+leaderLatch.get().start();
+LOG.info("Queued up for leader lock.");
+} else {
+LOG.info("Node already in queue for leader lock.");
+}
+} catch (Exception e) {
+LOG.warn("failed to add LeaderLatchListener", e);
+}
+
+}
+
+@Override
+// Only started latches can be closed.
+public void removeFromLeaderLockQueue() {
+if 
(LeaderLatch.State.STARTED.equals(leaderLatch.get().getState())) {
+try {
+leaderLatch.get().close();
+LOG.info("Removed from leader lock queue.");
+} catch (IOException e) {
+LOG.warn("failed to  close leaderLatch!!");
+}
--- End diff --

Here too, lets not eat the exception.  At least wrap it and rethrow it, but 
preferably update the Interface to allow us to throw it as is.


> port backtype.storm.zookeeper to java
> -
>
> 

[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on the pull request:

https://github.com/apache/storm/pull/1047#issuecomment-175091255
  
I am done with my first pass through the code.  Overall things look good, 
but there are a few corner cases around error recovery and running on Windows 
that need to be fixed before this can go in.  Also please be sure to run all of 
the tests and that they all pass.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (STORM-1257) port backtype.storm.zookeeper to java

2016-01-26 Thread ASF GitHub Bot (JIRA)

[ 
https://issues.apache.org/jira/browse/STORM-1257?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15117452#comment-15117452
 ] 

ASF GitHub Bot commented on STORM-1257:
---

Github user revans2 commented on the pull request:

https://github.com/apache/storm/pull/1047#issuecomment-175091255
  
I am done with my first pass through the code.  Overall things look good, 
but there are a few corner cases around error recovery and running on Windows 
that need to be fixed before this can go in.  Also please be sure to run all of 
the tests and that they all pass.


> port backtype.storm.zookeeper to java
> -
>
> Key: STORM-1257
> URL: https://issues.apache.org/jira/browse/STORM-1257
> Project: Apache Storm
>  Issue Type: New Feature
>  Components: storm-core
>Reporter: Robert Joseph Evans
>Assignee: John Fang
>  Labels: java-migration, jstorm-merger
>
> A wrapper around zookeeper/curator.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)


[GitHub] storm pull request: [STORM-1257] port backtype.storm.zookeeper to ...

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1047#discussion_r50853930
  
--- Diff: 
storm-core/src/jvm/org/apache/storm/zookeeper/LeaderElectorImp.java ---
@@ -0,0 +1,135 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.zookeeper;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.leader.LeaderLatch;
+import org.apache.curator.framework.recipes.leader.LeaderLatchListener;
+import org.apache.curator.framework.recipes.leader.Participant;
+import org.apache.storm.nimbus.ILeaderElector;
+import org.apache.storm.nimbus.NimbusInfo;
+import org.apache.storm.utils.Utils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+
+
+public class LeaderElectorImp implements ILeaderElector {
+private static Logger LOG = 
LoggerFactory.getLogger(LeaderElectorImp.class);
+private Map conf;
+private List servers;
+private CuratorFramework zk;
+private String leaderlockPath;
+private String id;
+private AtomicReference leaderLatch;
+private AtomicReference leaderLatchListener;
+
+public LeaderElectorImp(Map conf, List servers, 
CuratorFramework zk, String leaderlockPath, String id, 
AtomicReference leaderLatch,
+AtomicReference 
leaderLatchListener) {
+this.conf = conf;
+this.servers = servers;
+this.zk = zk;
+this.leaderLatch = leaderLatch;
+this.id = id;
+this.leaderLatch = leaderLatch;
+this.leaderLatchListener = leaderLatchListener;
+}
+
+@Override
+public void prepare(Map conf) {
+LOG.info("no-op for zookeeper implementation");
+}
+
+@Override
+public void addToLeaderLockQueue() {
+// if this latch is already closed, we need to create new instance.
+try {
+if 
(LeaderLatch.State.CLOSED.equals(leaderLatch.get().getState())) {
+leaderLatch.set(new LeaderLatch(zk, leaderlockPath));
+
leaderLatchListener.set(Zookeeper.leaderLatchListenerImpl(conf, zk, 
leaderLatch.get()));
+}
+// Only if the latch is not already started we invoke start
+if 
(LeaderLatch.State.LATENT.equals(leaderLatch.get().getState())) {
+leaderLatch.get().addListener(leaderLatchListener.get());
+leaderLatch.get().start();
+LOG.info("Queued up for leader lock.");
+} else {
+LOG.info("Node already in queue for leader lock.");
+}
+} catch (Exception e) {
+LOG.warn("failed to add LeaderLatchListener", e);
+}
+
+}
+
+@Override
+// Only started latches can be closed.
+public void removeFromLeaderLockQueue() {
+if 
(LeaderLatch.State.STARTED.equals(leaderLatch.get().getState())) {
+try {
+leaderLatch.get().close();
+LOG.info("Removed from leader lock queue.");
+} catch (IOException e) {
+LOG.warn("failed to  close leaderLatch!!");
+}
--- End diff --

Here too, lets not eat the exception.  At least wrap it and rethrow it, but 
preferably update the Interface to allow us to throw it as is.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


Re: [DISCUSSION] Repo cleanup

2016-01-26 Thread Kyle Nusbaum
Great. 

I quit deleting branches from the ASF repo before I got too far because I 
noticed github wasn't mirroring the deletes. 

Taylor, do you have access to any special tool to do stuff like this, or should 
I file a ticket with infra?

I deleted the following branches from the ASF repo before stopping:
STORM-633
STORM-648
STORM-651
STORM-1153-V1


-- Kyle 

On Sunday, January 24, 2016 5:52 PM, Jungtaek Lim  wrote:
 

 +1 for cleanup.

- Jungtaek Lim (HeartSaVioR)

2016년 1월 23일 (토) 오전 7:49, Kyle Nusbaum 님이
작성:

> Please check out this jira and let me know what you all think. I won't
> take any action until I get some responses here.
>
> Even if I get positive reaction here, I'm going to leave it up to the
> owners of the unmerged branches to take care of them. I will only delete
> merged branches.
> https://issues.apache.org/jira/browse/STORM-1497
>  -- Kyle

  

[GitHub] storm pull request: [STORM-1483] add storm-mongodb connector

2016-01-26 Thread revans2
Github user revans2 commented on a diff in the pull request:

https://github.com/apache/storm/pull/1038#discussion_r50866045
  
--- Diff: 
external/storm-mongodb/src/main/java/org/apache/storm/mongodb/trident/state/MongoState.java
 ---
@@ -0,0 +1,97 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.storm.mongodb.trident.state;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.Validate;
+import org.apache.storm.mongodb.common.MongoDBClient;
+import org.apache.storm.mongodb.common.mapper.MongoMapper;
+import org.apache.storm.trident.operation.TridentCollector;
+import org.apache.storm.trident.state.State;
+import org.apache.storm.trident.tuple.TridentTuple;
+import org.bson.Document;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.Lists;
+
+public class MongoState implements State {
+
+private static final Logger LOG = 
LoggerFactory.getLogger(MongoState.class);
+
+private Options options;
+private MongoDBClient mongoClient;
+private Map map;
+
+protected MongoState(Map map, int partitionIndex, int numPartitions, 
Options options) {
+this.options = options;
+this.map = map;
+}
+
+public static class Options implements Serializable {
+private String url;
+private String collectionName;
+private MongoMapper mapper;
+
+public Options withUrl(String url) {
+this.url = url;
+return this;
+}
+
+public Options withCollectionName(String collectionName) {
+this.collectionName = collectionName;
+return this;
+}
+
+public Options withMapper(MongoMapper mapper) {
+this.mapper = mapper;
+return this;
+}
+}
+
+protected void prepare() {
+Validate.notEmpty(options.url, "url can not be blank or null");
+Validate.notEmpty(options.collectionName, "collectionName can not 
be blank or null");
+Validate.notNull(options.mapper, "MongoMapper can not be null");
+
+this.mongoClient = new MongoDBClient(options.url, 
options.collectionName);
+}
+
+@Override
+public void beginCommit(Long txid) {
+LOG.debug("beginCommit is noop.");
+}
+
+@Override
+public void commit(Long txid) {
+LOG.debug("commit is noop.");
+}
+
+public void updateState(List tuples, TridentCollector 
collector) {
+List documents = Lists.newArrayList();
+for (TridentTuple tuple : tuples) {
+Document document = options.mapper.toDocument(tuple);
+documents.add(document);
+}
+this.mongoClient.insert(documents);
--- End diff --

The issue here is with failures.  I am not an mongodb expert so I don't 
know what happens if you insert in a document that is already there. If you 
have a distributed state there will be multiple instances of this class spear 
throughout your topology.  If a single tuple fails as part of the updateState 
trident will replay the entire batch.  In that case we can try to insert 
documents that were already inserted.  I am not worried about consistency, 
because there is no query possible from trident.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


  1   2   >