Example usage for org.apache.thrift.protocol TProtocolFactory TProtocolFactory

List of usage examples for org.apache.thrift.protocol TProtocolFactory TProtocolFactory

Introduction

In this page you can find the example usage for org.apache.thrift.protocol TProtocolFactory TProtocolFactory.

Prototype

TProtocolFactory

Source Link

Usage

From source file:com.facebook.nifty.duplex.TDuplexProtocolFactory.java

License:Apache License

public TProtocolFactory getInputProtocolFactory() {
    return new TProtocolFactory() {
        @Override/* www.  j a  va2s.c  om*/
        public TProtocol getProtocol(TTransport trans) {
            return getProtocolPair(TTransportPair.fromSingleTransport(trans)).getInputProtocol();
        }
    };
}

From source file:com.facebook.nifty.duplex.TDuplexProtocolFactory.java

License:Apache License

public TProtocolFactory getOutputProtocolFactory() {
    return new TProtocolFactory() {
        @Override/*from  www  .j a va 2s . com*/
        public TProtocol getProtocol(TTransport trans) {
            return getProtocolPair(TTransportPair.fromSingleTransport(trans)).getOutputProtocol();
        }
    };
}

From source file:com.si.jupiter.smart.duplex.TDuplexProtocolFactory.java

License:Apache License

public TProtocolFactory getInputProtocolFactory() {
    return new TProtocolFactory() {
        public TProtocol getProtocol(TTransport trans) {
            return getProtocolPair(TTransportPair.fromSingleTransport(trans)).getInputProtocol();
        }/*from   w ww  .j a v  a2  s  .  co  m*/
    };
}

From source file:com.si.jupiter.smart.duplex.TDuplexProtocolFactory.java

License:Apache License

public TProtocolFactory getOutputProtocolFactory() {
    return new TProtocolFactory() {
        public TProtocol getProtocol(TTransport trans) {
            return getProtocolPair(TTransportPair.fromSingleTransport(trans)).getOutputProtocol();
        }//from   w  ww.  j a va 2  s  .c o  m
    };
}

From source file:org.hawk.service.servlet.Activator.java

License:Open Source License

@Override
public void start(BundleContext bundleContext) throws Exception {
    Activator.context = bundleContext;
    HManager.getInstance();/*from ww  w . j a  v a 2s .c  o m*/

    String artemisHost = System.getProperty(ARTEMIS_HOST_PROPERTY);
    if (artemisHost == null) {
        artemisHost = TransportConstants.DEFAULT_HOST;
    }

    String sArtemisPort = System.getProperty(ARTEMIS_PORT_PROPERTY);
    int artemisPort;
    if (sArtemisPort == null) {
        artemisPort = TransportConstants.DEFAULT_PORT;
    } else {
        artemisPort = Integer.valueOf(sArtemisPort);
    }

    artemis = new Server(artemisHost, artemisPort);
    String sListenAll = System.getProperty(ARTEMIS_LISTENALL_PROPERTY);
    if (sListenAll != null) {
        artemis.setListenOnAllInterfaces(Boolean.valueOf(sListenAll));
    }
    String sSSLEnabled = System.getProperty(ARTEMIS_SSL_PROPERTY);
    if (sSSLEnabled != null) {
        artemis.setSSLEnabled(Boolean.valueOf(sSSLEnabled));
    }
    try {
        artemis.start();
    } catch (Exception e) {
        throw new ServletException(e);
    }

    final String sTCPPort = System.getProperty(TCP_PORT_PROPERTY);
    if (sTCPPort != null) {
        final String sThriftProtocol = System.getProperty(TCP_TPROTOCOL_PROPERTY);
        final ThriftProtocol thriftProtocol = (sThriftProtocol != null)
                ? ThriftProtocol.valueOf(sThriftProtocol)
                : ThriftProtocol.TUPLE;

        final TServerSocket tcpServerSocket = new TServerSocket(Integer.valueOf(sTCPPort));
        final HawkThriftIface hawkIface = new HawkThriftIface(ThriftProtocol.TUPLE, null, artemis);
        final Processor<Iface> hawkTCPProcessor = new Hawk.Processor<Hawk.Iface>(hawkIface);
        final Args tcpServerArgs = new TThreadPoolServer.Args(tcpServerSocket).maxWorkerThreads(10_000)
                .protocolFactory(new TProtocolFactory() {
                    private static final long serialVersionUID = 1L;

                    @Override
                    public TProtocol getProtocol(TTransport arg0) {
                        return thriftProtocol.getProtocolFactory().getProtocol(new TZlibTransport(arg0));
                    }
                }).processor(hawkTCPProcessor);

        tcpServer = new TThreadPoolServer(tcpServerArgs);
        new Thread(new Runnable() {
            @Override
            public void run() {
                final Bundle bundle = context.getBundle();
                Platform.getLog(bundle).log(
                        new Status(IStatus.INFO, bundle.getSymbolicName(), "Starting Hawk TCP server on port "
                                + sTCPPort + " with Thrift protocol " + thriftProtocol.name()));
                tcpServer.serve();
            }
        }).start();
    }
}