List of usage examples for org.apache.zookeeper KeeperException getMessage
@Override
public String getMessage()
From source file:pt.uminho.di.tests.zookeeper.ManagedZooKeeperClient.java
License:Apache License
public boolean createEntry(String command, String parameters, int iter) { boolean success = false; // create log entry String uuid = IDGenerator.getUUID(); String path = "/log/entries/" + uuid + ".dat"; String dataStr = command + ";" + parameters; byte[] data = dataStr.getBytes(); try {//from w ww. j a va2 s.c o m if (start[iter] == null) start[iter] = System.nanoTime(); String returnPath = zooKeeper.create(path, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); finish[iter] = System.nanoTime(); success = path.equalsIgnoreCase(returnPath); results[iter] = Boolean.toString(success); } catch (KeeperException ex) { logger.error(ex.getMessage(), ex); success = false; } catch (InterruptedException ex) { logger.error(ex.getMessage(), ex); success = false; } return success; }
From source file:pt.uminho.di.tests.zookeeper.ZooKeeperClient.java
License:Apache License
public void initializedLogDirectories() { // create directory if it doesn't exist String[] pathParts = { "log", "entries" }; StringBuilder pathSB = new StringBuilder(); for (String pathElement : pathParts) { pathSB.append('/').append(pathElement); String pathString = pathSB.toString(); //send requests to create all parts of the path without waiting for the //results of previous calls to return try {//ww w .j a v a2s .co m Stat response = zooKeeper.exists(pathString, false); logger.info(pathString + " exists? Response: " + response); if (response == null) { String reply = zooKeeper.create(pathString, null, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); logger.info("Create " + pathString + " : " + reply); } } catch (KeeperException ex) { logger.error(ex.getMessage(), ex); } catch (InterruptedException ex) { logger.error(ex.getMessage(), ex); } } }
From source file:pt.uminho.di.tests.zookeeper.ZooKeeperClient.java
License:Apache License
public void createEntry(int iter) { // create log entry String uuid = IDGenerator.getUUID(); String path = "/log/entries/" + uuid + ".dat"; String dataStr = "bla: yep"; byte[] data = dataStr.getBytes(); try {/*from w w w . j av a 2 s . c om*/ long start = System.nanoTime(); String returnPath = zooKeeper.create(path, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); long finish = System.nanoTime(); lats[iter] = finish - start; boolean success = path.equalsIgnoreCase(returnPath); results[iter] = Boolean.toString(success); logger.debug("Path: " + path + "; ReturnPath: " + returnPath + "; success: " + success); } catch (KeeperException ex) { logger.error(ex.getMessage(), ex); } catch (InterruptedException ex) { logger.error(ex.getMessage(), ex); } }
From source file:tajo.engine.cluster.WorkerCommunicator.java
License:Apache License
@Override public void nodeChildrenChanged(String path) { if (path.equals(NConstants.ZNODE_LEAFSERVERS)) { try {/* w w w . j av a2 s . co m*/ ZkUtil.listChildrenAndWatchThem(zkClient, NConstants.ZNODE_LEAFSERVERS); update(tracker.getMembers()); } catch (KeeperException e) { LOG.error(e.getMessage(), e); } } }