Search in sources :

Example 1 with MonitoredRPCHandler

use of org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler in project hbase by apache.

the class RpcServer method getStatus.

protected static MonitoredRPCHandler getStatus() {
    // It is ugly the way we park status up in RpcServer.  Let it be for now.  TODO.
    MonitoredRPCHandler status = RpcServer.MONITORED_RPC.get();
    if (status != null) {
        return status;
    }
    status = TaskMonitor.get().createRPCStatus(Thread.currentThread().getName());
    status.pause("Waiting for a call");
    RpcServer.MONITORED_RPC.set(status);
    return status;
}
Also used : MonitoredRPCHandler(org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler)

Example 2 with MonitoredRPCHandler

use of org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler in project hbase by apache.

the class TestHRegion method testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization.

/**
   * Testcase to check state of region initialization task set to ABORTED or not
   * if any exceptions during initialization
   *
   * @throws Exception
   */
@Test
public void testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization() throws Exception {
    HRegionInfo info;
    try {
        FileSystem fs = Mockito.mock(FileSystem.class);
        Mockito.when(fs.exists((Path) Mockito.anyObject())).thenThrow(new IOException());
        HTableDescriptor htd = new HTableDescriptor(tableName);
        htd.addFamily(new HColumnDescriptor("cf"));
        info = new HRegionInfo(htd.getTableName(), HConstants.EMPTY_BYTE_ARRAY, HConstants.EMPTY_BYTE_ARRAY, false);
        Path path = new Path(dir + "testStatusSettingToAbortIfAnyExceptionDuringRegionInitilization");
        region = HRegion.newHRegion(path, null, fs, CONF, info, htd, null);
        // region initialization throws IOException and set task state to ABORTED.
        region.initialize();
        fail("Region initialization should fail due to IOException");
    } catch (IOException io) {
        List<MonitoredTask> tasks = TaskMonitor.get().getTasks();
        for (MonitoredTask monitoredTask : tasks) {
            if (!(monitoredTask instanceof MonitoredRPCHandler) && monitoredTask.getDescription().contains(region.toString())) {
                assertTrue("Region state should be ABORTED.", monitoredTask.getState().equals(MonitoredTask.State.ABORTED));
                break;
            }
        }
    } finally {
        HBaseTestingUtility.closeRegionAndWAL(region);
    }
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) Path(org.apache.hadoop.fs.Path) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) MonitoredRPCHandler(org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler) FileSystem(org.apache.hadoop.fs.FileSystem) FaultyFileSystem(org.apache.hadoop.hbase.regionserver.TestStore.FaultyFileSystem) FilterList(org.apache.hadoop.hbase.filter.FilterList) ArrayList(java.util.ArrayList) List(java.util.List) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor) MonitoredTask(org.apache.hadoop.hbase.monitoring.MonitoredTask) Test(org.junit.Test)

Aggregations

MonitoredRPCHandler (org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler)2 IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 Path (org.apache.hadoop.fs.Path)1 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 FilterList (org.apache.hadoop.hbase.filter.FilterList)1 MonitoredTask (org.apache.hadoop.hbase.monitoring.MonitoredTask)1 FaultyFileSystem (org.apache.hadoop.hbase.regionserver.TestStore.FaultyFileSystem)1 Test (org.junit.Test)1