Search in sources :

Example 66 with TTransport

use of org.apache.thrift.transport.TTransport in project lucida by claritylab.

the class QADaemon method connectToCMD.

private static void connectToCMD() {
    String LUCID = "QA";
    QuerySpec spec = new QuerySpec();
    spec.name = "" + 8083;
    // Initialize thrift objects.
    TTransport transport = new TSocket("localhost", 8080);
    TProtocol protocol = new TBinaryProtocol(new TFramedTransport(transport));
    LucidaService.Client client = new LucidaService.Client(protocol);
    try {
        transport.open();
        System.out.println("Connecting to CMD at port " + 8080);
        // Register itself to CMD.
        client.create(LUCID, spec);
        transport.close();
        System.out.println("Successfully connected to CMD");
    } catch (TException x) {
        x.printStackTrace();
    }
}
Also used : TException(org.apache.thrift.TException) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) TFramedTransport(org.apache.thrift.transport.TFramedTransport) TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Example 67 with TTransport

use of org.apache.thrift.transport.TTransport in project lucida by claritylab.

the class CalendarClient method main.

public static void main(String[] args) {
    // Collect the port number.
    int port = 8084;
    if (args.length == 1) {
        port = Integer.parseInt(args[0]);
    } else {
        System.out.println("Using default port for Calendar Client: " + port);
    }
    // Query.
    String LUCID = "Clinc";
    String query_input_data = "What is on my Google calendar for last week?";
    QueryInput query_input = new QueryInput();
    query_input.type = "query";
    query_input.data = new ArrayList<String>();
    query_input.data.add(query_input_data);
    QuerySpec query_spec = new QuerySpec();
    query_spec.content = new ArrayList<QueryInput>();
    query_spec.content.add(query_input);
    // Initialize thrift objects.
    // TTransport transport = new TSocket("clarity08.eecs.umich.edu", port);
    TTransport transport = new TSocket("localhost", port);
    TProtocol protocol = new TBinaryProtocol(new TFramedTransport(transport));
    LucidaService.Client client = new LucidaService.Client(protocol);
    try {
        // Talk to the Calendar server.
        transport.open();
        System.out.println(query_input_data);
        System.out.println("///// Connecting to Calendar... /////");
        String results = client.infer(LUCID, query_spec);
        System.out.println("///// Result: /////");
        System.out.println(results);
        transport.close();
    } catch (TException e) {
        e.printStackTrace();
    }
    return;
}
Also used : TException(org.apache.thrift.TException) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) TFramedTransport(org.apache.thrift.transport.TFramedTransport) TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Example 68 with TTransport

use of org.apache.thrift.transport.TTransport in project jstorm by alibaba.

the class SimpleTransportPlugin method connect.

/**
     * Connect to the specified server via framed transport
     * 
     * @param transport The underlying Thrift transport.
     * @param serverHost unused.
     * @param asUser unused.
     */
@Override
public TTransport connect(TTransport transport, String serverHost, String asUser) throws TTransportException {
    int maxBufferSize = type.getMaxBufferSize(storm_conf);
    // create a framed transport
    TTransport conn = new TFramedTransport(transport, maxBufferSize);
    // connect
    conn.open();
    LOG.debug("Simple client transport has been established");
    return conn;
}
Also used : TFramedTransport(org.apache.thrift.transport.TFramedTransport) TTransport(org.apache.thrift.transport.TTransport)

Example 69 with TTransport

use of org.apache.thrift.transport.TTransport in project jstorm by alibaba.

the class TBackoffConnect method doConnectWithRetry.

public TTransport doConnectWithRetry(ITransportPlugin transportPlugin, TTransport underlyingTransport, String host, String asUser) throws IOException {
    boolean connected = false;
    TTransport transportResult = null;
    while (!connected) {
        try {
            transportResult = transportPlugin.connect(underlyingTransport, host, asUser);
            connected = true;
        } catch (TTransportException ex) {
            retryNext(ex);
        }
    }
    return transportResult;
}
Also used : TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport)

Example 70 with TTransport

use of org.apache.thrift.transport.TTransport in project brisk by riptano.

the class BriskTool method getConnection.

private Brisk.Iface getConnection() throws IOException {
    TTransport trans = new TFramedTransport(new TSocket(host, port));
    try {
        trans.open();
    } catch (TTransportException e) {
        throw new IOException("unable to connect to brisk server");
    }
    Brisk.Iface client = new Brisk.Client(new TBinaryProtocol(trans));
    return client;
}
Also used : TBinaryProtocol(org.apache.cassandra.thrift.TBinaryProtocol) TFramedTransport(org.apache.thrift.transport.TFramedTransport) Brisk(org.apache.cassandra.thrift.Brisk) Iface(org.apache.cassandra.thrift.Brisk.Iface) TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport) IOException(java.io.IOException) TSocket(org.apache.thrift.transport.TSocket)

Aggregations

TTransport (org.apache.thrift.transport.TTransport)99 TSocket (org.apache.thrift.transport.TSocket)43 TProtocol (org.apache.thrift.protocol.TProtocol)42 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)36 TFramedTransport (org.apache.thrift.transport.TFramedTransport)28 TTransportException (org.apache.thrift.transport.TTransportException)20 Test (org.junit.Test)20 TException (org.apache.thrift.TException)18 IOException (java.io.IOException)12 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)10 ArrayList (java.util.ArrayList)9 TIOStreamTransport (org.apache.thrift.transport.TIOStreamTransport)8 HashMap (java.util.HashMap)6 Socket (java.net.Socket)5 TCLIService (org.apache.hive.service.rpc.thrift.TCLIService)5 THttpClient (org.apache.thrift.transport.THttpClient)4 TSaslClientTransport (org.apache.thrift.transport.TSaslClientTransport)4 ChannelBuffer (com.alibaba.dubbo.remoting.buffer.ChannelBuffer)3 Request (com.alibaba.dubbo.remoting.exchange.Request)3 Demo (com.alibaba.dubbo.rpc.gen.thrift.Demo)3