use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class RouterPathTest method testUserServicePath.
@Test
public void testUserServicePath() {
String path = "/v3/namespaces/n1/apps/a1/services/s1/methods/m1";
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), path);
RouteDestination result = pathLookup.getRoutingService(FALLBACKSERVICE, path, httpRequest);
Assert.assertEquals(ServiceDiscoverable.getName("n1", "a1", "s1"), result.getServiceName());
Assert.assertTrue(ServiceDiscoverable.isServiceDiscoverable(result.getServiceName()));
Assert.assertNull(result.getVersion());
path = "/v3/namespaces/n1/apps/a1/versions/v1/services/s1/methods/m1";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), path);
result = pathLookup.getRoutingService(FALLBACKSERVICE, path, httpRequest);
Assert.assertEquals(ServiceDiscoverable.getName("n1", "a1", "s1"), result.getServiceName());
Assert.assertTrue(ServiceDiscoverable.isServiceDiscoverable(result.getServiceName()));
Assert.assertEquals("v1", result.getVersion());
}
use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class RouterPathTest method testRouterFlowPathLookUp.
@Test
public void testRouterFlowPathLookUp() throws Exception {
String flowPath = "/v3/namespaces/default//apps/ResponseCodeAnalytics/flows/LogAnalyticsFlow/status";
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), flowPath);
RouteDestination result = pathLookup.getRoutingService(FALLBACKSERVICE, flowPath, httpRequest);
Assert.assertEquals(RouterPathLookup.APP_FABRIC_HTTP, result);
}
use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class RouterPathTest method testMetricsPath.
private void testMetricsPath(String path) {
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), path);
RouteDestination result = pathLookup.getRoutingService(FALLBACKSERVICE, path, httpRequest);
Assert.assertEquals(RouterPathLookup.METRICS, result);
}
use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class DefaultStreamManager method send.
@Override
public void send(File file, String contentType) throws Exception {
String path = String.format("/v3/namespaces/%s/streams/%s/batch", streamId.getNamespaceId(), streamId.getId());
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, path);
request.setHeader(HttpHeaders.Names.CONTENT_TYPE, contentType);
final MockResponder responder = new MockResponder();
final BodyConsumer bodyConsumer = streamHandler.batch(request, responder, streamId.getNamespaceId(), streamId.getId());
Preconditions.checkNotNull(bodyConsumer, "BodyConsumer from stream batch load call should not be null");
ByteStreams.readBytes(Files.newInputStreamSupplier(file), new ByteProcessor<BodyConsumer>() {
@Override
public boolean processBytes(byte[] buf, int off, int len) throws IOException {
bodyConsumer.chunk(ChannelBuffers.wrappedBuffer(buf, off, len), responder);
return true;
}
@Override
public BodyConsumer getResult() {
bodyConsumer.finished(responder);
return bodyConsumer;
}
});
Preconditions.checkState(HttpResponseStatus.OK.equals(responder.getStatus()), "Failed to load events to stream %s in batch", streamId);
}
use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method getVersionedInfo.
public ApplicationDetail getVersionedInfo(ApplicationId appId) throws Exception {
DefaultHttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, String.format("%s/apps/%s/versions/%s", getNamespacePath(appId.getNamespace()), appId.getApplication(), appId.getVersion()));
request.setHeader(Constants.Gateway.API_KEY, "api-key-example");
MockResponder mockResponder = new MockResponder();
appLifecycleHttpHandler.getAppVersionInfo(request, mockResponder, appId.getNamespace(), appId.getApplication(), appId.getVersion());
verifyResponse(HttpResponseStatus.OK, mockResponder.getStatus(), "Getting app version info failed");
return mockResponder.decodeResponseContent(new TypeToken<ApplicationDetail>() {
}.getType(), GSON);
}
Aggregations