@Override public GraphManager provide() { E.checkState(this.manager != null, "Please wait for the server to initialize"); return this.manager; }
public final synchronized Cluster cluster() { E.checkState(this.cluster != null, "Cassandra cluster has not been initialized"); return this.cluster; }
private void checkResultsSize(Object results) { int size = 0; if (results instanceof Collection) { size = ((Collection<?>) results).size(); } E.checkState(size <= TASK_RESULTS_MAX_SIZE, "Job results size %s has exceeded the max limit %s", size, TASK_RESULTS_MAX_SIZE); }
public Id elementId() { E.checkState(this.elementIds.size() == 1, "Expect one element id, actual %s", this.elementIds.size()); return this.elementIds.iterator().next(); }
public void depends(Id id) { E.checkState(this.status == TaskStatus.NEW, "Can't add dependency in status '%s'", this.status); if (this.dependencies == null) { this.dependencies = InsertionOrderUtil.newSet(); } this.dependencies.add(id); }
private Table table(String table) throws IOException { E.checkState(this.hbase != null, "HBase connection is not opened"); TableName tableName = TableName.valueOf(this.namespace, table); return this.hbase.getTable(tableName); }
protected final void checkClusterConnected() { E.checkState(this.sessions != null, "Cassandra store has not been initialized"); this.sessions.checkClusterConnected(); }
public Object userpropValue(Id field) { Set<Object> values = this.userpropValues(field); if (values.isEmpty()) { return null; } E.checkState(values.size() == 1, "Expect one user-property value of field '%s', " + "but got '%s'", field, values.size()); return values.iterator().next(); }
public Id indexField() { E.checkState(this.indexType == IndexType.RANGE || this.indexType == IndexType.SEARCH, "Can't call indexField() for %s index label", this.indexType.string()); E.checkState(this.indexFields.size() == 1, "There should be only one field in %s index label, " + "but got: %s", this.indexType.string(), this.indexFields); return this.indexFields.get(0); }
public int sessionId() { String[] parts = this.getName().split("-"); E.checkState(parts.length == 2, "Invalid file name format '%s' for palo temp file, " + "the legal format is session{m}-part{n}", this.getName()); return Integer.parseInt(parts[0].substring("session".length())); }
public int sessionPart() { String[] parts = this.getName().split("-"); E.checkState(parts.length == 2, "Invalid file name format '%s' for palo temp file, " + "the legal format is session{m}-part{n}", this.getName()); return Integer.parseInt(parts[1].substring("part".length())); }
@Override public void setup(final Map<String, Object> config) { E.checkState(config != null, "Must provide a 'config' in the 'authentication'"); String path = (String) config.get("tokens"); E.checkState(path != null, "Credentials configuration missing key 'tokens'"); OptionSpace.register("tokens", ServerOptions.instance()); this.setup(new HugeConfig(path)); }
@Override protected final long skip(BackendEntry entry, long skip) { CassandraBackendEntry e = (CassandraBackendEntry) entry; E.checkState(e.subRows().size() > skip, "Invalid entry to skip"); for (long i = 0; i < skip; i++) { e.subRows().remove(0); } return e.subRows().size(); }
protected Id schemaId() { String name = this.task().name(); String[] parts = name.split(SPLITOR, 3); E.checkState(parts.length == 3 && parts[1] != null, "Task name should be formatted to String " + "'TYPE:ID:NAME', but got '%s'", name); return IdGenerator.of(Long.valueOf(parts[1])); }
private <T extends SerialEnum> T readEnum(HugeKeys key, Class<T> clazz) { byte[] value = column(key); E.checkState(value.length == 1, "The length of column '%s' must be 1, but is '%s'", key, value.length); return SerialEnum.fromCode(clazz, value[0]); }
protected final void checkSessionConnected() { E.checkState(this.sessions != null, "Cassandra store has not been initialized"); try { this.sessions.checkSessionConnected(); } catch (DriverException e) { throw new BackendException("Can't connect to cassandra", e); } }
@Override protected final long skip(BackendEntry entry, long skip) { BinaryBackendEntry e = (BinaryBackendEntry) entry; E.checkState(e.columnsSize() > skip, "Invalid entry to skip"); for (long i = 0; i < skip; i++) { e.removeColumn(0); } return e.columnsSize(); }
@Watched(prefix = "edge") protected void ensureEdgeProperties() { if (this.propLoaded) { return; } Iterator<Edge> edges = tx().queryEdges(this.id()); E.checkState(edges.hasNext(), "Edge '%s' does not exist", this.id); this.copyProperties((HugeEdge) edges.next()); }
private CassandraBackendEntry wrapByVertex(CassandraBackendEntry edge) { assert edge.type().isEdge(); String ownerVertex = edge.column(HugeKeys.OWNER_VERTEX); E.checkState(ownerVertex != null, "Invalid backend entry"); Id vertexId = IdGenerator.of(ownerVertex); CassandraBackendEntry vertex = new CassandraBackendEntry( HugeType.VERTEX, vertexId); vertex.column(HugeKeys.ID, ownerVertex); vertex.column(HugeKeys.PROPERTIES, ImmutableMap.of()); vertex.subRow(edge.row()); return vertex; }
private MysqlBackendEntry wrapByVertex(MysqlBackendEntry edge) { assert edge.type().isEdge(); String ownerVertex = edge.column(HugeKeys.OWNER_VERTEX); E.checkState(ownerVertex != null, "Invalid backend entry"); Id vertexId = IdGenerator.of(ownerVertex); MysqlBackendEntry vertex = new MysqlBackendEntry(HugeType.VERTEX, vertexId); vertex.column(HugeKeys.ID, ownerVertex); vertex.column(HugeKeys.PROPERTIES, ""); vertex.subRow(edge.row()); return vertex; }