Creates pipeline for http requests.

@param pipeline      the client channel pipeline
@param targetHandler the target handler
962421
public void configureHttpPipeline(ChannelPipeline pipeline, TargetHandler targetHandler) {
        pipeline.addLast(Constants.HTTP_CLIENT_CODEC, new HttpClientCodec());
        addCommonHandlers(pipeline);
        pipeline.addLast(Constants.BACK_PRESSURE_HANDLER, new BackPressureHandler());
        pipeline.addLast(Constants.TARGET_HANDLER, targetHandler);
    }
1334921
public final static PipeConnectionEvent build(AbstractPipe source, EventType type, IConsumer consumer, Map<String, Object> paramMap) {
        return new PipeConnectionEvent(source, type, consumer, paramMap);
    }
376671
private void configureH2cPipeline(ChannelPipeline pipeline) {
        // Add handler to handle http2 requests without an upgrade
        pipeline.addLast(new Http2WithPriorKnowledgeHandler(
                interfaceId, serverName, serverConnectorFuture, this));
        // Add http2 upgrade decoder and upgrade handler
        final HttpServerCodec sourceCodec = new HttpServerCodec(reqSizeValidationConfig.getMaxUriLength(),
                                                                reqSizeValidationConfig.getMaxHeaderSize(),
                                                                reqSizeValidationConfig.getMaxChunkSize());

        final HttpServerUpgradeHandler.UpgradeCodecFactory upgradeCodecFactory = protocol -> {
            if (AsciiString.contentEquals(Http2CodecUtil.HTTP_UPGRADE_PROTOCOL_NAME, protocol)) {
                return new Http2ServerUpgradeCodec(
                        Constants.HTTP2_SOURCE_CONNECTION_HANDLER,
                        new Http2SourceConnectionHandlerBuilder(
                                interfaceId, serverConnectorFuture, serverName, this).build());
            } else {
                return null;
            }
        };
        pipeline.addLast(Constants.HTTP_SERVER_CODEC, sourceCodec);
        pipeline.addLast(Constants.HTTP_COMPRESSOR, new CustomHttpContentCompressor());
        if (httpTraceLogEnabled) {
            pipeline.addLast(HTTP_TRACE_LOG_HANDLER,
                             new HttpTraceLoggingHandler(TRACE_LOG_DOWNSTREAM));
        }
        if (httpAccessLogEnabled) {
            pipeline.addLast(HTTP_ACCESS_LOG_HANDLER, new HttpAccessLoggingHandler(ACCESS_LOG));
        }
        pipeline.addLast(Constants.HTTP2_UPGRADE_HANDLER,
                         new HttpServerUpgradeHandler(sourceCodec, upgradeCodecFactory, Integer.MAX_VALUE));
        /* Max size of the upgrade request is limited to 2GB. Need to see whether there is a better approach to handle
           large upgrade requests. Requests will be propagated to next handlers if no upgrade has been attempted */
        pipeline.addLast(Constants.HTTP2_TO_HTTP_FALLBACK_HANDLER,
                         new Http2ToHttpFallbackHandler(this));
    }
636997
public static ModelControllerClient createReceiving(final Channel channel, final ExecutorService executorService) {
        final ManagementClientChannelStrategy strategy = ManagementClientChannelStrategy.create(channel);
        final ManagementChannelHandler handler = new ManagementChannelHandler(strategy, executorService);
        final ExistingChannelModelControllerClient client = new ExistingChannelModelControllerClient(handler);
        handler.addHandlerFactory(client);
        channel.addCloseHandler(new CloseHandler<Channel>() {
            @Override
            public void handleClose(Channel closed, IOException exception) {
                handler.shutdown();
                try {
                    handler.awaitCompletion(1, TimeUnit.SECONDS);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                } finally {
                    handler.shutdownNow();
                }
            }
        });
        channel.receiveMessage(handler.getReceiver());
        return client;
    }
1270716
public Object getServiceFromProxy(TargetMetaDef targetMetaDef) {

    RemoteInvocationHandler handler = null;
    Object dynamicProxy = null;

    try {
      Debug.logVerbose("[JdonFramework] ---> create a new ProxyInstance", module);
      handler = new RemoteInvocationHandler(targetMetaDef);

      ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
      Class serviceClass = classLoader.loadClass(targetMetaDef.getClassName());

      dynamicProxy =
          Proxy.newProxyInstance(
          classLoader,
          new Class[] {serviceClass},
          handler);

    } catch (Exception ex) {
      ex.printStackTrace();
    }
    return dynamicProxy;

  }
