gpt4 book ai didi

org.apache.accumulo.fate.zookeeper.ZooUtil类的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 15:49:31 28 4
gpt4 key购买 nike

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

ZooUtil介绍

暂无

代码示例

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

@Override
public List<ACL> getACL(String zPath, Stat stat) throws KeeperException, InterruptedException {
 return ZooUtil.getACL(info, zPath, stat);
}

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

/**
 * Iterate over the queued work to remove entries that have been completed.
 */
@Override
protected void cleanupFinishedWork() {
 final Iterator<String> work = queuedWork.iterator();
 final String instanceId = client.getInstanceID();
 while (work.hasNext()) {
  String filename = work.next();
  // Null equates to the work was finished
  if (zooCache.get(ZooUtil.getRoot(instanceId) + ReplicationConstants.ZOO_WORK_QUEUE + "/"
    + filename) == null) {
   work.remove();
  }
 }
}

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

public static boolean exists(ZooKeeperConnectionInfo info, String zPath)
  throws KeeperException, InterruptedException {
 return getStatus(info, zPath) != null;
}

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

public static byte[] getData(ZooKeeperConnectionInfo info, String zPath, Stat stat)
  throws KeeperException, InterruptedException {
 final Retry retry = RETRY_FACTORY.createRetry();
 while (true) {
  try {
   return getZooKeeper(info).getData(zPath, false, stat);
  } catch (KeeperException e) {
   final Code c = e.code();
   if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) {
    retryOrThrow(retry, e);
   } else {
    throw e;
   }
  }
  retry.waitForNextAttempt();
 }
}

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

@Override
public List<String> getMasterLocations() {
 String masterLocPath = ZooUtil.getRoot(getInstanceID()) + Constants.ZMASTER_LOCK;
 OpTimer timer = null;
 if (log.isTraceEnabled()) {
  log.trace("tid={} Looking up master location in zookeeper.", Thread.currentThread().getId());
  timer = new OpTimer().start();
 }
 byte[] loc = ZooUtil.getLockData(zooCache, masterLocPath);
 if (timer != null) {
  timer.stop();
  log.trace("tid={} Found master at {} in {}", Thread.currentThread().getId(),
    (loc == null ? "null" : new String(loc, UTF_8)),
    String.format("%.3f secs", timer.scale(TimeUnit.SECONDS)));
 }
 if (loc == null) {
  return Collections.emptyList();
 }
 return Collections.singletonList(new String(loc, UTF_8));
}

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

public static void recursiveCopyPersistent(ZooKeeperConnectionInfo info, String source,
  String destination, NodeExistsPolicy policy) throws KeeperException, InterruptedException {
 Stat stat = null;
 if (!exists(info, source))
  throw KeeperException.create(Code.NONODE, source);
 if (exists(info, destination)) {
  switch (policy) {
   case OVERWRITE:
 byte[] data = getData(info, source, stat);
  putPersistentData(info, destination, data, policy);
  if (stat.getNumChildren() > 0) {
   List<String> children;
   while (true) {
    try {
     children = getZooKeeper(info).getChildren(source, false);
     break;
    } catch (KeeperException e) {
     if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT
       || c == Code.SESSIONEXPIRED) {
      retryOrThrow(retry, e);
     } else {
      throw e;
    recursiveCopyPersistent(info, source + "/" + child, destination + "/" + child, policy);

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

while (true) {
 try {
  children = getZooKeeper(info).getChildren(zPath, false);
  break;
 } catch (KeeperException e) {
  final Code c = e.code();
  if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) {
   retryOrThrow(retry, e);
  } else {
   throw e;
 recursiveDelete(info, zPath + "/" + child, NodeMissingPolicy.SKIP);
  stat = getZooKeeper(info).exists(zPath, null);
    getZooKeeper(info).delete(zPath, -1);
    return;
   } catch (NoNodeException e) {
  final Code c = e.code();
  if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) {
   retryOrThrow(retry, e);
  } else {
   throw e;

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

public static boolean putPersistentData(ZooKeeperConnectionInfo info, String zPath, byte[] data,
  int version, NodeExistsPolicy policy, List<ACL> acls)
  throws KeeperException, InterruptedException {
 return putData(info, zPath, data, CreateMode.PERSISTENT, version, policy, acls);
}

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

@Override
public String putEphemeralData(String zPath, byte[] data)
  throws KeeperException, InterruptedException {
 return ZooUtil.putEphemeralData(info, zPath, data);
}

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

@Override
public String putEphemeralSequential(String zPath, byte[] data)
  throws KeeperException, InterruptedException {
 return ZooUtil.putEphemeralSequential(info, zPath, data);
}

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

@Override
public boolean isLockHeld(ZooUtil.LockID lockID) throws KeeperException, InterruptedException {
 return ZooUtil.isLockHeld(info, lockID);
}

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

protected static ZooKeeper getZooKeeper(ZooKeeperConnectionInfo info) {
 return getZooKeeper(info.keepers, info.timeout, info.scheme, info.auth);
}

代码示例来源:origin: org.apache.accumulo/accumulo-fate

public static void recursiveCopyPersistent(ZooKeeperConnectionInfo info, String source,
  String destination, NodeExistsPolicy policy) throws KeeperException, InterruptedException {
 Stat stat = null;
 if (!exists(info, source))
  throw KeeperException.create(Code.NONODE, source);
 if (exists(info, destination)) {
  switch (policy) {
   case OVERWRITE:
 byte[] data = getData(info, source, stat);
  putPersistentData(info, destination, data, policy);
  if (stat.getNumChildren() > 0) {
   List<String> children;
   while (true) {
    try {
     children = getZooKeeper(info).getChildren(source, false);
     break;
    } catch (KeeperException e) {
     if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT
       || c == Code.SESSIONEXPIRED) {
      retryOrThrow(retry, e);
     } else {
      throw e;
    recursiveCopyPersistent(info, source + "/" + child, destination + "/" + child, policy);

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

public static String putEphemeralData(ZooKeeperConnectionInfo info, String zPath, byte[] data)
  throws KeeperException, InterruptedException {
 final Retry retry = RETRY_FACTORY.createRetry();
 while (true) {
  try {
   return getZooKeeper(info).create(zPath, data, ZooUtil.PUBLIC, CreateMode.EPHEMERAL);
  } catch (KeeperException e) {
   final Code c = e.code();
   if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) {
    retryOrThrow(retry, e);
   } else {
    throw e;
   }
  }
  retry.waitForNextAttempt();
 }
}

代码示例来源:origin: org.apache.accumulo/accumulo-fate

while (true) {
 try {
  children = getZooKeeper(info).getChildren(zPath, false);
  break;
 } catch (KeeperException e) {
  final Code c = e.code();
  if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) {
   retryOrThrow(retry, e);
  } else {
   throw e;
 recursiveDelete(info, zPath + "/" + child, NodeMissingPolicy.SKIP);
  stat = getZooKeeper(info).exists(zPath, null);
    getZooKeeper(info).delete(zPath, -1);
    return;
   } catch (NoNodeException e) {
  final Code c = e.code();
  if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) {
   retryOrThrow(retry, e);
  } else {
   throw e;

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

/**
 * Create a persistent node with the default ACL
 *
 * @return true if the node was created or altered; false if it was skipped
 */
public static boolean putPersistentData(ZooKeeperConnectionInfo info, String zPath, byte[] data,
  NodeExistsPolicy policy) throws KeeperException, InterruptedException {
 return putData(info, zPath, data, CreateMode.PERSISTENT, -1, policy, PUBLIC);
}

代码示例来源:origin: org.apache.accumulo/accumulo-fate

@Override
public String putEphemeralData(String zPath, byte[] data)
  throws KeeperException, InterruptedException {
 return ZooUtil.putEphemeralData(info, zPath, data);
}

代码示例来源:origin: org.apache.accumulo/accumulo-fate

@Override
public String putEphemeralSequential(String zPath, byte[] data)
  throws KeeperException, InterruptedException {
 return ZooUtil.putEphemeralSequential(info, zPath, data);
}

代码示例来源:origin: org.apache.accumulo/accumulo-fate

@Override
public boolean isLockHeld(ZooUtil.LockID lockID) throws KeeperException, InterruptedException {
 return ZooUtil.isLockHeld(info, lockID);
}

代码示例来源:origin: org.apache.accumulo/accumulo-fate

protected static ZooKeeper getZooKeeper(ZooKeeperConnectionInfo info) {
 return getZooKeeper(info.keepers, info.timeout, info.scheme, info.auth);
}

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