本文整理汇总了Java中org.apache.thrift.transport.TFramedTransport.open方法的典型用法代码示例。如果您正苦于以下问题:Java TFramedTransport.open方法的具体用法?Java TFramedTransport.open怎么用?Java TFramedTransport.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.thrift.transport.TFramedTransport
的用法示例。
在下文中一共展示了TFramedTransport.open方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeObject
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public PooledObject makeObject() throws Exception {
//logger.debug("makeObject...........");
try {
String host = this.host;
int port = this.port;
int timeout = this.timeout;
TFramedTransport transport = new TFramedTransport(new TSocket(host, port, timeout));
TBinaryProtocol protocol = new TBinaryProtocol(transport);
FrcService.Client client = new FrcService.Client(protocol, protocol);
transport.open();
RpcClient<Client> rpcClient = new RpcClient(client, transport, 1);
return this.wrap(rpcClient);
} catch (Exception e) {
logger.error("exception", e);
return null;
}
}
示例2: getPJTClient
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
/**
* Used for getting a client to the CoronaProxyJobTracker
* @param conf
* @return Returns a client to the CPJT
* @throws IOException
*/
public static CoronaProxyJobTrackerService.Client
getPJTClient(CoronaConf conf) throws IOException {
InetSocketAddress address =
NetUtils.createSocketAddr(conf.getProxyJobTrackerThriftAddress());
TFramedTransport transport = new TFramedTransport(
new TSocket(address.getHostName(), address.getPort()));
CoronaProxyJobTrackerService.Client client =
new CoronaProxyJobTrackerService.Client(new TBinaryProtocol(transport));
try {
transport.open();
} catch (TException e) {
LOG.info("Transport Exception: ", e);
}
return client;
}
示例3: setSafeMode
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
/**
* Turns on the Safe Mode if safeMode is true. Turns off the Safe Mode if
* safeMode is false.
* @param safeMode Is true if we want the Safe Mode to be on. false
* otherwise.
* @return 0 if successful.
* @throws IOException
*/
private int setSafeMode(boolean safeMode) throws IOException {
// Get the current configuration
CoronaConf conf = new CoronaConf(getConf());
InetSocketAddress address = NetUtils.createSocketAddr(conf
.getClusterManagerAddress());
TFramedTransport transport = new TFramedTransport(
new TSocket(address.getHostName(), address.getPort()));
ClusterManagerService.Client client = new ClusterManagerService.Client(
new TBinaryProtocol(transport));
try {
transport.open();
if (client.setSafeMode(safeMode)) {
System.out.println("The safeMode is: " +
(safeMode ? "ON" : "OFF"));
} else {
System.err.println("Could not set the safeMode flag");
}
} catch (TException e) {
throw new IOException(e);
}
return 0;
}
示例4: persistState
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
/**
* Persists the state of the ClusterManager
* @return 0 if successful.
* @throws IOException
*/
private int persistState() throws IOException {
// Get the current configuration
CoronaConf conf = new CoronaConf(getConf());
InetSocketAddress address = NetUtils.createSocketAddr(conf
.getClusterManagerAddress());
TFramedTransport transport = new TFramedTransport(
new TSocket(address.getHostName(), address.getPort()));
ClusterManagerService.Client client = new ClusterManagerService.Client(
new TBinaryProtocol(transport));
try {
transport.open();
if (!client.persistState()) {
System.err.println("Persisting Cluster Manager state failed. ");
}
} catch (TException e) {
throw new IOException(e);
}
return 0;
}
示例5: initializeClusterManagerClient
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
private synchronized void initializeClusterManagerClient()
throws IOException {
// Connect to cluster manager thrift service
String target = CoronaConf.getClusterManagerAddress(fConf);
LOG.info("Connecting to Cluster Manager at " + target);
InetSocketAddress address = NetUtils.createSocketAddr(target);
transport = new TFramedTransport(
new TSocket(address.getHostName(), address.getPort()));
TProtocol protocol = new TBinaryProtocol(transport);
client = new ClusterManagerService.Client(protocol);
try {
transport.open();
} catch (TTransportException e) {
throw new IOException(e);
}
}
示例6: open
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
private boolean open() {
try {
TSocket socket = new TSocket((String) config.get(KEY_SCRIBE_HOST),
TypeUtils.getInteger(config.get(KEY_SCRIBE_PORT)),
TypeUtils.getInteger(config.get(KEY_SCRIBE_TIMEOUT_MS)));
transport = new TFramedTransport(socket);
transport.open();
} catch (TException tx) {
LOG.log(Level.SEVERE, "Failed to open connection to scribe server " + connectionString(), tx);
return false;
}
LOG.info("Opened connection to scribe server " + connectionString());
TProtocol protocol = new TBinaryProtocol(transport);
client = new scribe.Client(protocol);
return true;
}
示例7: ThriftClient
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
/**
* default public constructor. Establishes connection with the Floe Server.
*
* @throws TTransportException Exception
*/
public ThriftClient() throws TTransportException {
String host = FloeConfig.getConfig().getString(
ConfigProperties.COORDINATOR_HOST);
int port = FloeConfig.getConfig().getInt(
ConfigProperties.COORDINATOR_PORT);
TTransport baseTransport = new TSocket(host, port);
transport = new TFramedTransport(baseTransport);
transport.open();
LOGGER.info("Connection to Floe Server has been established.");
if (transport != null) {
protocol = new TBinaryProtocol(transport);
}
}
示例8: CassandraConnection
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
/**
* Construct an CassandaraConnection with optional authentication.
*
* @param host the host to connect to
* @param port the port to use
* @param username the username to authenticate with (may be null
* for no authentication)
* @param password the password to authenticate with (may be null
* for no authentication)
* @throws Exception if the connection fails
*/
public CassandraConnection(String host, int port,
String username, String password, int timeout) throws Exception {
TSocket socket = new TSocket(host, port);
if (timeout > 0) {
socket.setTimeout(timeout);
}
m_transport = new TFramedTransport(socket);
TProtocol protocol = new TBinaryProtocol(m_transport);
m_client = new Cassandra.Client(protocol);
m_transport.open();
if (!Const.isEmpty(username) && !Const.isEmpty(password)) {
Map<String, String> creds = new HashMap<String, String>();
creds.put("username", username);
creds.put("password", password);
m_client.login(new AuthenticationRequest(creds));
}
}
示例9: open
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
public void open() {
try {
// FIXME: Is this the optimal code for thrift 0.5? This code seems to change
// with every new Cassandra release and they never update the sample code.
// Probably need to get the source package and look at the unit tests to verify.
TSocket socket = new TSocket(this.host, this.port);
transport = new TFramedTransport(socket);
TProtocol protocol = new TBinaryProtocol(transport);
client = new Cassandra.Client(protocol);
transport.open();
}
catch (TTransportException exc) {
close();
throw new StorageException("Error opening Cassandra connection", exc);
}
}
示例10: makeObject
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
@Override
public PooledObject<TTransport> makeObject(ThriftServer thriftServer) throws Exception {
TSocket tsocket = new TSocket(thriftServer.getHost(), thriftServer.getPort());
tsocket.setTimeout(timeout);
TFramedTransport transport = new TFramedTransport(tsocket);
transport.open();
DefaultPooledObject<TTransport> result = new DefaultPooledObject<TTransport>(transport);
logger.trace("Make new thrift connection: {}:{}", thriftServer.getHost(), thriftServer.getPort());
return result;
}
示例11: getConnection
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
private void getConnection() throws TTransportException {
log.info(String.format("Connecting to Cassandra at %s:%d", cassHost, cassPort));
tr = new TFramedTransport(new TSocket(cassHost, cassPort));
proto = new TBinaryProtocol(tr);
client = new Cassandra.Client(proto);
tr.open();
}
示例12: getCMSClient
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
/**
* Get the thrift client to communicate with the cluster manager
* @return a thrift client initialized to talk to the cluster manager
* @param conf The configuration.
* @throws TTransportException
*/
private static ClusterManagerService.Client getCMSClient(CoronaConf conf)
throws TTransportException {
InetSocketAddress address = NetUtils.createSocketAddr(conf
.getClusterManagerAddress());
TFramedTransport transport = new TFramedTransport(
new TSocket(address.getHostName(), address.getPort()));
ClusterManagerService.Client client = new ClusterManagerService.Client(
new TBinaryProtocol(transport));
transport.open();
return client;
}
示例13: initializePJTClient
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
private void initializePJTClient()
throws IOException {
InetSocketAddress address =
NetUtils.createSocketAddr(new CoronaConf(conf).getProxyJobTrackerThriftAddress());
pjtTransport = new TFramedTransport(
new TSocket(address.getHostName(), address.getPort()));
pjtClient =
new CoronaProxyJobTrackerService.Client(new TBinaryProtocol(pjtTransport));
try {
pjtTransport.open();
} catch (TException e) {
LOG.info("Transport Exception: ", e);
}
}
示例14: main
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
public static void main(String[] args) throws TException {
System.out.println("Initial connect...");
TFramedTransport transport = new TFramedTransport(new TSocket("localhost",9090));
transport.open();
TProtocol protocol = new TBinaryProtocol(transport);
IsoBlockProjectorService.Client client = new IsoBlockProjectorService.Client(protocol);
System.out.println("Version: "+ client.getVersion());
IBPProjectionFrame frame = client.getDownFrame(0, new IBPiVector(0,0,0),new IBPiVector(0,0,0));
}
示例15: connect
import org.apache.thrift.transport.TFramedTransport; //导入方法依赖的package包/类
public Cassandra.Client connect() throws TTransportException, TException, InvalidRequestException {
TFramedTransport tf = new TFramedTransport(tr);
TProtocol proto = new TBinaryProtocol(tf);
Cassandra.Client client = new Cassandra.Client(proto);
tf.open();
//client.set_keyspace(KEYSPACE);
client.send_set_keyspace(KEYSPACE);
return client;
}