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."); } }
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; }
/** * 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); } }
public static synchronized ZooReaderWriter getInstance() { if (instance == null) { AccumuloConfiguration conf = SiteConfiguration.getInstance(); instance = new ZooReaderWriter(conf.get(Property.INSTANCE_ZK_HOST), (int) conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), conf.get(Property.INSTANCE_SECRET)); } return instance; }
public static synchronized ZooReaderWriter getInstance() { if (instance == null) { AccumuloConfiguration conf = ServerConfiguration.getSiteConfiguration(); instance = new ZooReaderWriter(conf.get(Property.INSTANCE_ZK_HOST), (int) conf.getTimeInMillis(Property.INSTANCE_ZK_TIMEOUT), conf.get(Property.INSTANCE_SECRET)); } return instance; }
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); } }
Instance instance = conn.getInstance(); ZooReaderWriter zk = new ZooReaderWriter(cluster.getZooKeepers(), 30000, OUR_SECRET); String path = ZooUtil.getRoot(instance) + Constants.ZGC_LOCK; for (int i = 0; i < 5; i++) {
private Multimap<String,String> getLogs(Connector conn) throws Exception { // Map of server to tableId Multimap<TServerInstance,String> serverToTableID = HashMultimap.create(); Scanner scanner = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY); scanner.setRange(MetadataSchema.TabletsSection.getRange()); scanner.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME); for (Entry<Key,Value> entry : scanner) { TServerInstance key = new TServerInstance(entry.getValue(), entry.getKey().getColumnQualifier()); byte[] tableId = KeyExtent.tableOfMetadataRow(entry.getKey().getRow()); serverToTableID.put(key, new String(tableId, UTF_8)); } // Map of logs to tableId Multimap<String,String> logs = HashMultimap.create(); Instance i = conn.getInstance(); ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), ""); WalStateManager wals = new WalStateManager(conn.getInstance(), zk); for (Entry<TServerInstance,List<UUID>> entry : wals.getAllMarkers().entrySet()) { for (UUID id : entry.getValue()) { Pair<WalState,Path> state = wals.state(entry.getKey(), id); for (String tableId : serverToTableID.get(entry.getKey())) { logs.put(state.getSecond().toString(), tableId); } } } return logs; }
private static String rewriteZooKeeperInstance(final Instance inst, String oldPass, String newPass) throws Exception { final ZooReaderWriter orig = new ZooReaderWriter(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), oldPass); final IZooReaderWriter new_ = new ZooReaderWriter(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), newPass); final String newInstanceId = UUID.randomUUID().toString(); String root = ZooUtil.getRoot(inst);
private void killMacGc() throws ProcessNotFoundException, InterruptedException, KeeperException { // kill gc started by MAC getCluster().killProcess(ServerType.GARBAGE_COLLECTOR, getCluster().getProcesses().get(ServerType.GARBAGE_COLLECTOR).iterator().next()); // delete lock in zookeeper if there, this will allow next GC to start quickly String path = ZooUtil.getRoot(new ZooKeeperInstance(getCluster().getClientConfig())) + Constants.ZGC_LOCK; ZooReaderWriter zk = new ZooReaderWriter(cluster.getZooKeepers(), 30000, OUR_SECRET); try { ZooLock.deleteLock(zk, path); } catch (IllegalStateException e) { } assertNull(getCluster().getProcesses().get(ServerType.GARBAGE_COLLECTOR)); }
private static void rewriteZooKeeperInstance(final Instance inst, final String newInstanceId, String oldPass, String newPass) throws Exception { final ZooReaderWriter orig = new ZooReaderWriter(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), oldPass); final IZooReaderWriter new_ = new ZooReaderWriter(inst.getZooKeepers(), inst.getZooKeepersSessionTimeOut(), newPass);
ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), ""); WalStateManager wals = new WalStateManager(i, zk);
attempts = 5; Instance i = conn.getInstance(); ZooReaderWriter zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), ""); while (wals.isEmpty() && attempts > 0) {
zk = new ZooReaderWriter(i.getZooKeepers(), i.getZooKeepersSessionTimeOut(), "");