Search in sources :

Example 26 with TFramedTransport

use of org.apache.thrift.transport.TFramedTransport in project summer by foxsugar.

the class RpcManager method bingReferr.

private static void bingReferr(String ip, long userId, int ref) throws TException {
    TTransport adminTransport = new TFramedTransport(new TSocket(ip, 9090));
    adminTransport.open();
    // TTransport adminTransport = TransportManager.getTransport(ip, 9090);
    GameRPC.Client client = GameRpcClient.getAClient(adminTransport);
    client.bindReferee(userId, ref);
    // 
    adminTransport.close();
}
Also used : TFramedTransport(org.apache.thrift.transport.TFramedTransport) TTransport(org.apache.thrift.transport.TTransport) GameRPC(com.code.server.rpc.idl.GameRPC) TSocket(org.apache.thrift.transport.TSocket)

Example 27 with TFramedTransport

use of org.apache.thrift.transport.TFramedTransport in project hbase by apache.

the class TestThriftServerCmdLine method talkToThriftServer.

private void talkToThriftServer() throws Exception {
    TSocket sock = new TSocket(InetAddress.getLocalHost().getHostName(), port);
    TTransport transport = sock;
    if (specifyFramed || implType.isAlwaysFramed) {
        transport = new TFramedTransport(transport);
    }
    sock.open();
    try {
        TProtocol prot;
        if (specifyCompact) {
            prot = new TCompactProtocol(transport);
        } else {
            prot = new TBinaryProtocol(transport);
        }
        Hbase.Client client = new Hbase.Client(prot);
        if (!tableCreated) {
            TestThriftServer.createTestTables(client);
            tableCreated = true;
        }
        TestThriftServer.checkTableList(client);
    } finally {
        sock.close();
    }
}
Also used : TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TProtocol(org.apache.thrift.protocol.TProtocol) TFramedTransport(org.apache.thrift.transport.TFramedTransport) TTransport(org.apache.thrift.transport.TTransport) TCompactProtocol(org.apache.thrift.protocol.TCompactProtocol) Hbase(org.apache.hadoop.hbase.thrift.generated.Hbase) TSocket(org.apache.thrift.transport.TSocket)

Example 28 with TFramedTransport

use of org.apache.thrift.transport.TFramedTransport 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 29 with TFramedTransport

use of org.apache.thrift.transport.TFramedTransport 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 30 with TFramedTransport

use of org.apache.thrift.transport.TFramedTransport in project cdap by caskdata.

the class ThriftHelper method getThriftProtocol.

/**
 * generic method to discover a thrift service and start up the
 * thrift transport and protocol layer.
 */
public static TProtocol getThriftProtocol(String serviceName, EndpointStrategy endpointStrategy) throws ServerException {
    Discoverable endpoint = endpointStrategy.pick();
    if (endpoint == null) {
        String message = String.format("Service '%s' is not registered in discovery service.", serviceName);
        LOG.error(message);
        throw new ServerException(message);
    }
    TTransport transport = new TFramedTransport(new TSocket(endpoint.getSocketAddress().getHostName(), endpoint.getSocketAddress().getPort()));
    try {
        transport.open();
    } catch (TTransportException e) {
        String message = String.format("Unable to connect to thrift service %s at %s. Reason: %s", serviceName, endpoint.getSocketAddress(), e.getMessage());
        LOG.error(message);
        throw new ServerException(message, e);
    }
    // now try to connect the thrift client
    return new TBinaryProtocol(transport);
}
Also used : Discoverable(org.apache.twill.discovery.Discoverable) ServerException(co.cask.cdap.common.service.ServerException) TBinaryProtocol(org.apache.thrift.protocol.TBinaryProtocol) TFramedTransport(org.apache.thrift.transport.TFramedTransport) TTransportException(org.apache.thrift.transport.TTransportException) TTransport(org.apache.thrift.transport.TTransport) TSocket(org.apache.thrift.transport.TSocket)

Aggregations

TFramedTransport (org.apache.thrift.transport.TFramedTransport)45 TSocket (org.apache.thrift.transport.TSocket)41 TTransport (org.apache.thrift.transport.TTransport)32 TBinaryProtocol (org.apache.thrift.protocol.TBinaryProtocol)25 TProtocol (org.apache.thrift.protocol.TProtocol)24 TException (org.apache.thrift.TException)14 IOException (java.io.IOException)11 TTransportException (org.apache.thrift.transport.TTransportException)11 TCompactProtocol (org.apache.thrift.protocol.TCompactProtocol)10 Cassandra (org.apache.cassandra.thrift.Cassandra)4 Hello (org.tech.model.Hello)4 SocketException (java.net.SocketException)3 HashMap (java.util.HashMap)3 GameRPC (com.code.server.rpc.idl.GameRPC)2 UnknownHostException (java.net.UnknownHostException)2 SSLSocket (javax.net.ssl.SSLSocket)2 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)2 ConfigurationException (org.apache.cassandra.config.ConfigurationException)2 AuthenticationRequest (org.apache.cassandra.thrift.AuthenticationRequest)2 TBinaryProtocol (org.apache.cassandra.thrift.TBinaryProtocol)2