本文整理了Java中com.github.ltsopensource.zookeeper.lts.ZkException
类的一些代码示例,展示了ZkException
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkException
类的具体详情如下:
包路径:com.github.ltsopensource.zookeeper.lts.ZkException
类名称:ZkException
暂无
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public <T> T getData(String path) {
// 暂时不watch data change 所以第二个参数为false
try {
byte[] data = zk.getData(path, false, null);
return (T) serializer.deserialize(data);
} catch (KeeperException e) {
throw new ZkException(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public boolean isZkNoNodeException() {
Throwable cause = getCause();
if (cause != null && cause instanceof KeeperException) {
return KeeperException.Code.NONODE != ((KeeperException) cause).code();
}
return false;
}
代码示例来源:origin: ltsopensource/light-task-scheduler
private void fireChangeEvent(String path, Set<ChildListener> listeners) {
if (listeners != null && !listeners.isEmpty()) {
for (ChildListener listener : listeners) {
try {
exists(path);
List<String> children = getChildren(path);
listener.childChanged(path, children);
} catch (ZkException e) {
if (e.isZkNoNodeException()) {
listener.childChanged(path, null);
} else {
throw e;
}
}
}
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public <T> T getData(String path) {
// 暂时不watch data change 所以第二个参数为false
try {
byte[] data = zk.getData(path, false, null);
return (T) serializer.deserialize(data);
} catch (KeeperException e) {
throw new ZkException(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public boolean isZkNoNodeException() {
Throwable cause = getCause();
if (cause != null && cause instanceof KeeperException) {
return KeeperException.Code.NONODE != ((KeeperException) cause).code();
}
return false;
}
代码示例来源:origin: ltsopensource/light-task-scheduler
private void fireChangeEvent(String path, Set<ChildListener> listeners) {
if (listeners != null && !listeners.isEmpty()) {
for (ChildListener listener : listeners) {
try {
exists(path);
List<String> children = getChildren(path);
listener.childChanged(path, children);
} catch (ZkException e) {
if (e.isZkNoNodeException()) {
listener.childChanged(path, null);
} else {
throw e;
}
}
}
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public void stopListener() {
try {
if (start.compareAndSet(true, false)) {
nodeCache.getListenable().removeListener(nodeCacheListener);
nodeCache.close();
}
} catch (IOException e) {
throw new ZkException(e);
}
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public boolean isZkNodeExistsException() {
Throwable cause = getCause();
if (cause != null && cause instanceof KeeperException) {
return KeeperException.Code.NODEEXISTS != ((KeeperException) cause).code();
}
return false;
}
}
代码示例来源:origin: com.github.ltsopensource/lts-core
private void fireChangeEvent(String path, Set<ChildListener> listeners) {
if (listeners != null && !listeners.isEmpty()) {
for (ChildListener listener : listeners) {
try {
exists(path);
List<String> children = getChildren(path);
listener.childChanged(path, children);
} catch (ZkException e) {
if (e.isZkNoNodeException()) {
listener.childChanged(path, null);
} else {
throw e;
}
}
}
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public void startListener() {
try {
if (start.compareAndSet(false, true)) {
childrenCache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
childrenCache.getListenable().addListener(childrenCacheListener);
}
} catch (Exception e) {
throw new ZkException(e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public boolean isZkNodeExistsException() {
Throwable cause = getCause();
if (cause != null && cause instanceof KeeperException) {
return KeeperException.Code.NODEEXISTS != ((KeeperException) cause).code();
}
return false;
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
protected List<String> addTargetChildListener(String path, ChildListener childListener) {
checkConnect();
synchronized (childListeners) {
Set<ChildListener> listeners = childListeners.get(path);
if (listeners == null) {
listeners = new CopyOnWriteArraySet<ChildListener>();
childListeners.put(path, listeners);
}
listeners.add(childListener);
}
try {
zk.exists(path, true);
try {
return zk.getChildren(path, true);
} catch (KeeperException e) {
if (!isZkNoNodeException(e)) {
throw e;
}
}
} catch (KeeperException e) {
throw new ZkException(e);
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
return null;
}
代码示例来源:origin: com.github.ltsopensource/lts-core
public boolean isZkNoNodeException() {
Throwable cause = getCause();
if (cause != null && cause instanceof KeeperException) {
return KeeperException.Code.NONODE != ((KeeperException) cause).code();
}
return false;
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public void startListener() {
try {
if (start.compareAndSet(false, true)) {
childrenCache.start(PathChildrenCache.StartMode.POST_INITIALIZED_EVENT);
childrenCache.getListenable().addListener(childrenCacheListener);
}
} catch (Exception e) {
throw new ZkException(e);
}
}
代码示例来源:origin: com.github.ltsopensource/lts-core
public boolean isZkNodeExistsException() {
Throwable cause = getCause();
if (cause != null && cause instanceof KeeperException) {
return KeeperException.Code.NODEEXISTS != ((KeeperException) cause).code();
}
return false;
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public boolean exists(String path) {
boolean watch = CollectionUtils.isNotEmpty(childListeners.get(path));
try {
return zk.exists(path, watch) != null;
} catch (KeeperException e) {
if (isZkNoNodeException(e)) {
return false;
} else {
throw new ZkException(e);
}
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public List<String> getChildren(String path) {
boolean watch = CollectionUtils.isNotEmpty(childListeners.get(path));
try {
return zk.getChildren(path, watch);
} catch (KeeperException e) {
if (isZkNoNodeException(e)) {
return null;
} else {
throw new ZkException(e);
}
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
@Override
public boolean exists(String path) {
boolean watch = CollectionUtils.isNotEmpty(childListeners.get(path));
try {
return zk.exists(path, watch) != null;
} catch (KeeperException e) {
if (isZkNoNodeException(e)) {
return false;
} else {
throw new ZkException(e);
}
} catch (InterruptedException e) {
throw new ZkInterruptedException(e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public void startListener() {
try {
if (start.compareAndSet(false, true)) {
nodeCache.start(true);
nodeCache.getListenable().addListener(nodeCacheListener);
}
} catch (Exception e) {
throw new ZkException(e);
}
}
代码示例来源:origin: ltsopensource/light-task-scheduler
public void startListener() {
try {
if (start.compareAndSet(false, true)) {
nodeCache.start(true);
nodeCache.getListenable().addListener(nodeCacheListener);
}
} catch (Exception e) {
throw new ZkException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!