private boolean setState ( NodeState to ) { try { NodeInfo myInfo = new NodeInfo ( to . toString ( ) , zk . get ( ) . getSessionId ( ) ) ; byte [ ] encoded = JsonUtil . asJSONBytes ( myInfo ) ; ZKUtils . set ( zk , "/" + name + "/nodes/" + myNodeID , encoded ) ; state . set ( to ) ; return true ; } catch ( Exception e ) { // InterruptedException, IOException LOG . warn ( "Problem trying to setState(" + to + "): " + e . getMessage ( ) , e ) ; return false ; } }
Sets the state of the current Ordasity node and notifies others via ZooKeeper .