@Override public byte[] execute() throws KeeperException, InterruptedException { return zk.getData(childPath, false, stat); } });
@Override public byte[] execute() throws KeeperException, InterruptedException { return zk.getData(childPath, false, stat); } });
@Override public Boolean execute() throws KeeperException, InterruptedException { data.add(zk.getData(path, watcher, stat)); return null; } });
@Override public Boolean execute() throws KeeperException, InterruptedException { data.add(zk.getData(path, watcher, stat)); return null; } });
@Override public Boolean execute() throws KeeperException, InterruptedException { byte[] currentData = zk.getData(path, false, new Stat()); if (!Arrays.equals(currentData, data)) { zk.setData(path, data, -1); } return null; } });
@Override public Boolean execute() throws KeeperException, InterruptedException { byte[] currentData = zk.getData(path, false, new Stat()); if (!Arrays.equals(currentData, data)) { zk.setData(path, data, -1); } return null; } });
@Override public List<IndexerProcess> execute() throws KeeperException, InterruptedException { List<IndexerProcess> indexerProcesses = Lists.newArrayList(); for (String childNode : zk.getChildren(zkBaseNode, false)) { List<String> nodeNameParts = Lists.newArrayList(Splitter.on(',').split(childNode)); if (indexerName.equals(nodeNameParts.get(0))) { byte[] errorBytes = zk.getData(zkBaseNode + "/" + childNode, false, null); IndexerProcess indexerProcess = new IndexerProcess(indexerName, nodeNameParts.get(1), errorBytes == null || errorBytes.length == 0? null : Bytes.toString(errorBytes)); indexerProcesses.add(indexerProcess); } } return indexerProcesses; }}); } catch (Exception e) {
@Override public List<IndexerProcess> execute() throws KeeperException, InterruptedException { List<IndexerProcess> indexerProcesses = Lists.newArrayList(); for (String childNode : zk.getChildren(zkBaseNode, false)) { List<String> nodeNameParts = Lists.newArrayList(Splitter.on(',').split(childNode)); if (indexerName.equals(nodeNameParts.get(0))) { byte[] errorBytes = zk.getData(zkBaseNode + "/" + childNode, false, null); IndexerProcess indexerProcess = new IndexerProcess(indexerName, nodeNameParts.get(1), errorBytes == null || errorBytes.length == 0? null : Bytes.toString(errorBytes)); indexerProcesses.add(indexerProcess); } } return indexerProcesses; }}); } catch (Exception e) {
private Configuration getHBaseConf(ZooKeeperItf zk, int hbaseMasterPort) throws KeeperException, InterruptedException, IOException { // Read the HBase/Hadoop configuration via the master web ui // This is debatable, but it avoids any pitfalls with conf dirs and also works with launch-test-lily byte[] masterServerName = removeMetaData(zk.getData("/hbase/master", false, new Stat())); String hbaseMasterHostName = getServerName(masterServerName).getHostname(); String url = String.format("http://%s:%d/conf", hbaseMasterHostName, hbaseMasterPort); System.out.println("Reading HBase configuration from " + url); byte[] data = readUrl(url); Configuration conf = new Configuration(); conf.addResource(new ByteArrayInputStream(data)); return conf; }
@Override public Object execute() throws KeeperException, InterruptedException { byte[] data = zk.getData(indexerPath, false, null); String trashPath = indexerTrashPath + "/" + indexerName; // An indexer with the same name might have existed before and hence already exist // in the indexer trash, handle this by appending a sequence number until a unique // name is found. String baseTrashpath = trashPath; int count = 0; while (zk.exists(trashPath, false) != null) { count++; trashPath = baseTrashpath + "." + count; } zk.create(trashPath, data, ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT); return null; } });
private Configuration getHBaseConf(ZooKeeperItf zk, int hbaseMasterPort) throws KeeperException, InterruptedException, IOException { // Read the HBase/Hadoop configuration via the master web ui // This is debatable, but it avoids any pitfalls with conf dirs and also works with launch-test-lily byte[] masterServerName = removeMetaData(zk.getData(zookeeperZNodeParent + "/master", false, new Stat())); String hbaseMasterHostName = getServerName(masterServerName).getHostname(); String ulrScheme = (useSSL) ? "https" : "http" ; String url = String.format("%s://%s:%d/conf", ulrScheme, hbaseMasterHostName, hbaseMasterPort); System.out.println("Reading HBase configuration from " + url); byte[] data = null; try { data = readUrl(url); } catch (ClientProtocolException ex) { if(!useSSL) { System.out.println("Hint : Please check if HBASE is configured with SSL. If yes then use --use-ssl option"); } throw ex; } Configuration conf = new Configuration(); conf.addResource(new ByteArrayInputStream(data)); return conf; }
@Override public Object execute() throws KeeperException, InterruptedException { byte[] data = zk.getData(indexerPath, false, null); String trashPath = indexerTrashPath + "/" + indexerName; // An indexer with the same name might have existed before and hence already exist // in the indexer trash, handle this by appending a sequence number until a unique // name is found. String baseTrashpath = trashPath; int count = 0; while (zk.exists(trashPath, false) != null) { count++; trashPath = baseTrashpath + "." + count; } zk.create(trashPath, data, CreateMode.PERSISTENT); return null; } });
byte[] data = zk.getData(hlogsPath + "/" + log, false, stat);
byte[] data = zk.getData(hlogsPath + "/" + log, false, stat);
private IndexerDefinition loadIndexer(String indexerName, boolean forCache) throws InterruptedException, KeeperException, IndexerNotFoundException { final String childPath = indexerCollectionPath + "/" + indexerName; final Stat stat = new Stat(); byte[] data; try { if (forCache) { // do not retry, install watcher data = zk.getData(childPath, watcher, stat); } else { // do retry, do not install watcher data = zk.retryOperation(new ZooKeeperOperation<byte[]>() { @Override public byte[] execute() throws KeeperException, InterruptedException { return zk.getData(childPath, false, stat); } }); } } catch (KeeperException.NoNodeException e) { throw new IndexerNotFoundException(indexerName); } IndexerDefinitionBuilder builder = IndexerDefinitionJsonSerDeser.INSTANCE.fromJsonBytes(data); builder.name(indexerName); builder.occVersion(stat.getVersion()); return builder.build(); }
private IndexerDefinition loadIndexer(String indexerName, boolean forCache) throws InterruptedException, KeeperException, IndexerNotFoundException { final String childPath = indexerCollectionPath + "/" + indexerName; final Stat stat = new Stat(); byte[] data; try { if (forCache) { // do not retry, install watcher data = zk.getData(childPath, watcher, stat); } else { // do retry, do not install watcher data = zk.retryOperation(new ZooKeeperOperation<byte[]>() { @Override public byte[] execute() throws KeeperException, InterruptedException { return zk.getData(childPath, false, stat); } }); } } catch (KeeperException.NoNodeException e) { throw new IndexerNotFoundException(indexerName); } IndexerDefinitionBuilder builder = IndexerDefinitionJsonSerDeser.INSTANCE.fromJsonBytes(data); builder.name(indexerName); builder.occVersion(stat.getVersion()); return builder.build(); }