public void testDeregisterOnOutOfScope() { Configuration conf = new Configuration(); ConfigurationManager cm = new ConfigurationManager(); cm.notifyAllObservers(conf); if (cm.getNumObservers() <= i) { outOfScopeObserversDeregistered = true; break;
public void deregister() { this.cm.deregisterObserver(this); } }
private void registerConfigurationObservers() { // Registering the compactSplitThread object with the ConfigurationManager. configurationManager.registerObserver(this.compactSplitThread); configurationManager.registerObserver(this.rpcServices); configurationManager.registerObserver(this); }
/** * Reload the configuration from disk. */ public void updateConfiguration() { LOG.info("Reloading the configuration from disk."); // Reload the configuration from disk. conf.reloadConfiguration(); configurationManager.notifyAllObservers(conf); }
/** * Test if observers get notified by the <code>ConfigurationManager</code> * when the Configuration is reloaded. */ @Test public void testCheckIfObserversNotified() { Configuration conf = new Configuration(); ConfigurationManager cm = new ConfigurationManager(); DummyConfigurationObserver d1 = new DummyConfigurationObserver(cm); // Check if we get notified. cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); // Now check if we get notified on change with more than one observers. DummyConfigurationObserver d2 = new DummyConfigurationObserver(cm); cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); assertTrue(d2.wasNotifiedOnChange()); d2.resetNotifiedOnChange(); // Now try deregistering an observer and verify that it was not notified d2.deregister(); cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); assertFalse(d2.wasNotifiedOnChange()); }
spanReceiverHost = SpanReceiverHost.getInstance(getConfiguration()); this.configurationManager = new ConfigurationManager(); setupWindows(getConfiguration(), getConfigurationManager());
@Override public void handle(Signal signal) { conf.reloadConfiguration(); cm.notifyAllObservers(conf); } });
/** * Test if observers get notified by the <code>ConfigurationManager</code> * when the Configuration is reloaded. */ @Test public void testCheckIfObserversNotified() { Configuration conf = new Configuration(); ConfigurationManager cm = new ConfigurationManager(); DummyConfigurationObserver d1 = new DummyConfigurationObserver(cm); // Check if we get notified. cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); // Now check if we get notified on change with more than one observers. DummyConfigurationObserver d2 = new DummyConfigurationObserver(cm); cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); assertTrue(d2.wasNotifiedOnChange()); d2.resetNotifiedOnChange(); // Now try deregistering an observer and verify that it was not notified d2.deregister(); cm.notifyAllObservers(conf); assertTrue(d1.wasNotifiedOnChange()); d1.resetNotifiedOnChange(); assertFalse(d2.wasNotifiedOnChange()); }
clusterStatusTracker.start(); this.configurationManager = new ConfigurationManager();
public void testDeregisterOnOutOfScope() { Configuration conf = new Configuration(); ConfigurationManager cm = new ConfigurationManager(); cm.notifyAllObservers(conf); if (cm.getNumObservers() <= i) { outOfScopeObserversDeregistered = true; break;
public void register() { this.cm.registerObserver(this); }
/** * Check if the number of compaction threads changes online * @throws IOException */ @Test public void testNumCompactionThreadsOnlineChange() throws IOException { assertTrue(rs1.compactSplitThread != null); int newNumSmallThreads = rs1.compactSplitThread.getSmallCompactionThreadNum() + 1; int newNumLargeThreads = rs1.compactSplitThread.getLargeCompactionThreadNum() + 1; conf.setInt("hbase.regionserver.thread.compaction.small", newNumSmallThreads); conf.setInt("hbase.regionserver.thread.compaction.large", newNumLargeThreads); rs1.getConfigurationManager().notifyAllObservers(conf); assertEquals(newNumSmallThreads, rs1.compactSplitThread.getSmallCompactionThreadNum()); assertEquals(newNumLargeThreads, rs1.compactSplitThread.getLargeCompactionThreadNum()); }
private void stopProcedureExecutor() { if (procedureExecutor != null) { configurationManager.deregisterObserver(procedureExecutor.getEnvironment()); procedureExecutor.getEnvironment().getRemoteDispatcher().stop(); procedureExecutor.stop(); procedureExecutor.join(); procedureExecutor = null; } if (procedureStore != null) { procedureStore.stop(isAborted()); procedureStore = null; } }
@Override public void addRegion(HRegion region) { this.onlineRegions.put(region.getRegionInfo().getEncodedName(), region); configurationManager.registerObserver(region); }
rs1.getConfigurationManager().notifyAllObservers(conf); conf.setFloat(strPrefix + "ratio.offpeak", (float)newOffPeakCompactionRatio); rs1.getConfigurationManager().notifyAllObservers(conf); assertEquals(newOffPeakCompactionRatio, hstore.getStoreEngine().getCompactionPolicy().getConf().getCompactionRatioOffPeak(), conf.setLong("hbase.regionserver.thread.compaction.throttle", newThrottlePoint); rs1.getConfigurationManager().notifyAllObservers(conf); assertEquals(newThrottlePoint, hstore.getStoreEngine().getCompactionPolicy().getConf().getThrottlePoint()); hstore.getStoreEngine().getCompactionPolicy().getConf().getMinFilesToCompact() + 1; conf.setLong(strPrefix + "min", newMinFilesToCompact); rs1.getConfigurationManager().notifyAllObservers(conf); assertEquals(newMinFilesToCompact, hstore.getStoreEngine().getCompactionPolicy().getConf().getMinFilesToCompact()); hstore.getStoreEngine().getCompactionPolicy().getConf().getMaxFilesToCompact() + 1; conf.setLong(strPrefix + "max", newMaxFilesToCompact); rs1.getConfigurationManager().notifyAllObservers(conf); assertEquals(newMaxFilesToCompact, hstore.getStoreEngine().getCompactionPolicy().getConf().getMaxFilesToCompact()); rs1.getConfigurationManager().notifyAllObservers(conf); assertFalse(hstore.getOffPeakHours().isOffPeakHour(4));
public void deregister() { this.cm.deregisterObserver(this); } }
private void createProcedureExecutor() throws IOException { MasterProcedureEnv procEnv = new MasterProcedureEnv(this); procedureStore = new WALProcedureStore(conf, new MasterProcedureEnv.WALStoreLeaseRecovery(this)); procedureStore.registerListener(new ProcedureStoreListener() { @Override public void abortProcess() { abort("The Procedure Store lost the lease", null); } }); MasterProcedureScheduler procedureScheduler = procEnv.getProcedureScheduler(); procedureExecutor = new ProcedureExecutor<>(conf, procEnv, procedureStore, procedureScheduler); configurationManager.registerObserver(procEnv); int cpus = Runtime.getRuntime().availableProcessors(); final int numThreads = conf.getInt(MasterProcedureConstants.MASTER_PROCEDURE_THREADS, Math.max( (cpus > 0 ? cpus / 4 : 0), MasterProcedureConstants.DEFAULT_MIN_MASTER_PROCEDURE_THREADS)); final boolean abortOnCorruption = conf.getBoolean(MasterProcedureConstants.EXECUTOR_ABORT_ON_CORRUPTION, MasterProcedureConstants.DEFAULT_EXECUTOR_ABORT_ON_CORRUPTION); procedureStore.start(numThreads); // Just initialize it but do not start the workers, we will start the workers later by calling // startProcedureExecutor. See the javadoc for finishActiveMasterInitialization for more // details. procedureExecutor.init(numThreads, abortOnCorruption); procEnv.getRemoteDispatcher().start(); }
/** * Reload the configuration from disk. */ public void updateConfiguration() { LOG.info("Reloading the configuration from disk."); // Reload the configuration from disk. conf.reloadConfiguration(); configurationManager.notifyAllObservers(conf); }
/** * {@inheritDoc} */ @Override public void deregisterChildren(ConfigurationManager manager) { for (Store s : this.stores.values()) { configurationManager.get().deregisterObserver(s); } }
(System.currentTimeMillis() - masterActiveTime) / 1000.0f)); this.masterFinishedInitializationTime = System.currentTimeMillis(); configurationManager.registerObserver(this.balancer); configurationManager.registerObserver(this.hfileCleaner); configurationManager.registerObserver(this.logCleaner);