本文整理匯總了Java中org.apache.thrift.transport.TTransport.open方法的典型用法代碼示例。如果您正苦於以下問題:Java TTransport.open方法的具體用法?Java TTransport.open怎麽用?Java TTransport.open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.thrift.transport.TTransport
的用法示例。
在下文中一共展示了TTransport.open方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
@Override
public TTransport create(ServiceInstance<RpcPayload> instance)
throws Exception {
TTransport transport = this.createNativeTransport(instance);
try {
transport.open();
} catch (TException ex) {
LOG.warn(
"Error when creating new transport on server: "
+ instance.getAddress() + ":" + instance.getPort(),
ex);
markError(instance);
throw ex;
}
return new ManagedTransport(transport, instance);
}
示例2: testScribeMessage
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
@Test
public void testScribeMessage() throws Exception {
TTransport transport = new TFramedTransport(new TSocket("localhost", port));
TProtocol protocol = new TBinaryProtocol(transport);
Scribe.Client client = new Scribe.Client(protocol);
transport.open();
LogEntry logEntry = new LogEntry("INFO", "Sending info msg to scribe source");
List<LogEntry> logEntries = new ArrayList<LogEntry>(1);
logEntries.add(logEntry);
client.Log(logEntries);
// try to get it from Channels
Transaction tx = memoryChannel.getTransaction();
tx.begin();
Event e = memoryChannel.take();
Assert.assertNotNull(e);
Assert.assertEquals("Sending info msg to scribe source", new String(e.getBody()));
tx.commit();
tx.close();
}
示例3: startClient
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
public static void startClient(String ip ,int port ,int timeout) throws Exception
{
TTransport transport = new TSocket(ip,port,timeout);
TProtocol protocol = new TBinaryProtocol(transport);
leafrpc.Client client = new leafrpc.Client(protocol);
transport.open();
int i = 0;
while(i < 2000000)
{
client.getID("");
++i;
}
transport.close();
}
示例4: startClient2
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
public static void startClient2(String ip ,int port ,int timeout) throws Exception
{
TTransport transport = new TFramedTransport(new TSocket(ip,port,timeout));
TProtocol protocol = new TBinaryProtocol(transport);
leafrpc.Client client = new leafrpc.Client(protocol);
transport.open();
for(int i = 0; i< 1000000; i++)
{
client.getID("");
if (i % 100000 == 0)
{
System.out.println(Thread.currentThread().getName() + " " + client.getID(""));
}
//ai.incrementAndGet();
}
transport.close();
}
示例5: makeObject
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
@Override
public TServiceClient makeObject() throws Exception {
InetSocketAddress address = serverAddressProvider.selector();
if(address==null){
new ThriftException("No provider available for remote service");
}
TSocket tsocket = new TSocket(address.getHostName(), address.getPort());
TTransport transport = new TFramedTransport(tsocket);
TProtocol protocol = new TBinaryProtocol(transport);
TServiceClient client = this.clientFactory.getClient(protocol);
transport.open();
if (callback != null) {
try {
callback.make(client);
} catch (Exception e) {
logger.warn("makeObject:{}", e);
}
}
return client;
}
示例6: Worker
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
public Worker(int id, long durationMillis, String path, int globals) throws IOException {
this.id = id;
this.workerDuration = durationMillis;
this.localPath = path + "/f" + Integer.toString(id);
this.globalPath = "/f" + Integer.toString(id);
this.instanceMap = new HashMap<>();
this.globals = globals;
String replicaHost = replicaAddr.split(":")[0];
int replicaPort = Integer.parseInt(replicaAddr.split(":")[1]);
TTransport transport = new TSocket(replicaHost, replicaPort);
try {
transport.open();
} catch (TTransportException e) {
throw new RuntimeException(e);
}
TProtocol protocol = new TBinaryProtocol(transport);
c = new FuseOps.Client(protocol);
out = new BufferedWriter(new FileWriter(new File(logPrefix + this.id)));
}
示例7: Worker
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
public Worker(int id, long durationMillis, String path, int globals) throws IOException {
this.id = id;
this.workerDuration = durationMillis;
this.path = path;
this.globals = globals;
String replicaHost = replicaAddr.split(":")[0];
int replicaPort = Integer.parseInt(replicaAddr.split(":")[1]);
TTransport transport = new TSocket(replicaHost, replicaPort);
try {
transport.open();
} catch (TTransportException e) {
throw new RuntimeException(e);
}
TProtocol protocol = new TBinaryProtocol(transport);
c = new FuseOps.Client(protocol);
out = new BufferedWriter(new FileWriter(new File(logPrefix + this.id)));
}
示例8: Worker
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
public Worker(int id, String path) throws IOException {
this.id = id;
this.path = path;
this.localPath = path + "/f" + Integer.toString(id);
this.globalPath = "/f" + Integer.toString(id);
this.instanceMap = new HashMap<>();
String replicaHost = replicaAddr.split(":")[0];
int replicaPort = Integer.parseInt(replicaAddr.split(":")[1]);
TTransport transport = new TSocket(replicaHost, replicaPort);
try {
transport.open();
} catch (TTransportException e) {
throw new RuntimeException(e);
}
TProtocol protocol = new TBinaryProtocol(transport);
c = new FuseOps.Client(protocol);
}
示例9: requestTransport
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
protected TProtocol requestTransport(String url) throws TTransportException {
// probably not thread safe, but we need it? Not atm.
TTransport act;
if (!activeTransports.containsKey(url)) {
logger.log(Level.DEBUG ,"Creating new transport for: " + url);
activeTransports.put(url, new THttpClient(url));
}
act = activeTransports.get(url);
if (!act.isOpen()) {
act.open();
}
// THINK: always create new protocol?
return new TJSONProtocol(act);
}
示例10: connectToCMD
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
private static void connectToCMD() {
QueryInput query_input = new QueryInput();
query_input.type = "ensemble";
query_input.data = new ArrayList<String>();
query_input.data.add("localhost");
query_input.tags = new ArrayList<String>();
query_input.tags.add("9090");
QuerySpec spec = new QuerySpec();
spec.content = new ArrayList<QueryInput>();
spec.content.add(query_input);
// 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("", spec);
transport.close();
System.out.println("Successfully connected to CMD");
} catch (TException x) {
x.printStackTrace();
}
}
示例11: testScribeMultipleMessages
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
@Test
public void testScribeMultipleMessages() throws Exception {
TTransport transport = new TFramedTransport(new TSocket("localhost", port));
TProtocol protocol = new TBinaryProtocol(transport);
Scribe.Client client = new Scribe.Client(protocol);
transport.open();
List<LogEntry> logEntries = new ArrayList<LogEntry>(10);
for (int i = 0; i < 10; i++) {
LogEntry logEntry = new LogEntry("INFO", String.format("Sending info msg# %d to scribe source", i));
logEntries.add(logEntry);
}
client.Log(logEntries);
// try to get it from Channels
Transaction tx = memoryChannel.getTransaction();
tx.begin();
for (int i = 0; i < 10; i++) {
Event e = memoryChannel.take();
Assert.assertNotNull(e);
Assert.assertEquals(String.format("Sending info msg# %d to scribe source", i), new String(e.getBody()));
}
tx.commit();
tx.close();
}
示例12: dropOldKeyspace
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
private void dropOldKeyspace() throws InvalidRequestException, SchemaDisagreementException, TException {
TTransport tr = new TFramedTransport(new TSocket("localhost", 9160));
TProtocol proto = new TBinaryProtocol(tr);
Cassandra.Client client = new Cassandra.Client(proto);
tr.open();
client.system_drop_keyspace(JANUSGRAPH);
LOGGER.info("DROPPED keyspace janusgraph");
tr.close();
}
示例13: getTimestamp
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
public static long getTimestamp(String ip, int port ,int timeout) throws Exception
{
TTransport transport = new TSocket(ip,port,timeout);
TProtocol protocol = new TBinaryProtocol(transport);
leafrpc.Client client = new leafrpc.Client(protocol);
transport.open();
long timestamp = client.gettimestamp(Utils.currentTimeMs());
transport.close();
return timestamp;
}
示例14: open
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
private void open( TProtocol protocol ) throws TTransportException {
if ( protocol != null ) {
TTransport transport = protocol.getTransport();
if ( transport != null && ! transport.isOpen() ) {
transport.open();
}
}
}
示例15: makeObject
import org.apache.thrift.transport.TTransport; //導入方法依賴的package包/類
@Override
public PooledObject<TTransport> makeObject(ThriftServerInfo info) throws Exception {
TTransport transport = transportProvider.apply(info);
transport.open();
DefaultPooledObject<TTransport> result = new DefaultPooledObject<>(transport);
logger.trace("make new thrift connection:{}", info);
return result;
}