janusgraph icon indicating copy to clipboard operation
janusgraph copied to clipboard

JanusGraphManagement does not allow to remove any property once set

Open wojciechwojcik opened this issue 7 years ago • 3 comments

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.

wojciechwojcik avatar Sep 26 '17 09:09 wojciechwojcik

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 avatar Sep 26 '17 13:09 robertdale

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()

robertdale avatar Oct 06 '17 12:10 robertdale

@robertdale whoa, nice hacking

pluradj avatar Oct 06 '17 14:10 pluradj