MCPcopy Create free account
hub / github.com/OpenTSDB/opentsdb / getStorageJSON

Method getStorageJSON

src/meta/TSMeta.java:845–877  ·  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

843 * @return A byte array to write to storage
844 */
845 private byte[] getStorageJSON() {
846 // 256 bytes is a good starting value, assumes default info
847 final ByteArrayOutputStream output = new ByteArrayOutputStream(256);
848 try {
849 final JsonGenerator json = JSON.getFactory().createGenerator(output);
850 json.writeStartObject();
851 json.writeStringField("tsuid", tsuid);
852 json.writeStringField("displayName", display_name);
853 json.writeStringField("description", description);
854 json.writeStringField("notes", notes);
855 json.writeNumberField("created", created);
856 if (custom == null) {
857 json.writeNullField("custom");
858 } else {
859 json.writeObjectFieldStart("custom");
860 for (Map.Entry<String, String> entry : custom.entrySet()) {
861 json.writeStringField(entry.getKey(), entry.getValue());
862 }
863 json.writeEndObject();
864 }
865 json.writeStringField("units", units);
866 json.writeStringField("dataType", data_type);
867 json.writeNumberField("retention", retention);
868 json.writeNumberField("max", max);
869 json.writeNumberField("min", min);
870
871 json.writeEndObject();
872 json.close();
873 return output.toByteArray();
874 } catch (IOException e) {
875 throw new RuntimeException("Unable to serialize TSMeta", e);
876 }
877 }
878
879 /**
880 * Asynchronously loads the UIDMeta objects into the given TSMeta object. Used

Callers 3

storeNewMethod · 0.95
getStorageJSONTagsMethod · 0.45
callMethod · 0.45

Calls 6

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

Tested by 1

getStorageJSONTagsMethod · 0.36