use of java.net.InetSocketAddress in project grpc-java by grpc.
the class StressTestClient method runStressTest.
@VisibleForTesting
void runStressTest() throws Exception {
Preconditions.checkState(!shutdown, "client was shutdown.");
if (testCaseWeightPairs.isEmpty()) {
return;
}
int numChannels = addresses.size() * channelsPerServer;
int numThreads = numChannels * stubsPerChannel;
threadpool = MoreExecutors.listeningDecorator(newFixedThreadPool(numThreads));
int serverIdx = -1;
for (InetSocketAddress address : addresses) {
serverIdx++;
for (int i = 0; i < channelsPerServer; i++) {
ManagedChannel channel = createChannel(address);
channels.add(channel);
for (int j = 0; j < stubsPerChannel; j++) {
String gaugeName = String.format("/stress_test/server_%d/channel_%d/stub_%d/qps", serverIdx, i, j);
Worker worker = new Worker(channel, testCaseWeightPairs, durationSecs, gaugeName);
workerFutures.add(threadpool.submit(worker));
}
}
}
}
use of java.net.InetSocketAddress in project grpc-java by grpc.
the class StressTestClient method serverAddressesToString.
private static String serverAddressesToString(List<InetSocketAddress> addresses) {
List<String> tmp = new ArrayList<String>();
for (InetSocketAddress address : addresses) {
URI uri;
try {
uri = new URI(null, null, address.getHostName(), address.getPort(), null, null, null);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
tmp.add(uri.getAuthority());
}
return Joiner.on(',').join(tmp);
}
use of java.net.InetSocketAddress in project grpc-java by grpc.
the class NettyFlowControlTest method resetConnection.
/**
* Resets client/server and their flow control windows.
*/
private void resetConnection(int clientFlowControlWindow) throws InterruptedException {
if (channel != null) {
if (!channel.isShutdown()) {
channel.shutdown();
channel.awaitTermination(100, TimeUnit.MILLISECONDS);
}
}
channel = NettyChannelBuilder.forAddress(new InetSocketAddress("localhost", proxyPort)).flowControlWindow(clientFlowControlWindow).negotiationType(NegotiationType.PLAINTEXT).build();
}
use of java.net.InetSocketAddress in project grpc-java by grpc.
the class StressTestClientTest method ipv6AddressesShouldBeSupported.
@Test
public void ipv6AddressesShouldBeSupported() {
StressTestClient client = new StressTestClient();
client.parseArgs(new String[] { "--server_addresses=[0:0:0:0:0:0:0:1]:8080," + "[1:2:3:4:f:e:a:b]:8083" });
assertEquals(2, client.addresses().size());
assertEquals(new InetSocketAddress("0:0:0:0:0:0:0:1", 8080), client.addresses().get(0));
assertEquals(new InetSocketAddress("1:2:3:4:f:e:a:b", 8083), client.addresses().get(1));
}
use of java.net.InetSocketAddress in project grpc-java by grpc.
the class NettyServerTest method getPort.
@Test
public void getPort() throws Exception {
InetSocketAddress addr = new InetSocketAddress(0);
NettyServer ns = new NettyServer(addr, NioServerSocketChannel.class, // no boss group
null, // no event group
null, new ProtocolNegotiators.PlaintextNegotiator(), // ignore
1, // ignore
1, // ignore
1, // ignore
1);
ns.start(new ServerListener() {
@Override
public ServerTransportListener transportCreated(ServerTransport transport) {
return null;
}
@Override
public void serverShutdown() {
}
});
// Check that we got an actual port.
assertThat(ns.getPort()).isGreaterThan(0);
// Cleanup
ns.shutdown();
}
Aggregations