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


Java HConnectionManager類代碼示例

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


HConnectionManager類屬於org.apache.hadoop.hbase.client包,在下文中一共展示了HConnectionManager類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
public static void main(String[] args) {

        try {
            Configuration conf = HBaseConfiguration.create();  // create a new hbase connection object. (singleton)
            conn = HConnectionManager.createConnection(conf);

            QueryAll("t");
        } catch (IOException e) {
            e.printStackTrace();
        }


        // createTable("wujintao");
        // insertData("wujintao");

        // QueryByCondition1("wujintao");
        // QueryByCondition2("wujintao");
        //QueryByCondition3("wujintao");
        //deleteRow("wujintao","abcdef");
        //deleteByCondition("wujintao","abcdef");
    }
 
開發者ID:yjp123456,項目名稱:SparkDemo,代碼行數:22,代碼來源:MyClass.java

示例2: open

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
/**
 * 連接HBase
 */
public static void open() {
	try {
		config = HBaseConfiguration.create();
		conn = HConnectionManager.createConnection(config);
		admin = new HBaseAdmin(conn);
		hbase_table = conn.getTable(ISAXIndex.TABLE_NAME);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
開發者ID:ItGql,項目名稱:SparkIsax,代碼行數:14,代碼來源:HBaseUtils.java

示例3: init

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
@Override
public void init(Context context) throws IOException {
  super.init(context);
  this.conf = HBaseConfiguration.create(ctx.getConfiguration());
  decorateConf();
  this.maxRetriesMultiplier = this.conf.getInt("replication.source.maxretriesmultiplier", 300);
  this.socketTimeoutMultiplier = this.conf.getInt("replication.source.socketTimeoutMultiplier",
      maxRetriesMultiplier);
  // TODO: This connection is replication specific or we should make it particular to
  // replication and make replication specific settings such as compression or codec to use
  // passing Cells.
  this.conn = HConnectionManager.createConnection(this.conf);
  this.sleepForRetries =
      this.conf.getLong("replication.source.sleepforretries", 1000);
  this.metrics = context.getMetrics();
  // ReplicationQueueInfo parses the peerId out of the znode for us
  this.replicationSinkMgr = new ReplicationSinkManager(conn, ctx.getPeerId(), this, this.conf);
  // per sink thread pool
  this.maxThreads = this.conf.getInt(HConstants.REPLICATION_SOURCE_MAXTHREADS_KEY,
    HConstants.REPLICATION_SOURCE_MAXTHREADS_DEFAULT);

  this.exec = new ThreadPoolExecutor(maxThreads, maxThreads, 60, TimeUnit.SECONDS,
      new LinkedBlockingQueue<Runnable>());
  this.exec.allowCoreThreadTimeOut(true);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:26,代碼來源:HBaseInterClusterReplicationEndpoint.java

示例4: loadDisabledTables

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
/**
 * Load the list of disabled tables in ZK into local set.
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
private void loadDisabledTables()
throws ZooKeeperConnectionException, IOException {
  HConnectionManager.execute(new HConnectable<Void>(getConf()) {
    @Override
    public Void connect(HConnection connection) throws IOException {
      ZooKeeperWatcher zkw = createZooKeeperWatcher();
      try {
        for (TableName tableName :
            ZKTableStateClientSideReader.getDisabledOrDisablingTables(zkw)) {
          disabledTables.add(tableName);
        }
      } catch (KeeperException ke) {
        throw new IOException(ke);
      } catch (InterruptedException e) {
        throw new InterruptedIOException();
      } finally {
        zkw.close();
      }
      return null;
    }
  });
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:HBaseFsck.java

示例5: testMultipleZK

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
@Test
public void testMultipleZK()
throws IOException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
  Table localMeta =
    new HTable(new Configuration(TEST_UTIL.getConfiguration()), TableName.META_TABLE_NAME);
  Configuration otherConf = new Configuration(TEST_UTIL.getConfiguration());
  otherConf.set(HConstants.ZOOKEEPER_QUORUM, "127.0.0.1");
  Table ipMeta = new HTable(otherConf, TableName.META_TABLE_NAME);

  // dummy, just to open the connection
  final byte [] row = new byte [] {'r'};
  localMeta.exists(new Get(row));
  ipMeta.exists(new Get(row));

  // make sure they aren't the same
  ZooKeeperWatcher z1 =
    getZooKeeperWatcher(HConnectionManager.getConnection(localMeta.getConfiguration()));
  ZooKeeperWatcher z2 =
    getZooKeeperWatcher(HConnectionManager.getConnection(otherConf));
  assertFalse(z1 == z2);
  assertFalse(z1.getQuorum().equals(z2.getQuorum()));

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

示例6: initialize

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
@Override
public void initialize(Configuration conf) throws IOException {
  this.conf = conf;
  this.hBaseAdmin = new HBaseAdmin(conf);
  this.connection = HConnectionManager.createConnection(conf);

  final TableName stateTable = TableName.valueOf(conf.get(TxConstants.TransactionPruning.PRUNE_STATE_TABLE,
                                                          TxConstants.TransactionPruning.DEFAULT_PRUNE_STATE_TABLE));
  LOG.info("Initializing plugin with state table {}:{}", stateTable.getNamespaceAsString(),
           stateTable.getNameAsString());
  createPruneTable(stateTable);
  this.dataJanitorState = new DataJanitorState(new DataJanitorState.TableSupplier() {
    @Override
    public HTableInterface get() throws IOException {
      return connection.getTable(stateTable);
    }
  });
}
 
開發者ID:apache,項目名稱:incubator-tephra,代碼行數:19,代碼來源:HBaseTransactionPruningPlugin.java

示例7: beforeTest

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
@Before
public void beforeTest() throws Exception {
  pruneStateTable = TableName.valueOf(conf.get(TxConstants.TransactionPruning.PRUNE_STATE_TABLE,
                                               TxConstants.TransactionPruning.DEFAULT_PRUNE_STATE_TABLE));
  HTable table = createTable(pruneStateTable.getName(), new byte[][]{DataJanitorState.FAMILY}, false,
                             // Prune state table is a non-transactional table, hence no transaction co-processor
                             Collections.<String>emptyList());
  table.close();
  connection = HConnectionManager.createConnection(conf);

  dataJanitorState =
    new DataJanitorState(new DataJanitorState.TableSupplier() {
      @Override
      public HTableInterface get() throws IOException {
        return connection.getTable(pruneStateTable);
      }
    });

}
 
開發者ID:apache,項目名稱:incubator-tephra,代碼行數:20,代碼來源:DataJanitorStateTest.java

示例8: init

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
/**
 * Sets up common resources required by all clients.
 */
public void init() throws IOException {
  Injector injector = Guice.createInjector(
      new ConfigModule(conf),
      new ZKModule(),
      new DiscoveryModules().getDistributedModules(),
      new TransactionModules().getDistributedModules(),
      new TransactionClientModule()
  );

  zkClient = injector.getInstance(ZKClientService.class);
  zkClient.startAndWait();
  txClient = injector.getInstance(TransactionServiceClient.class);

  createTableIfNotExists(conf, TABLE, new byte[][]{ FAMILY });
  conn = HConnectionManager.createConnection(conf);
}
 
開發者ID:apache,項目名稱:incubator-tephra,代碼行數:20,代碼來源:BalanceBooks.java

示例9: loadDisabledTables

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
/**
 * Load the list of disabled tables in ZK into local set.
 * @throws ZooKeeperConnectionException
 * @throws IOException
 */
private void loadDisabledTables()
throws ZooKeeperConnectionException, IOException {
  HConnectionManager.execute(new HConnectable<Void>(getConf()) {
    @Override
    public Void connect(HConnection connection) throws IOException {
      ZooKeeperWatcher zkw = connection.getZooKeeperWatcher();
      try {
        for (String tableName : ZKTableReadOnly.getDisabledOrDisablingTables(zkw)) {
          disabledTables.add(Bytes.toBytes(tableName));
        }
      } catch (KeeperException ke) {
        throw new IOException(ke);
      }
      return null;
    }
  });
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:23,代碼來源:HBaseFsck.java

示例10: testMultipleZK

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
@Test
public void testMultipleZK() {
  try {
    HTable localMeta =
      new HTable(new Configuration(TEST_UTIL.getConfiguration()), HConstants.META_TABLE_NAME);
    Configuration otherConf = new Configuration(TEST_UTIL.getConfiguration());
    otherConf.set(HConstants.ZOOKEEPER_QUORUM, "127.0.0.1");
    HTable ipMeta = new HTable(otherConf, HConstants.META_TABLE_NAME);

    // dummy, just to open the connection
    localMeta.exists(new Get(HConstants.LAST_ROW));
    ipMeta.exists(new Get(HConstants.LAST_ROW));

    // make sure they aren't the same
    assertFalse(HConnectionManager.getConnection(localMeta.getConfiguration()).getZooKeeperWatcher()
        == HConnectionManager.getConnection(otherConf).getZooKeeperWatcher());
    assertFalse(HConnectionManager.getConnection(localMeta.getConfiguration())
        .getZooKeeperWatcher().getQuorum().equals(HConnectionManager
            .getConnection(otherConf).getZooKeeperWatcher().getQuorum()));
    localMeta.close();
    ipMeta.close();
  } catch (Exception e) {
    e.printStackTrace();
    fail();
  }
}
 
開發者ID:fengchen8086,項目名稱:LCIndex-HBase-0.94.16,代碼行數:27,代碼來源:TestZooKeeper.java

示例11: waitForConnection

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的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

示例12: init

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
@Override
public void init(Context context) throws IOException {
  super.init(context);
  this.conf = HBaseConfiguration.create(ctx.getConfiguration());
  decorateConf();
  this.maxRetriesMultiplier = this.conf.getInt("replication.source.maxretriesmultiplier", 300);
  this.socketTimeoutMultiplier = this.conf.getInt("replication.source.socketTimeoutMultiplier",
      maxRetriesMultiplier);
  // TODO: This connection is replication specific or we should make it particular to
  // replication and make replication specific settings such as compression or codec to use
  // passing Cells.
  this.conn = HConnectionManager.createConnection(this.conf);
  this.sleepForRetries =
      this.conf.getLong("replication.source.sleepforretries", 1000);
  this.metrics = context.getMetrics();
  // ReplicationQueueInfo parses the peerId out of the znode for us
  this.replicationSinkMgr = new ReplicationSinkManager(conn, ctx.getPeerId(), this, this.conf);
}
 
開發者ID:grokcoder,項目名稱:pbase,代碼行數:19,代碼來源:HBaseInterClusterReplicationEndpoint.java

示例13: getCurrentConnection

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
/**
 * Get the cached connection for the current user.
 * If none or timed out, create a new one.
 */
ConnectionInfo getCurrentConnection() throws IOException {
  String userName = getEffectiveUser();
  ConnectionInfo connInfo = connections.get(userName);
  if (connInfo == null || !connInfo.updateAccessTime()) {
    Lock lock = locker.acquireLock(userName);
    try {
      connInfo = connections.get(userName);
      if (connInfo == null) {
        UserGroupInformation ugi = realUser;
        if (!userName.equals(realUserName)) {
          ugi = UserGroupInformation.createProxyUser(userName, realUser);
        }
        User user = userProvider.create(ugi);
        HConnection conn = HConnectionManager.createConnection(conf, user);
        connInfo = new ConnectionInfo(conn, userName);
        connections.put(userName, connInfo);
      }
    } finally {
      lock.unlock();
    }
  }
  return connInfo;
}
 
開發者ID:grokcoder,項目名稱:pbase,代碼行數:28,代碼來源:ConnectionCache.java

示例14: getImage

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
public static ImageInfo getImage(Configuration conf, Long id) throws DataException {
	
	HConnection connection = null;
	HTable table = null;
	
	try {
		connection = HConnectionManager.createConnection(conf);
		table = new HTable(conf, IMG_TABLE);
		
		Get get = new Get(Bytes.toBytes(id));
		Result res = table.get(get);
		return getImageFromResult(res);
		
	} catch (IOException e) {
		throw new DataException("Error reading image: " + e.getMessage());
	} finally {
		close(connection, table);
	 }
}
 
開發者ID:DaniUPC,項目名稱:near-image-replica-detection,代碼行數:20,代碼來源:HBaseClient.java

示例15: getCurrentConnection

import org.apache.hadoop.hbase.client.HConnectionManager; //導入依賴的package包/類
private ConnectionInfo getCurrentConnection() throws IOException {
  String userName = effectiveUser.get().getUserName();
  ConnectionInfo connInfo = connections.get(userName);
  if (connInfo == null || !connInfo.updateAccessTime()) {
    Lock lock = locker.acquireLock(userName);
    try {
      connInfo = connections.get(userName);
      if (connInfo == null) {
        User user = userProvider.create(effectiveUser.get());
        HConnection conn = HConnectionManager.createConnection(conf, user);
        connInfo = new ConnectionInfo(conn, userName);
        connections.put(userName, connInfo);
      }
    } finally {
      lock.unlock();
    }
  }
  return connInfo;
}
 
開發者ID:tenggyut,項目名稱:HIndex,代碼行數:20,代碼來源:RESTServlet.java


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