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


Java TSocket.open方法代碼示例

本文整理匯總了Java中org.apache.thrift.transport.TSocket.open方法的典型用法代碼示例。如果您正苦於以下問題:Java TSocket.open方法的具體用法?Java TSocket.open怎麽用?Java TSocket.open使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.thrift.transport.TSocket的用法示例。


在下文中一共展示了TSocket.open方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: logThrift

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
private static int logThrift(HostAndPort address, List<LogEntry> messages)
{
    try {
        TSocket socket = new TSocket(address.getHost(), address.getPort());
        socket.open();
        try {
            TBinaryProtocol tp = new TBinaryProtocol(new TFramedTransport(socket));
            assertEquals(new scribe.Client(tp).Log(messages), ResultCode.OK);
        }
        finally {
            socket.close();
        }
    }
    catch (TException e) {
        throw new RuntimeException(e);
    }
    return 1;
}
 
開發者ID:airlift,項目名稱:drift,代碼行數:19,代碼來源:TestApacheThriftMethodInvoker.java

示例2: makeObject

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
@Override
    public TServiceClient makeObject() throws Exception {
        TSocket tsocket = new TSocket(server.getHost(), server.getPort());
        tsocket.open();
//        TTransport transport = new TFramedTransport(tsocket);
        TJSONProtocol protocol = new TJSONProtocol(tsocket);
        TMultiplexedProtocol uProtocol=new TMultiplexedProtocol(protocol, proccessName);
        TServiceClient client = this.clientFactory.getClient(uProtocol);
        if (callback != null) {
            try {
                callback.make(client);
            } catch (Exception e) {
                logger.warn("makeObject:{}", e);
            }
        }
        return client;
    }
 
開發者ID:somewhereMrli,項目名稱:albedo-thrift,代碼行數:18,代碼來源:ThriftClientPoolFactory.java

示例3: thriftTest

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
@Test
public void thriftTest() throws TException {
    TSocket transport = new TSocket("127.0.0.1", 8080);
    transport.open();
    TProtocol protocol = new TBinaryProtocol(transport);
    TMultiplexedProtocol mp1 = new TMultiplexedProtocol(protocol,"helloWorld");
    HelloWorld.Client client = new HelloWorld.Client(mp1);
    User user = new User();
    user.setName("{\"proid\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}");
    user.setId(234242453);
    user.setIsman(true);
    Result result = client.createNewBaseResInfo(user);
    Assert.notNull(result);
    System.out.println(result.getMsg());
    System.out.println("end>>>>>>>>>>>>>>>>");

}
 
開發者ID:paullyphang,項目名稱:nebo,代碼行數:18,代碼來源:NeboTestCase.java

示例4: create

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
@Override
public Client create() throws Exception {
  TSocket transport = new TSocket(host, port);
  try {
    transport.open();
  } catch (TTransportException e) {
    throw new InterpreterException(e);
  }

  TProtocol protocol = new  TBinaryProtocol(transport);
  Client client = new RemoteInterpreterService.Client(protocol);

  synchronized (clientSocketMap) {
    clientSocketMap.put(client, transport);
  }
  return client;
}
 
開發者ID:lorthos,項目名稱:incubator-zeppelin-druid,代碼行數:18,代碼來源:ClientFactory.java

示例5: createConnection

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
/**
 * 創建原始連接的方法
 * 
 * @throws ThriftConnectionPoolException
 *             創建連接出現問題時拋出該異常
 */
@SuppressWarnings("unchecked")
private void createConnection() throws ThriftConnectionPoolException {
	try {
		transport = new TSocket(host, port, connectionTimeOut);
		transport.open();
		TProtocol protocol = createTProtocol(transport);
		// 反射實例化客戶端對象
		Constructor<? extends TServiceClient> clientConstructor = clientClass.getConstructor(TProtocol.class);
		client = (T) clientConstructor.newInstance(protocol);
		if (logger.isDebugEnabled()) {
			logger.debug("創建新連接成功:" + host + " 端口:" + port);
		}
	} catch (Exception e) {
		throw new ThriftConnectionPoolException("無法連接服務器:" + host + " 端口:" + port);
	}
}
 
開發者ID:wmz7year,項目名稱:Thrift-Connection-Pool,代碼行數:23,代碼來源:DefaultThriftConnection.java

