public String getClientAddressString() { if (clientAddress == null) return null; return clientAddress.getHost() + ":" + clientAddress.getPort(); }
public String host() { return getLocation().getHost(); }
private void addToQueue(HostAndPort server, KeyExtent extent, Map<String,MapFileInfo> thriftImports) { if (!thriftImports.isEmpty()) { loadMsgs.increment(server, 1); Map<String,MapFileInfo> prev = loadQueue.computeIfAbsent(server, k -> new HashMap<>()) .putIfAbsent(extent.toThrift(), thriftImports); Preconditions.checkState(prev == null, "Unexpectedly saw extent %s twice", extent); // keep a very rough estimate of how much is memory so we can send if over a few megs is // buffered queuedDataSize += thriftImports.keySet().stream().mapToInt(String::length).sum() + server.getHost().length() + 4 + thriftImports.size() * 32; } }
/** * Creates a Thrift TTransport to the given address with the given timeout. All created resources * are closed if an exception is thrown. * * @param addr * The address to connect the client to * @param timeoutMillis * The timeout in milliseconds for the connection * @return A TTransport connected to the given <code>addr</code> * @throws IOException * If the transport fails to be created/connected */ public static TTransport create(HostAndPort addr, long timeoutMillis) throws IOException { return INSTANCE.createInternal(new InetSocketAddress(addr.getHost(), addr.getPort()), timeoutMillis); }
private void addBlocks(VolumeManager fs, String host, ArrayList<String> files, Map<String,Long> totalBlocks, Map<String,Long> localBlocks) throws Exception { long allBlocks = 0; long matchingBlocks = 0; if (!totalBlocks.containsKey(host)) { totalBlocks.put(host, 0L); localBlocks.put(host, 0L); } for (String file : files) { Path filePath = new Path(file); FileSystem ns = fs.getVolumeByPath(filePath).getFileSystem(); FileStatus fileStatus = ns.getFileStatus(filePath); BlockLocation[] fileBlockLocations = ns.getFileBlockLocations(fileStatus, 0, fileStatus.getLen()); for (BlockLocation blockLocation : fileBlockLocations) { allBlocks++; for (String location : blockLocation.getHosts()) { HostAndPort hap = HostAndPort.fromParts(location, 0); if (hap.getHost().equals(host)) { matchingBlocks++; break; } } } } totalBlocks.put(host, allBlocks + totalBlocks.get(host)); localBlocks.put(host, matchingBlocks + localBlocks.get(host)); }
/** * 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; }
/** * Creates a TThreadPoolServer for normal unsecure operation. Useful for comparing performance * against SSL or SASL transports. * * @param address * Address to bind to * @param processor * TProcessor for the server * @param maxMessageSize * Maximum size of a Thrift message allowed * @return A configured TThreadPoolServer and its bound address information */ public static ServerAddress createBlockingServer(HostAndPort address, TProcessor processor, TProtocolFactory protocolFactory, long maxMessageSize, String serverName, int numThreads, int numSimpleTimerThreads, long timeBetweenThreadChecks) throws TTransportException { InetSocketAddress isa = new InetSocketAddress(address.getHost(), address.getPort()); // Must use an ISA, providing only a port would ignore the hostname given TServerSocket transport = new TServerSocket(isa); ThreadPoolExecutor pool = createSelfResizingThreadPool(serverName, numThreads, numSimpleTimerThreads, timeBetweenThreadChecks); TThreadPoolServer server = createTThreadPoolServer(transport, processor, ThriftUtil.transportFactory(maxMessageSize), protocolFactory, pool); if (address.getPort() == 0) { address = HostAndPort.fromParts(address.getHost(), transport.getServerSocket().getLocalPort()); log.info("Blocking Server bound on {}", address); } return new ServerAddress(server, address); }
try { transport = getSslServerSocket(address.getPort(), (int) socketTimeout, InetAddress.getByName(address.getHost()), sslParams); } catch (UnknownHostException e) { throw new TTransportException(e); address = HostAndPort.fromParts(address.getHost(), transport.getServerSocket().getLocalPort()); log.info("SSL Thread Pool Server bound on {}", address);
@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; } }
log.info("Creating SASL thread pool thrift server on listening on {}:{}", address.getHost(), address.getPort()); InetSocketAddress isa = new InetSocketAddress(address.getHost(), address.getPort()); hostname = InetAddress.getByName(address.getHost()).getCanonicalHostName(); fqdn = InetAddress.getLocalHost().getCanonicalHostName(); } catch (UnknownHostException e) { address = HostAndPort.fromParts(address.getHost(), transport.getServerSocket().getLocalPort()); log.info("SASL thrift server bound on {}", address);
? Property.TSERV_MAX_MESSAGE_SIZE : Property.GENERAL_MAX_MESSAGE_SIZE); ServerAddress sp = TServerUtils.startServer(context, clientAddress.getHost(), Property.REPLICATION_RECEIPT_SERVICE_PORT, processor, "ReplicationServicerHandler", "Replication Servicer", Property.TSERV_PORTSEARCH, Property.REPLICATION_MIN_THREADS,
: AddressUtil.parseAddress(masters.get(0), false).getHost(); Integer onlineTabletServers = mmi.tServerInfo.size(); Integer totalTabletServers = tservers.size();
transport = TSSLTransportFactory.getClientSocket(address.getHost(), address.getPort(), timeout); } else { transport = createClient(wrappingSslSockFactory, address.getHost(), address.getPort(), timeout); log.trace("Creating SASL connection to {}:{}", address.getHost(), address.getPort()); final String hostname = InetAddress.getByName(address.getHost()).getCanonicalHostName(); log.trace("Opening normal transport"); if (timeout == 0) { transport = new TSocket(address.getHost(), address.getPort()); transport.open(); } else {
private HostAndPort startTabletClientService() throws UnknownHostException { // start listening for client connection last clientHandler = new ThriftClientHandler(); Iface rpcProxy = TraceWrap.service(clientHandler); final Processor<Iface> processor; if (context.getThriftServerType() == ThriftServerType.SASL) { Iface tcredProxy = TCredentialsUpdatingWrapper.service(rpcProxy, ThriftClientHandler.class, getConfiguration()); processor = new Processor<>(tcredProxy); } else { processor = new Processor<>(rpcProxy); } HostAndPort address = startServer(context.getServerConfFactory().getSystemConfiguration(), clientAddress.getHost(), Property.TSERV_CLIENTPORT, processor, "Thrift Client Server"); log.info("address = {}", address); return address; }
/** * Create a NonBlockingServer with a custom thread pool that can dynamically resize itself. */ public static ServerAddress createNonBlockingServer(HostAndPort address, TProcessor processor, TProtocolFactory protocolFactory, final String serverName, final int numThreads, final int numSTThreads, long timeBetweenThreadChecks, long maxMessageSize) throws TTransportException { final TNonblockingServerSocket transport = new TNonblockingServerSocket( new InetSocketAddress(address.getHost(), address.getPort())); final CustomNonBlockingServer.Args options = new CustomNonBlockingServer.Args(transport); options.protocolFactory(protocolFactory); options.transportFactory(ThriftUtil.transportFactory(maxMessageSize)); options.maxReadBufferBytes = maxMessageSize; options.stopTimeoutVal(5); // Create our own very special thread pool. ThreadPoolExecutor pool = createSelfResizingThreadPool(serverName, numThreads, numSTThreads, timeBetweenThreadChecks); options.executorService(pool); options.processorFactory(new TProcessorFactory(processor)); if (address.getPort() == 0) { address = HostAndPort.fromParts(address.getHost(), transport.getPort()); } return new ServerAddress(new CustomNonBlockingServer(options), address); }
if (serverAddress.address.getHost().equals("0.0.0.0")) {
public String getClientAddressString() { if (clientAddress == null) return null; return clientAddress.getHost() + ":" + clientAddress.getPort(); }
public String getReplicationAddressSTring() { if (null == replicationAddress) { return null; } return replicationAddress.getHost() + ":" + replicationAddress.getPort(); }
@Override protected String getTitle(HttpServletRequest req) { List<String> masters = Monitor.getContext().getInstance().getMasterLocations(); return "Master Server" + (masters.size() == 0 ? "" : ":" + AddressUtil.parseAddress(masters.get(0), false).getHost()); }
private void doDetailTable(HttpServletRequest req, StringBuilder sb, HostAndPort address, int numTablets, TabletStats total, TabletStats historical) { Table detailTable = new Table("tServerDetail", "Details"); detailTable.setSubCaption(address.getHost() + ":" + address.getPort()); detailTable.addSortableColumn("Hosted Tablets", new NumberType<Integer>(), null); detailTable.addSortableColumn("Entries", new NumberType<Long>(), null); detailTable.addSortableColumn("Minor Compacting", new NumberType<Integer>(), null); detailTable.addSortableColumn("Major Compacting", new NumberType<Integer>(), null); detailTable.addSortableColumn("Splitting", new NumberType<Integer>(), null); detailTable.addRow(numTablets, total.numEntries, total.minors.status, total.majors.status, historical.splits.status); detailTable.generate(req, sb); }