@Override public int getEstimatedRegionServerCount() { int serverCount = -1; try { serverCount = adm.getClusterStatus().getServers().size(); log.debug("Read {} servers from HBase ClusterStatus", serverCount); } catch (IOException e) { log.debug("Unable to retrieve HBase cluster status", e); } return serverCount; }
@Test public void testObserver() throws IOException { int preCount = MyObserver.PRE_COUNT.get(); int postCount = MyObserver.POST_COUNT.get(); Assert.assertTrue(Stream.of(ADMIN.getClusterStatus().getMasterCoprocessors()) .anyMatch(s -> s.equals(MyObserver.class.getSimpleName()))); Assert.assertEquals(preCount + 1, MyObserver.PRE_COUNT.get()); Assert.assertEquals(postCount + 1, MyObserver.POST_COUNT.get()); }
@Override protected boolean doAction() throws Exception { Admin admin = null; try { admin = util.getAdmin(); ClusterStatus status = admin.getClusterStatus(); return status != null; } finally { if (admin != null) { admin.close(); } } }
public static void main(final String[] args) throws IOException { final boolean deleteAllAtEOJ = true; /** * ConnectionFactory#createConnection() automatically looks for * hbase-site.xml (HBase configuration parameters) on the system's * CLASSPATH, to enable creation of Connection to HBase via ZooKeeper. */ try (Connection connection = ConnectionFactory.createConnection(); Admin admin = connection.getAdmin()) { admin.getClusterStatus(); // assure connection successfully established System.out.println("\n*** Hello HBase! -- Connection has been " + "established via ZooKeeper!!\n"); createNamespaceAndTable(admin); System.out.println("Getting a Table object for [" + MY_TABLE_NAME + "] with which to perform CRUD operations in HBase."); try (Table table = connection.getTable(MY_TABLE_NAME)) { putRowToTable(table); getAndPrintRowContents(table); if (deleteAllAtEOJ) { deleteRow(table); } } if (deleteAllAtEOJ) { deleteNamespaceAndTable(admin); } } }
ClusterStatus clusterStatus = admin.getClusterStatus(); Collection<ServerName> servers = clusterStatus.getServers(); final long megaByte = 1024L * 1024L;
public static void main(final String[] args) throws IOException { final boolean deleteAllAtEOJ = true; /** * ConnectionFactory#createConnection() automatically looks for * hbase-site.xml (HBase configuration parameters) on the system's * CLASSPATH, to enable creation of Connection to HBase via ZooKeeper. */ try (Connection connection = ConnectionFactory.createConnection(); Admin admin = connection.getAdmin()) { admin.getClusterStatus(); // assure connection successfully established System.out.println("\n*** Hello HBase! -- Connection has been " + "established via ZooKeeper!!\n"); createNamespaceAndTable(admin); System.out.println("Getting a Table object for [" + MY_TABLE_NAME + "] with which to perform CRUD operations in HBase."); try (Table table = connection.getTable(MY_TABLE_NAME)) { putRowToTable(table); getAndPrintRowContents(table); if (deleteAllAtEOJ) { deleteRow(table); } } if (deleteAllAtEOJ) { deleteNamespaceAndTable(admin); } } }
private static void logError(String msg, Context context) throws IOException { TableName table = getTableName(context.getConfiguration()); LOG.error("Failure in chain verification: " + msg); try (Connection connection = ConnectionFactory.createConnection(context.getConfiguration()); Admin admin = connection.getAdmin()) { LOG.error("cluster status:\n" + admin.getClusterStatus()); LOG.error("table regions:\n" + Joiner.on("\n").join(admin.getTableRegions(table))); } } }
clusterStatus = admin.getClusterStatus(); } catch (Exception e) { logger.debug(e.getMessage(), e);
admin.listTableNames(); final ClusterStatus clusterStatus = admin.getClusterStatus(); if (clusterStatus != null) { final ServerName master = clusterStatus.getMaster();
admin.listTableNames(); final ClusterStatus clusterStatus = admin.getClusterStatus(); if (clusterStatus != null) { final ServerName master = clusterStatus.getMaster();
@Test public void testDefaults() throws Exception { ClusterStatus origin = ADMIN.getClusterStatus(); ClusterStatus defaults = new ClusterStatus(ADMIN.getClusterMetrics(EnumSet.allOf(Option.class))); checkPbObjectNotNull(origin); checkPbObjectNotNull(defaults); Assert.assertEquals(origin.getHBaseVersion(), defaults.getHBaseVersion()); Assert.assertEquals(origin.getClusterId(), defaults.getClusterId()); Assert.assertTrue(origin.getAverageLoad() == defaults.getAverageLoad()); Assert.assertTrue(origin.getBackupMastersSize() == defaults.getBackupMastersSize()); Assert.assertTrue(origin.getDeadServersSize() == defaults.getDeadServersSize()); Assert.assertTrue(origin.getRegionsCount() == defaults.getRegionsCount()); Assert.assertTrue(origin.getServersSize() == defaults.getServersSize()); Assert.assertTrue(origin.getMasterInfoPort() == defaults.getMasterInfoPort()); Assert.assertTrue(origin.equals(defaults)); }
ClusterStatus status = admin.getClusterStatus(); // co ClusterStatusExample-1-GetStatus Get the cluster status.
@Override public int getEstimatedRegionServerCount() { int serverCount = -1; try { serverCount = adm.getClusterStatus().getServers().size(); log.debug("Read {} servers from HBase ClusterStatus", serverCount); } catch (IOException e) { log.debug("Unable to retrieve HBase cluster status", e); } return serverCount; }
@Override public int getEstimatedRegionServerCount() { int serverCount = -1; try { serverCount = adm.getClusterStatus().getServers().size(); log.debug("Read {} servers from HBase ClusterStatus", serverCount); } catch (IOException e) { log.debug("Unable to retrieve HBase cluster status", e); } return serverCount; }
@Override public int getEstimatedRegionServerCount() { int serverCount = -1; try { serverCount = adm.getClusterStatus().getServers().size(); log.debug("Read {} servers from HBase ClusterStatus", serverCount); } catch (IOException e) { log.debug("Unable to retrieve HBase cluster status", e); } return serverCount; }
/** * Alternative getCurrentNrHRS which is no longer available. * @param connection * @return Rough count of regionservers out on cluster. * @throws IOException */ private static int getRegionServerCount(final Connection connection) throws IOException { try (Admin admin = connection.getAdmin()) { ClusterStatus status = admin.getClusterStatus(); Collection<ServerName> servers = status.getServers(); return servers == null || servers.isEmpty()? 0: servers.size(); } }
void connect() throws IOException { if ((this.conn == null) || (this.conn.isClosed())) { this.conn = this.hbase.createConnection(); this.updaters.clear(); _log.info("hbase master {} is connected", conn.getAdmin().getClusterStatus().getMaster()); } }
@Test public void testObserver() throws IOException { int preCount = MyObserver.PRE_COUNT.get(); int postCount = MyObserver.POST_COUNT.get(); Assert.assertTrue(Stream.of(ADMIN.getClusterStatus().getMasterCoprocessors()) .anyMatch(s -> s.equals(MyObserver.class.getSimpleName()))); Assert.assertEquals(preCount + 1, MyObserver.PRE_COUNT.get()); Assert.assertEquals(postCount + 1, MyObserver.POST_COUNT.get()); }
@Override protected boolean doAction() throws Exception { Admin admin = null; try { admin = util.getAdmin(); ClusterStatus status = admin.getClusterStatus(); return status != null; } finally { if (admin != null) { admin.close(); } } }
private static void logError(String msg, Context context) throws IOException { TableName table = getTableName(context.getConfiguration()); LOG.error("Failure in chain verification: " + msg); try (Connection connection = ConnectionFactory.createConnection(context.getConfiguration()); Admin admin = connection.getAdmin()) { LOG.error("cluster status:\n" + admin.getClusterStatus()); LOG.error("table regions:\n" + Joiner.on("\n").join(admin.getTableRegions(table))); } } }