List of usage examples for org.apache.zookeeper KeeperException code
Code code
To view the source code for org.apache.zookeeper KeeperException code.
Click Source Link
From source file:com.edmunds.etm.common.impl.UrlTokenRepository.java
License:Apache License
/** * Deletes the specified token.//www. ja v a 2 s . c om * * @param name name of the token to delete * @throws TokenNotFoundException if the token was not found */ public void deleteToken(String name) throws TokenNotFoundException { String path = controllerPaths.getUrlToken(name); try { connection.delete(path, -1); } catch (KeeperException e) { if (e.code() == Code.NONODE) { throw new TokenNotFoundException(e); } else { logger.error(String.format("Error deleting URL token: %s", name), e); throw new RuntimeException(e); } } catch (InterruptedException e) { throw new RuntimeException(e); } }
From source file:com.edmunds.etm.management.impl.VipManager.java
License:Apache License
private void createPersistentNode(String path, final byte[] data) { AsyncCallback.StringCallback cb = new AsyncCallback.StringCallback() { @Override//from w ww . j a va2s .c om public void processResult(int rc, String p, Object ctx, String name) { onPersistentNodeCreated(KeeperException.Code.get(rc), p, data); } }; connection.createPersistent(path, data, cb, null); }
From source file:com.edmunds.etm.management.impl.VipManager.java
License:Apache License
private void onPersistentNodeCreated(KeeperException.Code rc, String path, byte[] data) { if (rc == KeeperException.Code.OK) { logger.debug(String.format("Created load balancer node: %s", path)); } else if (rc == KeeperException.Code.NODEEXISTS) { logger.warn(String.format("Attempted to create existing node %s, updating instead", path)); setNodeData(path, data);/*from w w w .j av a 2 s.co m*/ } else if (isRetryableError(rc)) { logger.warn(String.format("Error %s while creating node %s, retrying", rc, path)); createPersistentNode(path, data); } else { // Unrecoverable error String message = String.format("Error %s while creating node: %s", rc, path); logger.error(message); // TODO: Flag error in central error reporter } }
From source file:com.edmunds.etm.management.impl.VipManager.java
License:Apache License
private void deleteNode(String path) { AsyncCallback.VoidCallback cb = new AsyncCallback.VoidCallback() { @Override/*from ww w. jav a 2s. c om*/ public void processResult(int rc, String path, Object ctx) { onNodeDeleted(KeeperException.Code.get(rc), path); } }; connection.delete(path, -1, cb, null); }
From source file:com.edmunds.etm.management.impl.VipManager.java
License:Apache License
private void onNodeDeleted(KeeperException.Code rc, String path) { if (rc == KeeperException.Code.OK) { logger.debug(String.format("Deleted node: %s", path)); } else if (rc == KeeperException.Code.NONODE) { logger.warn(String.format("Node already deleted: %s", path)); } else if (isRetryableError(rc)) { logger.warn(String.format("Error %s while deleting node %s, retrying", rc, path)); deleteNode(path);/*from w ww . ja va2s .co m*/ } else { // Unrecoverable error String message = String.format("Error %s while deleting node: %s", rc, path); logger.error(message); // TODO: Flag error in central error reporter } }
From source file:com.edmunds.etm.management.impl.VipManager.java
License:Apache License
private void setNodeData(final String path, final byte[] data) { AsyncCallback.StatCallback cb = new AsyncCallback.StatCallback() { @Override// w w w. ja va2 s . c om public void processResult(int rc, String p, Object ctx, Stat stat) { onNodeDataSet(KeeperException.Code.get(rc), p, data); } }; connection.setData(path, data, -1, cb, null); }
From source file:com.edmunds.etm.management.impl.VipManager.java
License:Apache License
private void onNodeDataSet(KeeperException.Code rc, String path, byte[] data) { if (rc == KeeperException.Code.OK) { logger.debug(String.format("Data set for node: %s", path)); } else if (rc == KeeperException.Code.NONODE) { logger.warn(String.format("Attempted to update nonexistent node %s, creating instead", path)); } else if (isRetryableError(rc)) { logger.warn(String.format("Error %s while setting data for node %s, retrying", rc, path)); setNodeData(path, data);//from w w w . j a v a 2 s.c o m } else { // Unrecoverable error String message = String.format("Error %s while setting data for node: %s", rc, path); logger.error(message); // TODO: Flag error in central error reporter } }
From source file:com.edmunds.etm.rules.impl.AgentConfigurationManager.java
License:Apache License
private void deployConfiguration(String nodePath, final byte[] configData) { final AsyncCallback.StatCallback cb = new AsyncCallback.StatCallback() { @Override// ww w .j a va 2 s .c om public void processResult(int rc, String path, Object ctx, Stat stat) { onConfigurationSetData(KeeperException.Code.get(rc), path, configData); } }; connection.setData(nodePath, configData, -1, cb, null); if (logger.isDebugEnabled()) { logRuleSet(configData); } }
From source file:com.edmunds.etm.rules.impl.AgentConfigurationManager.java
License:Apache License
protected void onConfigurationSetData(KeeperException.Code rc, String path, byte[] data) { if (rc == KeeperException.Code.OK) { return;/*from w w w . j a va2 s . com*/ } if (ZooKeeperUtils.isRetryableError(rc)) { // Retry recoverable errors logger.warn(String.format("Error %s while setting node %s, retrying", rc, path)); deployConfiguration(path, data); } else { // Log other errors logger.error(String.format("Error %s while setting node %s", rc, path)); } }
From source file:com.edmunds.zookeeper.util.ZooKeeperUtils.java
License:Apache License
public static boolean isRetryableError(KeeperException.Code code) { return retryableErrors.contains(code); }