JanusGraph / janusgraph

JanusGraph: an open-source, distributed graph database
https://janusgraph.org
Other
5.32k stars 1.17k forks source link

JanusGraphManagement does not allow to remove any property once set #555

Closed wojciechwojcik closed 1 year ago

wojciechwojcik commented 7 years ago

JanusGraphManagement has only methods get() and set() for changing config values. Set method does not accept null values, which means there is NO way to clear any property once set.

As an example if I have configured some mixed index backend using property: index.search.backend=solr there is NO way to tell Janus to actually stop using this backend.

Since there can be an arbitrary number of indexing backends and there is NO default value for index.[X].* properties, there must be a way to actually remove them without dropping the whole janus database.

robertdale commented 7 years ago

It's delegated to JanusGraphConfiguration.

If there becomes the ability to clear index.*.backend properties, be sure to document that indexes on that backend would first have to be DISABLE and REMOVE (which effectively disables using that backend).

robertdale commented 7 years ago

Here's sample code on how to remove a property:

import org.janusgraph.diskstorage.configuration.TransactionalConfiguration;
import org.janusgraph.diskstorage.configuration.ModifiableConfiguration;
import static org.janusgraph.graphdb.configuration.GraphDatabaseConfiguration.*;
import org.janusgraph.diskstorage.configuration.BasicConfiguration;
import static org.janusgraph.diskstorage.es.ElasticSearchIndex.*;

// Get and Set to true (default is false)
graph = JanusGraphFactory.open('conf/janusgraph-cassandra-es.properties')
transactionalConfig = new TransactionalConfiguration(graph.getBackend().getGlobalSystemConfig())
modifyConfig = new ModifiableConfiguration(ROOT_NS, transactionalConfig, BasicConfiguration.Restriction.GLOBAL);
modifyConfig.get(USE_DEPRECATED_MULTITYPE_INDEX, "search")
modifyConfig.set(USE_DEPRECATED_MULTITYPE_INDEX, true, "search")
transactionalConfig.commit()
graph.tx().commit()
modifyConfig.get(USE_DEPRECATED_MULTITYPE_INDEX, "search")
graph.close()

// Get and Remove
graph = JanusGraphFactory.open('conf/janusgraph-cassandra-es.properties')
transactionalConfig = new TransactionalConfiguration(graph.getBackend().getGlobalSystemConfig())
modifyConfig = new ModifiableConfiguration(ROOT_NS, transactionalConfig, BasicConfiguration.Restriction.GLOBAL);
// verify true value persisted
modifyConfig.get(USE_DEPRECATED_MULTITYPE_INDEX, "search")
// Remove
modifyConfig.remove(USE_DEPRECATED_MULTITYPE_INDEX, "search")
transactionalConfig.commit()
graph.tx().commit()
// Should get default false
modifyConfig.get(USE_DEPRECATED_MULTITYPE_INDEX, "search")
graph.close()

// Verify graph can be created and get default value false
graph = JanusGraphFactory.open('conf/janusgraph-cassandra-es.properties')
transactionalConfig = new TransactionalConfiguration(graph.getBackend().getGlobalSystemConfig())
modifyConfig = new ModifiableConfiguration(ROOT_NS, transactionalConfig, BasicConfiguration.Restriction.GLOBAL);
modifyConfig.get(USE_DEPRECATED_MULTITYPE_INDEX, "search")
graph.close()
pluradj commented 7 years ago

@robertdale whoa, nice hacking