本文整理汇总了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\":\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"}");
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);
}
}