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

Method parseTelnet

src/tsd/HistogramDataPointRpc.java:209–242  ·  view source on GitHub ↗
(final TSDB tsdb, final String encoded)

Source from the content-addressed store, hash-verified

207 }
208
209 SimpleHistogram parseTelnet(final TSDB tsdb, final String encoded) {
210 final SimpleHistogram shdp = new SimpleHistogram(tsdb.histogramManager()
211 .getCodec(SimpleHistogramDecoder.class));
212
213 final String[] buckets = Tags.splitString(encoded, ':');
214 if (buckets.length < 1) {
215 throw new IllegalArgumentException("Must have at least one bucket in the "
216 + "histogram.");
217 }
218
219 for (final String bucket : buckets) {
220 final String[] kv = Tags.splitString(bucket, '=');
221 if (kv.length != 2) {
222 throw new IllegalArgumentException("Improperly formatted bucket: "
223 + bucket);
224 }
225
226 kv[0] = kv[0].toLowerCase();
227 if (kv[0].equals("u")) {
228 shdp.setUnderflow(Long.parseLong(kv[1]));
229 } else if (kv[0].equals("o")) {
230 shdp.setOverflow(Long.parseLong(kv[1]));
231 } else {
232 final String[] bounds = Tags.splitString(kv[0], ',');
233 if (bounds.length != 2) {
234 throw new IllegalArgumentException("Improperly formatted bounds: "
235 + bucket);
236 }
237 shdp.addBucket(Float.parseFloat(bounds[0]), Float.parseFloat(bounds[1]),
238 Long.parseLong(kv[1]));
239 }
240 }
241 return shdp;
242 }
243
244 @VisibleForTesting
245 boolean enabled() {

Callers 2

importDataPointMethod · 0.95

Calls 8

splitStringMethod · 0.95
setUnderflowMethod · 0.95
setOverflowMethod · 0.95
addBucketMethod · 0.95
getCodecMethod · 0.80
histogramManagerMethod · 0.80
parseLongMethod · 0.80
equalsMethod · 0.45

Tested by

no test coverage detected