org.I0Itec.zkclient.exception.ZkException.<init>()方法的使用及代码示例

x33g5p2x  于2022-02-05 转载在 其他  
字(7.9k)|赞(0)|评价(0)|浏览(158)

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

ZkException.<init>介绍

暂无

代码示例

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

throw new ZkException("zookeeper_create_error, serveraddrs=" + cluster1, e);

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

private boolean isZkSaslEnabled() {
  boolean isSecurityEnabled = false;
  boolean zkSaslEnabled = Boolean.parseBoolean(System.getProperty(ZK_SASL_CLIENT, "true"));
  String zkLoginContextName = System.getProperty(ZK_LOGIN_CONTEXT_NAME_KEY, "Client");
  if (!zkSaslEnabled) {
    LOG.warn("Client SASL has been explicitly disabled with " + ZK_SASL_CLIENT);
    return false;
  }
  String loginConfigFile = System.getProperty(JAVA_LOGIN_CONFIG_PARAM);
  if (loginConfigFile != null && loginConfigFile.length() > 0) {
    LOG.info("JAAS File name: " + loginConfigFile);
    File configFile = new File(loginConfigFile);
    if (!configFile.canRead()) {
      throw new IllegalArgumentException("File " + loginConfigFile + "cannot be read.");
    }
    try {
      Configuration loginConf = Configuration.getConfiguration();
      isSecurityEnabled = loginConf.getAppConfigurationEntry(zkLoginContextName) != null;
    } catch (Exception e) {
      throw new ZkException(e);
    }
  }
  return isSecurityEnabled;
}

代码示例来源:origin: com.alibaba.otter/shared.common

@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: com.github.sgroschupf/zkclient

private void startSingleZkServer(final int tickTime, final File dataDir, final File dataLogDir, final int port) {
  try {
    _zk = new ZooKeeperServer(dataDir, dataLogDir, tickTime);
    _zk.setMinSessionTimeout(_minSessionTimeout);
    _nioFactory = new NIOServerCnxn.Factory(new InetSocketAddress(port));
    _nioFactory.startup(_zk);
  } catch (IOException e) {
    throw new ZkException("Unable to start single ZooKeeper server.", e);
  } catch (InterruptedException e) {
    throw new ZkInterruptedException(e);
  }
}

代码示例来源:origin: com.alibaba.otter/shared.common

throw new ZkException("zookeeper_create_error, serveraddrs=" + cluster1, e);

代码示例来源:origin: org.apache.helix/helix-core

private void reconnectOnExpiring() {
 int retryCount = 0;
 ExponentialBackoffStrategy retryStrategy =
   new ExponentialBackoffStrategy(MAX_RECONNECT_INTERVAL_MS, true);
 Exception reconnectException = new ZkException("Shutdown triggered.");
 while (!_closed) {
  try {
   reconnect();
   fireNewSessionEvents();
   return;
  } catch (ZkInterruptedException interrupt) {
   reconnectException = interrupt;
   break;
  } catch (Exception e) {
   reconnectException = e;
   long waitInterval = retryStrategy.getNextWaitInterval(retryCount++);
   LOG.warn("ZkClient reconnect on expiring failed. Will retry after {} ms", waitInterval, e);
   try {
    Thread.sleep(waitInterval);
   } catch (InterruptedException ex) {
    reconnectException = ex;
    break;
   }
  }
 }
 LOG.info("Unable to re-establish connection. Notifying consumer of the following exception: ",
   reconnectException);
 fireSessionEstablishmentError(reconnectException);
}

代码示例来源:origin: apache/helix

private void reconnectOnExpiring() {
 int retryCount = 0;
 ExponentialBackoffStrategy retryStrategy =
   new ExponentialBackoffStrategy(MAX_RECONNECT_INTERVAL_MS, true);
 Exception reconnectException = new ZkException("Shutdown triggered.");
 while (!isClosed()) {
  try {
   reconnect();
   fireNewSessionEvents();
   return;
  } catch (ZkInterruptedException interrupt) {
   reconnectException = interrupt;
   break;
  } catch (Exception e) {
   reconnectException = e;
   long waitInterval = retryStrategy.getNextWaitInterval(retryCount++);
   LOG.warn("ZkClient reconnect on expiring failed. Will retry after {} ms", waitInterval, e);
   try {
    Thread.sleep(waitInterval);
   } catch (InterruptedException ex) {
    reconnectException = ex;
    break;
   }
  }
 }
 LOG.info("Unable to re-establish connection. Notifying consumer of the following exception: ",
   reconnectException);
 fireSessionEstablishmentError(reconnectException);
}

代码示例来源:origin: com.101tec/zkclient

private void startSingleZkServer(final int tickTime, final File dataDir, final File dataLogDir, final int port) {
  try {
    _zk = new ZooKeeperServer(dataDir, dataLogDir, tickTime);
    _zk.setMinSessionTimeout(_minSessionTimeout);
    _nioFactory = new NIOServerCnxnFactory();
    int maxClientConnections = 0; // 0 means unlimited
    _nioFactory.configure(new InetSocketAddress(port), maxClientConnections);
    _nioFactory.startup(_zk);
  } catch (IOException e) {
    throw new ZkException("Unable to start single ZooKeeper server.", e);
  } catch (InterruptedException e) {
    throw new ZkInterruptedException(e);
  }
}

代码示例来源:origin: com.github.sgroschupf/zkclient

return new ZkException(e);

代码示例来源:origin: com.101tec/zkclient

return new ZkException(e);

相关文章