hi , i want to manage my some programme .
if some node or process running is dead
i want to know the status about it .
and auto failover .
here is my fold in zookeeper
/mylive
          /node1
          /node2

i read a lot of docs about java programme,
but i dont understand how it works.
--------------------------------------------------------------------
some model for my programme

LiveNode  running my programme.
               if node1 is dead or error ,it auto deletes /mylive/node1

RecoverMan  watches live nodes
                     if node1 is dead  ,it auto failover to /mylive/node2

how to code this?
------------------------------------------------------------------------
public class LiveNode implements Watcher {
        public init(){
         //  zk  init
         zk = new ZooKeeper("192.168.1.101:2181", 3000, this);
         zk.create("/mylive/node1", new byte[0], Ids.OPEN_ACL_UNSAFE,
                    CreateMode.PERSISTENT);
        }

        public void process(WatchedEvent event) {
           //TODO do what?
           //to delete path .but it happen before node1 died
        }

        public void running(){

         System.out.println("i am running...");
         Thread.sleep(10000l);
         System.out.println("i am dead...");
        }

        public static void main(String[] args) {
           LiveNode live=new LiveNode();
           live.init();
           live.running();
        }
}

Reply via email to