private MasterSyncObserver getMasterSyncObserver() { return (MasterSyncObserver)TEST_UTIL.getHBaseCluster().getMaster() .getMasterCoprocessorHost().findCoprocessor(MasterSyncObserver.class.getName()); } }
@Before public void before() throws IOException { String methodName = this.name.getMethodName(); this.ms = new MockMasterServices(HTU.getConfiguration(), null); this.mch = new MasterCoprocessorHost(this.ms, HTU.getConfiguration()); this.mch.preMasterInitialization(); }
/** * @return array of coprocessor SimpleNames. */ public String[] getMasterCoprocessors() { Set<String> masterCoprocessors = getMasterCoprocessorHost().getCoprocessors(); return masterCoprocessors.toArray(new String[masterCoprocessors.size()]); }
try { if (master.cpHost != null) { master.cpHost.preBalanceSwitch(newValue); master.cpHost.postBalanceSwitch(oldValue, newValue);
if (cpHost != null) { snapshotPOJO = ProtobufUtil.createSnapshotDesc(snapshot); cpHost.preCloneSnapshot(snapshotPOJO, htd); cpHost.postCloneSnapshot(snapshotPOJO, htd);
if (this.cpHost.preBalance()) { LOG.debug("Coprocessor bypassing balancer request"); return false; this.cpHost.postBalance(rpCount < plans.size() ? plans.subList(0, rpCount) : plans); } catch (IOException ioe) {
@Test public void testCoprocessorLoading() throws Exception { MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster().getMasterCoprocessorHost(); cpHost.load(MyAccessController.class, Coprocessor.PRIORITY_HIGHEST, conf); AccessController ACCESS_CONTROLLER = cpHost.findCoprocessor(MyAccessController.class); MasterCoprocessorEnvironment CP_ENV = cpHost.createEnvironment( ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf); RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0) .getRegionServerCoprocessorHost(); RegionServerCoprocessorEnvironment RSCP_ENV = rsHost.createEnvironment( ACCESS_CONTROLLER, Coprocessor.PRIORITY_HIGHEST, 1, conf); }
cpHost.preRestoreSnapshot(reqSnapshot, snapshotTableDesc); cpHost.postRestoreSnapshot(reqSnapshot, snapshotTableDesc); Bytes.toBytes(tableName)); if (cpHost != null) { cpHost.preCloneSnapshot(reqSnapshot, htd); cpHost.postCloneSnapshot(reqSnapshot, htd);
this.cpHost = new MasterCoprocessorHost(this, this.conf); this.cpHost.preMasterInitialization(); } catch (IOException e) { LOG.error("Coprocessor preMasterInitialization() hook failed", e); this.cpHost.postStartMaster(); } catch (IOException ioe) { LOG.error("Coprocessor postStartMaster() hook failed", ioe);
@Override public AssignRegionResponse assignRegion(RpcController controller, AssignRegionRequest req) throws ServiceException { try { master.checkInitialized(); final RegionSpecifierType type = req.getRegion().getType(); if (type != RegionSpecifierType.REGION_NAME) { LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME + " actual: " + type); } final byte[] regionName = req.getRegion().getValue().toByteArray(); final RegionInfo regionInfo = master.getAssignmentManager().getRegionInfo(regionName); if (regionInfo == null) throw new UnknownRegionException(Bytes.toStringBinary(regionName)); final AssignRegionResponse arr = AssignRegionResponse.newBuilder().build(); if (master.cpHost != null) { master.cpHost.preAssign(regionInfo); } LOG.info(master.getClientIdAuditPrefix() + " assign " + regionInfo.getRegionNameAsString()); master.getAssignmentManager().assign(regionInfo); if (master.cpHost != null) { master.cpHost.postAssign(regionInfo); } return arr; } catch (IOException ioe) { throw new ServiceException(ioe); } }
/** * Determines if there is a MasterCoprocessor deployed which implements * {@link org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsService.Interface}. */ boolean hasVisibilityLabelsServiceCoprocessor(MasterCoprocessorHost cpHost) { return checkCoprocessorWithService( cpHost.findCoprocessors(MasterCoprocessor.class), VisibilityLabelsService.Interface.class); }
public void stopMaster() throws IOException { if (cpHost != null) { cpHost.preStopMaster(); } stop("Stopped by " + Thread.currentThread().getName()); }
master.getMasterCoprocessorHost().load( FailingSplitMasterObserver.class, Coprocessor.PRIORITY_USER, master.getMasterCoprocessorHost().findCoprocessor(FailingSplitMasterObserver.class); assertNotNull(observer); observer.latch.await();
public MasterCoprocessorHost(final MasterServices services, final Configuration conf) { super(services); this.conf = conf; this.masterServices = services; // Log the state of coprocessor loading here; should appear only once or // twice in the daemon log, depending on HBase version, because there is // only one MasterCoprocessorHost instance in the master process boolean coprocessorsEnabled = conf.getBoolean(COPROCESSORS_ENABLED_CONF_KEY, DEFAULT_COPROCESSORS_ENABLED); LOG.trace("System coprocessor loading is {}", (coprocessorsEnabled ? "enabled" : "disabled")); loadSystemCoprocessors(conf, MASTER_COPROCESSOR_CONF_KEY); }
this.cpHost = new MasterCoprocessorHost(this, this.conf); this.cpHost.postStartMaster(); } catch (IOException ioe) { LOG.error("Coprocessor postStartMaster() hook failed", ioe);
@Test public void testMasterCoprocessorHostDefaults() throws Exception { Configuration conf = new Configuration(CONF); MasterServices masterServices = mock(MasterServices.class); systemCoprocessorLoaded.set(false); new MasterCoprocessorHost(masterServices, conf); assertEquals("System coprocessors loading default was not honored", CoprocessorHost.DEFAULT_COPROCESSORS_ENABLED, systemCoprocessorLoaded.get()); }
@BeforeClass public static void setupBeforeClass() throws Exception { // setup configuration conf = TEST_UTIL.getConfiguration(); conf.setInt(HConstants.REGION_SERVER_HIGH_PRIORITY_HANDLER_COUNT, 10); // Enable security enableSecurity(conf); // Verify enableSecurity sets up what we require verifyConfiguration(conf); TEST_UTIL.startMiniCluster(); MasterCoprocessorHost cpHost = TEST_UTIL.getMiniHBaseCluster().getMaster() .getMasterCoprocessorHost(); cpHost.load(AccessController.class, Coprocessor.PRIORITY_HIGHEST, conf); AccessController ac = (AccessController) cpHost.findCoprocessor(AccessController.class.getName()); cpHost.createEnvironment(ac, Coprocessor.PRIORITY_HIGHEST, 1, conf); RegionServerCoprocessorHost rsHost = TEST_UTIL.getMiniHBaseCluster().getRegionServer(0) .getRegionServerCoprocessorHost(); rsHost.createEnvironment(ac, Coprocessor.PRIORITY_HIGHEST, 1, conf); // Wait for the ACL table to become available TEST_UTIL.waitTableEnabled(AccessControlLists.ACL_TABLE_NAME); // create a set of test users USER_OWNER = User.createUserForTesting(conf, "owner", new String[0]); USER_OTHER = User.createUserForTesting(conf, "other", new String[0]); }
cpHost.preRestoreSnapshot(reqSnapshot, snapshotTableDesc); cpHost.postRestoreSnapshot(reqSnapshot, snapshotTableDesc); cpHost.preCloneSnapshot(reqSnapshot, htd); cpHost.postCloneSnapshot(reqSnapshot, htd);
this.cpHost = new MasterCoprocessorHost(this, this.conf); this.cpHost.preMasterInitialization(); } catch (IOException e) { LOG.error("Coprocessor preMasterInitialization() hook failed", e); this.cpHost.postStartMaster(); } catch (IOException ioe) { LOG.error("Coprocessor postStartMaster() hook failed", ioe);
@Override public void assign(final byte [] regionName)throws IOException { checkInitialized(); Pair<HRegionInfo, ServerName> pair = MetaReader.getRegion(this.catalogTracker, regionName); if (pair == null) throw new UnknownRegionException(Bytes.toString(regionName)); if (cpHost != null) { if (cpHost.preAssign(pair.getFirst())) { return; } } assignRegion(pair.getFirst()); if (cpHost != null) { cpHost.postAssign(pair.getFirst()); } }