當前位置: 首頁>>代碼示例>>Java>>正文


Java TTransport.open方法代碼示例

本文整理匯總了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);
}
 
開發者ID:jigsaw-projects,項目名稱:jigsaw-payment,代碼行數:17,代碼來源:AbstractTransportPool.java

示例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();
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:22,代碼來源:TestScribeSource.java

示例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();
}
 
開發者ID:weizhenyi,項目名稱:leaf-snowflake,代碼行數:17,代碼來源:rpcClient.java

示例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();
}
 
開發者ID:weizhenyi,項目名稱:leaf-snowflake,代碼行數:19,代碼來源:rpcClient.java

示例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;
}
 
開發者ID:somewhereMrli,項目名稱:albedo-thrift,代碼行數:21,代碼來源:ThriftClientPoolFactory.java

示例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)));
}
 
開發者ID:pacheco,項目名稱:GlobalFS,代碼行數:21,代碼來源:MicroBenchAppend.java

示例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)));
}
 
開發者ID:pacheco,項目名稱:GlobalFS,代碼行數:19,代碼來源:MicroBenchGetdir.java

示例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);
}
 
開發者ID:pacheco,項目名稱:GlobalFS,代碼行數:19,代碼來源:PopulateFiles.java

示例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);
    }
 
開發者ID:Ericsson,項目名稱:CodeCheckerEclipsePlugin,代碼行數:20,代碼來源:ThriftTransportFactory.java

示例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();
    }
}
 
開發者ID:k0105,項目名稱:ensemble,代碼行數:26,代碼來源:ThriftServer.java

示例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();
}
 
開發者ID:moueimei,項目名稱:flume-release-1.7.0,代碼行數:29,代碼來源:TestScribeSource.java

示例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();
}
 
開發者ID:marcelocf,項目名稱:janusgraph_tutorial,代碼行數:11,代碼來源:Schema.java

示例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;
}
 
開發者ID:weizhenyi,項目名稱:leaf-snowflake,代碼行數:11,代碼來源:rpcClient.java

示例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();
        }
    }
}
 
開發者ID:dneves,項目名稱:thrift-ui-fx,代碼行數:9,代碼來源:MethodRequestController.java

示例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;
}
 
開發者ID:ngayngo9x,項目名稱:q-thrift,代碼行數:9,代碼來源:DefaultThriftConnectionPoolImpl.java


注:本文中的org.apache.thrift.transport.TTransport.open方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。