@Override public void run() { try { TabletServerMutations<QCMutation> mutations = dequeue(location); if (mutations != null) sendToServer(HostAndPort.fromString(location), mutations); } finally { reschedule(this); } } }
public AssignmentTask(Map<Path,List<KeyExtent>> assignmentFailures, String location, Map<KeyExtent,List<PathSize>> assignmentsPerTablet) { this.assignmentFailures = assignmentFailures; this.location = HostAndPort.fromString(location); this.assignmentsPerTablet = assignmentsPerTablet; }
public HostAndPort getHostAndPort() { return HostAndPort.fromString(server); }
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); location = HostAndPort.fromString(in.readObject().toString()); }
private HostAndPort getMasterAddress() { try { List<String> locations = context.getMasterLocations(); if (locations.size() == 0) return null; return HostAndPort.fromString(locations.get(0)); } catch (Exception e) { log.warn("Failed to obtain master host " + e); } return null; }
public static HostAndPort parseAddress(String address, boolean ignoreMissingPort) throws NumberFormatException { address = address.replace('+', ':'); HostAndPort hap = HostAndPort.fromString(address); if (!ignoreMissingPort && !hap.hasPort()) throw new IllegalArgumentException( "Address was expected to contain port. address=" + address); return hap; }
protected TServerInstance parse(byte[] current) { String str = new String(current, UTF_8); String[] parts = str.split("[|]", 2); HostAndPort address = HostAndPort.fromString(parts[0]); if (parts.length > 1 && parts[1] != null && parts[1].length() > 0) { return new TServerInstance(address, parts[1]); } else { // a 1.2 location specification: DO NOT WANT return null; } }
public TServerInstance(String formattedString) { int pos = formattedString.indexOf("["); if (pos < 0 || !formattedString.endsWith("]")) { throw new IllegalArgumentException(formattedString); } this.location = HostAndPort.fromString(formattedString.substring(0, pos)); this.session = formattedString.substring(pos + 1, formattedString.length() - 1); this.cachedStringRepresentation = hostPort() + "[" + session + "]"; }
public static SuspendingTServer fromValue(Value value) { String valStr = value.toString(); String[] parts = valStr.split("[|]", 2); return new SuspendingTServer(HostAndPort.fromString(parts[0]), Long.parseLong(parts[1])); }
/** * Build a HostAndPort instance from separate host and port values. * * <p> * Note: Non-bracketed IPv6 literals are allowed. Use #requireBracketsForIPv6() to prohibit these. * * @param host * the host string to parse. Must not contain a port number. * @param port * a port number from [0..65535] * @return if parsing was successful, a populated HostAndPort object. * @throws IllegalArgumentException * if {@code host} contains a port number, or {@code port} is out of range. */ public static HostAndPort fromParts(String host, int port) { checkArgument(isValidPort(port), "Port out of range: %s", port); HostAndPort parsedHost = fromString(host); checkArgument(!parsedHost.hasPort(), "Host has a port: %s", host); return new HostAndPort(parsedHost.host, port, parsedHost.hasBracketlessColons); }
public static MasterClientService.Client getConnection(ClientContext context) { checkArgument(context != null, "context is null"); List<String> locations = context.getMasterLocations(); if (locations.size() == 0) { log.debug("No masters..."); return null; } HostAndPort master = HostAndPort.fromString(locations.get(0)); if (master.getPort() == 0) return null; try { // Master requests can take a long time: don't ever time out return ThriftUtil.getClientNoTimeout(new MasterClientService.Client.Factory(), master, context); } catch (TTransportException tte) { Throwable cause = tte.getCause(); if (cause != null && cause instanceof UnknownHostException) { // do not expect to recover from this throw new RuntimeException(tte); } log.debug("Failed to connect to master=" + master + ", will retry... ", tte); return null; } }
public static void fetchScans() throws Exception { if (context == null) return; for (String server : context.instanceOperations().getTabletServers()) { final HostAndPort parsedServer = HostAndPort.fromString(server); Client tserver = ThriftUtil.getTServerClient(parsedServer, context); try { List<ActiveScan> scans = tserver.getActiveScans(null, context.rpcCreds()); synchronized (allScans) { allScans.put(parsedServer, new ScanStats(scans)); } } catch (Exception ex) { log.debug("Failed to get active scans from {}", server, ex); } finally { ThriftUtil.returnClient(tserver); } } // Age off old scan information Iterator<Entry<HostAndPort,ScanStats>> entryIter = allScans.entrySet().iterator(); long now = System.currentTimeMillis(); while (entryIter.hasNext()) { Entry<HostAndPort,ScanStats> entry = entryIter.next(); if (now - entry.getValue().fetched > 5 * 60 * 1000) { entryIter.remove(); } } }
static void close(ScanState scanState) { if (!scanState.finished && scanState.scanID != null && scanState.prevLoc != null) { TInfo tinfo = Tracer.traceInfo(); log.debug("Closing active scan {} {}", scanState.prevLoc, scanState.scanID); HostAndPort parsedLocation = HostAndPort.fromString(scanState.prevLoc.tablet_location); TabletClientService.Client client = null; try { client = ThriftUtil.getTServerClient(parsedLocation, scanState.context); client.closeScan(tinfo, scanState.scanID); } catch (TException e) { // ignore this is a best effort log.debug("Failed to close active scan " + scanState.prevLoc + " " + scanState.scanID, e); } finally { if (client != null) ThriftUtil.returnClient(client); } } } }
HostAndPort location = HostAndPort.fromString(entry.getKey()); Map<String,List<TRowRange>> allFiles = entry.getValue();
/** * Generates a new JSON object with scan information * * @return Scan JSON object */ @GET public Scans getTables() { Scans scans = new Scans(); Map<HostAndPort,ScanStats> entry = Monitor.getScans(); // Adds new scans to the array for (TabletServerStatus tserverInfo : Monitor.getMmi().getTServerInfo()) { ScanStats stats = entry.get(HostAndPort.fromString(tserverInfo.name)); if (stats != null) { scans.addScan(new ScanInformation(tserverInfo, stats.scanCount, stats.oldestScan)); } } return scans; } }
HostAndPort coordinatorAddr = HostAndPort.fromString(replCoordinatorAddr);
final HostAndPort parsedLocation = HostAndPort.fromString(tabLoc.tablet_location); try { updateServer(context, m, tabLoc.tablet_extent, parsedLocation);
@Override public AppenderSkeleton apply(MonitorLocation loc) { int defaultPort = Integer.parseUnsignedInt(Property.MONITOR_LOG4J_PORT.getDefaultValue()); HostAndPort remote = HostAndPort.fromString(loc.getLocation()); SocketAppender socketAppender = new SocketAppender(); socketAppender.setApplication(System.getProperty("accumulo.application", "unknown")); socketAppender.setRemoteHost(remote.getHost()); socketAppender.setPort(remote.getPortOrDefault(defaultPort)); return socketAppender; } }
@Override public List<ActiveCompaction> getActiveCompactions(String tserver) throws AccumuloException, AccumuloSecurityException { final HostAndPort parsedTserver = HostAndPort.fromString(tserver); Client client = null; try { client = ThriftUtil.getTServerClient(parsedTserver, context); List<ActiveCompaction> as = new ArrayList<>(); for (org.apache.accumulo.core.tabletserver.thrift.ActiveCompaction activeCompaction : client .getActiveCompactions(Tracer.traceInfo(), context.rpcCreds())) { as.add(new ActiveCompactionImpl(context, activeCompaction)); } return as; } catch (TTransportException e) { throw new AccumuloException(e); } catch (ThriftSecurityException e) { throw new AccumuloSecurityException(e.user, e.code, e); } catch (TException e) { throw new AccumuloException(e); } finally { if (client != null) ThriftUtil.returnClient(client); } }
@Override public List<ActiveScan> getActiveScans(String tserver) throws AccumuloException, AccumuloSecurityException { final HostAndPort parsedTserver = HostAndPort.fromString(tserver); Client client = null; try { client = ThriftUtil.getTServerClient(parsedTserver, context); List<ActiveScan> as = new ArrayList<>(); for (org.apache.accumulo.core.tabletserver.thrift.ActiveScan activeScan : client .getActiveScans(Tracer.traceInfo(), context.rpcCreds())) { try { as.add(new ActiveScanImpl(context, activeScan)); } catch (TableNotFoundException e) { throw new AccumuloException(e); } } return as; } catch (TTransportException e) { throw new AccumuloException(e); } catch (ThriftSecurityException e) { throw new AccumuloSecurityException(e.user, e.code, e); } catch (TException e) { throw new AccumuloException(e); } finally { if (client != null) ThriftUtil.returnClient(client); } }