gpt4 book ai didi

com.github.ltsopensource.zookeeper.lts.ZkInterruptedException类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 12:32:36 28 4
gpt4 key购买 nike

本文整理了Java中com.github.ltsopensource.zookeeper.lts.ZkInterruptedException类的一些代码示例,展示了ZkInterruptedException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZkInterruptedException类的具体详情如下:
包路径:com.github.ltsopensource.zookeeper.lts.ZkInterruptedException
类名称:ZkInterruptedException

ZkInterruptedException介绍

暂无

代码示例

代码示例来源: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

@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

@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: 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 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 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
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: ltsopensource/light-task-scheduler

@Override
public void setData(String path, Object data) {
  byte[] bytes = serializer.serialize(data);
  try {
    zk.setData(path, bytes, -1);
  } catch (KeeperException e) {
    throw new ZkException(e);
  } catch (InterruptedException e) {
    throw new ZkInterruptedException(e);
  }
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
public void setData(String path, Object data) {
  byte[] bytes = serializer.serialize(data);
  try {
    zk.setData(path, bytes, -1);
  } catch (KeeperException e) {
    throw new ZkException(e);
  } catch (InterruptedException e) {
    throw new ZkInterruptedException(e);
  }
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
public boolean delete(String path) {
  try {
    zk.delete(path, -1);
    return true;
  } catch (InterruptedException e) {
    throw new ZkInterruptedException(e);
  } catch (KeeperException e) {
    if (isZkNoNodeException(e)) {
      return false;
    } else {
      throw new ZkException(e);
    }
  }
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
public boolean delete(String path) {
  try {
    zk.delete(path, -1);
    return true;
  } catch (InterruptedException e) {
    throw new ZkInterruptedException(e);
  } catch (KeeperException e) {
    if (isZkNoNodeException(e)) {
      return false;
    } else {
      throw new ZkException(e);
    }
  }
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
protected String createEphemeral(String path, Object data, boolean sequential) {
  checkConnect();
  final byte[] bytes = data == null ? null : serialize(data);
  if (sequential) {
    try {
      return zk.create(path, bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
    } catch (KeeperException e) {
      throw new ZkException("path[\" + path + \"], sequential[true] , code:" + e.code(), e);
    } catch (InterruptedException e) {
      throw new ZkInterruptedException("create ephemeral path[" + path + "], sequential[true]", e);
    }
  } else {
    try {
      zk.create(path, bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
      return path;
    } catch (KeeperException e) {
      if (isZkNodeExistsException(e)) {
        // 已经存在 ignored
      } else {
        throw new ZkException("path[\" + path + \"], sequential[false] , code:" + e.code(), e);
      }
    } catch (InterruptedException e) {
      throw new ZkInterruptedException("create ephemeral path[" + path + "], sequential[false]", e);
    }
  }
  return null;
}

代码示例来源:origin: ltsopensource/light-task-scheduler

@Override
protected String createEphemeral(String path, Object data, boolean sequential) {
  checkConnect();
  final byte[] bytes = data == null ? null : serialize(data);
  if (sequential) {
    try {
      return zk.create(path, bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL_SEQUENTIAL);
    } catch (KeeperException e) {
      throw new ZkException("path[\" + path + \"], sequential[true] , code:" + e.code(), e);
    } catch (InterruptedException e) {
      throw new ZkInterruptedException("create ephemeral path[" + path + "], sequential[true]", e);
    }
  } else {
    try {
      zk.create(path, bytes, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
      return path;
    } catch (KeeperException e) {
      if (isZkNodeExistsException(e)) {
        // 已经存在 ignored
      } else {
        throw new ZkException("path[\" + path + \"], sequential[false] , code:" + e.code(), e);
      }
    } catch (InterruptedException e) {
      throw new ZkInterruptedException("create ephemeral path[" + path + "], sequential[false]", e);
    }
  }
  return null;
}

代码示例来源:origin: ltsopensource/light-task-scheduler

throw new ZkException("path[\" + path + \"], sequential[true] , code:" + e.code(), e);
} catch (InterruptedException e) {
  throw new ZkInterruptedException("create persistent path[" + path + "], sequential[true]", e);
  throw new ZkInterruptedException("create persistent path[" + path + "], sequential[false]", e);

代码示例来源:origin: ltsopensource/light-task-scheduler

throw new ZkException("path[\" + path + \"], sequential[true] , code:" + e.code(), e);
} catch (InterruptedException e) {
  throw new ZkInterruptedException("create persistent path[" + path + "], sequential[true]", e);
  throw new ZkInterruptedException("create persistent path[" + path + "], sequential[false]", e);

代码示例来源:origin: com.github.ltsopensource/lts-core

@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: com.github.ltsopensource/lts-core

@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: com.github.ltsopensource/lts-core

@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

@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);
  }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com