Search in sources :

Example 71 with DefaultHttpRequest

use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.

the class AppFabricClient method scheduleStatus.

public String scheduleStatus(String namespaceId, String appId, String schedId, int expectedResponseCode) throws Exception {
    MockResponder responder = new MockResponder();
    String uri = String.format("%s/apps/%s/schedules/%s/status", getNamespacePath(namespaceId), appId, schedId);
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
    try {
        programLifecycleHttpHandler.getStatus(request, responder, namespaceId, appId, "schedules", schedId);
    } catch (NotFoundException e) {
        return "NOT_FOUND";
    }
    verifyResponse(HttpResponseStatus.valueOf(expectedResponseCode), responder.getStatus(), "Get schedules status failed");
    Map<String, String> json = responder.decodeResponseContent(MAP_TYPE);
    return json.get("status");
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) NotFoundException(co.cask.cdap.common.NotFoundException)

Example 72 with DefaultHttpRequest

use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.

the class AppFabricClient method deleteApplication.

public void deleteApplication(ApplicationId appId) throws Exception {
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE, String.format("%s/apps/%s/versions/%s", getNamespacePath(appId.getNamespace()), appId.getApplication(), appId.getVersion()));
    request.headers().set(Constants.Gateway.API_KEY, "api-key-example");
    MockResponder mockResponder = new MockResponder();
    appLifecycleHttpHandler.deleteApp(request, mockResponder, appId.getNamespace(), appId.getApplication());
    verifyResponse(HttpResponseStatus.OK, mockResponder.getStatus(), "Deleting app failed");
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest)

Example 73 with DefaultHttpRequest

use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.

the class AppFabricClient method listAppVersions.

public Collection<String> listAppVersions(ApplicationId appId) throws Exception {
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, String.format("%s/apps/%s/versions", getNamespacePath(appId.getNamespace()), appId.getApplication()));
    request.headers().set(Constants.Gateway.API_KEY, "api-key-example");
    MockResponder mockResponder = new MockResponder();
    appLifecycleHttpHandler.listAppVersions(request, mockResponder, appId.getNamespace(), appId.getApplication());
    verifyResponse(HttpResponseStatus.OK, mockResponder.getStatus(), "Failed to list application versions");
    return mockResponder.decodeResponseContent(new TypeToken<Collection<String>>() {
    }.getType(), GSON);
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) TypeToken(com.google.gson.reflect.TypeToken)

Example 74 with DefaultHttpRequest

use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.

the class AppFabricClient method getFlowletInstances.

public Instances getFlowletInstances(String namespaceId, String applicationId, String flowName, String flowletName) throws Exception {
    MockResponder responder = new MockResponder();
    String uri = String.format("%s/apps/%s/flows/%s/flowlets/%s/instances", getNamespacePath(namespaceId), applicationId, flowName, flowletName);
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
    programLifecycleHttpHandler.getFlowletInstances(request, responder, namespaceId, applicationId, flowName, flowletName);
    verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Get flowlet instances failed");
    return responder.decodeResponseContent(Instances.class);
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest)

Example 75 with DefaultHttpRequest

use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.

the class AppFabricClient method deleteSchedule.

public void deleteSchedule(ScheduleId scheduleId) throws Exception {
    MockResponder responder = new MockResponder();
    ApplicationId application = scheduleId.getParent();
    String uri = String.format("%s/apps/%s/versions/%s/schedules/%s", getNamespacePath(application.getNamespace()), application.getApplication(), application.getVersion(), scheduleId.getSchedule());
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE, uri);
    programLifecycleHttpHandler.deleteSchedule(request, responder, application.getNamespace(), application.getApplication(), application.getVersion(), scheduleId.getSchedule());
    verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Delete schedule failed");
}
Also used : DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) ApplicationId(co.cask.cdap.proto.id.ApplicationId)

Aggregations

DefaultHttpRequest (io.netty.handler.codec.http.DefaultHttpRequest)115 HttpRequest (io.netty.handler.codec.http.HttpRequest)81 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)53 Test (org.junit.Test)51 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)44 HttpMethod (io.netty.handler.codec.http.HttpMethod)23 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)20 DefaultLastHttpContent (io.netty.handler.codec.http.DefaultLastHttpContent)18 LastHttpContent (io.netty.handler.codec.http.LastHttpContent)16 HttpContent (io.netty.handler.codec.http.HttpContent)13 HttpObject (io.netty.handler.codec.http.HttpObject)13 DefaultHttpContent (io.netty.handler.codec.http.DefaultHttpContent)12 ByteBuf (io.netty.buffer.ByteBuf)11 HttpTrade (org.jocean.http.server.HttpServerBuilder.HttpTrade)11 Test (org.junit.jupiter.api.Test)10 Channel (io.netty.channel.Channel)9 ArrayList (java.util.ArrayList)9 Nettys4Test (org.jocean.http.util.Nettys4Test)9 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)8 DisposableWrapper (org.jocean.idiom.DisposableWrapper)6