Create a flow on existing connection.
@param flow Flow.
@param rp ReplyProcessor for the specified flow.
@return Client Connection object.
540322
public ClientConnection createFlow(final Flow flow, final ReplyProcessor rp) {
        Exceptions.checkNotClosed(closed.get(), this);
        Preconditions.checkState(!disableFlow.get(), "Ensure flows are enabled.");
        log.info("Creating Flow {} for endpoint {}. The current Channel is {}.", flow.getFlowId(), connectionName, channel.get());
        if (flowIdReplyProcessorMap.put(flow.getFlowId(), rp) != null) {
            throw new IllegalArgumentException("Multiple flows cannot be created with the same Flow id " + flow.getFlowId());
        }
        return new ClientConnectionImpl(connectionName, flow.getFlowId(), batchSizeTracker, this);
    }
1237403
@Override
    public IResponse createResponse(IRequest ireq, HttpInboundConnection inboundConnection) {
        return new IResponse31Impl(ireq, inboundConnection);
    }
395155
public static TcpClientTransport create(int port) {
    TcpClient tcpClient = TcpClient.create().port(port);
    return create(tcpClient);
  }
1324363
public synchronized void create( HttpServletRequest request,
                                     HttpServletResponse response,
                                     ServletContext servletContext )
    {
        PerRequestState prevState = setPerRequestState( new PerRequestState( request, response, null ) );

        try
        {
            try
            {
                // we start the context on the bean so user control can run against Controls in the onCreate() method
                super.create( request, response, servletContext );
            }
            catch ( Throwable th )
            {
                try
                {
                    _log.info( "Handling exception in onCreate(), FlowController " + this, th );
                    reinitialize(request, response, servletContext);
                    ActionForward fwd = handleException( th, null, null, request, response );
                    if ( fwd == null ) fwd = NULL_ACTION_FORWARD;
                    request.setAttribute( ONCREATE_EXCEPTION_FORWARD, fwd );
                }
                catch ( Exception e )
                {
                    _log.error( "Exception thrown while handling exception in onCreate(): " + e.getMessage(), th );
                }
            }
        }
        finally
        {
            if(prevState != null)
                setPerRequestState( prevState );

            PageFlowControlContainer pfcc = PageFlowControlContainerFactory.getControlContainer(request,getServletContext());
            pfcc.endContextOnPageFlow(this);
        }

        PageFlowEventReporter er = AdapterManager.getServletContainerAdapter( servletContext ).getEventReporter();
        RequestContext requestContext = new RequestContext( request, response );
        er.flowControllerCreated( requestContext, this );
    }
71411
def CreateFlow(self, name=None, args=None, runner_args=None):
    """"""

    if not name:
      raise ValueError("name can't be empty")

    request = flow_pb2.ApiCreateFlowArgs(client_id=self.client_id)

    request.flow.name = name
    if runner_args:
      request.flow.runner_args.CopyFrom(runner_args)

    if args:
      request.flow.args.value = args.SerializeToString()
      request.flow.args.type_url = utils.GetTypeUrl(args)

    data = self._context.SendRequest("CreateFlow", request)
    return flow.Flow(data=data, context=self._context)
920641
public TrmClientAttachRequest2 createNewTrmClientAttachRequest2() throws MessageCreateFailedException {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "createNewTrmClientAttachRequest2");
    TrmClientAttachRequest2 msg = null;
    try {
      msg = new TrmClientAttachRequest2Impl();
    }
    catch (MessageDecodeFailedException e) {
      /* No need to FFDC this as JsMsgObject will already have done so */
      // No FFDC code needed
      throw new MessageCreateFailedException(e);
    }
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "createNewTrmClientAttachRequest2");
    return msg;
  }
1231155
private ClientConnection createHttpClientConnection(final StreamConnection connection, final OptionMap options, final ByteBufferPool bufferPool) {
		try {
			Class<?> cls = Class.forName("io.undertow.client.http.HttpClientConnection");
			
			Constructor<?> o = cls.getDeclaredConstructor(StreamConnection.class, OptionMap.class, ByteBufferPool.class);
			
			o.setAccessible(true);
			
			return (ClientConnection) o.newInstance(connection, options, bufferPool);			
		}catch(Exception e) {
			logger.error(e.getMessage(), e);
		}

		return null;
	}
116019
@Override
  public CreateResponse create(FlowConfig flowConfig) {
    List<ServiceRequester> requestorList = this.requesterService.findRequesters(this);

    try {
      String serialized = this.requesterService.serialize(requestorList);
      flowConfig.getProperties().put(RequesterService.REQUESTER_LIST, serialized);
      LOG.info("Rest requester list is " + serialized);
    } catch (IOException e) {
      throw new FlowConfigLoggedException(HttpStatus.S_401_UNAUTHORIZED,
          "cannot get who is the requester", e);
    }
    return this.flowConfigsResourceHandler.createFlowConfig(flowConfig);
  }