示例6: setup

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
private void setup(String server, int port) throws Exception
{
    /* Establish a thrift connection to the cassandra instance */
    TSocket socket = new TSocket(server, port);
    System.out.println(" connected to " + server + ":" + port + ".");
    TBinaryProtocol binaryProtocol = new TBinaryProtocol(new TFramedTransport(socket));
    Cassandra.Client cassandraClient = new Cassandra.Client(binaryProtocol);
    socket.open();
    thriftClient = cassandraClient;
    String seed = DatabaseDescriptor.getSeeds().iterator().next().getHostAddress();
    conf = new Configuration();
    ConfigHelper.setOutputPartitioner(conf, DatabaseDescriptor.getPartitioner().getClass().getName());
    ConfigHelper.setOutputInitialAddress(conf, seed);
    ConfigHelper.setOutputRpcPort(conf, Integer.toString(DatabaseDescriptor.getRpcPort()));

}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:17,代碼來源:TestRingCache.java

示例7: setUp

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
public void setUp() throws Exception {
    super.setUp();
    Path rootDir = getDir(ROOT_DIR);
    Configuration conf = createJobConf();
    FileSystem fs = FileSystem.get(conf);
    fs.delete(rootDir, true);
    Path metastorePath = new Path("/tmp/metastore_db");
    fs.delete(metastorePath, true);
    Path warehouse = new Path("/tmp/warehouse");
    fs.delete(warehouse, true);
    fs.mkdirs(warehouse);

    if (standAloneServer) {
        try {
            transport = new TSocket(host, port);
            TProtocol protocol = new TBinaryProtocol(transport);
            client = new HiveClient(protocol);
            transport.open();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    } else {
        client = new HiveServer.HiveServerHandler();
    }
}
 
開發者ID:jmrozanec,項目名稱:hive-unit,代碼行數:26,代碼來源:HiveTestService.java

示例8: newClient

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
private Client newClient() throws TException{
	transport = new TSocket("localhost", PORT);
	transport.open();
	TMultiplexedProtocol protocol = new TMultiplexedProtocol(
			new TBinaryProtocol(transport), "Algorithm");
	return new Client(protocol);
}
 
開發者ID:kaichao,項目名稱:algorithm.annotation,代碼行數:8,代碼來源:AlgorithmClient.java

示例9: openTransport

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
private void openTransport() throws TTransportException {
transport = new TSocket(params.getHost(), params.getPort(), TsfileJDBCConfig.connectionTimeoutInMs);
try {
	transport.getSocket().setKeepAlive(true);
} catch (SocketException e) {
    System.out.println("Cannot set socket keep alive because: " + e.getMessage());
}
if (!transport.isOpen()) {
    transport.open();
}
  }
 
開發者ID:thulab,項目名稱:iotdb-jdbc,代碼行數:12,代碼來源:TsfileConnection.java

示例10: init

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
public synchronized void init() throws TTransportException {
	if (null != client) {
		return;
	}
	if (null == truststore) {
		transport = new TSocket(ip, port);
		transport.open();
	} else {
		/*
		 * Similar to the server, you can use the parameters to setup
		 * client parameters or use the default settings. On the client
		 * side, you will need a TrustStore which contains the trusted
		 * certificate along with the public key. For this example it's
		 * a self-signed cert.
		 */
		String truststore_arr[] = truststore.split("@");
		if (truststore_arr.length != 2) {
			throw new RuntimeException("client.truststore 格式錯誤(缺少 @密碼):" + truststore);
		}
		TSSLTransportParameters params = new TSSLTransportParameters();
		if (truststore_arr[0].endsWith(".truststore")) {
			params.setTrustStore(truststore_arr[0], truststore_arr[1], "SunX509", "JKS");
		} else {
			params.setTrustStore(truststore_arr[0], truststore_arr[1], "X509", "BKS");
		}
		/*
		 * Get a client transport instead of a server transport. The
		 * connection is opened on invocation of the factory method, no
		 * need to specifically call open()
		 */
		transport = TSSLTransportFactory.getClientSocket(ip, port, RemoteSyncConfig.getTimeout(), params);
	}

	TProtocol protocol = new TBinaryProtocol(transport);
	client = new SyncFileServer.Client(protocol);
}
 
開發者ID:xxonehjh,項目名稱:remote-files-sync,代碼行數:37,代碼來源:ThriftClientPool.java

示例11: main

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
public static void main(final String[] args) throws Exception {
  TSocket transport = new TSocket("localhost", 8000);
  transport.open();
  TBinaryProtocol protocol = new TBinaryProtocol(transport);
  TMultiplexedProtocol mp = new TMultiplexedProtocol(protocol, "greeterService");
  Greeter.Client client = new Greeter.Client(mp);
  HelloRequest req = new HelloRequest("world");
  HelloReply rep = client.sayHello(req);
  System.out.println("Message: " + rep.message);
}
 
開發者ID:bigdullrock,項目名稱:nifty-spring-boot-starter,代碼行數:11,代碼來源:SampleClient.java

示例12: setUp

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
  TSocket transport = new TSocket("localhost", port);
  transport.open();
  TMultiplexedProtocol mp =
      new TMultiplexedProtocol(new TBinaryProtocol(transport), "Greeter");
  client = new Greeter.Client(mp);
}
 
