private static FateStatus getFateStatus(Instance instance, AccumuloCluster cluster) { try { AdminUtil<String> admin = new AdminUtil<>(false); String secret = cluster.getSiteConfiguration().get(Property.INSTANCE_SECRET); IZooReaderWriter zk = new ZooReaderWriterFactory().getZooReaderWriter( instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), secret); ZooStore<String> zs = new ZooStore<>(ZooUtil.getRoot(instance) + Constants.ZFATE, zk); FateStatus fateStatus = admin.getStatus(zs, zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS, null, null); return fateStatus; } catch (KeeperException | InterruptedException e) { throw new RuntimeException(e); } } }
/** * Gets a reader/writer, retrieving ZooKeeper information from the site configuration. The same * instance may be returned for multiple calls. * * @return reader/writer */ public IZooReaderWriter getInstance() { synchronized (ZooReaderWriterFactory.class) { if (instance == null) { AccumuloConfiguration conf = SiteConfiguration.getInstance(); instance = getZooReaderWriter(conf.get(Property.INSTANCE_ZK_HOST), (int) conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), conf.get(Property.INSTANCE_SECRET)); } return instance; } } }
/** * Checks fates in zookeeper looking for transaction associated with a compaction as a double * check that the test will be valid because the running compaction does have a fate transaction * lock. * * @return true if corresponding fate transaction found, false otherwise */ private boolean findFate(final String tableName) { Instance instance = connector.getInstance(); AdminUtil<String> admin = new AdminUtil<>(false); try { String tableId = Tables.getTableId(instance, tableName); log.trace("tid: {}", tableId); String secret = cluster.getSiteConfiguration().get(Property.INSTANCE_SECRET); IZooReaderWriter zk = new ZooReaderWriterFactory().getZooReaderWriter( instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), secret); ZooStore<String> zs = new ZooStore<>(ZooUtil.getRoot(instance) + Constants.ZFATE, zk); AdminUtil.FateStatus fateStatus = admin.getStatus(zs, zk, ZooUtil.getRoot(instance) + Constants.ZTABLE_LOCKS + "/" + tableId, null, null); for (AdminUtil.TransactionStatus tx : fateStatus.getTransactions()) { if (tx.getTop().contains("CompactionDriver") && tx.getDebug().contains("CompactRange")) { return true; } } } catch (KeeperException | TableNotFoundException | InterruptedException ex) { throw new IllegalStateException(ex); } // did not find appropriate fate transaction for compaction. return Boolean.FALSE; }
IZooReaderWriter zrw = new ZooReaderWriterFactory().getZooReaderWriter( cc.get(Property.INSTANCE_ZK_HOST), (int) cc.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), cc.get(Property.INSTANCE_SECRET));
try { String secret = getCluster().getSiteConfiguration().get(Property.INSTANCE_SECRET); IZooReaderWriter writer = new ZooReaderWriterFactory() .getZooReaderWriter(cluster.getZooKeepers(), 30 * 1000, secret); String root = "/accumulo/" + getConnector().getInstance().getInstanceID(); List<String> children = Collections.emptyList();
final long zkTimeout = AccumuloConfiguration.getTimeInMillis( getCluster().getConfig().getSiteConfig().get(Property.INSTANCE_ZK_TIMEOUT.getKey())); IZooReaderWriter zrw = new ZooReaderWriterFactory().getZooReaderWriter( getCluster().getZooKeepers(), (int) zkTimeout, defaultConfig.get(Property.INSTANCE_SECRET)); final String zInstanceRoot = Constants.ZROOT + "/" + conn.getInstance().getInstanceID();