use of org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv in project hbase by apache.
the class TestDirectStoreSplitsMerges method testCommitDaughterRegionNoFiles.
@Test
public void testCommitDaughterRegionNoFiles() throws Exception {
TableName table = TableName.valueOf(name.getMethodName());
TEST_UTIL.createTable(table, FAMILY_NAME);
HRegion region = TEST_UTIL.getHBaseCluster().getRegions(table).get(0);
HRegionFileSystem regionFS = region.getStores().get(0).getRegionFileSystem();
RegionInfo daughterA = RegionInfoBuilder.newBuilder(table).setStartKey(region.getRegionInfo().getStartKey()).setEndKey(Bytes.toBytes("002")).setSplit(false).setRegionId(region.getRegionInfo().getRegionId() + EnvironmentEdgeManager.currentTime()).build();
Path splitDir = regionFS.getSplitsDir(daughterA);
MasterProcedureEnv env = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterProcedureExecutor().getEnvironment();
Path result = regionFS.commitDaughterRegion(daughterA, new ArrayList<>(), env);
assertEquals(splitDir, result);
}
use of org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv in project hbase by apache.
the class TestMetaFixer method testOverlap.
@Test
public void testOverlap() throws Exception {
TableName tn = TableName.valueOf(this.name.getMethodName());
testOverlapCommon(tn);
HMaster services = TEST_UTIL.getHBaseCluster().getMaster();
HbckChore hbckChore = services.getHbckChore();
CatalogJanitor cj = services.getCatalogJanitor();
cj.scan();
Report report = cj.getLastReport();
assertEquals(6, report.getOverlaps().size());
assertEquals(1, MetaFixer.calculateMerges(10, report.getOverlaps()).size());
MetaFixer fixer = new MetaFixer(services);
fixer.fixOverlaps(report);
HBaseTestingUtil.await(10, () -> {
try {
if (cj.scan() > 0) {
// It submits GC once, then it will immediately kick off another GC to test if
// GCMultipleMergedRegionsProcedure is idempotent. If it is not, it will create
// a hole.
Map<RegionInfo, Result> mergedRegions = cj.getLastReport().mergedRegions;
for (Map.Entry<RegionInfo, Result> e : mergedRegions.entrySet()) {
List<RegionInfo> parents = CatalogFamilyFormat.getMergeRegions(e.getValue().rawCells());
if (parents != null) {
ProcedureExecutor<MasterProcedureEnv> pe = services.getMasterProcedureExecutor();
pe.submitProcedure(new GCMultipleMergedRegionsProcedure(pe.getEnvironment(), e.getKey(), parents));
}
}
return true;
}
return false;
} catch (Exception e) {
throw new RuntimeException(e);
}
});
// Wait until all GCs settled down
HBaseTestingUtil.await(10, () -> {
return services.getMasterProcedureExecutor().getActiveProcIds().isEmpty();
});
// No orphan regions on FS
hbckChore.choreForTesting();
assertEquals(0, hbckChore.getOrphanRegionsOnFS().size());
// No holes reported.
cj.scan();
final Report postReport = cj.getLastReport();
assertTrue(postReport.isEmpty());
}
use of org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv in project hbase by apache.
the class TestRegisterPeerWorkerWhenRestarting method testRestart.
@Test
public void testRestart() throws Exception {
UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.STANDBY);
UTIL1.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.ACTIVE);
UTIL1.getAdmin().disableReplicationPeer(PEER_ID);
write(UTIL1, 0, 100);
Thread.sleep(2000);
// peer is disabled so no data have been replicated
verifyNotReplicatedThroughRegion(UTIL2, 0, 100);
// transit the A to DA first to avoid too many error logs.
UTIL1.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.DOWNGRADE_ACTIVE);
HMaster master = UTIL2.getHBaseCluster().getMaster();
// make sure the transiting can not succeed
FAIL = true;
ProcedureExecutor<MasterProcedureEnv> procExec = master.getMasterProcedureExecutor();
Thread t = new Thread() {
@Override
public void run() {
try {
UTIL2.getAdmin().transitReplicationPeerSyncReplicationState(PEER_ID, SyncReplicationState.DOWNGRADE_ACTIVE);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
};
t.start();
// wait until we are in the states where we need to register peer worker when restarting
UTIL2.waitFor(60000, () -> procExec.getProcedures().stream().filter(p -> p instanceof RecoverStandbyProcedure).map(p -> (RecoverStandbyProcedure) p).anyMatch(p -> p.getCurrentStateId() == DISPATCH_WALS_VALUE || p.getCurrentStateId() == UNREGISTER_PEER_FROM_WORKER_STORAGE_VALUE));
// failover to another master
MasterThread mt = UTIL2.getMiniHBaseCluster().getMasterThread();
mt.getMaster().abort("for testing");
mt.join();
FAIL = false;
t.join();
// make sure the new master can finish the transition
UTIL2.waitFor(60000, () -> UTIL2.getAdmin().getReplicationPeerSyncReplicationState(PEER_ID) == SyncReplicationState.DOWNGRADE_ACTIVE);
verify(UTIL2, 0, 100);
}
use of org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv in project hbase by apache.
the class TestSyncReplicationReplayWALManager method setUp.
@Before
public void setUp() throws IOException, ReplicationException {
wokenProcedures = new ArrayDeque<>();
onlineServers = new HashSet<>();
listeners = new ArrayList<>();
ServerManager serverManager = mock(ServerManager.class);
doAnswer(inv -> listeners.add(inv.getArgument(0))).when(serverManager).registerListener(any(ServerListener.class));
ServerMetrics serverMetrics = mock(ServerMetrics.class);
doAnswer(inv -> onlineServers.stream().collect(Collectors.toMap(Function.identity(), k -> serverMetrics))).when(serverManager).getOnlineServers();
MasterFileSystem mfs = mock(MasterFileSystem.class);
when(mfs.getFileSystem()).thenReturn(UTIL.getTestFileSystem());
when(mfs.getWALRootDir()).thenReturn(new Path("/"));
scheduler = mock(MasterProcedureScheduler.class);
doAnswer(new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
ProcedureEvent<?> event = ((ProcedureEvent<?>[]) invocation.getArgument(0))[0];
event.wakeInternal(new MasterProcedureScheduler(pid -> null) {
@Override
public void addFront(Iterator<Procedure> procedureIterator) {
procedureIterator.forEachRemaining(wokenProcedures::add);
}
});
return null;
}
}).when(scheduler).wakeEvents(any(ProcedureEvent[].class));
MasterProcedureEnv env = mock(MasterProcedureEnv.class);
when(env.getProcedureScheduler()).thenReturn(scheduler);
ProcedureExecutor<MasterProcedureEnv> procExec = mock(ProcedureExecutor.class);
when(procExec.getEnvironment()).thenReturn(env);
MasterServices services = mock(MasterServices.class);
when(services.getServerManager()).thenReturn(serverManager);
when(services.getMasterFileSystem()).thenReturn(mfs);
when(services.getMasterProcedureExecutor()).thenReturn(procExec);
manager = new SyncReplicationReplayWALManager(services);
assertEquals(1, listeners.size());
}
use of org.apache.hadoop.hbase.master.procedure.MasterProcedureEnv in project hbase by apache.
the class TestHStoreFile method splitStoreFile.
private Path splitStoreFile(final HRegionFileSystem regionFs, final RegionInfo hri, final String family, final HStoreFile sf, final byte[] splitKey, boolean isTopRef) throws IOException {
Path path = regionFs.splitStoreFile(hri, family, sf, splitKey, isTopRef, null);
if (null == path) {
return null;
}
List<Path> splitFiles = new ArrayList<>();
splitFiles.add(path);
MasterProcedureEnv mockEnv = mock(MasterProcedureEnv.class);
MasterServices mockServices = mock(MasterServices.class);
when(mockEnv.getMasterServices()).thenReturn(mockServices);
when(mockEnv.getMasterConfiguration()).thenReturn(new Configuration());
TableDescriptors mockTblDescs = mock(TableDescriptors.class);
when(mockServices.getTableDescriptors()).thenReturn(mockTblDescs);
TableDescriptor mockTblDesc = TableDescriptorBuilder.newBuilder(hri.getTable()).setColumnFamily(ColumnFamilyDescriptorBuilder.of(family)).build();
when(mockTblDescs.get(any())).thenReturn(mockTblDesc);
Path regionDir = regionFs.commitDaughterRegion(hri, splitFiles, mockEnv);
return new Path(new Path(regionDir, family), path.getName());
}
Aggregations