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();
}
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();
}
}
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();
}
}
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;
}
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);
}
Aggregations