當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。