Search in sources :

Example 11 with CoprocessorEnvironment

use of org.apache.hadoop.hbase.CoprocessorEnvironment in project hbase by apache.

the class TestCoprocessorConfiguration method testReadOnlyConfiguration.

/**
 * Rough test that Coprocessor Environment is Read-Only.
 * Just check a random CP and see that it returns a read-only config.
 */
@Test
public void testReadOnlyConfiguration() throws Exception {
    Configuration conf = new Configuration(CONF);
    HRegion region = mock(HRegion.class);
    when(region.getRegionInfo()).thenReturn(REGIONINFO);
    when(region.getTableDescriptor()).thenReturn(TABLEDESC);
    RegionServerServices rsServices = mock(RegionServerServices.class);
    RegionCoprocessorHost rcp = new RegionCoprocessorHost(region, rsServices, conf);
    boolean found = false;
    for (String cpStr : rcp.getCoprocessors()) {
        CoprocessorEnvironment cpenv = rcp.findCoprocessorEnvironment(cpStr);
        if (cpenv != null) {
            found = true;
        }
        Configuration c = cpenv.getConfiguration();
        thrown.expect(UnsupportedOperationException.class);
        c.set("one.two.three", "four.five.six");
    }
    assertTrue("Should be at least one CP found", found);
}
Also used : HRegion(org.apache.hadoop.hbase.regionserver.HRegion) RegionServerServices(org.apache.hadoop.hbase.regionserver.RegionServerServices) Configuration(org.apache.hadoop.conf.Configuration) HBaseConfiguration(org.apache.hadoop.hbase.HBaseConfiguration) RegionCoprocessorHost(org.apache.hadoop.hbase.regionserver.RegionCoprocessorHost) CoprocessorEnvironment(org.apache.hadoop.hbase.CoprocessorEnvironment) Test(org.junit.Test)

Aggregations

Configuration (org.apache.hadoop.conf.Configuration)11 CoprocessorEnvironment (org.apache.hadoop.hbase.CoprocessorEnvironment)11 Test (org.junit.Test)8 HBaseConfiguration (org.apache.hadoop.hbase.HBaseConfiguration)5 File (java.io.File)4 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)4 Path (org.apache.hadoop.fs.Path)3 SingleProcessHBaseCluster (org.apache.hadoop.hbase.SingleProcessHBaseCluster)3 Admin (org.apache.hadoop.hbase.client.Admin)3 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)3 TableDescriptorBuilder (org.apache.hadoop.hbase.client.TableDescriptorBuilder)3 HashMap (java.util.HashMap)2 Set (java.util.Set)2 FileSystem (org.apache.hadoop.fs.FileSystem)2 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1