56792
@Override
  public Table<Node, String, Set<QueueSpecification>> create(FlowSpecification input) {
    Table<Node, String, Set<QueueSpecification>> table = HashBasedTable.create();

    String flow = input.getName();
    Map<String, FlowletDefinition> flowlets = input.getFlowlets();

    // Iterate through connections of a flow.
    for (FlowletConnection connection : input.getConnections()) {
      final String source = connection.getSourceName();
      final String target = connection.getTargetName();
      final Node sourceNode = new Node(connection.getSourceType(), source);

      Set<QueueSpecification> queueSpec = generateQueueSpecification(flow, connection, flowlets.get(target).getInputs(),
                                                                     flowlets.get(source).getOutputs());

      Set<QueueSpecification> queueSpecifications = table.get(sourceNode, target);
      if (queueSpecifications == null) {
        queueSpecifications = Sets.newHashSet();
        table.put(sourceNode, target, queueSpecifications);
      }
      queueSpecifications.addAll(queueSpec);
    }
    return table;
  }
746831
public static TcpClient<ByteBuf, ByteBuf> newClient(ConnectionProviderFactory<ByteBuf, ByteBuf> providerFactory,
                                                        Observable<Host> hostStream) {
        return TcpClientImpl.create(providerFactory, hostStream);
    }
862968
public static PageFlowController getPageFlow(ServletRequest request, ServletResponse response) {
        assert request instanceof HttpServletRequest;

        PageFlowController jpf = PageFlowUtils.getCurrentPageFlow((HttpServletRequest)request);
        if(jpf != null)
            return jpf;
        else {
            String message = "There is no current Page Flow!";
            LOGGER.error(message);
            throw new RuntimeException(message);
        }
    }
689177
PartitionRequestClient createPartitionRequestClient(ConnectionID connectionId) throws IOException, InterruptedException {
		Object entry;
		PartitionRequestClient client = null;

		while (client == null) {
			entry = clients.get(connectionId);

			if (entry != null) {
				// Existing channel or connecting channel
				if (entry instanceof PartitionRequestClient) {
					client = (PartitionRequestClient) entry;
				}
				else {
					ConnectingChannel future = (ConnectingChannel) entry;
					client = future.waitForChannel();

					clients.replace(connectionId, future, client);
				}
			}
			else {
				// No channel yet. Create one, but watch out for a race.
				// We create a "connecting future" and atomically add it to the map.
				// Only the thread that really added it establishes the channel.
				// The others need to wait on that original establisher's future.
				ConnectingChannel connectingChannel = new ConnectingChannel(connectionId, this);
				Object old = clients.putIfAbsent(connectionId, connectingChannel);

				if (old == null) {
					nettyClient.connect(connectionId.getAddress()).addListener(connectingChannel);

					client = connectingChannel.waitForChannel();

					clients.replace(connectionId, connectingChannel, client);
				}
				else if (old instanceof ConnectingChannel) {
					client = ((ConnectingChannel) old).waitForChannel();

					clients.replace(connectionId, old, client);
				}
				else {
					client = (PartitionRequestClient) old;
				}
			}

			// Make sure to increment the reference count before handing a client
			// out to ensure correct bookkeeping for channel closing.
			if (!client.incrementReferenceCounter()) {
				destroyPartitionRequestClient(connectionId, client);
				client = null;
			}
		}

		return client;
	}
463540
public Connection getConnection(RpcClient rpcClient, ClientTransportConfig transportConfig, Url url) {
        if (rpcClient == null || transportConfig == null || url == null) {
            return null;
        }
        Connection connection;
        try {
            connection = rpcClient.getConnection(url, url.getConnectTimeout());
        } catch (InterruptedException e) {
            throw new SofaRpcRuntimeException(e);
        } catch (RemotingException e) {
            throw new SofaRpcRuntimeException(e);
        }
        if (connection == null) {
            return null;
        }

        return connection;
    }
