use of org.apache.hadoop.hbase.procedure2.Procedure in project hbase by apache.
the class MasterProcedureScheduler method wakeServerExclusiveLock.
/**
* Wake the procedures waiting for the specified server
* @see #waitServerExclusiveLock(Procedure,ServerName)
* @param procedure the procedure releasing the lock
* @param serverName the server that has the exclusive lock
*/
public void wakeServerExclusiveLock(final Procedure procedure, final ServerName serverName) {
schedLock();
try {
final LockAndQueue lock = locking.getServerLock(serverName);
lock.releaseExclusiveLock(procedure);
addToRunQueue(serverRunQueue, getServerQueue(serverName));
int waitingCount = wakeWaitingProcedures(lock);
wakePollIfNeeded(waitingCount);
} finally {
schedUnlock();
}
}
use of org.apache.hadoop.hbase.procedure2.Procedure in project hbase by apache.
the class TestProcedureUtil method testConvert.
@Test
public void testConvert() throws Exception {
// check Procedure to protobuf conversion
final TestProcedure proc1 = new TestProcedure(10);
final ProcedureProtos.Procedure proto1 = ProcedureUtil.convertToProtoProcedure(proc1);
final TestProcedure proc2 = (TestProcedure) ProcedureUtil.convertToProcedure(proto1);
final ProcedureProtos.Procedure proto2 = ProcedureUtil.convertToProtoProcedure(proc2);
assertEquals(false, proto2.hasResult());
assertEquals("Procedure protobuf does not match", proto1, proto2);
// remove the state-data from the procedure protobuf to compare it to the gen ProcedureInfo
final ProcedureProtos.Procedure pbproc = proto2.toBuilder().clearStateData().build();
// check ProcedureInfo to protobuf conversion
final ProcedureInfo protoInfo1 = ProcedureUtil.convertToProcedureInfo(proc1);
final ProcedureProtos.Procedure proto3 = ProcedureUtil.convertToProtoProcedure(protoInfo1);
final ProcedureInfo protoInfo2 = ProcedureUtil.convertToProcedureInfo(proto3);
final ProcedureProtos.Procedure proto4 = ProcedureUtil.convertToProtoProcedure(protoInfo2);
assertEquals("ProcedureInfo protobuf does not match", proto3, proto4);
assertEquals("ProcedureInfo/Procedure protobuf does not match", pbproc, proto3);
assertEquals("ProcedureInfo/Procedure protobuf does not match", pbproc, proto4);
}
use of org.apache.hadoop.hbase.procedure2.Procedure in project hbase by apache.
the class TestWALProcedureStore method testWalReplayOrder_ABC_BAD.
@Test(timeout = 60000)
public void testWalReplayOrder_ABC_BAD() throws Exception {
/*
* | A B C | -> | B A D |
*/
TestProcedure a = new TestProcedure(1, 0);
TestProcedure b = new TestProcedure(2, 1);
TestProcedure c = new TestProcedure(3, 2);
TestProcedure d = new TestProcedure(4, 0);
procStore.insert(a, null);
a.addStackId(0);
procStore.update(a);
procStore.insert(a, new Procedure[] { b });
b.addStackId(1);
procStore.update(b);
procStore.insert(b, new Procedure[] { c });
b.addStackId(2);
procStore.update(b);
procStore.rollWriterForTesting();
b.addStackId(3);
procStore.update(b);
a.addStackId(4);
procStore.update(a);
procStore.insert(d, null);
d.addStackId(0);
procStore.update(d);
storeRestart(new ProcedureStore.ProcedureLoader() {
@Override
public void setMaxProcId(long maxProcId) {
assertEquals(4, maxProcId);
}
@Override
public void load(ProcedureIterator procIter) throws IOException {
assertTrue(procIter.hasNext());
assertEquals(4, procIter.nextAsProcedureInfo().getProcId());
// TODO: This will be multiple call once we do fast-start
//assertFalse(procIter.hasNext());
assertTrue(procIter.hasNext());
assertEquals(1, procIter.nextAsProcedureInfo().getProcId());
assertTrue(procIter.hasNext());
assertEquals(2, procIter.nextAsProcedureInfo().getProcId());
assertTrue(procIter.hasNext());
assertEquals(3, procIter.nextAsProcedureInfo().getProcId());
assertFalse(procIter.hasNext());
}
@Override
public void handleCorrupted(ProcedureIterator procIter) throws IOException {
assertFalse(procIter.hasNext());
}
});
}
use of org.apache.hadoop.hbase.procedure2.Procedure in project hbase by apache.
the class TestWALProcedureStore method trackersLoadedForAllOldLogs.
/**
* Tests that tracker for all old logs are loaded back after procedure store is restarted.
*/
@Test
public void trackersLoadedForAllOldLogs() throws Exception {
for (int i = 0; i <= 20; ++i) {
procStore.insert(new TestProcedure(i), null);
if (i > 0 && (i % 5) == 0) {
LoadCounter loader = new LoadCounter();
storeRestart(loader);
}
}
assertEquals(5, procStore.getActiveLogs().size());
for (int i = 0; i < procStore.getActiveLogs().size() - 1; ++i) {
ProcedureStoreTracker tracker = procStore.getActiveLogs().get(i).getTracker();
assertTrue(tracker != null && !tracker.isEmpty());
}
}
use of org.apache.hadoop.hbase.procedure2.Procedure in project hbase by apache.
the class TestWALProcedureStore method testLoadChildren.
@Test
public void testLoadChildren() throws Exception {
TestProcedure a = new TestProcedure(1, 0);
TestProcedure b = new TestProcedure(2, 1);
TestProcedure c = new TestProcedure(3, 1);
// INIT
procStore.insert(a, null);
// Run A first step
a.addStackId(0);
procStore.update(a);
// Run A second step
a.addStackId(1);
procStore.insert(a, new Procedure[] { b, c });
// Run B first step
b.addStackId(2);
procStore.update(b);
// Run C first and last step
c.addStackId(3);
procStore.update(c);
// Run B second setp
b.addStackId(4);
procStore.update(b);
// back to A
a.addStackId(5);
a.setFinishedState();
procStore.delete(a, new long[] { b.getProcId(), c.getProcId() });
restartAndAssert(3, 0, 1, 0);
}
Aggregations