当前位置: 首页>>代码示例>>Java>>正文


Java TFramedTransport.open方法代码示例

本文整理汇总了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;
    }

}
 
开发者ID:songbin,项目名称:frc,代码行数:21,代码来源:FrcFactory.java

示例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;
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:22,代码来源:ClusterManagerAvailabilityChecker.java

示例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;
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:34,代码来源:CoronaAdmin.java

示例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;
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:28,代码来源:CoronaAdmin.java

示例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);
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:17,代码来源:CoronaTaskTracker.java

示例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;
}
 
开发者ID:twitter,项目名称:heron,代码行数:20,代码来源:ScribeSink.java

示例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);
    }
}
 
开发者ID:usc-cloud,项目名称:floe2,代码行数:21,代码来源:ThriftClient.java

示例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));
  }
}
 
开发者ID:javachen,项目名称:learning-hadoop,代码行数:31,代码来源:CassandraConnection.java

示例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);
    }
}
 
开发者ID:opendaylight,项目名称:archived-net-virt-platform,代码行数:17,代码来源:Connection.java

示例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;
}
 
开发者ID:cyfonly,项目名称:ThriftJ,代码行数:13,代码来源:ThriftConnectionFactory.java

示例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();
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:8,代码来源:CassandraBase.java

示例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;
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:18,代码来源:CoronaClient.java

示例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);
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:15,代码来源:CoronaJobTracker.java

示例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));
}
 
开发者ID:gentili,项目名称:IsoBlockProjector,代码行数:12,代码来源:testConnect.java

示例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;
}
 
开发者ID:lhfei,项目名称:hadoop-in-action,代码行数:12,代码来源:Connector.java


注:本文中的org.apache.thrift.transport.TFramedTransport.open方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。