gpt4 book ai didi

org.apache.helix.manager.zk.zookeeper.ZkConnection类的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 09:47:23 28 4
gpt4 key购买 nike

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

ZkConnection介绍

暂无

代码示例

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

public ZkClient(final String zkServers, final int sessionTimeout, final int connectionTimeout,
  final ZkSerializer zkSerializer, final long operationRetryTimeout) {
 this(new ZkConnection(zkServers, sessionTimeout), connectionTimeout, zkSerializer,
   operationRetryTimeout);
}

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

@Override
 public Stat call() throws Exception {
  Stat stat = ((ZkConnection) getConnection()).getZookeeper().exists(path, false);
  return stat;
 }
});

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

public void writeData(String path, byte[] data) throws KeeperException, InterruptedException {
 writeData(path, data, -1);
}

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

protected void simulateSessionExpiry(ZkConnection zkConnection) throws IOException,
  InterruptedException {
 ZooKeeper oldZookeeper = zkConnection.getZookeeper();
 LOG.info("Old sessionId = " + oldZookeeper.getSessionId());
 Watcher watcher = new Watcher() {
  @Override
  public void process(WatchedEvent event) {
   LOG.info("In New connection, process event:" + event);
  }
 };
 ZooKeeper newZookeeper =
   new ZooKeeper(zkConnection.getServers(), oldZookeeper.getSessionTimeout(), watcher,
     oldZookeeper.getSessionId(), oldZookeeper.getSessionPasswd());
 LOG.info("New sessionId = " + newZookeeper.getSessionId());
 // Thread.sleep(3000);
 newZookeeper.close();
 Thread.sleep(10000);
 oldZookeeper = zkConnection.getZookeeper();
 LOG.info("After session expiry sessionId = " + oldZookeeper.getSessionId());
}

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

private void reconnect() {
 getEventLock().lock();
 try {
  ZkConnection connection = ((ZkConnection) getConnection());
  connection.reconnect(this);
 } catch (InterruptedException e) {
  throw new ZkInterruptedException(e);
 } finally {
  getEventLock().unlock();
 }
}

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

/**
 * expire zk session asynchronously
 * @param client
 * @throws Exception
 */
public static void asyncExpireSession(HelixZkClient client) throws Exception {
 final ZkClient zkClient = (ZkClient) client;
 ZkConnection connection = ((ZkConnection) zkClient.getConnection());
 ZooKeeper curZookeeper = connection.getZookeeper();
 LOG.info("Before expiry. sessionId: " + Long.toHexString(curZookeeper.getSessionId()));
 Watcher watcher = new Watcher() {
  @Override
  public void process(WatchedEvent event) {
   LOG.info("Process watchEvent: " + event);
  }
 };
 final ZooKeeper dupZookeeper =
   new ZooKeeper(connection.getServers(), curZookeeper.getSessionTimeout(), watcher,
     curZookeeper.getSessionId(), curZookeeper.getSessionPasswd());
 // wait until connected, then close
 while (dupZookeeper.getState() != States.CONNECTED) {
  Thread.sleep(10);
 }
 dupZookeeper.close();
 connection = (ZkConnection) zkClient.getConnection();
 curZookeeper = connection.getZookeeper();
 // System.err.println("zk: " + oldZookeeper);
 LOG.info("After expiry. sessionId: " + Long.toHexString(curZookeeper.getSessionId()));
}

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

