@Override public Configuration configuration() { return this.graph.configuration(); }
public String defaultLabel() { Configuration conf = HugeFeatures.this.graph.configuration(); return ((HugeConfig) conf).get(CoreOptions.VERTEX_DEFAULT_LABEL); } }
public static SnowflakeIdGenerator instance(HugeGraph graph) { String graphname = graph.name(); SnowflakeIdGenerator generator = INSTANCES.get(graphname); if (generator == null) { synchronized (INSTANCES) { if (!INSTANCES.containsKey(graphname)) { HugeConfig conf = graph.configuration(); INSTANCES.put(graphname, new SnowflakeIdGenerator(conf)); } generator = INSTANCES.get(graphname); assert generator != null; } } return generator; }
@GET @Timed @Path("{name}/conf") @Produces(APPLICATION_JSON_WITH_CHARSET) @RolesAllowed("admin") public File getConf(@Context GraphManager manager, @PathParam("name") String name) { LOG.debug("Get graph configuration by name '{}'", name); HugeGraph g = graph(manager, name); File file = g.configuration().getFile(); if (file == null) { throw new NotSupportedException("Can't access the api in " + "a node which started with non local file config."); } return file; }
public AbstractTransaction(HugeGraph graph, BackendStore store) { E.checkNotNull(graph, "graph"); E.checkNotNull(store, "store"); this.graph = graph; this.serializer = this.graph.serializer(); this.store = store; this.reset(); store.open(graph.configuration()); }
private Cache cache(String prefix) { HugeConfig conf = super.graph().configuration(); final String name = prefix + "-" + super.graph().name(); final int capacity = conf.get(CoreOptions.SCHEMA_CACHE_CAPACITY); // NOTE: must disable schema cache-expire due to getAllSchema() return CacheManager.instance().cache(name, capacity); }
public CachedGraphTransaction(HugeGraph graph, BackendStore store) { super(graph, store); HugeConfig conf = graph.configuration(); int capacity = conf.get(CoreOptions.VERTEX_CACHE_CAPACITY); int expire = conf.get(CoreOptions.VERTEX_CACHE_EXPIRE); this.verticesCache = this.cache("vertex", capacity, expire); capacity = conf.get(CoreOptions.EDGE_CACHE_CAPACITY); expire = conf.get(CoreOptions.EDGE_CACHE_EXPIRE); this.edgesCache = this.cache("edge", capacity, expire); }
public GraphTransaction(HugeGraph graph, BackendStore store) { super(graph, store); this.indexTx = new GraphIndexTransaction(graph, store); assert !this.indexTx.autoCommit(); final HugeConfig conf = graph.configuration(); this.checkVertexExist = conf.get( CoreOptions.VERTEX_CHECK_CUSTOMIZED_ID_EXIST); this.vertexesCapacity = conf.get(CoreOptions.VERTEX_TX_CAPACITY); this.edgesCapacity = conf.get(CoreOptions.EDGE_TX_CAPACITY); this.locksTable = new LockUtil.LocksTable(graph.name()); }
@Override public PropertyKey create() { SchemaTransaction tx = this.transaction; SchemaElement.checkName(this.name, tx.graph().configuration()); PropertyKey propertyKey = tx.getPropertyKey(this.name); if (propertyKey != null) { if (this.checkExist) { throw new ExistedException("property key", this.name); } return propertyKey; } tx.checkIdIfRestoringMode(HugeType.PROPERTY_KEY, this.id); this.checkUserdata(Action.INSERT); propertyKey = this.build(); tx.addPropertyKey(propertyKey); return propertyKey; }
/** * Create index label with sync mode */ @Override public IndexLabel create() { // Create index label async IndexLabel.CreatedIndexLabel createdIndexLabel = this.createWithTask(); Id task = createdIndexLabel.task(); if (task == null) { // Task id will be null if creating index label already exists. return createdIndexLabel.indexLabel(); } // Wait task completed (change to sync mode) HugeGraph graph = this.transaction.graph(); long timeout = graph.configuration().get(CoreOptions.TASK_WAIT_TIMEOUT); try { graph.taskScheduler().waitUntilTaskCompleted(task, timeout); } catch (TimeoutException e) { throw new HugeException( "Failed to wait index-creating task completed", e); } // Return index label without task-info return createdIndexLabel.indexLabel(); }
@Override public VertexLabel create() { SchemaTransaction tx = this.transaction; SchemaElement.checkName(this.name, tx.graph().configuration()); VertexLabel vertexLabel = tx.getVertexLabel(this.name); if (vertexLabel != null) { if (this.checkExist) { throw new ExistedException("vertex label", this.name); } return vertexLabel; } tx.checkIdIfRestoringMode(HugeType.VERTEX_LABEL, this.id); this.checkProperties(Action.INSERT); this.checkIdStrategy(); this.checkNullableKeys(Action.INSERT); this.checkUserdata(Action.INSERT); vertexLabel = this.build(); tx.addVertexLabel(vertexLabel); return vertexLabel; }
@Override public EdgeLabel create() { SchemaTransaction tx = this.transaction; SchemaElement.checkName(this.name, tx.graph().configuration()); EdgeLabel edgeLabel = tx.getEdgeLabel(this.name); if (edgeLabel != null) { if (this.checkExist) { throw new ExistedException("edge label", this.name); } return edgeLabel; } tx.checkIdIfRestoringMode(HugeType.EDGE_LABEL, this.id); if (this.frequency == Frequency.DEFAULT) { this.frequency = Frequency.SINGLE; } // These methods will check params and fill to member variables this.checkRelation(); this.checkProperties(Action.INSERT); this.checkSortKeys(); this.checkNullableKeys(Action.INSERT); this.checkUserdata(Action.INSERT); edgeLabel = this.build(); tx.addEdgeLabel(edgeLabel); return edgeLabel; }
@Watched(prefix = "schema") private static Id asyncRun(HugeGraph graph, HugeType schemaType, Id schemaId, SchemaCallable callable, Set<Id> dependencies) { String schemaName = graph.schemaTransaction() .getSchema(schemaType, schemaId).name(); String name = SchemaCallable.formatTaskName(schemaType, schemaId, schemaName); JobBuilder<Object> builder = JobBuilder.of(graph).name(name) .job(callable) .dependencies(dependencies); HugeTask<?> task = builder.schedule(); // If SCHEMA_SYNC_DELETION is true, wait async thread done before // continue. This is used when running tests. if (graph.configuration().get(CoreOptions.SCHEMA_SYNC_DELETION)) { try { task.get(); assert task.completed(); } catch (Exception e) { throw new HugeException("Async task failed", e); } } return task.id(); } }
public String defaultLabel() { Configuration conf = HugeFeatures.this.graph.configuration(); return ((HugeConfig) conf).get(CoreOptions.VERTEX_DEFAULT_LABEL); } }
txCap = graph.configuration().get(CoreOptions.EDGE_TX_CAPACITY); assert txCap / TX_BATCH > 0 && txCap % TX_BATCH == 0; for (int i = 0; i < txCap / TX_BATCH; i++) {
public IndexLabel.CreatedIndexLabel createWithTask() { SchemaTransaction tx = this.transaction; SchemaElement.checkName(this.name, tx.graph().configuration()); IndexLabel indexLabel = tx.getIndexLabel(this.name); if (indexLabel != null) {
public AbstractTransaction(HugeGraph graph, BackendStore store) { E.checkNotNull(graph, "graph"); E.checkNotNull(store, "store"); this.graph = graph; this.serializer = this.graph.serializer(); this.store = store; this.reset(); store.open(graph.configuration()); }
public CachedGraphTransaction(HugeGraph graph, BackendStore store) { super(graph, store); HugeConfig conf = graph.configuration(); int capacity = conf.get(CoreOptions.VERTEX_CACHE_CAPACITY); int expire = conf.get(CoreOptions.VERTEX_CACHE_EXPIRE); this.verticesCache = this.cache("vertex", capacity, expire); capacity = conf.get(CoreOptions.EDGE_CACHE_CAPACITY); expire = conf.get(CoreOptions.EDGE_CACHE_EXPIRE); this.edgesCache = this.cache("edge", capacity, expire); }
private Cache cache(String prefix) { HugeConfig conf = super.graph().configuration(); final String name = prefix + "-" + super.graph().name(); final int capacity = conf.get(CoreOptions.SCHEMA_CACHE_CAPACITY); // NOTE: must disable schema cache-expire due to getAllSchema() return CacheManager.instance().cache(name, capacity); }
public GraphTransaction(HugeGraph graph, BackendStore store) { super(graph, store); this.indexTx = new GraphIndexTransaction(graph, store); assert !this.indexTx.autoCommit(); final HugeConfig conf = graph.configuration(); this.checkVertexExist = conf.get( CoreOptions.VERTEX_CHECK_CUSTOMIZED_ID_EXIST); this.vertexesCapacity = conf.get(CoreOptions.VERTEX_TX_CAPACITY); this.edgesCapacity = conf.get(CoreOptions.EDGE_TX_CAPACITY); this.locksTable = new LockUtil.LocksTable(graph.name()); }