@Override public void close() throws HugeException { this.taskManager.closeScheduler(this); try { this.closeTx(); } finally { this.closed = true; this.storeProvider.close(); LockUtil.destroy(this.name); } // Make sure that all transactions are closed in all threads E.checkState(this.tx.closed(), "Ensure tx closed in all threads when closing graph"); }
public static void destroy(String graph) { LockManager.instance().destroy(join(graph, INDEX_LABEL_DELETE)); LockManager.instance().destroy(join(graph, EDGE_LABEL_DELETE)); LockManager.instance().destroy(join(graph, VERTEX_LABEL_DELETE)); LockManager.instance().destroy(join(graph, INDEX_LABEL_REBUILD)); LockManager.instance().destroy(join(graph, INDEX_LABEL_ADD_UPDATE)); LockManager.instance().destroy(join(graph, EDGE_LABEL_ADD_UPDATE)); LockManager.instance().destroy(join(graph, VERTEX_LABEL_ADD_UPDATE)); LockManager.instance().destroy(join(graph, PROPERTY_KEY_ADD_UPDATE)); }
public static List<Lock> lock(String... locks) { List<Lock> lockList = new ArrayList<>(); E.checkArgument(locks.length % 3 == 0, "Invalid arguments number, expect multiple of 3."); for (int i = 0; i < locks.length; i += 3) { switch (locks[i]) { case WRITE: lockList.add(lockWrite(locks[i + 1], locks[i + 2], WRITE_WAIT_TIMEOUT)); break; case READ: lockList.add(lockRead(locks[i + 1], locks[i + 2])); break; default: throw new IllegalArgumentException(String.format( "Invalid args '%s' at position '%s', " + "expect 'write' or 'read'", locks[i], i)); } } return lockList; }
protected void addSchema(SchemaElement schema) { LOG.debug("SchemaTransaction add {} with id '{}'", schema.type(), schema.id()); LockUtil.Locks locks = new LockUtil.Locks(this.graph().name()); try { locks.lockWrites(LockUtil.hugeType2Group(schema.type()), schema.id()); this.beforeWrite(); this.doInsert(this.serialize(schema)); this.indexTx.updateNameIndex(schema, false); this.afterWrite(); } finally { locks.unlock(); } }
public HugeGraph(HugeConfig configuration) { this.configuration = configuration; this.schemaEventHub = new EventHub("schema"); this.indexEventHub = new EventHub("index"); final int limit = configuration.get(CoreOptions.RATE_LIMIT); this.rateLimiter = limit > 0 ? RateLimiter.create(limit) : null; this.taskManager = TaskManager.instance(); this.features = new HugeFeatures(this, true); this.name = configuration.get(CoreOptions.STORE); this.closed = false; this.mode = GraphMode.NONE; LockUtil.init(this.name); try { this.storeProvider = this.loadStoreProvider(); } catch (BackendException e) { String message = "Failed to init backend store"; LOG.error("{}: {}", message, e.getMessage()); throw new HugeException(message); } this.tx = new TinkerpopTransaction(this); this.taskManager.addScheduler(this); this.variables = null; }
protected void removeSchema(SchemaElement schema) { LOG.debug("SchemaTransaction remove {} by id '{}'", schema.type(), schema.id()); LockUtil.Locks locks = new LockUtil.Locks(this.graph().name()); try { locks.lockWrites(LockUtil.hugeType2Group(schema.type()), schema.id()); this.beforeWrite(); this.indexTx.updateNameIndex(schema, true); BackendEntry e = this.serializer.writeId(schema.type(), schema.id()); this.doRemove(e); this.afterWrite(); } finally { locks.unlock(); } }
public HugeGraph(HugeConfig configuration) { this.configuration = configuration; this.schemaEventHub = new EventHub("schema"); this.indexEventHub = new EventHub("index"); final int limit = configuration.get(CoreOptions.RATE_LIMIT); this.rateLimiter = limit > 0 ? RateLimiter.create(limit) : null; this.taskManager = TaskManager.instance(); this.features = new HugeFeatures(this, true); this.name = configuration.get(CoreOptions.STORE); this.closed = false; this.mode = GraphMode.NONE; LockUtil.init(this.name); try { this.storeProvider = this.loadStoreProvider(); } catch (BackendException e) { String message = "Failed to init backend store"; LOG.error("{}: {}", message, e.getMessage()); throw new HugeException(message); } this.tx = new TinkerpopTransaction(this); this.taskManager.addScheduler(this); this.variables = null; }
public static List<Lock> lock(String... locks) { List<Lock> lockList = new ArrayList<>(); E.checkArgument(locks.length % 3 == 0, "Invalid arguments number, expect multiple of 3."); for (int i = 0; i < locks.length; i += 3) { switch (locks[i]) { case WRITE: lockList.add(lockWrite(locks[i + 1], locks[i + 2], WRITE_WAIT_TIMEOUT)); break; case READ: lockList.add(lockRead(locks[i + 1], locks[i + 2])); break; default: throw new IllegalArgumentException(String.format( "Invalid args '%s' at position '%s', " + "expect 'write' or 'read'", locks[i], i)); } } return lockList; }
public static void init(String graph) { LockManager.instance().create(join(graph, INDEX_LABEL_DELETE)); LockManager.instance().create(join(graph, EDGE_LABEL_DELETE)); LockManager.instance().create(join(graph, VERTEX_LABEL_DELETE)); LockManager.instance().create(join(graph, INDEX_LABEL_REBUILD)); LockManager.instance().create(join(graph, INDEX_LABEL_ADD_UPDATE)); LockManager.instance().create(join(graph, EDGE_LABEL_ADD_UPDATE)); LockManager.instance().create(join(graph, VERTEX_LABEL_ADD_UPDATE)); LockManager.instance().create(join(graph, PROPERTY_KEY_ADD_UPDATE)); }
protected void addSchema(SchemaElement schema) { LOG.debug("SchemaTransaction add {} with id '{}'", schema.type(), schema.id()); LockUtil.Locks locks = new LockUtil.Locks(this.graph().name()); try { locks.lockWrites(LockUtil.hugeType2Group(schema.type()), schema.id()); this.beforeWrite(); this.doInsert(this.serialize(schema)); this.indexTx.updateNameIndex(schema, false); this.afterWrite(); } finally { locks.unlock(); } }
@Override public void close() throws HugeException { this.taskManager.closeScheduler(this); try { this.closeTx(); } finally { this.closed = true; this.storeProvider.close(); LockUtil.destroy(this.name); } // Make sure that all transactions are closed in all threads E.checkState(this.tx.closed(), "Ensure tx closed in all threads when closing graph"); }
public static void init(String graph) { LockManager.instance().create(join(graph, INDEX_LABEL_DELETE)); LockManager.instance().create(join(graph, EDGE_LABEL_DELETE)); LockManager.instance().create(join(graph, VERTEX_LABEL_DELETE)); LockManager.instance().create(join(graph, INDEX_LABEL_REBUILD)); LockManager.instance().create(join(graph, INDEX_LABEL_ADD_UPDATE)); LockManager.instance().create(join(graph, EDGE_LABEL_ADD_UPDATE)); LockManager.instance().create(join(graph, VERTEX_LABEL_ADD_UPDATE)); LockManager.instance().create(join(graph, PROPERTY_KEY_ADD_UPDATE)); }
protected void removeSchema(SchemaElement schema) { LOG.debug("SchemaTransaction remove {} by id '{}'", schema.type(), schema.id()); LockUtil.Locks locks = new LockUtil.Locks(this.graph().name()); try { locks.lockWrites(LockUtil.hugeType2Group(schema.type()), schema.id()); this.beforeWrite(); this.indexTx.updateNameIndex(schema, true); BackendEntry e = this.serializer.writeId(schema.type(), schema.id()); this.doRemove(e); this.afterWrite(); } finally { locks.unlock(); } }
public static void destroy(String graph) { LockManager.instance().destroy(join(graph, INDEX_LABEL_DELETE)); LockManager.instance().destroy(join(graph, EDGE_LABEL_DELETE)); LockManager.instance().destroy(join(graph, VERTEX_LABEL_DELETE)); LockManager.instance().destroy(join(graph, INDEX_LABEL_REBUILD)); LockManager.instance().destroy(join(graph, INDEX_LABEL_ADD_UPDATE)); LockManager.instance().destroy(join(graph, EDGE_LABEL_ADD_UPDATE)); LockManager.instance().destroy(join(graph, VERTEX_LABEL_ADD_UPDATE)); LockManager.instance().destroy(join(graph, PROPERTY_KEY_ADD_UPDATE)); }