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

Method parsePutV1

src/tsd/HttpJsonSerializer.java:136–159  ·  view source on GitHub ↗

Parses one or more data points for storage @return an array of data points to process for storage @throws JSONException if parsing failed @throws BadRequestException if the content was missing or parsing failed

()

Source from the content-addressed store, hash-verified

134 * @throws BadRequestException if the content was missing or parsing failed
135 */
136 @Override
137 public List<IncomingDataPoint> parsePutV1() {
138 if (!query.hasContent()) {
139 throw new BadRequestException("Missing request content");
140 }
141
142 // convert to a string so we can handle character encoding properly
143 final String content = query.getContent().trim();
144 final int firstbyte = content.charAt(0);
145 try {
146 if (firstbyte == '{') {
147 final IncomingDataPoint dp =
148 JSON.parseToObject(content, IncomingDataPoint.class);
149 final ArrayList<IncomingDataPoint> dps =
150 new ArrayList<IncomingDataPoint>(1);
151 dps.add(dp);
152 return dps;
153 } else {
154 return JSON.parseToObject(content, TR_INCOMING);
155 }
156 } catch (IllegalArgumentException iae) {
157 throw new BadRequestException("Unable to parse the given JSON", iae);
158 }
159 }
160
161 /**
162 * Parses one or more data points for storage

Callers

nothing calls this directly

Calls 4

parseToObjectMethod · 0.95
hasContentMethod · 0.45
getContentMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected