Map<Long,List<String>> waitingLocks = new HashMap<>(); List<String> lockedIds = zk.getChildren(lockPath); List<String> lockNodes = zk.getChildren(lockPath + "/" + id); lockNodes = new ArrayList<>(lockNodes); Collections.sort(lockNodes); byte[] data = zk.getData(lockPath + "/" + id + "/" + node, null); String lda[] = new String(data, UTF_8).split(":");
public static Set<Long> allTransactionsAlive(ServerContext context, String type) throws KeeperException, InterruptedException { final IZooReader reader = context.getZooReaderWriter(); final Set<Long> result = new HashSet<>(); final String parent = context.getZooKeeperRoot() + "/" + type; reader.sync(parent); List<String> children = reader.getChildren(parent); for (String child : children) { if (child.endsWith("-running")) { continue; } result.add(Long.parseLong(child)); } return result; }
/** * Determines if there could be an accumulo instance running via zookeeper lock checking * * @return true iff all servers show no indication of being registered in zookeeper, otherwise * false * @throws IOException * if there are issues connecting to ZooKeeper to determine service status */ public static boolean isAccumuloOffline(IZooReader reader, String rootPath) throws IOException { try { for (String child : reader.getChildren(rootPath + Constants.ZTSERVERS)) { if (!reader.getChildren(rootPath + Constants.ZTSERVERS + "/" + child).isEmpty()) return false; } if (!reader.getChildren(rootPath + Constants.ZMASTER_LOCK).isEmpty()) return false; if (!reader.getChildren(rootPath + Constants.ZMONITOR_LOCK).isEmpty()) return false; if (!reader.getChildren(rootPath + Constants.ZGC_LOCK).isEmpty()) return false; } catch (KeeperException | InterruptedException e) { throw new IOException("Issues contacting ZooKeeper to get Accumulo status.", e); } return true; }
/** * Determines if there could be an accumulo instance running via zookeeper lock checking * * @return true iff all servers show no indication of being registered in zookeeper, otherwise * false * @throws IOException * if there are issues connecting to ZooKeeper to determine service status */ public static boolean isAccumuloOffline(IZooReader reader, String rootPath) throws IOException { try { for (String child : reader.getChildren(rootPath + Constants.ZTSERVERS)) { if (!reader.getChildren(rootPath + Constants.ZTSERVERS + "/" + child).isEmpty()) return false; } if (!reader.getChildren(rootPath + Constants.ZMASTER_LOCK).isEmpty()) return false; if (!reader.getChildren(rootPath + Constants.ZMONITOR_LOCK).isEmpty()) return false; if (!reader.getChildren(rootPath + Constants.ZGC_LOCK).isEmpty()) return false; } catch (KeeperException e) { throw new IOException("Issues contacting ZooKeeper to get Accumulo status.", e); } catch (InterruptedException e) { throw new IOException("Issues contacting ZooKeeper to get Accumulo status.", e); } return true; }
Map<Long,List<String>> waitingLocks = new HashMap<>(); List<String> lockedIds = zk.getChildren(lockPath); List<String> lockNodes = zk.getChildren(lockPath + "/" + id); lockNodes = new ArrayList<>(lockNodes); Collections.sort(lockNodes); byte[] data = zk.getData(lockPath + "/" + id + "/" + node, null); String lda[] = new String(data, UTF_8).split(":");
public static Set<Long> allTransactionsAlive(String type) throws KeeperException, InterruptedException { final Instance instance = HdfsZooInstance.getInstance(); final IZooReader reader = ZooReaderWriter.getInstance(); final Set<Long> result = new HashSet<>(); final String parent = ZooUtil.getRoot(instance) + "/" + type; reader.sync(parent); List<String> children = reader.getChildren(parent); for (String child : children) { if (child.endsWith("-running")) { continue; } result.add(Long.parseLong(child)); } return result; }