/** * 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); }
@Override public void handle(Signal signal) { conf.reloadConfiguration(); cm.notifyAllObservers(conf); } });
cm.notifyAllObservers(conf);
/** * 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()); }
/** * 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()); }
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));
/** * 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); }
public void handle(Signal signal) { getConfiguration().reloadConfiguration(); configurationManager.notifyAllObservers(getConfiguration()); } });
/** * 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()); }
/** * 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()); }
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));