public TServerInstance(String address, long session) { this(AddressUtil.parseAddress(address, false), Long.toHexString(session)); }
(AddressUtil.getAddressCacheNegativeTtl((UnknownHostException) e) + 1) * 1000);
"Master Client Service Handler", null, Property.MASTER_MINTHREADS, Property.MASTER_THREADCHECK, Property.GENERAL_MAX_MESSAGE_SIZE); clientService = serverPort.server; InetSocketAddress sock = org.apache.accumulo.core.util.AddressUtil.parseAddress(hostname, serverPort.port); String address = org.apache.accumulo.core.util.AddressUtil.toString(sock); log.info("Setting master lock data to " + address); masterLock.replaceLockData(address.getBytes(UTF_8));
public String getClientAddressString() { if (clientAddress == null) return null; return AddressUtil.toString(clientAddress); }
String monitorAddressAndPort = org.apache.accumulo.core.util.AddressUtil.toString(monitorAddress); ZooReaderWriter.getInstance().putPersistentData(ZooUtil.getRoot(instance) + Constants.ZMONITOR_HTTP_ADDR, monitorAddressAndPort.getBytes(UTF_8), NodeExistsPolicy.OVERWRITE); org.apache.accumulo.core.util.AddressUtil.getHostAddress(monitorAddress)); } else { log.warn("Not starting log4j listener as we could not determine address to use");
public String hostPort() { return org.apache.accumulo.core.util.AddressUtil.toString(getLocation()); }
public static HostAndPort parseAddress(String address, int defaultPort) { return parseAddress(address, true).withDefaultPort(defaultPort); }
.getAddressCacheNegativeTtl((UnknownHostException) (exception.getCause())) + 1) * 1000); } else {
public Value asMutationValue() { return new Value(org.apache.accumulo.core.util.AddressUtil.toString(getLocation()).getBytes(UTF_8)); }
public TServerInstance(Value address, Text session) { this(AddressUtil.parseAddress(new String(address.get(), UTF_8), false), session.toString()); }
.getAddressCacheNegativeTtl((UnknownHostException) (exception.getCause())) + 1) * 1000); } else {
boolean holdsLock(InetSocketAddress addr) { try { String zpath = ZooUtil.getRoot(instance) + Constants.ZTSERVERS + "/" + org.apache.accumulo.core.util.AddressUtil.toString(addr); List<String> children = ZooReaderWriter.getInstance().getChildren(zpath); return !(children == null || children.isEmpty()); } catch (KeeperException.NoNodeException ex) { return false; } catch (Exception ex) { log.debug(ex, ex); return true; } }
public HostAndPort getAddress(Service service) { return AddressUtil.parseAddress(getAddressString(service), false); }
log.warn("Unable to connect to HDFS, will retry. cause: " + exception.getCause()); sleep = Math.max(sleep, (AddressUtil.getAddressCacheNegativeTtl((UnknownHostException) (exception.getCause())) + 1) * 1000); } else { log.error("Unable to connect to HDFS and have exceeded max number of retries.", exception);
@Override public void setFutureLocations(Collection<Assignment> assignments) throws DistributedStoreException { if (assignments.size() != 1) throw new IllegalArgumentException("There is only one root tablet"); Assignment assignment = assignments.iterator().next(); if (assignment.tablet.compareTo(Constants.ROOT_TABLET_EXTENT) != 0) throw new IllegalArgumentException("You can only store the root tablet location"); String value = AddressUtil.toString(assignment.server.getLocation()) + "|" + assignment.server.getSession(); Iterator<TabletLocationState> currentIter = iterator(); TabletLocationState current = currentIter.next(); if (current.current != null) { throw new IllegalDSException("Trying to set the root tablet location: it is already set to " + current.current); } store.put(Constants.ZROOT_TABLET_FUTURE_LOCATION, value.getBytes(UTF_8)); }
private Set<TServerInstance> parseServers(String servers) { if (servers == null) return null; // parse "host:port[INSTANCE]" Set<TServerInstance> result = new HashSet<>(); if (servers.length() > 0) { for (String part : servers.split(",")) { String parts[] = part.split("\\[", 2); String hostport = parts[0]; String instance = parts[1]; if (instance != null && instance.endsWith("]")) instance = instance.substring(0, instance.length() - 1); result.add(new TServerInstance(AddressUtil.parseAddress(hostport, false), instance)); } } return result; }
private static void stopTabletServer(Instance instance, final TCredentials creds, List<String> servers, final boolean force) throws AccumuloException, AccumuloSecurityException { for (String server : servers) { InetSocketAddress address = AddressUtil.parseAddress(server, Property.TSERV_CLIENTPORT); final String finalServer = org.apache.accumulo.core.util.AddressUtil.toString(address); log.info("Stopping server " + finalServer); MasterClient.execute(HdfsZooInstance.getInstance(), new ClientExec<MasterClientService.Client>() { @Override public void execute(MasterClientService.Client client) throws Exception { client.shutdownTabletServer(Tracer.traceInfo(), creds, finalServer, force); } }); } } }
TServerInstance find(Map<String,TServerInfo> servers, String tabletServer) { HostAndPort addr; String sessionId = null; if (tabletServer.charAt(tabletServer.length() - 1) == ']') { int index = tabletServer.indexOf('['); if (index == -1) { throw new IllegalArgumentException("Could not parse tabletserver '" + tabletServer + "'"); } addr = AddressUtil.parseAddress(tabletServer.substring(0, index), false); // Strip off the last bracket sessionId = tabletServer.substring(index + 1, tabletServer.length() - 1); } else { addr = AddressUtil.parseAddress(tabletServer, false); } for (Entry<String,TServerInfo> entry : servers.entrySet()) { if (entry.getValue().instance.getLocation().equals(addr)) { // Return the instance if we have no desired session ID, or we match the desired session ID if (sessionId == null || sessionId.equals(entry.getValue().instance.getSession())) return entry.getValue().instance; } } return null; }
@Override public void setLocations(Collection<Assignment> assignments) throws DistributedStoreException { if (assignments.size() != 1) throw new IllegalArgumentException("There is only one root tablet"); Assignment assignment = assignments.iterator().next(); if (assignment.tablet.compareTo(Constants.ROOT_TABLET_EXTENT) != 0) throw new IllegalArgumentException("You can only store the root tablet location"); String value = AddressUtil.toString(assignment.server.getLocation()) + "|" + assignment.server.getSession(); Iterator<TabletLocationState> currentIter = iterator(); TabletLocationState current = currentIter.next(); if (current.current != null) { throw new IllegalDSException("Trying to set the root tablet location: it is already set to " + current.current); } if (!current.future.equals(assignment.server)) { throw new IllegalDSException("Root tablet is already assigned to " + current.future); } store.put(Constants.ZROOT_TABLET_LOCATION, value.getBytes(UTF_8)); store.put(Constants.ZROOT_TABLET_LAST_LOCATION, value.getBytes(UTF_8)); // Make the following unnecessary by making the entire update atomic store.remove(Constants.ZROOT_TABLET_FUTURE_LOCATION); log.debug("Put down root tablet location"); }
/** * Generates a recovery tserver list * * @return Recovery tserver list */ @Path("recovery") @GET public TabletServersRecovery getTserverRecovery() { TabletServersRecovery recoveryList = new TabletServersRecovery(); MasterMonitorInfo mmi = Monitor.getMmi(); if (mmi == null) { throw new WebApplicationException(Status.INTERNAL_SERVER_ERROR); } for (TabletServerStatus server : mmi.tServerInfo) { if (server.logSorts != null) { for (RecoveryStatus recovery : server.logSorts) { String serv = AddressUtil.parseAddress(server.name, false).getHost(); String log = recovery.name; int time = recovery.runtime; double progress = recovery.progress; recoveryList.addRecovery(new TabletServerRecoveryInformation(serv, log, time, progress)); } } } return recoveryList; }