public static BasicConfiguration getConfig(ReadConfiguration config) { return new BasicConfiguration(ROOT_NS,config, BasicConfiguration.Restriction.NONE); }
public Map<ConfigElement.PathIdentifier,Object> getAll() { Map<ConfigElement.PathIdentifier,Object> result = Maps.newHashMap(); for (String key : config.getKeys("")) { Preconditions.checkArgument(StringUtils.isNotBlank(key)); try { final ConfigElement.PathIdentifier pid = ConfigElement.parse(getRootNamespace(),key); Preconditions.checkArgument(pid.element.isOption() && !pid.lastIsUmbrella); result.put(pid, get((ConfigOption) pid.element, pid.umbrellaElements)); } catch (IllegalArgumentException e) { log.debug("Ignored configuration entry for {} since it does not map to an option",key,e); } } return result; }
/** * Opens a {@link JanusGraph} database configured according to the provided configuration. * * @param configuration Configuration for the graph database * @return JanusGraph graph database */ public static JanusGraph open(BasicConfiguration configuration) { return open(configuration.getConfiguration()); }
BasicConfiguration localBasicConfiguration = new BasicConfiguration(ROOT_NS,localConfig, BasicConfiguration.Restriction.NONE); ModifiableConfiguration overwrite = new ModifiableConfiguration(ROOT_NS,new CommonsConfiguration(), BasicConfiguration.Restriction.NONE); localConfiguration.setAll(getLocalSubset(localBasicConfiguration.getAll())); if (!localBasicConfiguration.has(LOCK_LOCAL_MEDIATOR_GROUP)) { overwrite.set(LOCK_LOCAL_MEDIATOR_GROUP, storeManager.getName()); globalWrite.setAll(getGlobalSubset(localBasicConfiguration.getAll())); if (!localBasicConfiguration.has(TIMESTAMP_PROVIDER)) { StoreFeatures f = storeManager.getFeatures(); final TimestampProviders backendPreference; log.info("Using configured timestamp provider {}", localBasicConfiguration.get(TIMESTAMP_PROVIDER)); if (localBasicConfiguration.has(ALLOW_UPGRADE)) { allowUpgrade = localBasicConfiguration.get(ALLOW_UPGRADE); } else if (globalWrite.has(ALLOW_UPGRADE)) { allowUpgrade = globalWrite.get(ALLOW_UPGRADE); if (localBasicConfiguration.has(ALLOW_STALE_CONFIG)) managedOverridesAllowed = localBasicConfiguration.get(ALLOW_STALE_CONFIG); else if (globalWrite.has(ALLOW_STALE_CONFIG)) managedOverridesAllowed = globalWrite.get(ALLOW_STALE_CONFIG); for (Map.Entry<ConfigElement.PathIdentifier, Object> ent : getManagedSubset(localBasicConfiguration.getAll()).entrySet()) { ConfigElement.PathIdentifier pid = ent.getKey(); assert pid.element.isOption();
@Override public void clear(Graph g, final Configuration configuration) throws Exception { if (null != g) { while (g instanceof WrappedGraph) g = ((WrappedGraph<? extends Graph>) g).getBaseGraph(); JanusGraph graph = (JanusGraph) g; if (graph.isOpen()) { if (g.tx().isOpen()) g.tx().rollback(); try { g.close(); } catch (IOException | IllegalStateException e) { logger.warn("Titan graph may not have closed cleanly", e); } } } WriteConfiguration config = new CommonsConfiguration(configuration); BasicConfiguration readConfig = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE); if (readConfig.has(GraphDatabaseConfiguration.STORAGE_BACKEND)) { JanusGraphBaseTest.clearGraph(config); } }
private void checkBackwardCompatibilityWithTitan(ModifiableConfiguration globalWrite, BasicConfiguration localBasicConfiguration, KCVSConfiguration keyColumnValueStoreConfiguration, ModifiableConfiguration overwrite) { String version = globalWrite.get(TITAN_COMPATIBLE_VERSIONS); Preconditions.checkArgument(version!=null,"JanusGraph version nor Titan compatibility have not been initialized"); if (!JanusGraphConstants.TITAN_COMPATIBLE_VERSIONS.contains(version)) { throw new JanusGraphException(String.format(INCOMPATIBLE_VERSION_EXCEPTION, version, JanusGraphConstants.VERSION)); } // When connecting to a store created by Titan the ID store name will not be in the // global configuration as it was not something which was configurable with Titan. // So to ensure compatibility override the default to titan_ids. boolean localIdStoreIsDefault = JanusGraphConstants.JANUSGRAPH_ID_STORE_NAME.equals(localBasicConfiguration.get(IDS_STORE_NAME)); boolean usingTitanIdStore = localIdStoreIsDefault || JanusGraphConstants.TITAN_ID_STORE_NAME.equals(localBasicConfiguration.get(IDS_STORE_NAME)); boolean existingKeyStore = keyColumnValueStoreConfiguration.get(IDS_STORE_NAME.getName(), IDS_STORE_NAME.getDatatype()) != null; Preconditions.checkArgument(usingTitanIdStore,"ID store for Titan compatibility has not been initialized to: " + JanusGraphConstants.TITAN_ID_STORE_NAME); if (!existingKeyStore) { log.info("Setting {} to {} for Titan compatibility", IDS_STORE_NAME.getName(), JanusGraphConstants.TITAN_ID_STORE_NAME); overwrite.set(IDS_STORE_NAME, JanusGraphConstants.TITAN_ID_STORE_NAME); } }
public<O> void remove(ConfigOption<O> option, String... umbrellaElements) { verifyOption(option); Preconditions.checkArgument(!option.isFixed() || !isFrozen(), "Cannot change configuration option: %s", option); String key = super.getPath(option,umbrellaElements); config.remove(key); }
@Override public boolean has(ConfigOption option, String... umbrellaElements) { verifyOption(option); return config.get(super.getPath(option,umbrellaElements),option.getDatatype())!=null; }
@Override public Configuration restrictTo(String... umbrellaElements) { return restrictTo(this,umbrellaElements); }
final String backend = readConfig.get(INDEX_BACKEND, INDEX); switch (backend) { case "elasticsearch":
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; }
@Override public<O> O get(ConfigOption<O> option, String... umbrellaElements) { verifyOption(option); O result = config.get(super.getPath(option,umbrellaElements),option.getDatatype()); return option.get(result); }
private void testIndexing(Cardinality cardinality) { if (supportsCollections()) { final PropertyKey stringProperty = mgmt.makePropertyKey("name").dataType(String.class).cardinality(cardinality).make(); final PropertyKey intProperty = mgmt.makePropertyKey("age").dataType(Integer.class).cardinality(cardinality).make(); final PropertyKey longProperty = mgmt.makePropertyKey("long").dataType(Long.class).cardinality(cardinality).make(); final PropertyKey uuidProperty = mgmt.makePropertyKey("uuid").dataType(UUID.class).cardinality(cardinality).make(); final PropertyKey geopointProperty = mgmt.makePropertyKey("geopoint").dataType(Geoshape.class).cardinality(cardinality).make(); mgmt.buildIndex("collectionIndex", Vertex.class).addKey(stringProperty, getStringMapping()).addKey(intProperty).addKey(longProperty).addKey(uuidProperty).addKey(geopointProperty).buildMixedIndex(INDEX); finishSchema(); testCollection(cardinality, "name", "Totoro", "Hiro"); testCollection(cardinality, "age", 1, 2); testCollection(cardinality, "long", 1L, 2L); testCollection(cardinality, "geopoint", Geoshape.point(1.0, 1.0), Geoshape.point(2.0, 2.0)); final String backend = readConfig.get(INDEX_BACKEND, INDEX); // Solr 6 has issues processing UUIDs with Multivalues // https://issues.apache.org/jira/browse/SOLR-11264 if (!"solr".equals(backend)) { testCollection(cardinality, "uuid", UUID.randomUUID(), UUID.randomUUID()); } } else { try { final PropertyKey stringProperty = mgmt.makePropertyKey("name").dataType(String.class).cardinality(cardinality).make(); //This should throw an exception mgmt.buildIndex("collectionIndex", Vertex.class).addKey(stringProperty, getStringMapping()).buildMixedIndex(INDEX); Assert.fail("Should have thrown an exception"); } catch (final JanusGraphException ignored) { } } }
public Configuration getConfig() { return new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config.copy(), BasicConfiguration.Restriction.NONE); }
, option(MAX_COMMIT_TIME), Duration.ofSeconds(1) , option(STORAGE_WRITE_WAITTIME), Duration.ofMillis(300) , option(TestMockIndexProvider.INDEX_BACKEND_PROXY, INDEX), readConfig.get(INDEX_BACKEND, INDEX) , option(INDEX_BACKEND, INDEX), TestMockIndexProvider.class.getName() , option(TestMockIndexProvider.INDEX_MOCK_FAILADD, INDEX), true
@Before public void setUp() throws Exception { this.config = getConfiguration(); TestGraphConfigs.applyOverrides(config); Preconditions.checkNotNull(config); logManagers = new HashMap<>(); clearGraph(config); readConfig = new BasicConfiguration(GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.NONE); open(config); }