本文整理匯總了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;
}
示例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;
}
示例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\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}");
user.setId(234242453);
user.setIsman(true);
Result result = client.createNewBaseResInfo(user);
Assert.notNull(result);
System.out.println(result.getMsg());
System.out.println("end>>>>>>>>>>>>>>>>");
}
示例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;
}
示例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);
}
}
示例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()));
}
示例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();
}
}
示例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);
}
示例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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
示例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);
}
}
示例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);
}
}