private static ZooCache getZooCache(Instance instance) { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(TABLES_PERMISSION); } return new ZooCacheFactory().getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); }
private Map<String,Boolean> _getWals(Connector c) throws Exception { Map<String,Boolean> result = new HashMap<>(); Instance i = c.getInstance(); ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), ""); WalStateManager wals = new WalStateManager(c.getInstance(), zk); for (Entry<Path,WalState> entry : wals.getAllState().entrySet()) { // WALs are in use if they are not unreferenced result.put(entry.getKey().toString(), entry.getValue() != WalState.UNREFERENCED); } return result; }
private static void verifyAccumuloIsDown(Instance inst, String oldPassword) throws Exception { ZooReader zooReader = new ZooReaderWriter(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), oldPassword); String root = ZooUtil.getRoot(inst); final List<String> ephemerals = new ArrayList<>(); recurse(zooReader, root, new Visitor() { @Override public void visit(ZooReader zoo, String path) throws Exception { Stat stat = zoo.getStatus(path); if (stat.getEphemeralOwner() != 0) ephemerals.add(path); } }); if (ephemerals.size() > 0) { System.err.println("The following ephemeral nodes exist, something is still running:"); for (String path : ephemerals) { System.err.println(path); } throw new Exception("Accumulo must be shut down in order to run this tool."); } }
@Override public ZooCache call() { final String zks = instance.getZooKeepers(); final int timeOut = instance.getZooKeepersSessionTimeOut(); return new ZooCacheFactory().getZooCache(zks, timeOut, new Watcher() { @Override public void process(WatchedEvent watchedEvent) { instanceToMapCache.invalidate(uuid); } }); } });
private static boolean verifyAccumuloIsDown(Instance inst, String oldPassword) { ZooReader zooReader = new ZooReaderWriter(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), oldPassword); String root = ZooUtil.getRoot(inst); final List<String> ephemerals = new ArrayList<String>(); recurse(zooReader, root, new Visitor() { public void visit(ZooReader zoo, String path) throws Exception { Stat stat = zoo.getStatus(path); if (stat.getEphemeralOwner() != 0) ephemerals.add(path); } }); if (ephemerals.size() == 0) { return true; } System.err.println("The following ephemeral nodes exist, something is still running:"); for (String path : ephemerals) { System.err.println(path); } return false; }
protected synchronized IZooReaderWriter getZooReaderWriter(Instance instance, String secret) { if (secret == null) { AccumuloConfiguration conf = SiteConfiguration.getInstance(); secret = conf.get(Property.INSTANCE_SECRET); } return new ZooReaderWriter(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), SCHEME, (USER + ":" + secret).getBytes()); }
ZookeeperLockChecker(Instance instance, ZooCacheFactory zcf) { zc = zcf.getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); this.root = ZooUtil.getRoot(instance) + Constants.ZTSERVERS; }
@Override public List<String> getTabletServers() { Instance instance = context.getInstance(); ZooCache cache = new ZooCacheFactory().getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); String path = ZooUtil.getRoot(instance) + Constants.ZTSERVERS; List<String> results = new ArrayList<>(); for (String candidate : cache.getChildren(path)) { List<String> children = cache.getChildren(path + "/" + candidate); if (children != null && children.size() > 0) { List<String> copy = new ArrayList<>(children); Collections.sort(copy); byte[] data = cache.get(path + "/" + candidate + "/" + copy.get(0)); if (data != null && !"master".equals(new String(data, UTF_8))) { results.add(candidate); } } } return results; }
/** * Fetch all of the WALs referenced by tablets in the metadata table for this table */ private Set<String> getWalsForTable(String tableName) throws Exception { final Connector conn = getConnector(); final String tableId = conn.tableOperations().tableIdMap().get(tableName); Assert.assertNotNull("Could not determine table ID for " + tableName, tableId); Instance i = conn.getInstance(); ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), ""); WalStateManager wals = new WalStateManager(conn.getInstance(), zk); Set<String> result = new HashSet<>(); for (Entry<Path,WalState> entry : wals.getAllState().entrySet()) { log.debug("Reading WALs: {}={}", entry.getKey(), entry.getValue()); result.add(entry.getKey().toString()); } return result; }
private static void deleteInstance(Instance origInstance, String oldPass) throws Exception { IZooReaderWriter orig = new ZooReaderWriter(origInstance.getZooKeepers(), origInstance.getZooKeepersSessionTimeOut(), oldPass); orig.recursiveDelete("/accumulo/" + origInstance.getInstanceID(), NodeMissingPolicy.SKIP); } }
@Override public void invalidateCache(Instance instance, String server) { ZooCache zooCache = zcf.getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut()); String root = ZooUtil.getRoot(instance) + Constants.ZTSERVERS; zooCache.clear(root + "/" + server); }
private void initializeZooCache() { synchronized (initLock) { if (null == tablePropCache) { tablePropCache = new ZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), new TableConfWatcher(instance)); } } }
synchronized public static ZooConfiguration getInstance(Instance inst, AccumuloConfiguration parent) { if (instance == null) { propCache = new ZooCache(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut()); instance = new ZooConfiguration(parent); instanceId = inst.getInstanceID(); } return instance; }
private synchronized ZooCachePropertyAccessor getPropCacheAccessor() { if (propCacheAccessor == null) { synchronized (propCaches) { PropCacheKey key = new PropCacheKey(instance.getInstanceID(), tableId); ZooCache propCache = propCaches.get(key); if (propCache == null) { propCache = zcf.getZooCache(instance.getZooKeepers(), instance.getZooKeepersSessionTimeOut(), new TableConfWatcher(instance)); propCaches.put(key, propCache); } propCacheAccessor = new ZooCachePropertyAccessor(propCache); } } return propCacheAccessor; }
private static void deleteInstance(Instance origInstance, String oldPass) throws Exception { IZooReaderWriter orig = new ZooReaderWriter(origInstance.getZooKeepers(), origInstance.getZooKeepersSessionTimeOut(), oldPass); orig.recursiveDelete("/accumulo/" + origInstance.getInstanceID(), NodeMissingPolicy.SKIP); } }
private synchronized ZooCachePropertyAccessor getPropCacheAccessor() { if (propCacheAccessor == null) { synchronized (propCaches) { PropCacheKey key = new PropCacheKey(inst.getInstanceID(), namespaceId); ZooCache propCache = propCaches.get(key); if (propCache == null) { propCache = zcf.getZooCache(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), new NamespaceConfWatcher(inst)); propCaches.put(key, propCache); } propCacheAccessor = new ZooCachePropertyAccessor(propCache); } } return propCacheAccessor; }
public MasterReplicationCoordinator(Master master) { this(master, new ZooReader(master.getInstance().getZooKeepers(), master.getInstance().getZooKeepersSessionTimeOut())); }
@Override public Set<TServerInstance> onlineTabletServers() { HashSet<TServerInstance> tservers = new HashSet<>(); for (String tserver : getConnector().instanceOperations().getTabletServers()) { try { String zPath = ZooUtil.getRoot(getConnector().getInstance()) + Constants.ZTSERVERS + "/" + tserver; long sessionId = ZooLock.getSessionId(new ZooCache(getCluster().getZooKeepers(), getConnector().getInstance().getZooKeepersSessionTimeOut()), zPath); tservers.add(new TServerInstance(tserver, sessionId)); } catch (Exception e) { throw new RuntimeException(e); } } return tservers; }
public static IteratorSetting iteratorSetting(int priority, int sleepAfterFirstWrite, long batchWriterTimeout, long batchWriterMaxMemory, int numEntriesToWrite, String tableName, Connector connector, AuthenticationToken token, boolean clearCacheAfterFirstWrite, boolean splitAfterFirstWrite) { return iteratorSetting(priority, sleepAfterFirstWrite, batchWriterTimeout, batchWriterMaxMemory, numEntriesToWrite, tableName, connector.getInstance().getZooKeepers(), connector.getInstance().getInstanceName(), connector.getInstance().getZooKeepersSessionTimeOut(), connector.whoami(), token, clearCacheAfterFirstWrite, splitAfterFirstWrite); }
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); } } }