当前位置: 首页>>代码示例>>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;未经允许,请勿转载。