1369826
public CreatePipelineResponse createPipeline(CreatePipelineRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");
        checkStringNotEmpty(request.getPipelineName(), 
                "The parameter pipelineName should NOT be null or empty string.");
        checkStringNotEmpty(request.getSourceBucket(), 
                "The parameter sourceBucket should NOT be null or empty string.");
        checkStringNotEmpty(request.getTargetBucket(), 
                "The parameter targetBucket should NOT be null or empty string.");
        if (request.getConfig() == null || request.getConfig().getCapacity() == null) {
            PipelineConfig config = new PipelineConfig();
            config.setCapacity(DEFAULT_PIPELINE_CAPACITY);
            request.setConfig(config);
        }
        InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, PIPELINE);
        
        return invokeHttpClient(internalRequest, CreatePipelineResponse.class);
    }
1309317
@Override
    public Configuration visit(AstConnectNode connectNode, State state) {

        // masking is a no-op by default for each stream
        state.readUnmasker = Masker.IDENTITY_MASKER;
        state.writeMasker = Masker.IDENTITY_MASKER;

        state.pipelineAsMap = new LinkedHashMap<>();

        for (AstStreamableNode streamable : connectNode.getStreamables()) {
            streamable.accept(this, state);
        }

        /* Add the completion handler */
        String handlerName = String.format("completion#%d", state.pipelineAsMap.size() + 1);
        CompletionHandler completionHandler = new CompletionHandler();
        completionHandler.setRegionInfo(connectNode.getRegionInfo());
        state.pipelineAsMap.put(handlerName, completionHandler);

        String awaitName = connectNode.getAwaitName();
        Barrier awaitBarrier = null;
        if (awaitName != null) {
            awaitBarrier = state.lookupBarrier(awaitName);
        }

        final ChannelPipeline pipeline = pipelineFromMap(state.pipelineAsMap);

        /*
         * TODO. This is weird. I will only have one pipeline per connect. But if I don't set a factory When a connect
         * occurs it will create a shallow copy of the pipeline I set. This doesn't work due to the beforeAdd methods in
         * ExecutionHandler. Namely when the pipeline is cloned it uses the same handler objects so the handler future
         * is not null and we fail with an assertion error.
         */
        ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() {
            private int numCalled;

            @Override
            public ChannelPipeline getPipeline() {
                if (numCalled++ != 0) {
                    throw new RobotException("getPipeline called more than once");
                }
                return pipeline;
            }
        };

        // Now that connect supports barrier and expression value, connect uri may not be available at this point.
        // To defer the evaluation of connect uri and initialization of ClientBootstrap, LocationResolver and
        // ClientResolver are created with information necessary to create ClientBootstrap when the connect uri
        // is available.
        Supplier<URI> locationResolver = connectNode.getLocation()::getValue;
        OptionsResolver optionsResolver = new OptionsResolver(connectNode.getOptions());

        ClientBootstrapResolver clientResolver = new ClientBootstrapResolver(bootstrapFactory, addressFactory,
                pipelineFactory, locationResolver, optionsResolver, awaitBarrier, connectNode.getRegionInfo());

        // retain pipelines for tear down
        state.configuration.getClientAndServerPipelines().add(pipeline);

        state.configuration.getClientResolvers().add(clientResolver);
        return state.configuration;
    }
339836
@Singleton
    HttpClientHandler<HttpRequest<?>, HttpResponse<?>> httpClientHandler(HttpTracing httpTracing) {
        return HttpClientHandler.create(httpTracing, new HttpClientAdapter<HttpRequest<?>, HttpResponse<?>>() {
            @Override
            public String method(HttpRequest<?> request) {
                return request.getMethod().name();
            }

            @Override
            public String url(HttpRequest<?> request) {
                return request.getUri().toString();
            }

            @Override
            public String requestHeader(HttpRequest<?> request, String name) {
                return request.getHeaders().get(name);
            }

            @Override
            public Integer statusCode(HttpResponse<?> response) {
                return response.getStatus().getCode();
            }

            @Override
            public boolean parseServerIpAndPort(HttpRequest<?> request, Endpoint.Builder builder) {
                InetAddress address = request.getServerAddress().getAddress();
                return builder.parseIp(address);
            }

            @Override
            public String methodFromResponse(HttpResponse<?> httpResponse) {
                return httpResponse.getAttribute(HttpAttributes.METHOD_NAME, String.class)
                                   .orElseGet(() -> super.methodFromResponse(httpResponse));
            }

            @Override
            public String route(HttpResponse<?> response) {
                Optional<String> value = response.getAttribute(HttpAttributes.URI_TEMPLATE, String.class);
                return value.orElseGet(() -> super.route(response));
            }
        });
    }
