/** * * @param hostname * name of the host * @param ports * array of ports * @return array of HostAndPort objects */ public static HostAndPort[] getHostAndPorts(String hostname, int[] ports) { HostAndPort[] addresses = new HostAndPort[ports.length]; for (int i = 0; i < ports.length; i++) { addresses[i] = HostAndPort.fromParts(hostname, ports[i]); } return addresses; }
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)); }
/** * 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); }
address = HostAndPort.fromParts(address.getHost(), transport.getServerSocket().getLocalPort()); log.info("SSL Thread Pool Server bound on {}", address);
.fromParts(InetAddress.getLocalHost().getHostName(), serverAddress.address.getPort())); } catch (UnknownHostException e) { throw new TTransportException(e);
address = HostAndPort.fromParts(address.getHost(), transport.getServerSocket().getLocalPort()); log.info("SASL thrift server bound on {}", address);
String monitorAddress = HostAndPort.fromParts(advertiseHost, server.getPort()).toString(); context.getZooReaderWriter().putPersistentData( context.getZooKeeperRoot() + Constants.ZMONITOR_HTTP_ADDR, monitorAddress.getBytes(UTF_8),
/** * * @param hostname * name of the host * @param ports * array of ports * @return array of HostAndPort objects */ public static HostAndPort[] getHostAndPorts(String hostname, int[] ports) { HostAndPort[] addresses = new HostAndPort[ports.length]; for (int i = 0; i < ports.length; i++) { addresses[i] = HostAndPort.fromParts(hostname, ports[i]); } return addresses; }
majorCompactorThread.start(); clientAddress = HostAndPort.fromParts(context.getHostname(), 0); try { AccumuloVFSClassLoader.getContextManager()
/** * 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); }
HostAndPort addr = HostAndPort.fromParts(hostname, port); return TServerUtils.startTServer(serverType, timedProcessor, serverName, threadName, minThreads, simpleTimerThreadpoolSize, timeBetweenThreadChecks, maxMessageSize,
@BeforeClass public static void setup() throws Exception { Properties prop = new Properties(); prop.setProperty("useMockInstance", "true"); prop.put("tokenClass", PasswordToken.class.getName()); proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port), new TCompactProtocol.Factory(), prop).server; log.info("Waiting for proxy to start"); while (!proxy.isServing()) { Thread.sleep(500); } log.info("Proxy started"); tpc = new TestProxyClient("localhost", port); userpass = tpc.proxy.login("root", Collections.singletonMap("password", "")); }
@BeforeClass public static void setup() throws Exception { Properties prop = new Properties(); prop.setProperty("useMockInstance", "true"); prop.put("tokenClass", PasswordToken.class.getName()); proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port), new TCompactProtocol.Factory(), prop).server; tpc = new TestProxyClient("localhost", port); userpass = tpc.proxy().login("root", Collections.singletonMap("password", "")); }
@BeforeClass public static void setup() throws Exception { Properties prop = new Properties(); prop.setProperty("useMockInstance", "true"); prop.put("tokenClass", PasswordToken.class.getName()); proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port), new TCompactProtocol.Factory(), prop).server; while (!proxy.isServing()) { Thread.sleep(500); } tpc = new TestProxyClient("localhost", port); userpass = tpc.proxy().login("root", Collections.singletonMap("password", "")); }
@BeforeClass public static void setup() throws Exception { Properties prop = new Properties(); prop.setProperty("useMockInstance", "true"); prop.put("tokenClass", PasswordToken.class.getName()); proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port), new TCompactProtocol.Factory(), prop).server; while (!proxy.isServing()) { Thread.sleep(500); } tpc = new TestProxyClient("localhost", port); userpass = tpc.proxy().login("root", Collections.singletonMap("password", "")); }
@BeforeClass public static void setup() throws Exception { Properties prop = new Properties(); prop.setProperty("useMockInstance", "true"); prop.put("tokenClass", PasswordToken.class.getName()); proxy = Proxy.createProxyServer(HostAndPort.fromParts("localhost", port), new TCompactProtocol.Factory(), prop).server; while (!proxy.isServing()) { Thread.sleep(500); } tpc = new TestProxyClient("localhost", port); userpass = tpc.proxy().login("root", Collections.singletonMap("password", "")); }
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)); }
/** * Creates a TTheadPoolServer 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 { TServerSocket transport = new TServerSocket(address.getPort()); 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); }
/** * 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, String threadName, 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); }