use of com.baidu.hugegraph.backend.store.BackendStore in project incubator-hugegraph by apache.
the class StoreStateMachine method applyCommand.
private Object applyCommand(StoreType type, StoreAction action, BytesBuffer buffer, boolean forwarded) {
E.checkState(type != StoreType.ALL, "Can't apply command for all store at one time");
BackendStore store = this.store(type);
switch(action) {
case CLEAR:
boolean clearSpace = buffer.read() > 0;
store.clear(clearSpace);
this.context.clearCache();
break;
case TRUNCATE:
store.truncate();
this.context.clearCache();
break;
case SNAPSHOT:
assert store == null;
this.node().snapshot();
break;
case BEGIN_TX:
store.beginTx();
break;
case COMMIT_TX:
List<BackendMutation> mutations = StoreSerializer.readMutations(buffer);
// RaftBackendStore doesn't write raft log for beginTx
store.beginTx();
for (BackendMutation mutation : mutations) {
store.mutate(mutation);
this.context.updateCacheIfNeeded(mutation, forwarded);
}
store.commitTx();
break;
case ROLLBACK_TX:
store.rollbackTx();
break;
case INCR_COUNTER:
// Do increase counter
IncrCounter counter = StoreSerializer.readIncrCounter(buffer);
store.increaseCounter(counter.type(), counter.increment());
break;
default:
throw new IllegalArgumentException("Invalid action " + action);
}
return null;
}
use of com.baidu.hugegraph.backend.store.BackendStore in project incubator-hugegraph by apache.
the class ScyllaDBStoreProvider method loadSchemaStore.
@Override
public BackendStore loadSchemaStore(HugeConfig config, String name) {
LOG.debug("ScyllaDBStoreProvider load SchemaStore '{}'", name);
if (!this.stores.containsKey(name)) {
BackendStore s = new ScyllaDBSchemaStore(this, keyspace(), name);
this.stores.putIfAbsent(name, s);
}
BackendStore store = this.stores.get(name);
E.checkNotNull(store, "store");
E.checkState(store instanceof ScyllaDBSchemaStore, "SchemaStore must be an instance of ScyllaDBSchemaStore");
return store;
}
use of com.baidu.hugegraph.backend.store.BackendStore in project incubator-hugegraph by apache.
the class ScyllaDBStoreProvider method loadGraphStore.
@Override
public BackendStore loadGraphStore(HugeConfig config, String name) {
LOG.debug("ScyllaDBStoreProvider load GraphStore '{}'", name);
if (!this.stores.containsKey(name)) {
BackendStore s = new ScyllaDBGraphStore(this, keyspace(), name);
this.stores.putIfAbsent(name, s);
}
BackendStore store = this.stores.get(name);
E.checkNotNull(store, "store");
E.checkState(store instanceof ScyllaDBGraphStore, "GraphStore must be an instance of ScyllaDBGraphStore");
return store;
}
Aggregations