668967
private void addCommonHandlers(ChannelPipeline pipeline) {
        pipeline.addLast(Constants.DECOMPRESSOR_HANDLER, new HttpContentDecompressor());
        if (httpTraceLogEnabled) {
            pipeline.addLast(Constants.HTTP_TRACE_LOG_HANDLER,
                    new HttpTraceLoggingHandler(Constants.TRACE_LOG_UPSTREAM));
        }
    }
1221392
private ChannelInitializer<SocketChannel> getChannelInitializer(final PravegaNodeUri location,
                                                                    final FlowHandler handler) {
        final SslContext sslCtx = getSslContext();

        return new ChannelInitializer<SocketChannel>() {
            @Override
            public void initChannel(SocketChannel ch) throws Exception {
                ChannelPipeline p = ch.pipeline();
                if (sslCtx != null) {
                    SslHandler sslHandler = sslCtx.newHandler(ch.alloc(), location.getEndpoint(), location.getPort());

                    if (clientConfig.isValidateHostName()) {
                        SSLEngine sslEngine = sslHandler.engine();
                        SSLParameters sslParameters = sslEngine.getSSLParameters();
                        sslParameters.setEndpointIdentificationAlgorithm("HTTPS");
                        sslEngine.setSSLParameters(sslParameters);
                    }
                    p.addLast(sslHandler);
                }
                p.addLast(
                        new ExceptionLoggingHandler(location.getEndpoint()),
                        new CommandEncoder(handler.getBatchSizeTracker()),
                        new LengthFieldBasedFrameDecoder(WireCommands.MAX_WIRECOMMAND_SIZE, 4, 4),
                        new CommandDecoder(),
                        handler);
            }
        };
    }
893567
def handle_target(self, request, controller_args, controller_kwargs):
        
        self.request = request
        super(AuthDecorator, self).handle_target(request, controller_args, controller_kwargs)
        del self.request
743729
protected void clientMessageHandler(DirectBuffer buffer, int offset, int length, Header header) {
        /**
         *  All incoming messages here are supposed to be "just messages", only unicast communication
         *  All of them should implement MeaningfulMessage interface
         */
        // TODO: to be implemented
        //  log.info("clientMessageHandler message request incoming");

        byte[] data = new byte[length];
        buffer.getBytes(offset, data);

        MeaningfulMessage message = (MeaningfulMessage) VoidMessage.fromBytes(data);
        completed.put(message.getTaskId(), message);
    }
38243
public static HttpPipeline createDefaultPipeline(Class<?> swaggerInterface, AsyncServiceClientCredentials credentials) {
        return createDefaultPipeline(swaggerInterface, new AsyncCredentialsPolicy(credentials));
    }
567656
public static HttpServerInterceptorChain<ByteBuf, ByteBuf, ByteBuf, ByteBuf> startRaw() {
        return new HttpServerInterceptorChain<>(new TransformingInterceptor<ByteBuf, ByteBuf, ByteBuf, ByteBuf>() {
            @Override
            public RequestHandler<ByteBuf, ByteBuf> intercept(RequestHandler<ByteBuf, ByteBuf> handler) {
                return handler;
            }
        });
    }
3458
@Override
    public java.util.concurrent.Future<ListPipelinesResult> listPipelinesAsync(
            com.amazonaws.handlers.AsyncHandler<ListPipelinesRequest, ListPipelinesResult> asyncHandler) {

        return listPipelinesAsync(new ListPipelinesRequest(), asyncHandler);
    }
751537
public HttpHandler createProxyHandler() {
        return ProxyHandler.builder()
                .setProxyClient(container.getProxyClient())
                .setMaxRequestTime(maxRequestTime)
                .setMaxConnectionRetries(maxRetries)
                .setReuseXForwarded(reuseXForwarded)
                .build();
    }
785861
@Override
    public java.util.concurrent.Future<CreateQueueResult> createQueueAsync(String queueName,
            com.amazonaws.handlers.AsyncHandler<CreateQueueRequest, CreateQueueResult> asyncHandler) {

        return createQueueAsync(new CreateQueueRequest().withQueueName(queueName), asyncHandler);
    }