public String toJson() { return JsonUtil.toJson(this); }
public static <T> T deepCopy(T object) { @SuppressWarnings("unchecked") Class<T> cls = (Class<T>) object.getClass(); return JsonUtil.fromJson(JsonUtil.toJson(object), cls); } }
@Override protected Object toLongList(Collection<Id> ids) { long[] values = new long[ids.size()]; int i = 0; for (Id id : ids) { values[i++] = id.asLong(); } return JsonUtil.toJson(values); }
public byte[] toBytes() { String json = JsonUtil.toJson(this.columns); try { return json.getBytes(CHARSET); } catch (UnsupportedEncodingException e) { throw new BackendException(e); } }
private String formatPropertyValue(HugeProperty<?> prop) { // May be a single value or a list of values return JsonUtil.toJson(prop.value()); }
@Override protected void writeUserdata(SchemaElement schema, TableBackendEntry entry) { assert entry instanceof CassandraBackendEntry; for (Map.Entry<String, Object> e : schema.userdata().entrySet()) { entry.column(HugeKeys.USER_DATA, e.getKey(), JsonUtil.toJson(e.getValue())); } }
@GET @Timed @Path("system") @Produces(APPLICATION_JSON_WITH_CHARSET) @RolesAllowed("admin") public String system() { return JsonUtil.toJson(this.systemMetrics.metrics()); }
@Override protected void writeUserdata(SchemaElement schema, TableBackendEntry entry) { assert entry instanceof MysqlBackendEntry; entry.column(HugeKeys.USER_DATA, JsonUtil.toJson(schema.userdata())); }
private static void writeUserdata(SchemaElement schema, TextBackendEntry entry) { entry.column(HugeKeys.USER_DATA, JsonUtil.toJson(schema.userdata())); }
private void writeUserdata(SchemaElement schema) { String userdataStr = JsonUtil.toJson(schema.userdata()); writeString(HugeKeys.USER_DATA, userdataStr); }
@GET @Timed @Path("histograms") @Produces(APPLICATION_JSON_WITH_CHARSET) @RolesAllowed("admin") public String histograms() { ServerReporter reporter = ServerReporter.instance(); return JsonUtil.toJson(reporter.histograms()); }
@GET @Timed @Path("gauges") @Produces(APPLICATION_JSON_WITH_CHARSET) @RolesAllowed("admin") public String gauges() { ServerReporter reporter = ServerReporter.instance(); return JsonUtil.toJson(reporter.gauges()); }
@GET @Timed @Path("counters") @Produces(APPLICATION_JSON_WITH_CHARSET) @RolesAllowed("admin") public String counters() { ServerReporter reporter = ServerReporter.instance(); return JsonUtil.toJson(reporter.counters()); }
@GET @Timed @Path("meters") @Produces(APPLICATION_JSON_WITH_CHARSET) @RolesAllowed("admin") public String meters() { ServerReporter reporter = ServerReporter.instance(); return JsonUtil.toJson(reporter.meters()); }
@GET @Timed @Path("timers") @Produces(APPLICATION_JSON_WITH_CHARSET) @RolesAllowed("admin") public String timers() { ServerReporter reporter = ServerReporter.instance(); return JsonUtil.toJson(reporter.timers()); } }
private static String writeIds(Collection<Id> ids) { Object[] array = new Object[ids.size()]; int i = 0; for (Id id : ids) { if (id.number()) { array[i++] = id.asLong(); } else { array[i++] = id.asString(); } } return JsonUtil.toJson(array); }
@Override protected void formatProperties(HugeElement element, TableBackendEntry.Row row) { Map<Number, Object> properties = new HashMap<>(); // Add all properties of a Vertex for (HugeProperty<?> prop : element.getProperties().values()) { Number key = prop.propertyKey().id().asLong(); Object val = prop.value(); properties.put(key, val); } row.column(HugeKeys.PROPERTIES, JsonUtil.toJson(properties)); }
@Override public BackendEntry writePropertyKey(PropertyKey propertyKey) { TextBackendEntry entry = newBackendEntry(propertyKey); entry.column(HugeKeys.NAME, JsonUtil.toJson(propertyKey.name())); entry.column(HugeKeys.DATA_TYPE, JsonUtil.toJson(propertyKey.dataType())); entry.column(HugeKeys.CARDINALITY, JsonUtil.toJson(propertyKey.cardinality())); entry.column(HugeKeys.PROPERTIES, writeIds(propertyKey.properties())); writeUserdata(propertyKey, entry); entry.column(HugeKeys.STATUS, JsonUtil.toJson(propertyKey.status())); return entry; }
protected void formatProperty(HugeProperty<?> prop, TableBackendEntry.Row row) { row.column(HugeKeys.PROPERTIES, prop.propertyKey().id().asLong(), JsonUtil.toJson(prop.value())); }