use of org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException in project hbase by apache.
the class TestSyncReplicationReplayWALManager method testUsedWorkers.
@Test
public void testUsedWorkers() throws ProcedureSuspendedException {
String peerId1 = "1";
String peerId2 = "2";
ServerName sn1 = ServerName.valueOf("host1", 123, 12345);
ServerName sn2 = ServerName.valueOf("host2", 234, 23456);
ServerName sn3 = ServerName.valueOf("host3", 345, 34567);
onlineServers.add(sn1);
manager.registerPeer(peerId1);
manager.registerPeer(peerId2);
// confirm that different peer ids does not affect each other
assertEquals(sn1, manager.acquirePeerWorker(peerId1, new NoopProcedure<>()));
assertEquals(sn1, manager.acquirePeerWorker(peerId2, new NoopProcedure<>()));
onlineServers.add(sn2);
assertEquals(sn2, manager.acquirePeerWorker(peerId1, new NoopProcedure<>()));
assertEquals(sn2, manager.acquirePeerWorker(peerId2, new NoopProcedure<>()));
NoopProcedure<?> proc = new NoopProcedure<>();
try {
manager.acquirePeerWorker(peerId1, proc);
fail("Should suspend");
} catch (ProcedureSuspendedException e) {
// expected
}
manager.releasePeerWorker(peerId1, sn1, scheduler);
assertEquals(1, wokenProcedures.size());
assertSame(proc, wokenProcedures.poll());
assertEquals(sn1, manager.acquirePeerWorker(peerId1, new NoopProcedure<>()));
NoopProcedure<?> proc1 = new NoopProcedure<>();
NoopProcedure<?> proc2 = new NoopProcedure<>();
try {
manager.acquirePeerWorker(peerId1, proc1);
fail("Should suspend");
} catch (ProcedureSuspendedException e) {
// expected
}
try {
manager.acquirePeerWorker(peerId1, proc2);
fail("Should suspend");
} catch (ProcedureSuspendedException e) {
// expected
}
listeners.get(0).serverAdded(sn3);
assertEquals(2, wokenProcedures.size());
assertSame(proc2, wokenProcedures.poll());
assertSame(proc1, wokenProcedures.poll());
}
use of org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException in project hbase by apache.
the class TestSplitWALManager method testAcquireAndRelease.
@Test
public void testAcquireAndRelease() throws Exception {
List<FakeServerProcedure> testProcedures = new ArrayList<>();
for (int i = 0; i < 4; i++) {
testProcedures.add(new FakeServerProcedure(TEST_UTIL.getHBaseCluster().getServerHoldingMeta()));
}
ServerName server = splitWALManager.acquireSplitWALWorker(testProcedures.get(0));
Assert.assertNotNull(server);
Assert.assertNotNull(splitWALManager.acquireSplitWALWorker(testProcedures.get(1)));
Assert.assertNotNull(splitWALManager.acquireSplitWALWorker(testProcedures.get(2)));
Exception e = null;
try {
splitWALManager.acquireSplitWALWorker(testProcedures.get(3));
} catch (ProcedureSuspendedException suspendException) {
e = suspendException;
}
Assert.assertNotNull(e);
Assert.assertTrue(e instanceof ProcedureSuspendedException);
splitWALManager.releaseSplitWALWorker(server, TEST_UTIL.getHBaseCluster().getMaster().getMasterProcedureExecutor().getEnvironment().getProcedureScheduler());
Assert.assertNotNull(splitWALManager.acquireSplitWALWorker(testProcedures.get(3)));
}
Aggregations