/** * Create a new ClientScanner for the specified table. An HConnection will be * retrieved using the passed Configuration. * Note that the passed {@link Scan}'s start row maybe changed changed. * * @param conf The {@link Configuration} to use. * @param scan {@link Scan} to use in this scanner * @param tableName The table that we wish to scan * @throws IOException */ public ClientScanner(final Configuration conf, final Scan scan, final byte[] tableName) throws IOException { this(conf, scan, tableName, HConnectionManager.getConnection(conf)); }
/** * Constructs the catalog tracker. Find current state of catalog tables. * Begin active tracking by executing {@link #start()} post construction. * Does not timeout. * @param zk If zk is null, we'll create an instance (and shut it down * when {@link #stop()} is called) else we'll use what is passed. * @param conf * @param abortable If fatal exception we'll call abort on this. May be null. * If it is we'll use the Connection associated with the passed * {@link Configuration} as our Abortable. * @throws IOException */ public CatalogTracker(final ZooKeeperWatcher zk, final Configuration conf, Abortable abortable) throws IOException { this(zk, conf, HConnectionManager.getConnection(conf), abortable); }
private HConnection getConnectionByTableName(final TableName tableName) throws IOException { HConnection hconn = this.tableNameToHConnectionMap.get(tableName); if (hconn == null) { synchronized (this.tableNameToHConnectionMap) { hconn = this.tableNameToHConnectionMap.get(tableName); if (hconn == null) { hconn = HConnectionManager.getConnection(conf); this.tableNameToHConnectionMap.put(tableName, hconn); } } } return hconn; } private TableName getTableFromLocationStr(String loc) {
/** * Workaround for the problem that zookeeper connections from HBase are not all closed. HBase (HConnection) does * reference counting to keep track of clients of connections, and apparently somewhere a close doesn't happen * while it should (thus the refCount is 1 at the end, in stead of 0). * * @param conf hbase configuration */ private void forceClose(Configuration conf) { final HConnection connection; try { connection = HConnectionManager.getConnection(conf); HConnectionManager.deleteStaleConnection(connection); } catch (ZooKeeperConnectionException e) { throw new RuntimeException("failed to close stale connection", e); } } }
ServerManager(final Server master, final MasterServices services, final boolean connect) throws ZooKeeperConnectionException { this.master = master; this.services = services; Configuration c = master.getConfiguration(); maxSkew = c.getLong("hbase.master.maxclockskew", 30000); warningSkew = c.getLong("hbase.master.warningclockskew", 10000); this.deadservers = new DeadServer(); this.connection = connect ? HConnectionManager.getConnection(c) : null; }
/** * Creates an object to access a HBase table. * Shares zookeeper connection and other resources with other HTable instances * created with the same <code>conf</code> instance. Uses already-populated * region cache if one is available, populated by any other HTable instances * sharing this <code>conf</code> instance. * Use this constructor when the ExecutorService is externally managed. * @param conf Configuration object to use. * @param tableName Name of the table. * @param pool ExecutorService to be used. * @throws IOException if a remote or network exception occurs */ public HTable(Configuration conf, final byte[] tableName, final ExecutorService pool) throws IOException { this.connection = HConnectionManager.getConnection(conf); this.configuration = conf; this.pool = pool; this.tableName = tableName; this.cleanupPoolOnClose = false; this.cleanupConnectionOnClose = true; this.finishSetup(); }
/** * Constructor that creates a connection to the local ZooKeeper ensemble. * @param conf Configuration to use * @throws IOException if the connection to ZK cannot be made * @throws RuntimeException if replication isn't enabled. */ public ReplicationAdmin(Configuration conf) throws IOException { if (!conf.getBoolean(HConstants.REPLICATION_ENABLE_KEY, false)) { throw new RuntimeException("hbase.replication isn't true, please " + "enable it in order to use replication"); } this.connection = HConnectionManager.getConnection(conf); ZooKeeperWatcher zkw = this.connection.getZooKeeperWatcher(); try { this.replicationZk = new ReplicationZookeeper(this.connection, conf, zkw); } catch (KeeperException e) { throw new IOException("Unable setup the ZooKeeper connection", e); } }
@Override public void setup(Context context) { Configuration conf = context.getConfiguration(); cfRenameMap = createCfRenameMap(conf); filter = instantiateFilter(conf); try { HConnection connection = HConnectionManager.getConnection(conf); ZooKeeperWatcher zkw = connection.getZooKeeperWatcher(); ReplicationZookeeper zkHelper = new ReplicationZookeeper(connection, conf, zkw); clusterId = zkHelper.getUUIDForCluster(zkw); } catch (ZooKeeperConnectionException e) { LOG.error("Problem connecting to ZooKeper during task setup", e); } catch (KeeperException e) { LOG.error("Problem reading ZooKeeper data during task setup", e); } catch (IOException e) { LOG.error("Problem setting up task", e); } } }
return; this.connection = HConnectionManager.getConnection(conf); this.configuration = conf;
HConnection connection = HConnectionManager.getConnection(conf); boolean connectSucceeded = false; try {
throws MasterNotRunningException, ZooKeeperConnectionException { this.conf = HBaseConfiguration.create(c); this.connection = HConnectionManager.getConnection(this.conf); this.pause = this.conf.getLong("hbase.client.pause", 1000); this.numRetries = this.conf.getInt("hbase.client.retries.number", 10); this.connection = HConnectionManager.getConnection(this.conf);
conf.getInt("hbase.regionserver.maxlogs", 32), new LogsComparator()); this.conn = HConnectionManager.getConnection(conf); this.zkHelper = manager.getRepZkWrapper(); this.ratio = this.conf.getFloat("replication.source.ratio", 0.1f);