use of org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration in project janusgraph by JanusGraph.
the class ConfigurationLint method validate.
public static Status validate(String filename) throws IOException {
try (final FileInputStream fis = new FileInputStream(filename)) {
new Properties().load(fis);
}
final PropertiesConfiguration apc;
try {
apc = new PropertiesConfiguration(filename);
} catch (ConfigurationException e) {
throw new IOException(e);
}
// new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS,
// , BasicConfiguration.Restriction.NONE);
Iterator<String> iterator = apc.getKeys();
int totalKeys = 0;
int keysVerified = 0;
while (iterator.hasNext()) {
totalKeys++;
String key = iterator.next();
String value = apc.getString(key);
try {
ConfigElement.PathIdentifier pid = ConfigElement.parse(GraphDatabaseConfiguration.ROOT_NS, key);
// ConfigElement shouldn't return null; failure here probably relates to janusgraph-core, not the file
Preconditions.checkState(null != pid);
Preconditions.checkState(null != pid.element);
if (!pid.element.isOption()) {
log.warn("Config key {} is a namespace (only options can be keys)", key);
continue;
}
final ConfigOption<?> opt;
try {
opt = (ConfigOption<?>) pid.element;
} catch (RuntimeException re) {
// This shouldn't happen given the preceding check, but catch it anyway
log.warn("Config key {} maps to the element {}, but it could not be cast to an option", key, pid.element, re);
continue;
}
try {
Object o = new CommonsConfiguration(apc).get(key, opt.getDatatype());
opt.verify(o);
keysVerified++;
} catch (RuntimeException re) {
log.warn("Config key {} is recognized, but its value {} could not be validated", key, value);
log.debug("Validation exception on {}={} follows", key, value, re);
}
} catch (RuntimeException re) {
log.warn("Unknown config key {}", key);
}
}
return new Status(totalKeys, totalKeys - keysVerified);
}
use of org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration in project janusgraph by JanusGraph.
the class RestClientSetupTest method baseConfigTest.
private ElasticSearchClient baseConfigTest(Map<String, String> extraConfigValues) throws Exception {
final CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration());
cc.set("index." + INDEX_NAME + ".backend", "elasticsearch");
cc.set("index." + INDEX_NAME + ".elasticsearch.interface", "REST_CLIENT");
for (Map.Entry<String, String> me : extraConfigValues.entrySet()) {
cc.set(me.getKey(), me.getValue());
}
final ModifiableConfiguration config = new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS, cc, BasicConfiguration.Restriction.NONE);
doReturn(restClientBuilderMock).when(restClientSetup).getRestClientBuilder(any());
doReturn(restElasticSearchClientMock).when(restClientSetup).getElasticSearchClient(any(RestClient.class), anyInt());
return restClientSetup.connect(config.restrictTo(INDEX_NAME));
}
use of org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration in project janusgraph by JanusGraph.
the class ElasticSearchIndexTest method getESTestConfig.
public Configuration getESTestConfig() {
final String index = "es";
final CommonsConfiguration cc = new CommonsConfiguration(new BaseConfiguration());
if (esr.getEsMajorVersion().value > 2) {
cc.set("index." + index + ".elasticsearch.ingest-pipeline.ingestvertex", "pipeline_1");
}
return esr.setElasticsearchConfiguration(new ModifiableConfiguration(GraphDatabaseConfiguration.ROOT_NS, cc, BasicConfiguration.Restriction.NONE), index).set(GraphDatabaseConfiguration.INDEX_MAX_RESULT_SET_SIZE, 3, index).restrictTo(index);
}
use of org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration in project janusgraph by JanusGraph.
the class LocalStoreManagerTest method getStoreManager.
public LocalStoreManager getStoreManager(Map<ConfigOption, String> map) throws BackendException {
final ModifiableConfiguration mc = new ModifiableConfiguration(ROOT_NS, new CommonsConfiguration(new BaseConfiguration()), NONE);
map.forEach(mc::set);
return new LocalStoreManagerSampleImplementation(mc);
}
use of org.janusgraph.diskstorage.configuration.backend.CommonsConfiguration in project janusgraph by JanusGraph.
the class GraphDatabaseConfigurationInstanceIdTest method graphShouldNotOpenWithSameInstanceId.
@Test
public void graphShouldNotOpenWithSameInstanceId() {
final Map<String, Object> map = new HashMap<String, Object>();
map.put(STORAGE_BACKEND.toStringWithoutRoot(), "inmemory");
map.put(UNIQUE_INSTANCE_ID.toStringWithoutRoot(), "not-unique");
final MapConfiguration config = new MapConfiguration(map);
final StandardJanusGraph graph1 = new StandardJanusGraph(new GraphDatabaseConfiguration(new CommonsConfiguration(config)));
assertEquals(graph1.openManagement().getOpenInstances().size(), 1);
assertEquals(graph1.openManagement().getOpenInstances().toArray()[0], "not-unique");
thrown.expect(JanusGraphException.class);
final String err = "A JanusGraph graph with the same instance id [not-unique] is already open. Might required forced shutdown.";
thrown.expectMessage(equalTo(err));
final StandardJanusGraph graph2 = new StandardJanusGraph(new GraphDatabaseConfiguration(new CommonsConfiguration(config)));
graph1.close();
}
Aggregations