本文整理了Java中org.I0Itec.zkclient.exception.ZkException
类的一些代码示例,展示了ZkException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkException
类的具体详情如下:
包路径:org.I0Itec.zkclient.exception.ZkException
类名称:ZkException
暂无
代码示例来源:origin: alibaba/canal
@Override
public void connect(Watcher watcher) {
ReflectionUtils.makeAccessible(zookeeperLockField);
ReflectionUtils.makeAccessible(zookeeperFiled);
Lock _zookeeperLock = (ReentrantLock) ReflectionUtils.getField(zookeeperLockField, this);
ZooKeeper _zk = (ZooKeeper) ReflectionUtils.getField(zookeeperFiled, this);
_zookeeperLock.lock();
try {
if (_zk != null) {
throw new IllegalStateException("zk client has already been started");
}
String zkServers = _serversList.get(0);
try {
logger.debug("Creating new ZookKeeper instance to connect to " + zkServers + ".");
_zk = new ZooKeeper(zkServers, _sessionTimeOut, watcher);
configMutliCluster(_zk);
ReflectionUtils.setField(zookeeperFiled, this, _zk);
} catch (IOException e) {
throw new ZkException("Unable to connect to " + zkServers, e);
}
} finally {
_zookeeperLock.unlock();
}
}
代码示例来源:origin: weibocom/motan
@Override
protected Registry createRegistry(URL registryUrl) {
try {
int timeout = registryUrl.getIntParameter(URLParamType.connectTimeout.getName(), URLParamType.connectTimeout.getIntValue());
int sessionTimeout = registryUrl.getIntParameter(URLParamType.registrySessionTimeout.getName(), URLParamType.registrySessionTimeout.getIntValue());
ZkClient zkClient = createInnerZkClient(registryUrl.getParameter("address"), sessionTimeout, timeout);
return new ZookeeperRegistry(registryUrl, zkClient);
} catch (ZkException e) {
LoggerUtil.error("[ZookeeperRegistry] fail to connect zookeeper, cause: " + e.getMessage());
throw e;
}
}
代码示例来源:origin: com.101tec/zkclient
public InMemoryConnection() {
try {
create("/", null, CreateMode.PERSISTENT);
} catch (KeeperException e) {
throw ZkException.create(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: com.alibaba.otter/shared.arbitrate
private void ensureExists(final String path) {
try {
if (zookeeper.exists(path)) {
return;
}
zookeeper.create(path, data, CreateMode.PERSISTENT);
} catch (ZkInterruptedException e) {
Thread.currentThread().interrupt();
interrupt = (InterruptedException) e.getCause();
} catch (ZkException e) {
exception = (KeeperException) e.getCause();
}
}
代码示例来源:origin: com.github.sgroschupf/zkclient
public InMemoryConnection() {
try {
create("/", null, CreateMode.PERSISTENT);
} catch (KeeperException e) {
throw ZkException.create(e);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: alibaba/canal
throw new ZkException("zookeeper_create_error, serveraddrs=" + cluster1, e);
代码示例来源:origin: com.alibaba.otter/shared.common
waitUntilConnected();
} catch (KeeperException e) {
throw ZkException.create(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
代码示例来源:origin: apache/helix
/**
* Sync remove. it tries to remove the ZNode and all its descendants if any, node does not exist
* is regarded as success
*/
@Override
public boolean remove(String path, int options) {
try {
// operation will not throw exception when path successfully deleted or does not exist
// despite real error, operation will throw exception when path not empty, and in this
// case, we try to delete recursively
_zkClient.delete(path);
} catch (ZkException e) {
LOG.debug("Failed to delete {} with opts {}, err: {}. Try recursive delete", path, options,
e.getMessage());
try {
_zkClient.deleteRecursively(path);
} catch (HelixException he) {
LOG.error("Failed to delete {} recursively with opts {}.", path, options, he);
return false;
}
}
return true;
}
代码示例来源:origin: apache/helix
protected void reconnect(Watcher watcher) throws InterruptedException {
_zookeeperLock.lock();
try {
if (_zk == null) {
throw new IllegalStateException("zk client has not been connected or already been closed");
}
ZooKeeper prevZk = _zk;
try {
LOG.debug("Creating new ZookKeeper instance to reconnect to " + _servers + ".");
_zk = new ZooKeeper(_servers, _sessionTimeOut, watcher);
prevZk.close();
} catch (IOException e) {
throw new ZkException("Unable to connect to " + _servers, e);
}
} finally {
_zookeeperLock.unlock();
}
}
代码示例来源:origin: com.github.sgroschupf/zkclient
waitUntilConnected();
} catch (KeeperException e) {
throw ZkException.create(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
代码示例来源:origin: com.alibaba.otter/shared.arbitrate
/**
* <pre>
* 算法:
* 1. 创建对应的transformed节点,标志transform已完成
* </pre>
*
* @param pipelineId 同步流id
*/
public void single(EtlEventData data) {
Assert.notNull(data);
String path = StagePathUtils.getTransformStage(data.getPipelineId(), data.getProcessId());
data.setCurrNid(ArbitrateConfigUtils.getCurrentNid());
// 序列化
byte[] bytes = JsonUtils.marshalToByte(data, SerializerFeature.WriteClassName);
try {
zookeeper.create(path, bytes, CreateMode.PERSISTENT);
} catch (ZkNoNodeException e) {
// process节点不存在,出现了rollback/shutdown操作,直接忽略
logger.warn("pipelineId[{}] transform ignore processId[{}] single by data:{}",
new Object[] { data.getPipelineId(), data.getProcessId(), data });
} catch (ZkNodeExistsException e) {
// process节点已存在,出现了ConnectionLoss retry操作
logger.warn("pipelineId[{}] transform ignore processId[{}] single by data:{}",
new Object[] { data.getPipelineId(), data.getProcessId(), data });
} catch (ZkException e) {
throw new ArbitrateException("transform_single", e.getMessage(), e);
}
}
代码示例来源:origin: com.101tec/zkclient
@Override
public void connect(Watcher watcher) {
_zookeeperLock.lock();
try {
if (_zk != null) {
throw new IllegalStateException("zk client has already been started");
}
try {
LOG.debug("Creating new ZookKeeper instance to connect to " + _servers + ".");
_zk = new ZooKeeper(_servers, _sessionTimeOut, watcher);
} catch (IOException e) {
throw new ZkException("Unable to connect to " + _servers, e);
}
} finally {
_zookeeperLock.unlock();
}
}
代码示例来源:origin: com.101tec/zkclient
waitForRetry();
} catch (KeeperException e) {
throw ZkException.create(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
代码示例来源:origin: com.alibaba.otter/shared.arbitrate
/**
* <pre>
* 算法:
* 1. 创建对应的selected节点,标志selected已完成
* </pre>
*
* @param pipelineId 同步流id
*/
public void single(EtlEventData data) {
Assert.notNull(data);
String path = StagePathUtils.getSelectStage(data.getPipelineId(), data.getProcessId());
data.setCurrNid(ArbitrateConfigUtils.getCurrentNid());
// 序列化
byte[] bytes = JsonUtils.marshalToByte(data, SerializerFeature.WriteClassName);
try {
zookeeper.create(path, bytes, CreateMode.PERSISTENT);
} catch (ZkNoNodeException e) {
// process节点不存在,出现了rollback/shutdown操作,直接忽略
logger.warn("pipelineId[{}] select ignore processId[{}] single by data:{}",
new Object[] { data.getPipelineId(), data.getProcessId(), data });
} catch (ZkNodeExistsException e) {
// process节点已存在,出现了ConnectionLoss retry操作
logger.warn("pipelineId[{}] select ignore processId[{}] single by data:{}",
new Object[] { data.getPipelineId(), data.getProcessId(), data });
} catch (ZkException e) {
throw new ArbitrateException("Select_single", e.getMessage(), e);
}
}
代码示例来源:origin: com.github.sgroschupf/zkclient
@Override
public void connect(Watcher watcher) {
_zookeeperLock.lock();
try {
if (_zk != null) {
throw new IllegalStateException("zk client has already been started");
}
try {
LOG.debug("Creating new ZookKeeper instance to connect to " + _servers + ".");
_zk = new ZooKeeper(_servers, _sessionTimeOut, watcher);
} catch (IOException e) {
throw new ZkException("Unable to connect to " + _servers, e);
}
} finally {
_zookeeperLock.unlock();
}
}
代码示例来源:origin: org.apache.helix/helix-core
waitForRetry();
} catch (KeeperException e) {
throw ZkException.create(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
代码示例来源:origin: com.alibaba.otter/shared.arbitrate
/**
* <pre>
* 算法:
* 1. 创建对应的extracted节点,标志extract已完成
* </pre>
*
* @param pipelineId 同步流id
*/
public void single(EtlEventData data) {
Assert.notNull(data);
String path = StagePathUtils.getExtractStage(data.getPipelineId(), data.getProcessId());
data.setCurrNid(ArbitrateConfigUtils.getCurrentNid());
// 序列化
byte[] bytes = JsonUtils.marshalToByte(data, SerializerFeature.WriteClassName);
try {
zookeeper.create(path, bytes, CreateMode.PERSISTENT);
} catch (ZkNoNodeException e) {
// process节点不存在,出现了rollback/shutdown操作,直接忽略
logger.warn("pipelineId[{}] extract ignore processId[{}] single by data:{}",
new Object[] { data.getPipelineId(), data.getProcessId(), data });
} catch (ZkNodeExistsException e) {
// process节点已存在,出现了ConnectionLoss retry操作
logger.warn("pipelineId[{}] extract ignore processId[{}] single by data:{}",
new Object[] { data.getPipelineId(), data.getProcessId(), data });
} catch (ZkInterruptedException e) {
// ignore
} catch (ZkException e) {
throw new ArbitrateException("Extract_single", e.getMessage(), e);
}
}
代码示例来源:origin: apache/helix
@Override
public void connect(Watcher watcher) {
_zookeeperLock.lock();
try {
if (_zk != null) {
throw new IllegalStateException("zk client has already been started");
}
try {
LOG.debug("Creating new ZookKeeper instance to connect to " + _servers + ".");
_zk = new ZooKeeper(_servers, _sessionTimeOut, watcher);
} catch (IOException e) {
throw new ZkException("Unable to connect to " + _servers, e);
}
} finally {
_zookeeperLock.unlock();
}
}
代码示例来源:origin: com.101tec/zkclient
public long getCreationTime(String path) {
acquireEventLock();
try {
return _connection.getCreateTime(path);
} catch (KeeperException e) {
throw ZkException.create(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
} finally {
getEventLock().unlock();
}
}
代码示例来源:origin: com.weibo/motan-registry-zookeeper
@Override
protected Registry createRegistry(URL registryUrl) {
try {
int timeout = registryUrl.getIntParameter(URLParamType.connectTimeout.getName(), URLParamType.connectTimeout.getIntValue());
int sessionTimeout = registryUrl.getIntParameter(URLParamType.registrySessionTimeout.getName(), URLParamType.registrySessionTimeout.getIntValue());
ZkClient zkClient = createInnerZkClient(registryUrl.getParameter("address"), sessionTimeout, timeout);
return new ZookeeperRegistry(registryUrl, zkClient);
} catch (ZkException e) {
LoggerUtil.error("[ZookeeperRegistry] fail to connect zookeeper, cause: " + e.getMessage());
throw e;
}
}
内容来源于网络,如有侵权,请联系作者删除!