@Override public StoreFeatures getFeatures() { return backend.getFeatures(); }
@Override public StoreFeatures getFeatures() { return manager.getFeatures(); }
public StoreFeatures storeFeatures() { return manager.getFeatures(); }
public StandardScanner(final KeyColumnValueStoreManager manager) { Preconditions.checkArgument(manager!=null); Preconditions.checkArgument(manager.getFeatures().hasScan(),"Provided data store does not support scans: %s",manager); this.manager = manager; this.openStores = new HashSet<>(4); this.runningJobs = new ConcurrentHashMap<>(); this.jobCounter = new AtomicLong(0); }
public TTLKCVSManager(KeyColumnValueStoreManager manager) { super(manager); Preconditions.checkArgument(manager.getFeatures().hasCellTTL()); Preconditions.checkArgument(!manager.getFeatures().hasStoreTTL(), "Using TTLKCVSManager with %s is redundant: underlying implementation already supports store-level ttl", manager); this.features = new StandardStoreFeatures.Builder(manager.getFeatures()).storeTTL(true).build(); }
@Override public void mutateMany(Map<String, Map<StaticBuffer, KCVMutation>> mutations, StoreTransaction txh) throws BackendException { if (!manager.getFeatures().hasStoreTTL()) { assert manager.getFeatures().hasCellTTL(); for (Map.Entry<String,Map<StaticBuffer, KCVMutation>> sentry : mutations.entrySet()) { Integer ttl = ttlEnabledStores.get(sentry.getKey()); if (null != ttl && 0 < ttl) { for (KCVMutation mut : sentry.getValue().values()) { if (mut.hasAdditions()) applyTTL(mut.getAdditions(), ttl); } } } } manager.mutateMany(mutations,txh); }
public ExpectedValueCheckingStoreManager(KeyColumnValueStoreManager storeManager, String lockStoreSuffix, LockerProvider lockerProvider, Duration maxReadTime) { super(storeManager); this.lockStoreSuffix = lockStoreSuffix; this.lockerProvider = lockerProvider; this.maxReadTime = maxReadTime; this.storeFeatures = new StandardStoreFeatures.Builder(storeManager.getFeatures()).locking(true).build(); this.stores = new HashMap<>(6); }
public static KCVSConfiguration getStandaloneGlobalConfiguration(final KeyColumnValueStoreManager manager, final Configuration config) { try { final StoreFeatures features = manager.getFeatures(); return getGlobalConfiguration(new BackendOperation.TransactionalProvider() { @Override public StoreTransaction openTx() throws BackendException { return manager.beginTransaction(StandardBaseTransactionConfig.of(config.get(TIMESTAMP_PROVIDER),features.getKeyConsistentTxConfig())); } @Override public void close() throws BackendException { manager.close(); } },manager.openDatabase(SYSTEM_PROPERTIES_STORE_NAME),config); } catch (BackendException e) { throw new JanusGraphException("Could not open global configuration",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; }
@Override public StoreTransaction openTx() throws BackendException { StandardBaseTransactionConfig config; if (keyConsistentOperations) { config = StandardBaseTransactionConfig.of(times,manager.storeManager.getFeatures().getKeyConsistentTxConfig()); } else { config = StandardBaseTransactionConfig.of(times); } return manager.storeManager.beginTransaction(config); }
@Test public void testGetSlices() throws Exception { if (!manager.getFeatures().hasMultiQuery()) return; populateDBWith100Keys(); tx.commit(); tx = startTx(); final List<StaticBuffer> keys = new ArrayList<>(100); for (int i = 1; i <= 100; i++) { keys.add(KeyColumnValueStoreUtil.longToByteBuffer(i)); } StaticBuffer start = KeyColumnValueStoreUtil.stringToByteBuffer("a"); StaticBuffer end = KeyColumnValueStoreUtil.stringToByteBuffer("d"); Map<StaticBuffer,EntryList> results = store.getSlice(keys, new SliceQuery(start, end), tx); Assert.assertEquals(100, results.size()); for (List<Entry> entries : results.values()) { Assert.assertEquals(3, entries.size()); } }
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 void open() throws BackendException { manager = new KeyColumnValueStoreManager[CONCURRENCY]; idAuthorities = new IDAuthority[CONCURRENCY]; for (int i = 0; i < CONCURRENCY; i++) { ModifiableConfiguration sc = StorageSetup.getConfig(baseStoreConfiguration.copy()); //sc.set(GraphDatabaseConfiguration.INSTANCE_RID_SHORT,(short)i); sc.set(GraphDatabaseConfiguration.UNIQUE_INSTANCE_ID_SUFFIX, (short)i); if (!sc.has(UNIQUE_INSTANCE_ID)) { String uniqueGraphId = getOrGenerateUniqueInstanceId(sc); log.debug("Setting unique instance id: {}", uniqueGraphId); sc.set(UNIQUE_INSTANCE_ID, uniqueGraphId); } sc.set(GraphDatabaseConfiguration.CLUSTER_MAX_PARTITIONS,MAX_NUM_PARTITIONS); manager[i] = openStorageManager(); StoreFeatures storeFeatures = manager[i].getFeatures(); KeyColumnValueStore idStore = manager[i].openDatabase("ids"); if (storeFeatures.isKeyConsistent()) idAuthorities[i] = new ConsistentKeyIDAuthority(idStore, manager[i], sc); else throw new IllegalArgumentException("Cannot open id store"); } }
@Test @Category({UnorderedKeyStoreTests.class}) public void testGetKeysWithSliceQuery() throws Exception { if (!manager.getFeatures().hasUnorderedScan()) { log.warn("Can't test key-unordered features on incompatible store. " + "This warning could indicate reduced test coverage and " + "a broken JUnit configuration. Skipping test {}.", name.getMethodName()); return; } populateDBWith100Keys(); tx.commit(); tx = startTx(); KeyIterator keyIterator = store.getKeys( new SliceQuery(new ReadArrayBuffer("b".getBytes()), new ReadArrayBuffer("c".getBytes())), tx); examineGetKeysResults(keyIterator, 0, 100); }
@Test @Category({OrderedKeyStoreTests.class}) public void testGetKeysWithKeyRange() throws Exception { if (!manager.getFeatures().hasOrderedScan()) { log.warn("Can't test ordered scans on incompatible store. " + "This warning could indicate reduced test coverage and " + "shouldn't happen in an ideal JUnit configuration. " + "Skipping test {}.", name.getMethodName()); return; } populateDBWith100Keys(); tx.commit(); tx = startTx(); KeyIterator keyIterator = store.getKeys(new KeyRangeQuery( KeyColumnValueStoreUtil.longToByteBuffer(10), // key start KeyColumnValueStoreUtil.longToByteBuffer(40), // key end new ReadArrayBuffer("b".getBytes()), // column start new ReadArrayBuffer("c".getBytes())), tx); examineGetKeysResults(keyIterator, 10, 40); }
if (storeManager.getFeatures().hasCellTTL() && !storeManager.getFeatures().hasStoreTTL()) { storeManager = new TTLKCVSManager(storeManager); } else if (!storeManager.getFeatures().hasStoreTTL()) { return; assertTrue(storeManager.getFeatures().hasStoreTTL());
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()); } } }
public void testGetKeysColumnSlicesSimple() throws BackendException { if (manager.getFeatures().hasScan()) {
@Test public void testLocalPartitionAcquisition() throws BackendException { for (int c = 0; c < CONCURRENCY; c++) { if (manager[c].getFeatures().hasLocalKeyPartition()) { try { List<KeyRange> partitions = idAuthorities[c].getLocalIDPartition(); for (KeyRange range : partitions) { assertEquals(range.getStart().length(), range.getEnd().length()); for (int i = 0; i < 2; i++) { Assert.assertTrue(range.getAt(i).length() >= 4); } } } catch (UnsupportedOperationException e) { Assert.fail(); } } } }
@Category({OrderedKeyStoreTests.class}) public void testOrderedGetKeysRespectsKeyLimit() throws BackendException { if (!manager.getFeatures().hasOrderedScan()) { log.warn("Can't test key-ordered features on incompatible store. " + "This warning could indicate reduced test coverage and "