Java 类org.apache.thrift.transport.TNonblockingServerTransport 实例源码

项目:rpc-comparison    文件:AskerServer.java   
private void nonBlockMode() {
        AskerHandler handler = new AskerHandler();
        Asker.Processor processor = new Asker.Processor(handler);
        try {
            TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
            THsHaServer.Args arg = new THsHaServer.Args(transport);
            arg.protocolFactory(new TCompactProtocol.Factory());
//            arg.transportFactory(new TFramedTransport.Factory());
//            arg.processorFactory(new TProcessorFactory(processor));
            arg.processor(processor);
            server = new THsHaServer(arg);
            start.countDown();

            System.out.println("Starting the nonBlock server...");
            server.serve();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
项目:flume-release-1.7.0    文件:ThriftTestingSource.java   
public ThriftTestingSource(String handlerName, int port, String protocol) throws Exception {
  TNonblockingServerTransport serverTransport =
      new TNonblockingServerSocket(new InetSocketAddress("0.0.0.0", port));
  ThriftSourceProtocol.Iface handler = getHandler(handlerName);

  TProtocolFactory transportProtocolFactory = null;
  if (protocol != null && protocol == ThriftRpcClient.BINARY_PROTOCOL) {
    transportProtocolFactory = new TBinaryProtocol.Factory();
  } else {
    transportProtocolFactory = new TCompactProtocol.Factory();
  }
  server = new THsHaServer(new THsHaServer.Args(serverTransport).processor(
      new ThriftSourceProtocol.Processor(handler)).protocolFactory(
          transportProtocolFactory));
  Executors.newSingleThreadExecutor().submit(new Runnable() {
    @Override
    public void run() {
      server.serve();
    }
  });
}
项目:flume-release-1.7.0    文件:ScribeSource.java   
public void run() {
  try {
    Scribe.Processor processor = new Scribe.Processor(new Receiver());
    TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
    THsHaServer.Args args = new THsHaServer.Args(transport);

    args.workerThreads(workers);
    args.processor(processor);
    args.transportFactory(new TFramedTransport.Factory(maxReadBufferBytes));
    args.protocolFactory(new TBinaryProtocol.Factory(false, false));
    args.maxReadBufferBytes = maxReadBufferBytes;

    server = new THsHaServer(args);

    LOG.info("Starting Scribe Source on port " + port);

    server.serve();
  } catch (Exception e) {
    LOG.warn("Scribe failed", e);
  }
}
项目:athena    文件:Bmv2ControlPlaneThriftServer.java   
@Override
protected boolean startThreads() {
    try {
        for (int i = 0; i < MAX_SELECTOR_THREADS; ++i) {
            selectorThreads.add(new TrackingSelectorThread(ACCEPT_QUEUE_LEN));
        }
        acceptThread = new AcceptThread((TNonblockingServerTransport) serverTransport_,
                                        createSelectorThreadLoadBalancer(selectorThreads));
        selectorThreads.forEach(Thread::start);
        acceptThread.start();
        return true;
    } catch (IOException e) {
        log.error("Failed to start threads!", e);
        return false;
    }
}
项目:fresco_floodlight    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:iTAP-controller    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:SDN-Multicast    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:arscheduler    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:QoS-floodlight    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:floodlight1.2-delay    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:floodlight-hardware    文件:PacketStreamerServer.java   
/**
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:ACAMPController    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:incubator-tephra    文件:TThreadedSelectorServerWithFix.java   
/**
 * Start the accept and selector threads running to deal with clients.
 *
 * @return true if everything went ok, false if we couldn't start for some
 *         reason.
 */
@Override
protected boolean startThreads() {
  LOGGER.info("Starting {}", TThreadedSelectorServerWithFix.class.getSimpleName());
  try {
    for (int i = 0; i < args.selectorThreads; ++i) {
      selectorThreads.add(new SelectorThread(args.acceptQueueSizePerThread));
    }
    acceptThread = new AcceptThread((TNonblockingServerTransport) serverTransport_,
                                    createSelectorThreadLoadBalancer(selectorThreads));
    stopped_ = false;
    for (SelectorThread thread : selectorThreads) {
      thread.start();
    }
    acceptThread.start();
    return true;
  } catch (IOException e) {
    LOGGER.error("Failed to start threads!", e);
    return false;
  }
}
项目:fast-failover-demo    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:cassandra-kmean    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:floodlightLB    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:DSC    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:ACaZoo    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:providence    文件:NonblockingSocketClientHandlerTest.java   
@BeforeClass
public static void setUpServer() throws Exception {
    setDefaultPollDelay(10, TimeUnit.MILLISECONDS);

    serializer = new TBinaryProtocolSerializer();
    factory = new TBinaryProtocol.Factory();
    port = findFreePort();
    impl = Mockito.mock(Iface.class);

    TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
    server = new TNonblockingServer(
            new TNonblockingServer.Args(transport)
                    .protocolFactory(factory)
                    .processor(new Processor<>(impl)));

    executor = Executors.newSingleThreadExecutor();
    executor.submit(server::serve);
    address = new InetSocketAddress("localhost", port);
}
项目:Multipath-Hedera-system-in-Floodlight-controller    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:internet_of_things_simulator    文件:TThreadedSelectorServer.java   
/**
 * Start the accept and selector threads running to deal with clients.
 * 
 * @return true if everything went ok, false if we couldn't start for some
 *         reason.
 */
@Override
protected boolean startThreads() {
  try {
    for (int i = 0; i < args.selectorThreads; ++i) {
      selectorThreads.add(new SelectorThread(args.acceptQueueSizePerThread));
    }
    acceptThread = new AcceptThread((TNonblockingServerTransport) serverTransport_,
      createSelectorThreadLoadBalancer(selectorThreads));
    for (SelectorThread thread : selectorThreads) {
      thread.start();
    }
    acceptThread.start();
    return true;
  } catch (IOException e) {
    LOGGER.error("Failed to start threads!", e);
    return false;
  }
}
项目:floodlight_with_topoguard    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:floodlight    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:scylla-tools-java    文件:CustomTNonBlockingServer.java   
@SuppressWarnings("resource")
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:springside-engine    文件:StandardNIOServer.java   
public static void main(String[] args) {
    try {
        handler = new CalculatorHandler();
        processor = new Calculator.Processor(handler);
        try {
            TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(9090);
            TServer server = new TThreadedSelectorServer(
                    new TThreadedSelectorServer.Args(serverTransport).processor(processor));

            System.out.println("Starting the  server...");
            server.serve();
        } catch (TTransportException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    } catch (Exception x) {
        x.printStackTrace();
    }
}
项目:GraphTrek    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:hbase    文件:ThriftServer.java   
private static TServer getTHsHaServer(TProtocolFactory protocolFactory,
    TProcessor processor, TTransportFactory transportFactory,
    int workerThreads, int maxCallQueueSize,
    InetSocketAddress inetSocketAddress, ThriftMetrics metrics)
    throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase HsHA Thrift server on " + inetSocketAddress.toString());
  THsHaServer.Args serverArgs = new THsHaServer.Args(serverTransport);
  if (workerThreads > 0) {
    // Could support the min & max threads, avoiding to preserve existing functionality.
    serverArgs.minWorkerThreads(workerThreads).maxWorkerThreads(workerThreads);
  }
  ExecutorService executorService = createExecutor(
      workerThreads, maxCallQueueSize, metrics);
  serverArgs.executorService(executorService);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new THsHaServer(serverArgs);
}
项目:hbase    文件:ThriftServer.java   
private static TServer getTThreadedSelectorServer(TProtocolFactory protocolFactory,
    TProcessor processor, TTransportFactory transportFactory,
    int workerThreads, int selectorThreads, int maxCallQueueSize,
    InetSocketAddress inetSocketAddress, ThriftMetrics metrics)
    throws TTransportException {
  TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(inetSocketAddress);
  log.info("starting HBase ThreadedSelector Thrift server on " + inetSocketAddress.toString());
  TThreadedSelectorServer.Args serverArgs = new TThreadedSelectorServer.Args(serverTransport);
  if (workerThreads > 0) {
    serverArgs.workerThreads(workerThreads);
  }
  if (selectorThreads > 0) {
    serverArgs.selectorThreads(selectorThreads);
  }

  ExecutorService executorService = createExecutor(
      workerThreads, maxCallQueueSize, metrics);
  serverArgs.executorService(executorService);
  serverArgs.processor(processor);
  serverArgs.transportFactory(transportFactory);
  serverArgs.protocolFactory(protocolFactory);
  return new TThreadedSelectorServer(serverArgs);
}
项目:FloodligtModule    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:osgi-bundle-frontapi    文件:ThriftUtils.java   
public static TServer createThreadedSelectorServer(TProcessorFactory processorFactory,
        int port, int clientTimeoutMillisecs, int maxFrameSize, long maxReadBufferSize)
        throws TTransportException {
    int numThreads = Math.max(2, Runtime.getRuntime().availableProcessors());
    int selectorThreads = Math.max(2, Runtime.getRuntime().availableProcessors() / 2);
    TNonblockingServerTransport transport = new TNonblockingServerSocket(port,
            clientTimeoutMillisecs);
    TProtocolFactory protocolFactory = new TBinaryProtocol.Factory();
    TTransportFactory transportFactory = new TFramedTransport.Factory(maxFrameSize);
    TThreadedSelectorServer.Args args = new TThreadedSelectorServer.Args(transport)
            .processorFactory(processorFactory).protocolFactory(protocolFactory)
            .transportFactory(transportFactory).workerThreads(numThreads)
            .acceptPolicy(AcceptPolicy.FAIR_ACCEPT).acceptQueueSizePerThread(10000)
            .selectorThreads(selectorThreads);
    args.maxReadBufferBytes = maxReadBufferSize;
    TThreadedSelectorServer server = new TThreadedSelectorServer(args);
    return server;
}
项目:smartenit    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:Cassandra-Wasef    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:lucida    文件:CalendarDaemon.java   
public static void main(String [] args) 
        throws TTransportException, IOException, InterruptedException { 
    Properties port_cfg = new Properties();
    InputStream input = new FileInputStream("../config.properties");
    port_cfg.load(input);
    String port_str = port_cfg.getProperty("CA_PORT");
    Integer port = Integer.valueOf(port_str);
    TProcessor proc = new LucidaService.AsyncProcessor(
            new CAServiceHandler.AsyncCAServiceHandler());
    TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
    TThreadedSelectorServer.Args arguments = new TThreadedSelectorServer.Args(transport)
    .processor(proc)    
    .protocolFactory(new TBinaryProtocol.Factory())
    .transportFactory(new TFramedTransport.Factory());
    final TThreadedSelectorServer server = new TThreadedSelectorServer(arguments);
    System.out.println("CA at port " + port_str);
    server.serve();
}
项目:lucida    文件:QADaemon.java   
/** 
 * Entry point for question-answer.
 * @param args the argument list. Provide port numbers
 * for both sirius and qa.
 */
public static void main(String [] args) 
        throws TTransportException, IOException, InterruptedException { 
    Properties port_cfg = new Properties();
    InputStream input = new FileInputStream("../../config.properties");
    port_cfg.load(input);
    String port_str = port_cfg.getProperty("QA_PORT");
    Integer port = Integer.valueOf(port_str);
    TProcessor proc = new LucidaService.AsyncProcessor(
            new QAServiceHandler.AsyncQAServiceHandler());
    TNonblockingServerTransport transport = new TNonblockingServerSocket(port);
    TThreadedSelectorServer.Args arguments = new TThreadedSelectorServer.Args(transport)
    .processor(proc)    
    .protocolFactory(new TBinaryProtocol.Factory())
    .transportFactory(new TFramedTransport.Factory());
    final TThreadedSelectorServer server = new TThreadedSelectorServer(arguments);
    System.out.println("QA at port " + port_str);
    server.serve();
}
项目:stratio-cassandra    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:cassandra-cqlMod    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:wso2-cassandra    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:cassandra-trunk    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}
项目:multicastSDN    文件:PacketStreamerServer.java   
/** 
 * The function to create a thrift Half-Sync and Half-Async Server.
 * @param processor
 */
public static void hshaServer(PacketStreamer.Processor<PacketStreamerHandler> processor) {
    try {
        TNonblockingServerTransport serverTransport = new TNonblockingServerSocket(port);
        THsHaServer.Args args = new THsHaServer.Args(serverTransport);
        args.processor(processor);
        args.transportFactory(new TFramedTransport.Factory());
        args.protocolFactory(new TBinaryProtocol.Factory(true, true));
        TServer server = new THsHaServer(args);

        log.info("Starting the packetstreamer hsha server on port {} ...", port);
        server.serve();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:cassandra-1.2.16    文件:CustomTNonBlockingServer.java   
public TServer buildTServer(Args args)
{
    if (DatabaseDescriptor.getClientEncryptionOptions().enabled)
        throw new RuntimeException("Client SSL is not supported for non-blocking sockets. Please remove client ssl from the configuration.");

    final InetSocketAddress addr = args.addr;
    TNonblockingServerTransport serverTransport;
    try
    {
        serverTransport = new TCustomNonblockingServerSocket(addr, args.keepAlive, args.sendBufferSize, args.recvBufferSize);
    }
    catch (TTransportException e)
    {
        throw new RuntimeException(String.format("Unable to create thrift socket to %s:%s", addr.getAddress(), addr.getPort()), e);
    }

    // This is single threaded hence the invocation will be all
    // in one thread.
    TNonblockingServer.Args serverArgs = new TNonblockingServer.Args(serverTransport).inputTransportFactory(args.inTransportFactory)
                                                                                     .outputTransportFactory(args.outTransportFactory)
                                                                                     .inputProtocolFactory(args.tProtocolFactory)
                                                                                     .outputProtocolFactory(args.tProtocolFactory)
                                                                                     .processor(args.processor);
    return new CustomTNonBlockingServer(serverArgs);
}