MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / getStorageJSON

Method getStorageJSON

src/meta/UIDMeta.java:500–527  ·  view source on GitHub ↗

Formats the JSON output for writing to storage. It drops objects we don't need or want to store (such as the UIDMeta objects or the total dps) to save space. It also serializes in order so that we can make a proper CAS call. Otherwise the POJO serializer may place the fields in any order and CAS cal

()

Source from the content-addressed store, hash-verified

498 * @return A byte array to write to storage
499 */
500 private byte[] getStorageJSON() {
501 // 256 bytes is a good starting value, assumes default info
502 final ByteArrayOutputStream output = new ByteArrayOutputStream(256);
503 try {
504 final JsonGenerator json = JSON.getFactory().createGenerator(output);
505 json.writeStartObject();
506 json.writeStringField("type", type.toString());
507 json.writeStringField("displayName", display_name);
508 json.writeStringField("description", description);
509 json.writeStringField("notes", notes);
510 json.writeNumberField("created", created);
511 if (custom == null) {
512 json.writeNullField("custom");
513 } else {
514 json.writeObjectFieldStart("custom");
515 for (Map.Entry<String, String> entry : custom.entrySet()) {
516 json.writeStringField(entry.getKey(), entry.getValue());
517 }
518 json.writeEndObject();
519 }
520
521 json.writeEndObject();
522 json.close();
523 return output.toByteArray();
524 } catch (IOException e) {
525 throw new RuntimeException("Unable to serialize UIDMeta", e);
526 }
527 }
528
529 // Getters and Setters --------------
530

Callers 2

callMethod · 0.45
storeNewMethod · 0.45

Calls 7

getFactoryMethod · 0.95
toByteArrayMethod · 0.80
writeStringFieldMethod · 0.65
toStringMethod · 0.45
getKeyMethod · 0.45
getValueMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected