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

Method importDataPoint

src/tsd/HistogramDataPointRpc.java:91–159  ·  view source on GitHub ↗
(final TSDB tsdb, 
                                             final String[] words)

Source from the content-addressed store, hash-verified

89 }
90
91 @Override
92 protected Deferred<Object> importDataPoint(final TSDB tsdb,
93 final String[] words) {
94 if (!enabled) {
95 throw new IllegalArgumentException(
96 "Histogram storage has not been enabled. Check the "
97 + "'tsd.core.histograms.config' configuration.");
98 }
99
100 words[0] = null; // Ditch the "histogram".
101 if (words.length < 5) { // Need at least: metric timestamp value tag
102 // ^ 5 and not 4 because words[0] is "histogram".
103 throw new IllegalArgumentException("not enough arguments"
104 + " (need least 5, got "
105 + (words.length - 1) + ')');
106 }
107 final String metric = words[1];
108 if (metric.length() <= 0) {
109 throw new IllegalArgumentException("empty metric name");
110 }
111 final long timestamp;
112 if (words[2].contains(".")) {
113 timestamp = Tags.parseLong(words[2].replace(".", ""));
114 } else {
115 timestamp = Tags.parseLong(words[2]);
116 }
117 if (timestamp <= 0) {
118 throw new IllegalArgumentException("invalid timestamp: " + timestamp);
119 }
120
121 boolean has_id = false;
122 int id = 0;
123 try {
124 id = Integer.parseInt(words[3]);
125 has_id = true;
126 } catch (NumberFormatException e) { }
127 final String value;
128 if (has_id) {
129 value = words[4];
130 } else {
131 // it's a simple Id
132 id = tsdb.histogramManager().getCodec(SimpleHistogramDecoder.class);
133 value = words[3];
134 }
135 if (value.length() <= 0) {
136 throw new IllegalArgumentException("empty histogram value");
137 }
138 final HashMap<String, String> tags = new HashMap<String, String>();
139 for (int i = has_id ? 5 : 4; i < words.length; i++) {
140 if (!words[i].isEmpty()) {
141 Tags.parse(tags, words[i]);
142 }
143 }
144
145 // validation and prepend the ID.
146 try {
147 final Histogram dp;
148 if (has_id) {

Callers

nothing calls this directly

Calls 11

parseLongMethod · 0.95
parseMethod · 0.95
base64StringToBytesMethod · 0.95
parseTelnetMethod · 0.95
containsMethod · 0.80
getCodecMethod · 0.80
histogramManagerMethod · 0.80
isEmptyMethod · 0.80
decodeMethod · 0.45
addHistogramPointMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected