Search in sources :

Example 11 with ProcedureSuspendedException

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());
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) NoopProcedure(org.apache.hadoop.hbase.procedure2.ProcedureTestingUtility.NoopProcedure) ProcedureSuspendedException(org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException) Test(org.junit.Test)

Example 12 with ProcedureSuspendedException

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)));
}
Also used : ServerName(org.apache.hadoop.hbase.ServerName) ArrayList(java.util.ArrayList) ProcedureSuspendedException(org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException) ProcedureSuspendedException(org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException) ProcedureYieldException(org.apache.hadoop.hbase.procedure2.ProcedureYieldException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

ProcedureSuspendedException (org.apache.hadoop.hbase.procedure2.ProcedureSuspendedException)11 IOException (java.io.IOException)9 ServerName (org.apache.hadoop.hbase.ServerName)5 ProcedureYieldException (org.apache.hadoop.hbase.procedure2.ProcedureYieldException)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 Configuration (org.apache.hadoop.conf.Configuration)1 Path (org.apache.hadoop.fs.Path)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)1 HRegionLocation (org.apache.hadoop.hbase.HRegionLocation)1 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)1 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)1 MasterServices (org.apache.hadoop.hbase.master.MasterServices)1 SplitWALManager (org.apache.hadoop.hbase.master.SplitWALManager)1 AssignmentManager (org.apache.hadoop.hbase.master.assignment.AssignmentManager)1 RegionStateNode (org.apache.hadoop.hbase.master.assignment.RegionStateNode)1 TransitRegionStateProcedure (org.apache.hadoop.hbase.master.assignment.TransitRegionStateProcedure)1 ClaimReplicationQueuesProcedure (org.apache.hadoop.hbase.master.replication.ClaimReplicationQueuesProcedure)1 FailedRemoteDispatchException (org.apache.hadoop.hbase.procedure2.FailedRemoteDispatchException)1