Java Code Examples for com.typesafe.config.ConfigFactory#invalidateCaches()
The following examples show how to use
com.typesafe.config.ConfigFactory#invalidateCaches() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Compiler.java From kite with Apache License 2.0 | 8 votes |
/** Loads the given config file from the local file system */ public Config parse(File file, Config... overrides) throws IOException { if (file == null || file.getPath().trim().length() == 0) { throw new MorphlineCompilationException("Missing morphlineFile parameter", null); } if (!file.exists()) { throw new FileNotFoundException("File not found: " + file); } if (!file.canRead()) { throw new IOException("Insufficient permissions to read file: " + file); } Config config = ConfigFactory.parseFile(file); for (Config override : overrides) { config = override.withFallback(config); } synchronized (LOCK) { ConfigFactory.invalidateCaches(); config = ConfigFactory.load(config); config.checkValid(ConfigFactory.defaultReference()); // eagerly validate aspects of tree config } return config; }
Example 2
Source File: ConfigLoader.java From casquatch with Apache License 2.0 | 6 votes |
/** * Load root config * @return typesafe config object */ private static Config root() { if(root==null ) { ConfigFactory.invalidateCaches(); if (log.isTraceEnabled()) { try { Enumeration<URL> classList = ConfigLoader.class.getClassLoader().getResources("reference.conf"); while (classList.hasMoreElements()) { log.trace("Loading reference.conf @ {}", classList.nextElement().getFile()); } } catch (Exception e) { log.trace("No reference.conf can be found"); } } root = ConfigFactory.load(); } return root; }
Example 3
Source File: UnitTopologyMain.java From eagle with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { // command line parse Options options = new Options(); options.addOption("c", true, "config URL (valid file name) - defaults application.conf according to typesafe config default behavior."); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("c")) { String fileName = cmd.getOptionValue("c", "application.conf"); System.setProperty("config.resource", fileName.startsWith("/") ? fileName : "/" + fileName); ConfigFactory.invalidateCaches(); } Config config = ConfigFactory.load(); // load config and start String topologyId = getTopologyName(config); ZKMetadataChangeNotifyService changeNotifyService = createZKNotifyService(config, topologyId); new UnitTopologyRunner(changeNotifyService).run(topologyId, config); }
Example 4
Source File: ConfigReloader.java From xio with Apache License 2.0 | 6 votes |
@VisibleForTesting void checkForUpdates() { try { // check to see if any of the specific watch files have changed if (haveWatchFilesChanged()) { // suck up the original file which includes all the sub files ConfigFactory.invalidateCaches(); Meta<T> update = load(metadata.path); updater.accept(metadata.value, update.value); metadata = update; } else { log.debug("No update: None of the watch files have changed", metadata.path); } } catch (Exception e) { log.error("Caught exception while checking for updates", e); } }
Example 5
Source File: MainTest.java From riposte-microservice-template with Apache License 2.0 | 5 votes |
@Test public void public_static_void_main_method_starts_the_server() throws Exception { // given System.setProperty("@appId", APP_ID); System.setProperty("@environment", "compiletimetest"); int serverPort = TestUtils.findFreePort(); System.setProperty("endpoints.port", String.valueOf(serverPort)); // We have to invalidate the typesafe config caches so that it will pick up our endpoints.port system property // override. ConfigFactory.invalidateCaches(); // when Main.main(new String[]{}); // then ExtractableResponse healthCheckCallResponse = given() .baseUri("http://localhost") .port(serverPort) .log().all() .when() .basePath("/healthcheck") .get() .then() .log().all() .extract(); assertThat(healthCheckCallResponse.statusCode()).isEqualTo(200); }
Example 6
Source File: MainTest.java From riposte-microservice-template with Apache License 2.0 | 5 votes |
@AfterClass public static void afterClass() { System.clearProperty("@appId"); System.clearProperty("@environment"); System.clearProperty("endpoints.port"); ConfigFactory.invalidateCaches(); }
Example 7
Source File: ChannelAccessTest.java From mewbase with MIT License | 5 votes |
private void setUpBadConfig() { // over-ride the good settings to make a JMS sink final String accessFactory = "mewbase.event.channels.access.factory"; System.setProperty(accessFactory, "not.a.valid.class"); // force reload of config values ConfigFactory.invalidateCaches(); ConfigFactory.load(); // cache side effects be gone }
Example 8
Source File: SimpleKBTest.java From Stargraph with MIT License | 5 votes |
@BeforeClass public void before() throws IOException { Path root = Files.createTempFile("stargraph-", "-dataDir"); Path ntPath = createPath(root, factsId).resolve("triples.nt"); copyResource("dataSets/simple/facts/triples.nt", ntPath); ConfigFactory.invalidateCaches(); Config config = ConfigFactory.load().getConfig("stargraph"); stargraph = new Stargraph(config, false); stargraph.setKBInitSet(kbName); stargraph.setDefaultIndicesFactory(new NullIndicesFactory()); stargraph.setGraphModelFactory(new NTriplesModelFactory(stargraph)); stargraph.setDataRootDir(root.toFile()); stargraph.initialize(); }
Example 9
Source File: IndexerTest.java From Stargraph with MIT License | 5 votes |
@BeforeClass public void before() { ConfigFactory.invalidateCaches(); Config config = ConfigFactory.load().getConfig("stargraph"); this.stargraph = new Stargraph(config, false); this.stargraph.setKBInitSet(kbId.getId()); this.stargraph.setDefaultIndicesFactory(new TestDataIndexer.Factory()); this.stargraph.initialize(); this.indexer = stargraph.getIndexer(kbId); List<String> expected = Arrays.asList("first", "second", "third"); this.expected = expected.stream().map(s -> new TestData(false, false, s)).collect(Collectors.toList()); }
Example 10
Source File: NERAndLinkingIT.java From Stargraph with MIT License | 5 votes |
@BeforeClass public void beforeClass() throws Exception { ConfigFactory.invalidateCaches(); Stargraph stargraph = new Stargraph(); ner = stargraph.getKBCore("dbpedia-2016").getNER(); Assert.assertNotNull(ner); }
Example 11
Source File: IndexUpdateIT.java From Stargraph with MIT License | 5 votes |
@BeforeClass public void before() throws Exception { ConfigFactory.invalidateCaches(); core = new Stargraph(); searcher = new ElasticSearcher(kbId, core); searcher.start(); indexer = new ElasticIndexer(kbId, core); indexer.start(); indexer.deleteAll(); }
Example 12
Source File: DatabaseJobHistoryStoreTest.java From incubator-gobblin with Apache License 2.0 | 5 votes |
@BeforeClass public void setUp() throws Exception { ConfigFactory.invalidateCaches(); testMetastoreDatabase = TestMetastoreDatabaseFactory.get(getVersion()); Properties properties = new Properties(); properties.setProperty(ConfigurationKeys.JOB_HISTORY_STORE_URL_KEY, testMetastoreDatabase.getJdbcUrl()); Injector injector = Guice.createInjector(new MetaStoreModule(properties)); this.jobHistoryStore = injector.getInstance(JobHistoryStore.class); }
Example 13
Source File: GrapheneCLITest.java From Graphene with GNU General Public License v3.0 | 5 votes |
@BeforeTest void setup() { originalOut = System.out; originalErr = System.err; System.setOut(new PrintStream(outContent)); System.setErr(new PrintStream(errContent)); asserted = true; System.setProperty("config.resource", "application-cli.local.conf"); ConfigFactory.invalidateCaches(); }
Example 14
Source File: WorkSlotStrategyTest.java From eagle with Apache License 2.0 | 4 votes |
@Test public void testMultipleStreams() { ConfigFactory.invalidateCaches(); System.setProperty("config.resource", "/application-multiplestreams.conf"); InMemScheduleConext context = new InMemScheduleConext(); StreamGroup group1 = createStreamGroup("s1", Arrays.asList("f1", "f2"), true); StreamGroup group2 = createStreamGroup("s2", Arrays.asList("f2", "f3"), false); StreamGroup group3 = createStreamGroup("s3", Arrays.asList("f4"), false); StreamGroup group4 = createStreamGroup("s4", Arrays.asList("f5"), false); TestTopologyMgmtService mgmtService = new TestTopologyMgmtService(3, 4, "prefix-time1", true); WorkQueueBuilder wrb = new WorkQueueBuilder(context, mgmtService); { StreamWorkSlotQueue queue = wrb.createQueue(new MonitoredStream(group1), group1.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values()); TopologyUsage usage = context.getTopologyUsages().values().iterator().next(); Assert.assertTrue(getMonitorStream(usage.getMonitoredStream()).containsKey(group1)); Assert.assertEquals(1, getMonitorStream(usage.getMonitoredStream()).get(group1).getQueues().size()); Assert.assertEquals(2, getMonitorStream(usage.getMonitoredStream()).get(group1).getQueues().get(0).getWorkingSlots().size()); List<String> group1Slots = new ArrayList<String>(); getMonitorStream(usage.getMonitoredStream()).get(group1).getQueues().get(0).getWorkingSlots().forEach(slot -> { group1Slots.add(slot.getBoltId()); }); StreamWorkSlotQueue queue2 = wrb.createQueue(new MonitoredStream(group2), group2.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values()); Assert.assertTrue(getMonitorStream(usage.getMonitoredStream()).containsKey(group2)); Assert.assertEquals(1, getMonitorStream(usage.getMonitoredStream()).get(group2).getQueues().size()); Assert.assertEquals(2, getMonitorStream(usage.getMonitoredStream()).get(group2).getQueues().get(0).getWorkingSlots().size()); getMonitorStream(usage.getMonitoredStream()).get(group2).getQueues().get(0).getWorkingSlots().forEach(slot -> { Assert.assertTrue(!group1Slots.contains(slot.getBoltId())); }); StreamWorkSlotQueue queue3 = wrb.createQueue(new MonitoredStream(group3), group3.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values()); Assert.assertTrue(getMonitorStream(usage.getMonitoredStream()).containsKey(group3)); Assert.assertEquals(1, getMonitorStream(usage.getMonitoredStream()).get(group3).getQueues().size()); Assert.assertEquals(2, getMonitorStream(usage.getMonitoredStream()).get(group3).getQueues().get(0).getWorkingSlots().size()); getMonitorStream(usage.getMonitoredStream()).get(group3).getQueues().get(0).getWorkingSlots().forEach(slot -> { Assert.assertTrue(!group1Slots.contains(slot.getBoltId())); }); StreamWorkSlotQueue queue4 = wrb.createQueue(new MonitoredStream(group4), group4.isDedicated(), 2, new HashMap<String, Object>()); print(context.getTopologyUsages().values()); Assert.assertTrue(!getMonitorStream(usage.getMonitoredStream()).containsKey(group4)); } }
Example 15
Source File: TypesafeConfigServerTest.java From riposte with Apache License 2.0 | 4 votes |
@Before public void beforeMethod() { clearSystemProps(); System.setProperty(MainClassUtils.DELAY_CRASH_ON_STARTUP_SYSTEM_PROP_KEY, "false"); ConfigFactory.invalidateCaches(); }
Example 16
Source File: DefaultEnvironment.java From pdfcompare with Apache License 2.0 | 4 votes |
public static Environment create() { ConfigFactory.invalidateCaches(); Config config = ConfigFactory.systemEnvironment().withFallback(ConfigFactory.load()); return new ConfigFileEnvironment(config); }
Example 17
Source File: ProcessorsTest.java From Stargraph with MIT License | 4 votes |
@BeforeClass public void beforeClass() { ConfigFactory.invalidateCaches(); config = ConfigFactory.load().getConfig("processor"); }
Example 18
Source File: RdfFreemarkerCli.java From streams with Apache License 2.0 | 4 votes |
public RdfFreemarkerCli(String[] args) { ConfigFactory.invalidateCaches(); this.args = args; this.typesafe = ConfigFactory.load(); }
Example 19
Source File: FactProviderTest.java From Stargraph with MIT License | 4 votes |
@BeforeMethod public void before() throws IOException { root = TestUtils.prepareObamaTestEnv(); ConfigFactory.invalidateCaches(); config = ConfigFactory.load().getConfig("stargraph"); }
Example 20
Source File: TwitterFollowingProviderIT.java From streams with Apache License 2.0 | 4 votes |
@Test(dataProvider = "TwitterFollowingProviderIT") public void testTwitterFollowingProvider(String endpoint, Boolean ids_only, Integer max_items) throws Exception { String configfile = "./target/test-classes/TwitterFollowingProviderIT.conf"; String outfile = "./target/test-classes/TwitterFollowingProviderIT-"+endpoint+"-"+ids_only+".stdout.txt"; String[] args = new String[2]; args[0] = configfile; args[1] = outfile; File conf = new File(configfile); Assert.assertTrue (conf.exists()); Assert.assertTrue (conf.canRead()); Assert.assertTrue (conf.isFile()); System.setProperty("ENDPOINT", endpoint); System.setProperty("IDS_ONLY", Boolean.toString(ids_only)); System.setProperty("MAX_ITEMS", Integer.toString(max_items)); ConfigFactory.invalidateCaches(); StreamsConfigurator.setConfig(ConfigFactory.load()); Thread testThread = new Thread(() -> { try { TwitterFollowingProvider.main(args); } catch ( Exception ex ) { LOGGER.error("Test Exception!", ex); } }); testThread.start(); testThread.join(60000); File out = new File(outfile); Assert.assertTrue (out.exists()); Assert.assertTrue (out.canRead()); Assert.assertTrue (out.isFile()); FileReader outReader = new FileReader(out); LineNumberReader outCounter = new LineNumberReader(outReader); while (outCounter.readLine() != null) {} Assert.assertEquals (outCounter.getLineNumber(), max_items.intValue()); }