634761
static void rcvCreateUCTransaction(CommsByteBuffer request, Conversation conversation,
                                      int requestNumber, boolean allocatedFromBufferPool,
                                      boolean partOfExchange)
   {
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.entry(tc, "rcvCreateUCTransaction",
                                           new Object[]
                                           {
                                              request,
                                              conversation,
                                              ""+requestNumber,
                                              ""+allocatedFromBufferPool
                                            });

      ConversationState convState = (ConversationState) conversation.getAttachment();

      short connectionObjectId = request.getShort();  // BIT16 ConnectionObjectId
      int clientTransactionId = request.getInt();     // BIT32 Client transaction Id

      // By default subordinates are allowed - however, a FAP version 5 client may specifically
      // request that a local transaction does not support them.
      // see the ConnectionProxy.createUncoordinateTransaction(boolean) method javadoc comment
      // for more details.
      boolean allowSubordinates = true;
      if (conversation.getHandshakeProperties().getFapLevel() >= JFapChannelConstants.FAP_VERSION_5)
      {
         allowSubordinates = (request.get() & 0x01) == 0x01;
      }

      if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
      {
         SibTr.debug(tc, "SICoreConnection Id:", connectionObjectId);
         SibTr.debug(tc, "Client transaction Id:", clientTransactionId);
      }

      CATConnection catConn = (CATConnection) convState.getObject(connectionObjectId);
      SICoreConnection connection = catConn.getSICoreConnection();

      ServerLinkLevelState linkState = (ServerLinkLevelState) conversation.getLinkLevelAttachment();
      SIUncoordinatedTransaction ucTran = null;
      try
      {
         ucTran = connection.createUncoordinatedTransaction(allowSubordinates);

      }
      // Don't bother with all the different types seeing as we don't throw them back
      catch (SIException e)
      {
         //No FFDC code needed
         //Only FFDC if we haven't received a meTerminated event.
         if(!convState.hasMETerminated())
         {
            FFDCFilter.processException(e,
                                        CLASS_NAME + ".rcvCreateUCTransaction",
                                        CommsConstants.STATICCATTRANSACTION_CREATE_01);
         }

         if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) SibTr.debug(tc, "Failed to create the transaction", e);

         // We have to mark this transaction as error now - so as to indicate to everyone that
         // it should not be used
         linkState.getTransactionTable().addLocalTran(clientTransactionId, conversation.getId(), IdToTransactionTable.INVALID_TRANSACTION);
         linkState.getTransactionTable().markAsRollbackOnly(clientTransactionId, e);
      }

      // If transaction creation succeeded then add it to the link level state table of
      // transactions.
      if (ucTran != null)
      {
         linkState.getTransactionTable().addLocalTran(clientTransactionId,
                                                      conversation.getId(),
                                                      ucTran);
      }

      request.release(allocatedFromBufferPool);

      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) SibTr.exit(tc, "rcvCreateUCTransaction");
   }
1160143
@SuppressWarnings("unchecked")
    public static <T> ConnectableFlowable<T> createFrom(Flowable<? extends T> source) {
        Flowable<T> sourceCast = (Flowable<T>) source;
        return create(sourceCast, DEFAULT_UNBOUNDED_FACTORY);
    }
373844
protected void createDefaultActionStates(final Flow flow) {
        createRealSubmitAction(flow);
        createInitialAuthenticationRequestValidationCheckAction(flow);
        createCreateTicketGrantingTicketAction(flow);
        createSendTicketGrantingTicketAction(flow);
        createGenerateServiceTicketAction(flow);
        createGatewayServicesMgmtAction(flow);
        createServiceAuthorizationCheckAction(flow);
        createRedirectToServiceActionState(flow);
        createHandleAuthenticationFailureAction(flow);
        createTerminateSessionAction(flow);
        createTicketGrantingTicketCheckAction(flow);
    }
90315
def SendReply(self,
                rdf_value=None,
                session_id=None,
                message_type=rdf_flows.GrrMessage.Type.MESSAGE):
    """"""
    # TODO(hanuszczak): This is pretty bad. Here we assume that if the session
    # id is not none we are "replying" to a well-known flow. If we are replying
    # to a well-known flow we cannot increment the response id (since these are
    # not really responses) because otherwise the parent flow will think it is
    # missing some responses.
    #
    # Moreover, the message queue (at least in the flow test helper workflow)
    # expects flow messages to have request id equal to 0. This is rather
    # convoluted and should be untangled in the future.
    #
    # Once we have a separate method for communicating with well-known flows
    # this if-statement should no longer be relevant (since setting custom
    # session ids would become illegal).
    if session_id is None:
      response_id = self.response_id
      request_id = self.message.request_id
      session_id = self.message.session_id
      self.response_id += 1
    else:
      response_id = 0
      request_id = 0

    self.grr_worker.SendReply(
        rdf_value,
        # This is not strictly necessary but adds context
        # to this response.
        name=self.__class__.__name__,
        session_id=session_id,
        response_id=response_id,
        request_id=request_id,
        message_type=message_type,
        task_id=self.message.Get("task_id") or None,
        require_fastpoll=self.require_fastpoll)