開發者ID:bigdullrock,項目名稱:nifty-spring-boot-starter,代碼行數:9,代碼來源:GreeterServiceTest.java

示例13: NaviHiveClientDriver

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
public NaviHiveClientDriver(ServerUrlUtil.ServerUrl server, String auth,
                            NaviPoolConfig poolConfig) {
    super(server, auth, poolConfig);
    try {
        transport = new TSocket(server.getHost(), server.getPort());
        TProtocol protocol = new TBinaryProtocol(transport);
        client = new HiveClient(protocol);
        transport.open();
    } catch (TTransportException e) {
        e.printStackTrace();
    }
}
 
開發者ID:sunguangran,項目名稱:navi,代碼行數:13,代碼來源:NaviHiveClientDriver.java

示例14: connect

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
/**
 * TODO.
 *
 * @throws HiveMetastoreException TODO
 */
private void connect() throws HiveMetastoreException {

  LOG.info("Connecting to ThriftHiveMetastore " + host + ":" + port);
  transport = new TSocket(host, port, 1000 * clientSocketTimeout);

  this.client = new ThriftHiveMetastore.Client(new TBinaryProtocol(transport));

  try {
    transport.open();
  } catch (TTransportException e) {
    close();
    throw new HiveMetastoreException(e);
  }
}
 
開發者ID:airbnb,項目名稱:reair,代碼行數:20,代碼來源:ThriftHiveMetastoreClient.java

示例15: createConnection

import org.apache.thrift.transport.TSocket; //導入方法依賴的package包/類
/**
 * 創建原始連接的方法
 * 
 * @throws ThriftConnectionPoolException
 *             創建連接出現問題時拋出該異常
 */
@SuppressWarnings("unchecked")
private void createConnection() throws ThriftConnectionPoolException {
	try {
		transport = new TSocket(host, port, connectionTimeOut);
		transport.open();
		TProtocol protocol = createTProtocol(transport);

		Iterator<Entry<String, Class<? extends TServiceClient>>> iterator = thriftClientClasses.entrySet()
				.iterator();
		while (iterator.hasNext()) {
			Entry<String, Class<? extends TServiceClient>> entry = iterator.next();
			String serviceName = entry.getKey();
			Class<? extends TServiceClient> clientClass = entry.getValue();
			TMultiplexedProtocol multiProtocol = new TMultiplexedProtocol(protocol, serviceName);
			// 反射實例化客戶端對象
			Constructor<? extends TServiceClient> clientConstructor = clientClass.getConstructor(TProtocol.class);
			T client = (T) clientConstructor.newInstance(multiProtocol);
			clients.put(serviceName, client);
			if (logger.isDebugEnabled()) {
				logger.debug("創建新連接成功:" + host + " 端口:" + port);
			}
		}

	} catch (Exception e) {
		e.printStackTrace();
		throw new ThriftConnectionPoolException("無法連接服務器:" + host + " 端口:" + port, e);
	}
}
 
開發者ID:wmz7year,項目名稱:Thrift-Connection-Pool,代碼行數:35,代碼來源:MulitServiceThriftConnecion.java


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