/** * Instantiate a ZooKeeper connection and watcher. * @param descriptor Descriptive string that is added to zookeeper sessionid * and used as identifier for this instance. * @throws java.io.IOException * @throws com.alibaba.wasp.ZooKeeperConnectionException */ public ZooKeeperWatcher(Configuration conf, String descriptor, Abortable abortable, boolean canCreateBaseZNode) throws IOException, ZooKeeperConnectionException { this.conf = conf; // Capture a stack trace now. Will print it out later if problem so we can // distingush amongst the myriad ZKWs. try { throw new Exception("ZKW CONSTRUCTOR STACK TRACE FOR DEBUGGING"); } catch (Exception e) { this.constructorCaller = e; } this.quorum = ZKConfig.getZKQuorumServersString(conf); // Identifier will get the session id appended later below down when we // handle the sync connect event. this.identifier = descriptor; this.abortable = abortable; setNodeNames(conf); this.recoverableZooKeeper = ZKUtil.connect(conf, quorum, this, descriptor); if (canCreateBaseZNode) { createBaseZNodes(); } }