use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class AppFabricClient method setServiceInstances.
public void setServiceInstances(String namespaceId, String applicationId, String serviceName, int instances) throws Exception {
MockResponder responder = new MockResponder();
String uri = String.format("%s/apps/%s/services/%s/instances", getNamespacePath(namespaceId), applicationId, serviceName);
HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.PUT, uri);
JsonObject json = new JsonObject();
json.addProperty("instances", instances);
request.setContent(ChannelBuffers.wrappedBuffer(json.toString().getBytes()));
programLifecycleHttpHandler.setServiceInstances(request, responder, namespaceId, applicationId, serviceName);
verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Set service instances failed");
}
use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class RouterPathTest method testRouterFeedsLookup.
@Test
public void testRouterFeedsLookup() {
final String namespacePath = "/v3//feeds/test";
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("PUT"), namespacePath);
RouteDestination result = pathLookup.getRoutingService(FALLBACKSERVICE, namespacePath, httpRequest);
Assert.assertEquals(null, result);
}
use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class RouterPathTest method testStreamPath.
@Test
public void testStreamPath() throws Exception {
//Following URIs might not give actual results but we want to test resilience of Router Path Lookup
String streamPath = "/v3/namespaces/default/streams";
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), streamPath);
RouteDestination result = pathLookup.getRoutingService(FALLBACKSERVICE, streamPath, httpRequest);
Assert.assertEquals(RouterPathLookup.STREAMS_SERVICE, result);
streamPath = "///v3/namespaces/default/streams///";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("POST"), streamPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, streamPath, httpRequest);
Assert.assertEquals(RouterPathLookup.STREAMS_SERVICE, result);
streamPath = "v3/namespaces/default///streams///";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("PUT"), streamPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, streamPath, httpRequest);
Assert.assertEquals(RouterPathLookup.STREAMS_SERVICE, result);
streamPath = "//v3/namespaces/default///streams/HelloStream//programs///";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), streamPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, streamPath, httpRequest);
Assert.assertEquals(RouterPathLookup.APP_FABRIC_HTTP, result);
streamPath = "//v3/namespaces/default///streams/HelloStream//programs///";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("DELETE"), streamPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, streamPath, httpRequest);
Assert.assertEquals(RouterPathLookup.STREAMS_SERVICE, result);
streamPath = "//v3/namespaces/default///streams/HelloStream//programs///";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("POST"), streamPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, streamPath, httpRequest);
Assert.assertEquals(RouterPathLookup.STREAMS_SERVICE, result);
streamPath = "v3/namespaces/default//streams//flows///";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("DELETE"), streamPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, streamPath, httpRequest);
Assert.assertEquals(RouterPathLookup.STREAMS_SERVICE, result);
streamPath = "v3/namespaces/default//streams/InvalidStreamName/programs/";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), streamPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, streamPath, httpRequest);
Assert.assertEquals(RouterPathLookup.APP_FABRIC_HTTP, result);
streamPath = "v3/namespaces/default//streams/InvalidStreamName/programs";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), streamPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, streamPath, httpRequest);
Assert.assertEquals(RouterPathLookup.APP_FABRIC_HTTP, result);
streamPath = "v3/namespaces/default//streams/InvalidStreamName/programs/";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("DELETE"), streamPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, streamPath, httpRequest);
Assert.assertEquals(RouterPathLookup.STREAMS_SERVICE, result);
streamPath = "v3/namespaces/default//streams/InvalidStreamName/info/";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), streamPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, streamPath, httpRequest);
Assert.assertEquals(RouterPathLookup.STREAMS_SERVICE, result);
}
use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class RouterPathTest method testRouterDeployPathLookUp.
@Test
public void testRouterDeployPathLookUp() throws Exception {
String path = "/v3/namespaces/default//apps/";
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("PUT"), path);
RouteDestination result = pathLookup.getRoutingService(FALLBACKSERVICE, path, 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 testAppFabricPath.
@Test
public void testAppFabricPath() throws Exception {
//Default destination for URIs will APP_FABRIC_HTTP
String path = "/v3/ping/";
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), path);
RouteDestination result = pathLookup.getRoutingService(FALLBACKSERVICE, path, httpRequest);
Assert.assertEquals(RouterPathLookup.APP_FABRIC_HTTP, result);
path = "/status";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), path);
result = pathLookup.getRoutingService(FALLBACKSERVICE, path, httpRequest);
Assert.assertEquals(RouterPathLookup.APP_FABRIC_HTTP, result);
path = "/v3/monitor///abcd/";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("POST"), path);
result = pathLookup.getRoutingService(FALLBACKSERVICE, path, httpRequest);
Assert.assertEquals(RouterPathLookup.APP_FABRIC_HTTP, result);
}
Aggregations