private Log openLog(String logManagerName, String logName) { try { ModifiableConfiguration configuration = new ModifiableConfiguration( GraphDatabaseConfiguration.ROOT_NS, config.copy(), BasicConfiguration.Restriction.NONE); configuration.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "reader"); configuration.set( GraphDatabaseConfiguration.LOG_READ_INTERVAL, Duration.ofMillis(500L), logManagerName); if (logStoreManager == null) { logStoreManager = Backend.getStorageManager(configuration); } StoreFeatures f = logStoreManager.getFeatures(); boolean part = f.isDistributed() && f.isKeyOrdered(); if (part) { for (String logname : new String[] {USER_LOG, TRANSACTION_LOG, MANAGEMENT_LOG}) configuration.set(KCVSLogManager.LOG_MAX_PARTITIONS, 8, logname); } assert logStoreManager != null; if (!logManagers.containsKey(logManagerName)) { // Open log manager - only supports KCVSLog Configuration logConfig = configuration.restrictTo(logManagerName); Preconditions.checkArgument( logConfig.get(LOG_BACKEND).equals(LOG_BACKEND.getDefaultValue())); logManagers.put(logManagerName, new KCVSLogManager(logStoreManager, logConfig)); } assert logManagers.containsKey(logManagerName); return logManagers.get(logManagerName).openLog(logName); } catch (BackendException e) { throw new TitanException("Could not open log: " + logName, e); } }
public void clopen(Object... settings) { config = getConfiguration(); if (mgmt != null && mgmt.isOpen()) mgmt.rollback(); if (null != tx && tx.isOpen()) tx.commit(); if (settings != null && settings.length > 0) { Map<TestConfigOption, Object> options = validateConfigOptions(settings); TitanManagement gconf = null; ModifiableConfiguration lconf = new ModifiableConfiguration( GraphDatabaseConfiguration.ROOT_NS, config, BasicConfiguration.Restriction.LOCAL); for (Map.Entry<TestConfigOption, Object> option : options.entrySet()) { if (option.getKey().option.isLocal()) { lconf.set(option.getKey().option, option.getValue(), option.getKey().umbrella); } else { if (gconf == null) gconf = graph.openManagement(); gconf.set( ConfigElement.getPath(option.getKey().option, option.getKey().umbrella), option.getValue()); } } if (gconf != null) gconf.commit(); lconf.close(); } if (null != graph && graph.isOpen()) graph.close(); Preconditions.checkNotNull(config); open(config); }
public static void clearGraph(WriteConfiguration config) throws BackendException { ModifiableConfiguration adjustedConfig = new ModifiableConfiguration( GraphDatabaseConfiguration.ROOT_NS, config.copy(), BasicConfiguration.Restriction.NONE); adjustedConfig.set(GraphDatabaseConfiguration.LOCK_LOCAL_MEDIATOR_GROUP, "tmp"); adjustedConfig.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID, "inst"); Backend backend = new Backend(adjustedConfig); backend.initialize(adjustedConfig); backend.clearStorage(); }