/** * Configures the provided configuration path to the given value. * * @param path * @param value * @return */ public Builder set(String path, Object value) { writeConfiguration.set(path, value); return this; }
public void commit() { for (Map.Entry<String,Object> entry : writtenValues.entrySet()) { if (config instanceof ConcurrentWriteConfiguration && readValues.containsKey(entry.getKey())) { ((ConcurrentWriteConfiguration)config) .set(entry.getKey(), entry.getValue(), readValues.get(entry.getKey())); } else { config.set(entry.getKey(),entry.getValue()); } } rollback(); }
public static void applyOverrides(final WriteConfiguration base) { if (null == overrides) return; for (String k : overrides.getKeys(null)) { base.set(k, overrides.get(k, Object.class)); } }
public void freezeConfiguration() { config.set(FROZEN_KEY, Boolean.TRUE); if (!isFrozen()) setFrozen(); }
@Override public void set(String s, Object o) { if (s==null) throw Graph.Variables.Exceptions.variableKeyCanNotBeNull(); if (StringUtils.isEmpty(s)) throw Graph.Variables.Exceptions.variableKeyCanNotBeEmpty(); if (o==null) throw Graph.Variables.Exceptions.variableValueCanNotBeNull(); config.set(s,o); }
@Test public void configTest() { config.set("test.key","world"); config.set("test.bar", 100); config.set("storage.xyz", true); config.set("storage.abc", Boolean.FALSE); config.set("storage.duba", new String[]{"x", "y"}); config.set("times.60m", Duration.ofMinutes(60)); config.set("obj", new Object()); // necessary for AbstractConfiguration.getSubset assertEquals("world", config.get("test.key", String.class)); assertEquals(ImmutableSet.of("test.key", "test.bar"), Sets.newHashSet(config.getKeys("test"))); // assertEquals(ImmutableSet.of("test.key", "test.bar", "test.baz"), Sets.newHashSet(config.getKeys("test"))); assertEquals(ImmutableSet.of("storage.xyz", "storage.duba", "storage.abc"), Sets.newHashSet(config.getKeys("storage"))); assertEquals(100,config.get("test.bar",Integer.class).intValue()); // assertEquals(1,config.get("test.baz",Integer.class).intValue()); assertEquals(true, config.get("storage.xyz", Boolean.class)); assertEquals(false, config.get("storage.abc", Boolean.class)); assertTrue(Arrays.equals(new String[]{"x", "y"},config.get("storage.duba",String[].class))); assertEquals(Duration.ofMinutes(60), config.get("times.60m", Duration.class)); assertTrue(Object.class.isAssignableFrom(config.get("obj", Object.class).getClass())); } }
public<O> ModifiableConfiguration set(ConfigOption<O> option, O value, String... umbrellaElements) { verifyOption(option); Preconditions.checkArgument(hasUpgradeableFixed(option.getName()) || !option.isFixed() || !isFrozen(), "Cannot change configuration option: %s", option); String key = super.getPath(option,umbrellaElements); value = option.verify(value); config.set(key,value); return this; }
wc.set(ConfigElement.getPath(ALLOW_STALE_CONFIG), false); wc.set(ConfigElement.getPath(MAX_COMMIT_TIME), customCommitTime); try { graph = (StandardJanusGraph) JanusGraphFactory.open(wc); wc.set(ConfigElement.getPath(ALLOW_STALE_CONFIG), true); wc.set(ConfigElement.getPath(MAX_COMMIT_TIME), customCommitTime); graph = (StandardJanusGraph) JanusGraphFactory.open(wc); wc.set(ConfigElement.getPath(ALLOW_STALE_CONFIG), false); graph = (StandardJanusGraph) JanusGraphFactory.open(wc); close(); wc.set(ConfigElement.getPath(MAX_COMMIT_TIME), customCommitTime); try { graph = (StandardJanusGraph) JanusGraphFactory.open(wc); wc.set(ConfigElement.getPath(ALLOW_STALE_CONFIG), true); wc.set(ConfigElement.getPath(MAX_COMMIT_TIME), customCommitTime); graph = (StandardJanusGraph) JanusGraphFactory.open(wc);
/** * Ensure clearing storage actually removes underlying database. * @throws Exception */ @Test public void testClearStorage() throws Exception { tearDown(); config.set(ConfigElement.getPath(GraphDatabaseConfiguration.DROP_ON_CLEAR), true); final Backend backend = getBackend(config, false); assertTrue("graph should exist before clearing storage", backend.getStoreManager().exists()); clearGraph(config); assertFalse("graph should not exist after clearing storage", backend.getStoreManager().exists()); }
/** * Ensure clearing storage actually removes underlying graph and index databases. * @throws Exception */ @Test public void testClearStorage() throws Exception { GraphOfTheGodsFactory.load(graph); tearDown(); config.set(ConfigElement.getPath(GraphDatabaseConfiguration.DROP_ON_CLEAR), true); final Backend backend = getBackend(config, false); assertStorageExists(backend, true); clearGraph(config); try { backend.close(); } catch (final Exception e) { /* Most backends do not support closing after clearing */} try (final Backend newBackend = getBackend(config, false)) { assertStorageExists(newBackend, false); } }