public Builder(KeyColumnValueStore store, StoreManager manager) { this.store = store; this.manager = manager; this.lockWait = GraphDatabaseConfiguration.LOCK_WAIT.getDefaultValue(); this.lockRetryCount = GraphDatabaseConfiguration.LOCK_RETRY.getDefaultValue(); }
@Override public <O> O get(ConfigOption<O> option, String... umbrellaElements) { return option.getDefaultValue(); }
private String getStringForDefaultValue(ConfigOption<?> c) { Object o = c.getDefaultValue(); if (null == o) { return "(no default value)"; } else if (o instanceof Duration) { Duration d = (Duration)o; return d.toMillis() + " ms"; } else if (o instanceof String[]) { return Joiner.on(",").join((String[])o); } return o.toString(); } }
public Builder() { this.rid = null; //TODO: can we ensure that this is always set correctly? Check the AstyanaxRecipe this.times = TimestampProviders.NANO; this.serializer = new ConsistentKeyLockerSerializer(); this.llm = null; // redundant, but it preserves this constructor's overall pattern this.lockState = new LockerState<>(); this.lockExpire = GraphDatabaseConfiguration.LOCK_EXPIRE.getDefaultValue(); this.log = LoggerFactory.getLogger(AbstractLocker.class); }
public KCVSLogManager getKCVSLogManager(String logName) { Preconditions.checkArgument(configuration.restrictTo(logName).get(LOG_BACKEND).equalsIgnoreCase(LOG_BACKEND.getDefaultValue())); return (KCVSLogManager)getLogManager(logName); }
private static LogManager getLogManager(Configuration config, String logName, KeyColumnValueStoreManager sm) { Configuration logConfig = config.restrictTo(logName); String backend = logConfig.get(LOG_BACKEND); if (backend.equalsIgnoreCase(LOG_BACKEND.getDefaultValue())) { return new KCVSLogManager(sm,logConfig); } else { Preconditions.checkArgument(config!=null); LogManager lm = getImplementationClass(logConfig,logConfig.get(LOG_BACKEND),REGISTERED_LOG_MANAGERS); Preconditions.checkNotNull(lm); return lm; } }
} else { Object value; if (config.has((ConfigOption)pp.element,pp.umbrellaElements) || ((ConfigOption) pp.element).getDefaultValue()!=null) { value = config.get((ConfigOption)pp.element,pp.umbrellaElements); } else {
public static String toString(ConfigElement element) { String result = element.getName(); if (element.isNamespace()) { result = "+ " + result; if (((ConfigNamespace)element).isUmbrella()) result += " [*]"; } else { result = "- " + result; ConfigOption option = (ConfigOption)element; result+= " ["; switch (option.getType()) { case FIXED: result+="f"; break; case GLOBAL_OFFLINE: result+="g!"; break; case GLOBAL: result+="g"; break; case MASKABLE: result+="m"; break; case LOCAL: result+="l"; break; } result+=","+option.getDatatype().getSimpleName(); result+=","+option.getDefaultValue(); result+="]"; } result = result + "\n"; String desc = element.getDescription(); result+="\t"+'"'+desc.substring(0, Math.min(desc.length(), 50))+'"'; return result; }
@Override public <O> O get(ConfigOption<O> option, String... umbrellaElements) { if (first.has(option, umbrellaElements)) return first.get(option, umbrellaElements); if (second.has(option, umbrellaElements)) return second.get(option, umbrellaElements); return option.getDefaultValue(); } @Override
if (null == opt.getDefaultValue()) { defaultValue += "(no default value)"; } else if (opt.getDatatype().isArray()) { defaultValue += Joiner.on(", ").join((Object[]) opt.getDefaultValue()); } else if (opt.getDatatype().isEnum()) { defaultValue += ((Enum)opt.getDefaultValue()).name(); } else { defaultValue += opt.getDefaultValue();
private Log openLog(String logManagerName, String logName) { try { final 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); } final StoreFeatures f = logStoreManager.getFeatures(); final boolean part = f.isDistributed() && f.isKeyOrdered(); if (part) { for (final String partitionedLogName : new String[]{USER_LOG,TRANSACTION_LOG,MANAGEMENT_LOG}) configuration.set(KCVSLogManager.LOG_MAX_PARTITIONS,8,partitionedLogName); } assert logStoreManager!=null; if (!logManagers.containsKey(logManagerName)) { //Open log manager - only supports KCVSLog final 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 (final BackendException e) { throw new JanusGraphException("Could not open log: "+ logName,e); } }
public StoreTransaction newTransaction(KeyColumnValueStoreManager manager) throws BackendException { StoreTransaction transaction = manager.beginTransaction(getTxConfig()); if (!manager.getFeatures().hasLocking() && manager.getFeatures().isKeyConsistent()) { transaction = new ExpectedValueCheckingTransaction(transaction, manager.beginTransaction(getConsistentTxConfig(manager)), GraphDatabaseConfiguration.STORAGE_READ_WAITTIME.getDefaultValue()); } return transaction; }
public void open() throws BackendException { manager = new KeyColumnValueStoreManager[CONCURRENCY]; tx = new StoreTransaction[CONCURRENCY][NUM_TX]; store = new KeyColumnValueStore[CONCURRENCY]; for (int i = 0; i < CONCURRENCY; i++) { final ModifiableConfiguration sc = GraphDatabaseConfiguration.buildGraphConfiguration(); sc.set(GraphDatabaseConfiguration.LOCK_LOCAL_MEDIATOR_GROUP,concreteClassName + i); sc.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID,"inst"+i); sc.set(GraphDatabaseConfiguration.LOCK_RETRY,10); sc.set(GraphDatabaseConfiguration.LOCK_EXPIRE, Duration.ofMillis(EXPIRE_MS)); manager[i] = openStorageManager(i, sc); StoreFeatures storeFeatures = manager[i].getFeatures(); store[i] = manager[i].openDatabase(DB_NAME); for (int j = 0; j < NUM_TX; j++) { tx[i][j] = manager[i].beginTransaction(getTxConfig()); log.debug("Began transaction of class {}", tx[i][j].getClass().getCanonicalName()); } if (!storeFeatures.hasLocking()) { Preconditions.checkArgument(storeFeatures.isKeyConsistent(),"Store needs to support some form of locking"); KeyColumnValueStore lockerStore = manager[i].openDatabase(DB_NAME + "_lock_"); ConsistentKeyLocker c = new ConsistentKeyLocker.Builder(lockerStore, manager[i]).fromConfig(sc).mediatorName(concreteClassName + i).build(); store[i] = new ExpectedValueCheckingStore(store[i], c); for (int j = 0; j < NUM_TX; j++) tx[i][j] = new ExpectedValueCheckingTransaction(tx[i][j], manager[i].beginTransaction(getConsistentTxConfig(manager[i])), GraphDatabaseConfiguration.STORAGE_READ_WAITTIME.getDefaultValue()); } } }
LoggerUtil.sanitizeAndLaunder(globalWrite.get(TIMESTAMP_PROVIDER))); } else { globalWrite.set(TIMESTAMP_PROVIDER, TIMESTAMP_PROVIDER.getDefaultValue()); log.info("Set default timestamp provider {}", LoggerUtil.sanitizeAndLaunder(globalWrite.get(TIMESTAMP_PROVIDER))); allowUpgrade = globalWrite.get(ALLOW_UPGRADE); } else { allowUpgrade = ALLOW_UPGRADE.getDefaultValue(); managedOverridesAllowed = globalWrite.get(ALLOW_STALE_CONFIG); else managedOverridesAllowed = ALLOW_STALE_CONFIG.getDefaultValue(); Preconditions.checkArgument(combinedConfig.get(LOG_BACKEND,TRANSACTION_LOG).equals(LOG_BACKEND.getDefaultValue()), "Must use default log backend for transaction log"); Preconditions.checkArgument(!combinedConfig.has(LOG_SEND_DELAY,TRANSACTION_LOG) || Preconditions.checkArgument(combinedConfig.get(LOG_BACKEND,MANAGEMENT_LOG).equals(LOG_BACKEND.getDefaultValue()), "Must use default log backend for system log"); Preconditions.checkArgument(!combinedConfig.has(LOG_SEND_DELAY,MANAGEMENT_LOG) ||
Preconditions.checkState(ALLOW_STALE_CONFIG.getDefaultValue()); Preconditions.checkState(ALLOW_STALE_CONFIG.getType().equals(ConfigOption.Type.MASKABLE)); Preconditions.checkState(!customCommitTime.equals(MAX_COMMIT_TIME.getDefaultValue())); graph = (StandardJanusGraph) JanusGraphFactory.open(wc); assertEquals(MAX_COMMIT_TIME.getDefaultValue(), graph.getConfiguration().getMaxCommitTime()); graph = (StandardJanusGraph) JanusGraphFactory.open(wc); assertEquals(MAX_COMMIT_TIME.getDefaultValue(), graph.getConfiguration().getMaxCommitTime());
final Instant startTime = times.getTime(); clopen(option(SYSTEM_LOG_TRANSACTIONS), true, option(LOG_BACKEND, USER_LOG), (withLogFailure ? TestMockLog.class.getName() : LOG_BACKEND.getDefaultValue()), option(TestMockLog.LOG_MOCK_FAILADD, USER_LOG), withLogFailure, option(KCVSLog.LOG_READ_LAG_TIME, USER_LOG), Duration.ofMillis(50),
private static int getPort(final Configuration config) throws BackendException { final String endpoint = JanusGraphConfigUtil.getNullableConfigValue(config, Constants.DYNAMODB_CLIENT_ENDPOINT); int port = DEFAULT_PORT; if (endpoint != null && !endpoint.equals(Constants.DYNAMODB_CLIENT_ENDPOINT.getDefaultValue())) { final URL url; try { url = new URL(endpoint); } catch (IOException e) { throw new PermanentBackendException("Unable to determine port from endpoint: " + endpoint); } port = url.getPort(); } return port; }