@Override public String toString() { return tsi.toString(); }
@Override public int hashCode() { return toString().hashCode(); }
public static void setCurrentServers(IteratorSetting cfg, Set<TServerInstance> goodServers) { if (goodServers != null) { List<String> servers = new ArrayList<>(); for (TServerInstance server : goodServers) servers.add(server.toString()); cfg.addOption(SERVERS_OPTION, Joiner.on(",").join(servers)); } }
public static void setShuttingDown(IteratorSetting cfg, Set<TServerInstance> servers) { if (servers != null) { List<String> serverList = new ArrayList<>(); for (TServerInstance server : servers) { serverList.add(server.toString()); } cfg.addOption(SHUTTING_DOWN_OPTION, Joiner.on(",").join(servers)); } }
@Override public String toString() { return tsi.toString(); }
@Override public int hashCode() { return toString().hashCode(); }
@Override public int hashCode() { return toString().hashCode(); }
public static void setShuttingDown(IteratorSetting cfg, Set<TServerInstance> servers) { if (servers != null) { List<String> serverList = new ArrayList<>(); for (TServerInstance server : servers) { serverList.add(server.toString()); } cfg.addOption(SHUTTING_DOWN_OPTION, Joiner.on(",").join(servers)); } }
public static void setCurrentServers(IteratorSetting cfg, Set<TServerInstance> goodServers) { if (goodServers != null) { List<String> servers = new ArrayList<>(); for (TServerInstance server : goodServers) servers.add(server.toString()); cfg.addOption(SERVERS_OPTION, Joiner.on(",").join(servers)); } }
public static void setCurrentServers(IteratorSetting cfg, Set<TServerInstance> goodServers) { if (goodServers != null) { List<String> servers = new ArrayList<String>(); for (TServerInstance server : goodServers) servers.add(server.toString()); cfg.addOption(SERVERS_OPTION, StringUtil.join(servers, ",")); } }
public void removeWalMarker(TServerInstance instance, UUID uuid) throws WalMarkerException { try { log.debug("Removing {}", uuid); String path = root() + "/" + instance.toString() + "/" + uuid.toString(); zoo.delete(path, -1); } catch (InterruptedException | KeeperException e) { throw new WalMarkerException(e); } }
private void updateState(TServerInstance tsi, Path path, WalState state) throws WalMarkerException { byte[] data = (state.toString() + "," + path.toString()).getBytes(UTF_8); try { NodeExistsPolicy policy = NodeExistsPolicy.OVERWRITE; if (state == WalState.OPEN) { policy = NodeExistsPolicy.FAIL; } log.debug("Setting {} to {}", path.getName(), state); zoo.putPersistentData(root() + "/" + tsi.toString() + "/" + path.getName(), data, policy); } catch (KeeperException | InterruptedException e) { throw new WalMarkerException(e); } }
public void initWalMarker(TServerInstance tsi) throws WalMarkerException { byte[] data = new byte[0]; try { zoo.putPersistentData(root() + "/" + tsi.toString(), data, NodeExistsPolicy.FAIL); } catch (KeeperException | InterruptedException e) { throw new WalMarkerException(e); } }
public Pair<WalState,Path> state(TServerInstance instance, UUID uuid) throws WalMarkerException { try { String path = root() + "/" + instance.toString() + "/" + uuid.toString(); return parse(zoo.getData(path, null)); } catch (KeeperException | InterruptedException e) { throw new WalMarkerException(e); } }
public void forget(TServerInstance instance) throws WalMarkerException { String path = root() + "/" + instance.toString(); try { zoo.recursiveDelete(path, NodeMissingPolicy.FAIL); } catch (InterruptedException | KeeperException e) { throw new WalMarkerException(e); } }
private Table<String,String,MutableInt> getCounts(Connector conn, String tablename) throws TableNotFoundException { Scanner s = conn.createScanner(MetadataTable.NAME, Authorizations.EMPTY); s.fetchColumnFamily(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME); String tableId = conn.tableOperations().tableIdMap().get(tablename); s.setRange(MetadataSchema.TabletsSection.getRange(tableId)); Table<String,String,MutableInt> groupLocationCounts = HashBasedTable.create(); for (Entry<Key,Value> entry : s) { String group = entry.getKey().getRow().toString(); if (group.endsWith("<")) { group = "03"; } else { group = group.substring(tableId.length() + 1).substring(0, 2); } String loc = new TServerInstance(entry.getValue(), entry.getKey().getColumnQualifier()) .toString(); MutableInt count = groupLocationCounts.get(group, loc); if (count == null) { count = new MutableInt(0); groupLocationCounts.put(group, loc, count); } count.increment(); } return groupLocationCounts; } }
public List<Path> getWalsInUse(TServerInstance tsi) throws WalMarkerException { List<Path> result = new ArrayList<>(); try { String zpath = root() + "/" + tsi.toString(); zoo.sync(zpath); for (String child : zoo.getChildren(zpath)) { Pair<WalState,Path> parts = parse(zoo.getData(zpath + "/" + child, null)); if (parts.getFirst() != WalState.UNREFERENCED) { result.add(parts.getSecond()); } } } catch (KeeperException.NoNodeException e) { log.debug("{} has no wal entry in zookeeper, assuming no logs", tsi); } catch (KeeperException | InterruptedException e) { throw new WalMarkerException(e); } return result; }