use of com.linkedin.r2.transport.common.Server in project rest.li by linkedin.
the class TestCompressionEcho method tearDown.
@Override
protected void tearDown(Client client, Server server) throws Exception {
for (Client compressionClient : _clients) {
final FutureCallback<None> clientShutdownCallback = new FutureCallback<>();
compressionClient.shutdown(clientShutdownCallback);
clientShutdownCallback.get();
}
super.tearDown(client, server);
}
use of com.linkedin.r2.transport.common.Server in project rest.li by linkedin.
the class TestGeneralEchoServiceTest method testFilterChainOnException.
@Test
public void testFilterChainOnException() throws Exception {
final EchoService client = getEchoClient(_client, URI.create("/unknown-service"));
final String msg = "This is a simple echo message";
final FutureCallback<String> callback = new FutureCallback<>();
client.echo(msg, callback);
try {
callback.get();
Assert.fail("Should have thrown an exception");
} catch (Exception e) {
// expected
}
// Make sure the server got its wire attribute
Assert.assertEquals(_serverCaptureFilter.getRequest().get(_toServerKey), _toServerValue);
// Make sure the client got its wire attribute, but not the server's wire attribute
Assert.assertEquals(_clientCaptureFilter.getResponse().get(_toClientKey), _toClientValue);
Assert.assertNull(_clientCaptureFilter.getResponse().get(_toServerKey));
}
use of com.linkedin.r2.transport.common.Server in project rest.li by linkedin.
the class Https2JettyServerProvider method createServer.
@Override
public Server createServer(ServerCreationContext context) {
int sslPort = context.getPort();
int httpPort = SslContextUtil.getHttpPortFromHttps(sslPort);
return new HttpServerFactory(context.getFilterChain()).createHttpsH2cServer(httpPort, sslPort, SslContextUtil.KEY_STORE, SslContextUtil.KEY_STORE_PASSWORD, context.getContextPath(), context.getThreadPoolSize(), context.getTransportDispatcher(), _servletType, context.getServerTimeout(), _serverROS);
}
use of com.linkedin.r2.transport.common.Server in project rest.li by linkedin.
the class TestLatencyInstrumentation method checkTimingKeyConsistency.
/**
* Ensures that the set of recorded timing keys is "consistent", meaning that for any code path (denoted by key "A")
* which is a subset of another code path (denoted by key "B"), the duration of key A must be less than that of key B.
*/
private void checkTimingKeyConsistency() {
ArrayList<Map.Entry<TimingKey, TimingContextUtil.TimingContext>> entrySet = new ArrayList<>(_resultMap.entrySet());
int size = entrySet.size();
// (e.g. duration of "fwk/server/response" > duration of "fwk/server/response/restli")
for (int i = 0; i < size; i++) {
TimingKey keyA = entrySet.get(i).getKey();
if (!keyA.getName().contains(FrameworkTimingKeys.KEY_PREFIX)) {
continue;
}
for (int j = 0; j < size; j++) {
TimingKey keyB = entrySet.get(j).getKey();
if (i == j || !keyB.getName().contains(FrameworkTimingKeys.KEY_PREFIX)) {
continue;
}
if (keyA.getName().contains(keyB.getName())) {
TimingContextUtil.TimingContext contextA = entrySet.get(i).getValue();
TimingContextUtil.TimingContext contextB = entrySet.get(j).getValue();
String message = String.format("Expected %s (%.2fms) < %s (%.2fms)", keyA, contextA.getDurationNano() * NANOS_TO_MILLIS, keyB, contextB.getDurationNano() * NANOS_TO_MILLIS);
Assert.assertTrue(contextA.getDurationNano() < contextB.getDurationNano(), message);
}
}
}
}
use of com.linkedin.r2.transport.common.Server in project rest.li by linkedin.
the class TestLatencyInstrumentation method beforeMethod.
@BeforeMethod
public void beforeMethod(Object[] args) throws Exception {
_countDownLatch = new CountDownLatch(1);
_useStreaming = (boolean) args[0];
_timingImportanceThreshold = (TimingImportance) args[3];
final InstrumentationTrackingFilter instrumentationTrackingFilter = new InstrumentationTrackingFilter();
final FilterChain filterChain = FilterChains.empty().addFirst(instrumentationTrackingFilter).addFirstRest(instrumentationTrackingFilter);
// System.setProperty("test.useStreamCodecServer", "true"); // Uncomment this to test with server streaming codec in IDEA
super.init(Collections.emptyList(), filterChain, false);
}
Aggregations