Search in sources :

Example 6 with RegionCoprocessorHost

use of org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost in project hbase by apache.

the class TestRegionObserverScannerOpenHook method testRegionObserverScanTimeStacking.

@Test
public void testRegionObserverScanTimeStacking() throws Exception {
    byte[] ROW = Bytes.toBytes("testRow");
    byte[] TABLE = Bytes.toBytes(getClass().getName());
    byte[] A = Bytes.toBytes("A");
    byte[][] FAMILIES = new byte[][] { A };
    // Use new HTU to not overlap with the DFS cluster started in #CompactionStacking
    Configuration conf = new HBaseTestingUtil().getConfiguration();
    HRegion region = initHRegion(TABLE, getClass().getName(), conf, FAMILIES);
    RegionCoprocessorHost h = region.getCoprocessorHost();
    h.load(NoDataFromScan.class, Coprocessor.PRIORITY_HIGHEST, conf);
    h.load(EmptyRegionObsever.class, Coprocessor.PRIORITY_USER, conf);
    Put put = new Put(ROW);
    put.addColumn(A, A, A);
    region.put(put);
    Get get = new Get(ROW);
    Result r = region.get(get);
    assertNull("Got an unexpected number of rows - no data should be returned with the NoDataFromScan coprocessor. Found: " + r, r.listCells());
    HBaseTestingUtil.closeRegionAndWAL(region);
}
Also used : HRegion(org.apache.hadoop.hbase.regionserver.HRegion) Configuration(org.apache.hadoop.conf.Configuration) RegionCoprocessorHost(org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost) Get(org.apache.hadoop.hbase.client.Get) HBaseTestingUtil(org.apache.hadoop.hbase.HBaseTestingUtil) Put(org.apache.hadoop.hbase.client.Put) Result(org.apache.hadoop.hbase.client.Result) Test(org.junit.Test)

Example 7 with RegionCoprocessorHost

use of org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost in project hbase by apache.

the class TestRegionCoprocessorHost method testPostScannerFilterRow.

@Test
public void testPostScannerFilterRow() throws IOException {
    // By default SimpleRegionObserver is set as region coprocessor which implements
    // postScannerFilterRow
    RegionCoprocessorHost host = new RegionCoprocessorHost(region, rsServices, conf);
    assertTrue("Region coprocessor implement postScannerFilterRow", host.hasCustomPostScannerFilterRow());
    // Set a region CP which doesn't implement postScannerFilterRow
    init(true);
    host = new RegionCoprocessorHost(region, rsServices, conf);
    assertFalse("Region coprocessor implement postScannerFilterRow", host.hasCustomPostScannerFilterRow());
    // Set multiple region CPs, in which one implements postScannerFilterRow
    init(false);
    host = new RegionCoprocessorHost(region, rsServices, conf);
    assertTrue("Region coprocessor doesn't implement postScannerFilterRow", host.hasCustomPostScannerFilterRow());
}
Also used : RegionCoprocessorHost(org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost) Test(org.junit.Test)

Example 8 with RegionCoprocessorHost

use of org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost in project hbase by apache.

the class TestRegionCoprocessorHost method testPreCompactScannerOpen.

@Test
public void testPreCompactScannerOpen() throws IOException {
    RegionCoprocessorHost host = new RegionCoprocessorHost(region, rsServices, conf);
    ScanInfo oldScanInfo = getScanInfo();
    HStore store = mock(HStore.class);
    when(store.getScanInfo()).thenReturn(oldScanInfo);
    ScanInfo newScanInfo = host.preCompactScannerOpen(store, ScanType.COMPACT_DROP_DELETES, mock(CompactionLifeCycleTracker.class), mock(CompactionRequest.class), mock(User.class));
    verifyScanInfo(newScanInfo);
}
Also used : CompactionLifeCycleTracker(org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker) User(org.apache.hadoop.hbase.security.User) RegionCoprocessorHost(org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost) ScanInfo(org.apache.hadoop.hbase.regionserver.ScanInfo) CompactionRequest(org.apache.hadoop.hbase.regionserver.compactions.CompactionRequest) HStore(org.apache.hadoop.hbase.regionserver.HStore) Test(org.junit.Test)

Example 9 with RegionCoprocessorHost

use of org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost in project hbase by apache.

the class TestRegionCoprocessorHost method testPreMemStoreCompactionCompactScannerOpen.

@Test
public void testPreMemStoreCompactionCompactScannerOpen() throws IOException {
    RegionCoprocessorHost host = new RegionCoprocessorHost(region, rsServices, conf);
    ScanInfo oldScanInfo = getScanInfo();
    HStore store = mock(HStore.class);
    when(store.getScanInfo()).thenReturn(oldScanInfo);
    ScanInfo newScanInfo = host.preMemStoreCompactionCompactScannerOpen(store);
    verifyScanInfo(newScanInfo);
}
Also used : RegionCoprocessorHost(org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost) ScanInfo(org.apache.hadoop.hbase.regionserver.ScanInfo) HStore(org.apache.hadoop.hbase.regionserver.HStore) Test(org.junit.Test)

Example 10 with RegionCoprocessorHost

use of org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost in project hbase by apache.

the class TestRegionObserverPreFlushAndPreCompact method testPreFlushReturningNull.

/**
 * Ensure we get expected exception when we try to return null from a preFlush call.
 * @throws IOException We expect it to throw {@link CoprocessorException}
 */
@Test(expected = CoprocessorException.class)
public void testPreFlushReturningNull() throws IOException {
    RegionCoprocessorHost rch = getRegionCoprocessorHost();
    rch.preFlush(null, null, null);
}
Also used : RegionCoprocessorHost(org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost) Test(org.junit.Test)

Aggregations

RegionCoprocessorHost (org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost)27 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)16 Test (org.junit.Test)16 Configuration (org.apache.hadoop.conf.Configuration)10 RegionServerServices (org.apache.hadoop.hbase.regionserver.RegionServerServices)8 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)6 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)5 RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)5 HStore (org.apache.hadoop.hbase.regionserver.HStore)4 ScanInfo (org.apache.hadoop.hbase.regionserver.ScanInfo)4 Path (org.apache.hadoop.fs.Path)3 Coprocessor (org.apache.hadoop.hbase.Coprocessor)3 Put (org.apache.hadoop.hbase.client.Put)3 TableDescriptorBuilder (org.apache.hadoop.hbase.client.TableDescriptorBuilder)3 HBaseTestingUtil (org.apache.hadoop.hbase.HBaseTestingUtil)2 Get (org.apache.hadoop.hbase.client.Get)2 Result (org.apache.hadoop.hbase.client.Result)2 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 CoprocessorEnvironment (org.apache.hadoop.hbase.CoprocessorEnvironment)1