ZooKeeper zookeeper = connection.getZookeeper();
System.out.println("old sessionId= " + zookeeper.getSessionId());
Watcher watcher = new Watcher() {
  new ZooKeeper(connection.getServers(), zookeeper.getSessionTimeout(), watcher,
    zookeeper.getSessionId(), zookeeper.getSessionPasswd());
Thread.sleep(3000);
Thread.sleep(10000);
connection = ((ZkConnection) _zkClient.getConnection());
zookeeper = connection.getZookeeper();
System.out.println("After session expiry sessionId= " + zookeeper.getSessionId());

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

public long getSessionId() {
 ZkConnection zkConnection = ((ZkConnection) getConnection());
 ZooKeeper zk = zkConnection.getZookeeper();
 if (zk == null) {
  throw new HelixException(
    "ZooKeeper connection information is not available now. ZkClient might be disconnected.");
 } else {
  return zkConnection.getZookeeper().getSessionId();
 }
}

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

public ZkClient(String zkServers, int sessionTimeout, int connectionTimeout,
  PathBasedZkSerializer zkSerializer, String monitorType, String monitorKey) {
 this(new ZkConnection(zkServers, sessionTimeout), connectionTimeout, zkSerializer, monitorType,
   monitorKey);
}

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

zkClient.subscribeStateChanges(listener);
ZkConnection connection = ((ZkConnection) zkClient.getConnection());
ZooKeeper oldZookeeper = connection.getZookeeper();
LOG.info("Old sessionId = " + oldZookeeper.getSessionId());
  new ZooKeeper(connection.getServers(), oldZookeeper.getSessionTimeout(), watcher,
    oldZookeeper.getSessionId(), oldZookeeper.getSessionPasswd());
LOG.info("New sessionId = " + newZookeeper.getSessionId());
Thread.sleep(10000);
connection = (ZkConnection) zkClient.getConnection();
oldZookeeper = connection.getZookeeper();
LOG.info("After session expiry sessionId = " + oldZookeeper.getSessionId());

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

@Override public Object call() throws Exception {
  ((ZkConnection) getConnection()).getZookeeper().exists(path, null, cb,
    new ZkAsyncCallbacks.ZkAsyncCallContext(_monitor, startT, 0, true));
  return null;
 }
});

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

public ZkClient(String zkServers, int sessionTimeout, int connectionTimeout,
  ZkSerializer zkSerializer) {
 this(new ZkConnection(zkServers, sessionTimeout), connectionTimeout, zkSerializer);
}

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

ZooKeeper curZookeeper = connection.getZookeeper();
LOG.info("Before expiry. sessionId: " + Long.toHexString(curZookeeper.getSessionId()));
  new ZooKeeper(connection.getServers(), curZookeeper.getSessionTimeout(), watcher,
    curZookeeper.getSessionId(), curZookeeper.getSessionPasswd());
curZookeeper = connection.getZookeeper();
zkClient.unsubscribeStateChanges(listener);

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

@Override public Object call() throws Exception {
  ((ZkConnection) getConnection()).getZookeeper().create(path, data, ZooDefs.Ids.OPEN_ACL_UNSAFE,
    // Arrays.asList(DEFAULT_ACL),
    mode, cb, new ZkAsyncCallbacks.ZkAsyncCallContext(_monitor, startT,
      data == null ? 0 : data.length, false));
  return null;
 }
});

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

public ZkClient(String zkServers, int sessionTimeout, int connectionTimeout,
  PathBasedZkSerializer zkSerializer) {
 this(new ZkConnection(zkServers, sessionTimeout), connectionTimeout, zkSerializer);
}

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

ZooKeeper curZookeeper = connection.getZookeeper();
String oldSessionId = Long.toHexString(curZookeeper.getSessionId());
LOG.info("Before session expiry. sessionId: " + oldSessionId + ", zk: " + curZookeeper);
  new ZooKeeper(connection.getServers(), curZookeeper.getSessionTimeout(), watcher,
    curZookeeper.getSessionId(), curZookeeper.getSessionPasswd());
curZookeeper = connection.getZookeeper();

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

@Override public Object call() throws Exception {
  ((ZkConnection) getConnection()).getZookeeper().getData(path, null, cb,
    new ZkAsyncCallbacks.ZkAsyncCallContext(_monitor, startT, 0, true));
  return null;
 }
});

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

public ZkClient(String zkServers, int connectionTimeout) {
 this(new ZkConnection(zkServers, DEFAULT_SESSION_TIMEOUT), connectionTimeout,
   new SerializableSerializer());
}

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

@Override public Object call() throws Exception {
  ((ZkConnection) getConnection()).getZookeeper().setData(path, data, version, cb,
    new ZkAsyncCallbacks.ZkAsyncCallContext(_monitor, startT,
      data == null ? 0 : data.length, false));
  return null;
 }
});

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

public ZkClient(String zkServers, int sessionTimeout, int connectionTimeout) {
 this(new ZkConnection(zkServers, sessionTimeout), connectionTimeout,
   new SerializableSerializer());
}

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