Java Code Examples for org.apache.hadoop.hbase.MiniHBaseCluster#getRegionServerThreads()
The following examples show how to use
org.apache.hadoop.hbase.MiniHBaseCluster#getRegionServerThreads() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestWALRecoveryCaching.java From phoenix with Apache License 2.0 | 5 votes |
/** * @param cluster * @param server * @param table * @return */ private List<HRegion> getRegionsFromServerForTable(MiniHBaseCluster cluster, ServerName server, byte[] table) { List<HRegion> online = Collections.emptyList(); for (RegionServerThread rst : cluster.getRegionServerThreads()) { // if its the server we are going to kill, get the regions we want to reassign if (rst.getRegionServer().getServerName().equals(server)) { online = rst.getRegionServer().getOnlineRegions(org.apache.hadoop.hbase.TableName.valueOf(table)); break; } } return online; }
Example 2
Source File: TestGetLastFlushedSequenceId.java From hbase with Apache License 2.0 | 5 votes |
@Test public void test() throws IOException, InterruptedException { testUtil.getAdmin().createNamespace( NamespaceDescriptor.create(tableName.getNamespaceAsString()).build()); Table table = testUtil.createTable(tableName, families); table.put(new Put(Bytes.toBytes("k")) .addColumn(family, Bytes.toBytes("q"), Bytes.toBytes("v"))); MiniHBaseCluster cluster = testUtil.getMiniHBaseCluster(); List<JVMClusterUtil.RegionServerThread> rsts = cluster.getRegionServerThreads(); Region region = null; for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) { HRegionServer hrs = rsts.get(i).getRegionServer(); for (Region r : hrs.getRegions(tableName)) { region = r; break; } } assertNotNull(region); Thread.sleep(2000); RegionStoreSequenceIds ids = testUtil.getHBaseCluster().getMaster() .getLastSequenceId(region.getRegionInfo().getEncodedNameAsBytes()); assertEquals(HConstants.NO_SEQNUM, ids.getLastFlushedSequenceId()); // This will be the sequenceid just before that of the earliest edit in memstore. long storeSequenceId = ids.getStoreSequenceId(0).getSequenceId(); assertTrue(storeSequenceId > 0); testUtil.getAdmin().flush(tableName); Thread.sleep(2000); ids = testUtil.getHBaseCluster().getMaster() .getLastSequenceId(region.getRegionInfo().getEncodedNameAsBytes()); assertTrue(ids.getLastFlushedSequenceId() + " > " + storeSequenceId, ids.getLastFlushedSequenceId() > storeSequenceId); assertEquals(ids.getLastFlushedSequenceId(), ids.getStoreSequenceId(0).getSequenceId()); table.close(); }
Example 3
Source File: TestFIFOCompactionPolicy.java From hbase with Apache License 2.0 | 5 votes |
private HStore getStoreWithName(TableName tableName) { MiniHBaseCluster cluster = TEST_UTIL.getMiniHBaseCluster(); List<JVMClusterUtil.RegionServerThread> rsts = cluster.getRegionServerThreads(); for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) { HRegionServer hrs = rsts.get(i).getRegionServer(); for (HRegion region : hrs.getRegions(tableName)) { return region.getStores().iterator().next(); } } return null; }
Example 4
Source File: TestPerColumnFamilyFlush.java From hbase with Apache License 2.0 | 5 votes |
private static Pair<HRegion, HRegionServer> getRegionWithName(TableName tableName) { MiniHBaseCluster cluster = TEST_UTIL.getMiniHBaseCluster(); List<JVMClusterUtil.RegionServerThread> rsts = cluster.getRegionServerThreads(); for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) { HRegionServer hrs = rsts.get(i).getRegionServer(); for (HRegion region : hrs.getRegions(tableName)) { return Pair.newPair(region, hrs); } } return null; }
Example 5
Source File: TestSplitTransactionOnCluster.java From hbase with Apache License 2.0 | 5 votes |
/** * Find regionserver other than the one passed. * Can't rely on indexes into list of regionservers since crashed servers * occupy an index. * @param cluster * @param notThisOne * @return A regionserver that is not <code>notThisOne</code> or null if none * found */ private HRegionServer getOtherRegionServer(final MiniHBaseCluster cluster, final HRegionServer notThisOne) { for (RegionServerThread rst: cluster.getRegionServerThreads()) { HRegionServer hrs = rst.getRegionServer(); if (hrs.getServerName().equals(notThisOne.getServerName())) continue; if (hrs.isStopping() || hrs.isStopped()) continue; return hrs; } return null; }
Example 6
Source File: TestCompactionWithThroughputController.java From hbase with Apache License 2.0 | 5 votes |
private HStore getStoreWithName(TableName tableName) { MiniHBaseCluster cluster = TEST_UTIL.getMiniHBaseCluster(); List<JVMClusterUtil.RegionServerThread> rsts = cluster.getRegionServerThreads(); for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) { HRegionServer hrs = rsts.get(i).getRegionServer(); for (Region region : hrs.getRegions(tableName)) { return ((HRegion) region).getStores().iterator().next(); } } return null; }
Example 7
Source File: TestFlushWithThroughputController.java From hbase with Apache License 2.0 | 5 votes |
private HStore getStoreWithName(TableName tableName) { MiniHBaseCluster cluster = hbtu.getMiniHBaseCluster(); List<JVMClusterUtil.RegionServerThread> rsts = cluster.getRegionServerThreads(); for (int i = 0; i < cluster.getRegionServerThreads().size(); i++) { HRegionServer hrs = rsts.get(i).getRegionServer(); for (Region region : hrs.getRegions(tableName)) { return ((HRegion) region).getStores().iterator().next(); } } return null; }
Example 8
Source File: TestWALRecoveryCaching.java From phoenix with Apache License 2.0 | 5 votes |
/** * @param cluster * @param server * @param table * @return */ private List<HRegion> getRegionsFromServerForTable(MiniHBaseCluster cluster, ServerName server, byte[] table) { List<HRegion> online = Collections.emptyList(); for (RegionServerThread rst : cluster.getRegionServerThreads()) { // if its the server we are going to kill, get the regions we want to reassign if (rst.getRegionServer().getServerName().equals(server)) { online = rst.getRegionServer().getRegions(org.apache.hadoop.hbase.TableName.valueOf(table)); break; } } return online; }
Example 9
Source File: TestWALRecoveryCaching.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * @param miniHBaseCluster * @param server * @param bs * @return */ private List<HRegion> getRegionsFromServerForTable(MiniHBaseCluster cluster, ServerName server, byte[] table) { List<HRegion> online = Collections.emptyList(); for (RegionServerThread rst : cluster.getRegionServerThreads()) { // if its the server we are going to kill, get the regions we want to reassign if (rst.getRegionServer().getServerName().equals(server)) { online = rst.getRegionServer().getOnlineRegions(table); break; } } return online; }
Example 10
Source File: TestRegionsOnMasterOptions.java From hbase with Apache License 2.0 | 4 votes |
private void checkBalance(int masterCount, int rsCount) throws Exception { StartMiniClusterOption option = StartMiniClusterOption.builder() .numMasters(MASTERS).numRegionServers(SLAVES).numDataNodes(SLAVES).build(); MiniHBaseCluster cluster = TEST_UTIL.startMiniCluster(option); TableName tn = TableName.valueOf(this.name.getMethodName()); try { Table t = TEST_UTIL.createMultiRegionTable(tn, HConstants.CATALOG_FAMILY, REGIONS); LOG.info("Server: " + cluster.getMaster().getServerManager().getOnlineServersList()); List<HRegion> regions = cluster.getMaster().getRegions(); int mActualCount = regions.size(); if (masterCount == 0 || masterCount == SYSTEM_REGIONS) { // 0 means no regions on master. assertEquals(masterCount, mActualCount); } else { // This is master as a regionserver scenario. checkCount(masterCount, mActualCount); } // Allow that balance is not exact. FYI, getRegionServerThreads does not include master // thread though it is a regionserver so we have to check master and then below the // regionservers. for (JVMClusterUtil.RegionServerThread rst: cluster.getRegionServerThreads()) { regions = rst.getRegionServer().getRegions(); int rsActualCount = regions.size(); checkCount(rsActualCount, rsCount); } HMaster oldMaster = cluster.getMaster(); cluster.killMaster(oldMaster.getServerName()); oldMaster.join(); while (cluster.getMaster() == null || cluster.getMaster().getServerName().equals(oldMaster.getServerName())) { Threads.sleep(10); } while (!cluster.getMaster().isInitialized()) { Threads.sleep(10); } while (cluster.getMaster().getAssignmentManager(). computeRegionInTransitionStat().getTotalRITs() > 0) { Threads.sleep(100); LOG.info("Waiting on RIT to go to zero before calling balancer..."); } LOG.info("Cluster is up; running balancer"); cluster.getMaster().balance(); regions = cluster.getMaster().getRegions(); int mNewActualCount = regions.size(); if (masterCount == 0 || masterCount == SYSTEM_REGIONS) { // 0 means no regions on master. After crash, should still be no regions on master. // If masterCount == SYSTEM_REGIONS, means master only carrying system regions and should // still only carry system regions post crash. assertEquals(masterCount, mNewActualCount); } } finally { LOG.info("Running shutdown of cluster"); TEST_UTIL.shutdownMiniCluster(); } }