use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project activemq-artemis by apache.
the class HttpAcceptorHandler method channelRead.
@Override
public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception {
FullHttpRequest request = (FullHttpRequest) msg;
HttpMethod method = request.method();
// if we are a post then we send upstream, otherwise we are just being prompted for a response.
if (method.equals(HttpMethod.POST)) {
ctx.fireChannelRead(ReferenceCountUtil.retain(((FullHttpRequest) msg).content()));
// add a new response
responses.put(new ResponseHolder(System.currentTimeMillis() + responseTime, new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK)));
ReferenceCountUtil.release(msg);
return;
}
super.channelRead(ctx, msg);
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project cdap by caskdata.
the class AppFabricClient method addSchedule.
public void addSchedule(ApplicationId application, ScheduleDetail scheduleDetail) throws Exception {
MockResponder responder = new MockResponder();
String uri = String.format("%s/apps/%s/versions/%s/schedules/%s", getNamespacePath(application.getNamespace()), application.getApplication(), application.getVersion(), scheduleDetail.getName());
FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.PUT, uri);
request.content().writeCharSequence(GSON.toJson(scheduleDetail), StandardCharsets.UTF_8);
HttpUtil.setContentLength(request, request.content().readableBytes());
programLifecycleHttpHandler.addSchedule(request, responder, application.getNamespace(), application.getApplication(), application.getVersion(), scheduleDetail.getName());
verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Add schedule failed");
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project cdap by caskdata.
the class AppFabricClient method suspend.
public void suspend(String namespaceId, String appId, String scheduleName) throws Exception {
MockResponder responder = new MockResponder();
String uri = String.format("%s/apps/%s/schedules/%s/suspend", getNamespacePath(namespaceId), appId, scheduleName);
FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, uri);
HttpUtil.setContentLength(request, request.content().readableBytes());
programLifecycleHttpHandler.performAction(request, responder, namespaceId, appId, "schedules", scheduleName, "suspend");
verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Suspend workflow schedules failed");
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest 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);
FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.PUT, uri);
JsonObject json = new JsonObject();
json.addProperty("instances", instances);
request.content().writeCharSequence(json.toString(), StandardCharsets.UTF_8);
HttpUtil.setContentLength(request, request.content().readableBytes());
programLifecycleHttpHandler.setServiceInstances(request, responder, namespaceId, applicationId, serviceName);
verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Set service instances failed");
}
use of org.apache.flink.shaded.netty4.io.netty.handler.codec.http.FullHttpRequest in project component-runtime by Talend.
the class PassthroughHandler method channelRead0.
@Override
protected void channelRead0(final ChannelHandlerContext ctx, final FullHttpRequest request) {
if (HttpMethod.CONNECT.name().equalsIgnoreCase(request.method().name())) {
final FullHttpResponse response = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, Unpooled.EMPTY_BUFFER);
setKeepAlive(response, true);
setContentLength(response, 0);
if (api.getSslContext() != null) {
final SSLEngine sslEngine = api.getSslContext().createSSLEngine();
sslEngine.setUseClientMode(false);
ctx.channel().pipeline().addFirst("ssl", new SslHandler(sslEngine, true));
final String uri = request.uri();
final String[] parts = uri.split(":");
ctx.channel().attr(BASE).set("https://" + parts[0] + (parts.length > 1 && !"443".equals(parts[1]) ? ":" + parts[1] : ""));
}
ctx.writeAndFlush(response);
return;
}
// copy to use in a separated thread
final FullHttpRequest req = request.copy();
api.getExecutor().execute(() -> doHttpRequest(req, ctx));
}
Aggregations