當前位置: 首頁>>代碼示例>>Java>>正文


Java HConnection.close方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.client.HConnection.close方法的典型用法代碼示例。如果您正苦於以下問題:Java HConnection.close方法的具體用法?Java HConnection.close怎麽用?Java HConnection.close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.client.HConnection的用法示例。


在下文中一共展示了HConnection.close方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: waitForConnection

import org.apache.hadoop.hbase.client.HConnection; //導入方法依賴的package包/類
public synchronized static void waitForConnection(long timeout, TimeUnit timeoutUnit) {
    long before = System.currentTimeMillis();
    long after;
    long timeoutMS = TimeUnit.MILLISECONDS.convert(timeout, timeoutUnit);
    do {
        try {
            HConnection hc = HConnectionManager.createConnection(HBaseConfiguration.create());
            hc.close();
            after = System.currentTimeMillis();
            log.info("HBase server to started after about {} ms", after - before);
            return;
        } catch (IOException e) {
            log.info("Exception caught while waiting for the HBase server to start", e);
        }
        after = System.currentTimeMillis();
    } while (timeoutMS > after - before);
    after = System.currentTimeMillis();
    log.warn("HBase server did not start in {} ms", after - before);
}
 
開發者ID:graben1437,項目名稱:titan1withtp3.1,代碼行數:20,代碼來源:HBaseStorageSetup.java

示例2: close

import org.apache.hadoop.hbase.client.HConnection; //導入方法依賴的package包/類
public static void close(HConnection conn) {
	if (conn != null) {
		try {
			conn.close();
		} catch (IOException e) {
			logger.warn("Error closing HBase connection: " + e.getMessage());
		}
	}
}
 
開發者ID:DaniUPC,項目名稱:near-image-replica-detection,代碼行數:10,代碼來源:HBaseClient.java

示例3: getHConnection

import org.apache.hadoop.hbase.client.HConnection; //導入方法依賴的package包/類
@Test
// 10 times: 751 mills.
public void getHConnection() throws Exception {
	int count = 10;
	HConnection result = null;
	long beg = System.currentTimeMillis();
	for (int i = 0; i < count; i++) {
		result = hzDataSource.getHConnection();
		System.out.println(result);
		assertNotNull(result);
		result.close();
	}
	long end = System.currentTimeMillis();
	System.out.println(count + " times: " + (end - beg) + " mills. ");
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:16,代碼來源:HzDataSourceImplTest.java

示例4: mockGetHConnection

import org.apache.hadoop.hbase.client.HConnection; //導入方法依賴的package包/類
@Test
public void mockGetHConnection() throws Exception {
	int count = 1;
	HConnection result = null;
	for (int i = 0; i < count; i++) {
		result = hzDataSource.getHConnection();
		result.close();
	}
	//
	System.out.println("[" + Thread.currentThread().getName() + "] "
			+ result);
	Thread.sleep(3 * 60 * 1000);
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:14,代碼來源:HzDataSourceImplTest.java

示例5: createHConnection

import org.apache.hadoop.hbase.client.HConnection; //導入方法依賴的package包/類
@Test
// 10 times: 2198 mills.
public void createHConnection() throws Exception {
	int count = 10;
	HConnection result = null;
	long beg = System.currentTimeMillis();
	for (int i = 0; i < count; i++) {
		result = factory.createHConnection();
		System.out.println(result);
		assertNotNull(result);
		result.close();
	}
	long end = System.currentTimeMillis();
	System.out.println(count + " times: " + (end - beg) + " mills. ");
}
 
開發者ID:mixaceh,項目名稱:openyu-commons,代碼行數:16,代碼來源:HConnectionFactoryImplTest.java

示例6: testClientSessionExpired

import org.apache.hadoop.hbase.client.HConnection; //導入方法依賴的package包/類
/**
 * See HBASE-1232 and http://wiki.apache.org/hadoop/ZooKeeper/FAQ#4.
 * @throws IOException
 * @throws InterruptedException
 */
// fails frequently, disabled for now, see HBASE-6406
//@Test
public void testClientSessionExpired() throws Exception {
  Configuration c = new Configuration(TEST_UTIL.getConfiguration());

  // We don't want to share the connection as we will check its state
  c.set(HConstants.HBASE_CLIENT_INSTANCE_ID, "1111");

  HConnection connection = HConnectionManager.getConnection(c);

  ZooKeeperWatcher connectionZK = getZooKeeperWatcher(connection);
  LOG.info("ZooKeeperWatcher= 0x"+ Integer.toHexString(
    connectionZK.hashCode()));
  LOG.info("getRecoverableZooKeeper= 0x"+ Integer.toHexString(
    connectionZK.getRecoverableZooKeeper().hashCode()));
  LOG.info("session="+Long.toHexString(
    connectionZK.getRecoverableZooKeeper().getSessionId()));

  TEST_UTIL.expireSession(connectionZK);

  LOG.info("Before using zkw state=" +
    connectionZK.getRecoverableZooKeeper().getState());
  // provoke session expiration by doing something with ZK
  try {
    connectionZK.getRecoverableZooKeeper().getZooKeeper().exists(
      "/1/1", false);
  } catch (KeeperException ignored) {
  }

  // Check that the old ZK connection is closed, means we did expire
  States state = connectionZK.getRecoverableZooKeeper().getState();
  LOG.info("After using zkw state=" + state);
  LOG.info("session="+Long.toHexString(
    connectionZK.getRecoverableZooKeeper().getSessionId()));

  // It's asynchronous, so we may have to wait a little...
  final long limit1 = System.currentTimeMillis() + 3000;
  while (System.currentTimeMillis() < limit1 && state != States.CLOSED){
    state = connectionZK.getRecoverableZooKeeper().getState();
  }
  LOG.info("After using zkw loop=" + state);
  LOG.info("ZooKeeper should have timed out");
  LOG.info("session="+Long.toHexString(
    connectionZK.getRecoverableZooKeeper().getSessionId()));

  // It's surprising but sometimes we can still be in connected state.
  // As it's known (even if not understood) we don't make the the test fail
  // for this reason.)
  // Assert.assertTrue("state=" + state, state == States.CLOSED);

  // Check that the client recovered
  ZooKeeperWatcher newConnectionZK = getZooKeeperWatcher(connection);

  States state2 = newConnectionZK.getRecoverableZooKeeper().getState();
  LOG.info("After new get state=" +state2);

  // As it's an asynchronous event we may got the same ZKW, if it's not
  //  yet invalidated. Hence this loop.
  final long limit2 = System.currentTimeMillis() + 3000;
  while (System.currentTimeMillis() < limit2 &&
    state2 != States.CONNECTED && state2 != States.CONNECTING) {

    newConnectionZK = getZooKeeperWatcher(connection);
    state2 = newConnectionZK.getRecoverableZooKeeper().getState();
  }
  LOG.info("After new get state loop=" + state2);

  Assert.assertTrue(
    state2 == States.CONNECTED || state2 == States.CONNECTING);

  connection.close();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:78,代碼來源:TestZooKeeper.java


注:本文中的org.apache.hadoop.hbase.client.HConnection.close方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。