Skip to content

Commit

Permalink
fix setting data for ephemeral nodes if there's a timeout after check…
Browse files Browse the repository at this point in the history
…ing for existence. switch task heartbeats to non-ephemeral zk nodes
  • Loading branch information
Nathan Marz committed Feb 22, 2012
1 parent 1f736b2 commit bf84f22
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/clj/backtype/storm/cluster.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(ns backtype.storm.cluster
(:import [org.apache.zookeeper.data Stat])
(:import [org.apache.zookeeper KeeperException])
(:import [org.apache.zookeeper KeeperException KeeperException$NoNodeException])
(:import [backtype.storm.utils Utils])
(:use [backtype.storm util log config])
(:use [clojure.contrib.core :only [dissoc-in]])
Expand Down Expand Up @@ -50,7 +50,12 @@
(set-ephemeral-node [this path data]
(zk/mkdirs zk (parent-path path))
(if (zk/exists zk path false)
(zk/set-data zk path data) ; should verify that it's ephemeral
(try-cause
(zk/set-data zk path data) ; should verify that it's ephemeral
(catch KeeperException$NoNodeException e
(log-warn-error e "Ephemeral node disappeared between checking for existing and setting data")
(zk/create-node zk path data :ephemeral)
))
(zk/create-node zk path data :ephemeral)
))

Expand Down Expand Up @@ -269,7 +274,7 @@
)

(task-heartbeat! [this storm-id task-id info]
(set-ephemeral-node cluster-state (taskbeat-path storm-id task-id) (Utils/serialize info))
(set-data cluster-state (taskbeat-path storm-id task-id) (Utils/serialize info))
)

(remove-task-heartbeat! [this storm-id task-id]
Expand Down

0 comments on commit bf84f22

Please sign in to comment.