id
int32 0
165k
| repo
stringlengths 7
58
| path
stringlengths 12
218
| func_name
stringlengths 3
140
| original_string
stringlengths 73
34.1k
| language
stringclasses 1
value | code
stringlengths 73
34.1k
| code_tokens
list | docstring
stringlengths 3
16k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 105
339
|
|---|---|---|---|---|---|---|---|---|---|---|---|
13,500
|
OpenTSDB/opentsdb
|
src/tsd/StatsRpc.java
|
StatsRpc.printRegionClientStats
|
private void printRegionClientStats(final TSDB tsdb, final HttpQuery query) {
final List<RegionClientStats> region_stats = tsdb.getClient().regionStats();
final List<Map<String, Object>> stats =
new ArrayList<Map<String, Object>>(region_stats.size());
for (final RegionClientStats rcs : region_stats) {
final Map<String, Object> stat_map = new HashMap<String, Object>(8);
stat_map.put("rpcsSent", rcs.rpcsSent());
stat_map.put("rpcsInFlight", rcs.inflightRPCs());
stat_map.put("pendingRPCs", rcs.pendingRPCs());
stat_map.put("pendingBatchedRPCs", rcs.pendingBatchedRPCs());
stat_map.put("dead", rcs.isDead());
stat_map.put("rpcid", rcs.rpcID());
stat_map.put("endpoint", rcs.remoteEndpoint());
stat_map.put("rpcsTimedout", rcs.rpcsTimedout());
stat_map.put("rpcResponsesTimedout", rcs.rpcResponsesTimedout());
stat_map.put("rpcResponsesUnknown", rcs.rpcResponsesUnknown());
stat_map.put("inflightBreached", rcs.inflightBreached());
stat_map.put("pendingBreached", rcs.pendingBreached());
stat_map.put("writesBlocked", rcs.writesBlocked());
stats.add(stat_map);
}
query.sendReply(query.serializer().formatRegionStatsV1(stats));
}
|
java
|
private void printRegionClientStats(final TSDB tsdb, final HttpQuery query) {
final List<RegionClientStats> region_stats = tsdb.getClient().regionStats();
final List<Map<String, Object>> stats =
new ArrayList<Map<String, Object>>(region_stats.size());
for (final RegionClientStats rcs : region_stats) {
final Map<String, Object> stat_map = new HashMap<String, Object>(8);
stat_map.put("rpcsSent", rcs.rpcsSent());
stat_map.put("rpcsInFlight", rcs.inflightRPCs());
stat_map.put("pendingRPCs", rcs.pendingRPCs());
stat_map.put("pendingBatchedRPCs", rcs.pendingBatchedRPCs());
stat_map.put("dead", rcs.isDead());
stat_map.put("rpcid", rcs.rpcID());
stat_map.put("endpoint", rcs.remoteEndpoint());
stat_map.put("rpcsTimedout", rcs.rpcsTimedout());
stat_map.put("rpcResponsesTimedout", rcs.rpcResponsesTimedout());
stat_map.put("rpcResponsesUnknown", rcs.rpcResponsesUnknown());
stat_map.put("inflightBreached", rcs.inflightBreached());
stat_map.put("pendingBreached", rcs.pendingBreached());
stat_map.put("writesBlocked", rcs.writesBlocked());
stats.add(stat_map);
}
query.sendReply(query.serializer().formatRegionStatsV1(stats));
}
|
[
"private",
"void",
"printRegionClientStats",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"HttpQuery",
"query",
")",
"{",
"final",
"List",
"<",
"RegionClientStats",
">",
"region_stats",
"=",
"tsdb",
".",
"getClient",
"(",
")",
".",
"regionStats",
"(",
")",
";",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"stats",
"=",
"new",
"ArrayList",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
"region_stats",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"final",
"RegionClientStats",
"rcs",
":",
"region_stats",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"stat_map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
"8",
")",
";",
"stat_map",
".",
"put",
"(",
"\"rpcsSent\"",
",",
"rcs",
".",
"rpcsSent",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"rpcsInFlight\"",
",",
"rcs",
".",
"inflightRPCs",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"pendingRPCs\"",
",",
"rcs",
".",
"pendingRPCs",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"pendingBatchedRPCs\"",
",",
"rcs",
".",
"pendingBatchedRPCs",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"dead\"",
",",
"rcs",
".",
"isDead",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"rpcid\"",
",",
"rcs",
".",
"rpcID",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"endpoint\"",
",",
"rcs",
".",
"remoteEndpoint",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"rpcsTimedout\"",
",",
"rcs",
".",
"rpcsTimedout",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"rpcResponsesTimedout\"",
",",
"rcs",
".",
"rpcResponsesTimedout",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"rpcResponsesUnknown\"",
",",
"rcs",
".",
"rpcResponsesUnknown",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"inflightBreached\"",
",",
"rcs",
".",
"inflightBreached",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"pendingBreached\"",
",",
"rcs",
".",
"pendingBreached",
"(",
")",
")",
";",
"stat_map",
".",
"put",
"(",
"\"writesBlocked\"",
",",
"rcs",
".",
"writesBlocked",
"(",
")",
")",
";",
"stats",
".",
"add",
"(",
"stat_map",
")",
";",
"}",
"query",
".",
"sendReply",
"(",
"query",
".",
"serializer",
"(",
")",
".",
"formatRegionStatsV1",
"(",
"stats",
")",
")",
";",
"}"
] |
Display stats for each region client
@param tsdb The TSDB to use for fetching stats
@param query The query to respond to
|
[
"Display",
"stats",
"for",
"each",
"region",
"client"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/StatsRpc.java#L153-L176
|
13,501
|
OpenTSDB/opentsdb
|
src/tsd/StatsRpc.java
|
StatsRpc.printThreadStats
|
private void printThreadStats(final HttpQuery query) {
final Set<Thread> threads = Thread.getAllStackTraces().keySet();
final List<Map<String, Object>> output =
new ArrayList<Map<String, Object>>(threads.size());
for (final Thread thread : threads) {
final Map<String, Object> status = new HashMap<String, Object>();
status.put("threadID", thread.getId());
status.put("name", thread.getName());
status.put("state", thread.getState().toString());
status.put("interrupted", thread.isInterrupted());
status.put("priority", thread.getPriority());
final List<String> stack =
new ArrayList<String>(thread.getStackTrace().length);
for (final StackTraceElement element: thread.getStackTrace()) {
stack.add(element.toString());
}
status.put("stack", stack);
output.add(status);
}
query.sendReply(query.serializer().formatThreadStatsV1(output));
}
|
java
|
private void printThreadStats(final HttpQuery query) {
final Set<Thread> threads = Thread.getAllStackTraces().keySet();
final List<Map<String, Object>> output =
new ArrayList<Map<String, Object>>(threads.size());
for (final Thread thread : threads) {
final Map<String, Object> status = new HashMap<String, Object>();
status.put("threadID", thread.getId());
status.put("name", thread.getName());
status.put("state", thread.getState().toString());
status.put("interrupted", thread.isInterrupted());
status.put("priority", thread.getPriority());
final List<String> stack =
new ArrayList<String>(thread.getStackTrace().length);
for (final StackTraceElement element: thread.getStackTrace()) {
stack.add(element.toString());
}
status.put("stack", stack);
output.add(status);
}
query.sendReply(query.serializer().formatThreadStatsV1(output));
}
|
[
"private",
"void",
"printThreadStats",
"(",
"final",
"HttpQuery",
"query",
")",
"{",
"final",
"Set",
"<",
"Thread",
">",
"threads",
"=",
"Thread",
".",
"getAllStackTraces",
"(",
")",
".",
"keySet",
"(",
")",
";",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"output",
"=",
"new",
"ArrayList",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"(",
"threads",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"final",
"Thread",
"thread",
":",
"threads",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"status",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"status",
".",
"put",
"(",
"\"threadID\"",
",",
"thread",
".",
"getId",
"(",
")",
")",
";",
"status",
".",
"put",
"(",
"\"name\"",
",",
"thread",
".",
"getName",
"(",
")",
")",
";",
"status",
".",
"put",
"(",
"\"state\"",
",",
"thread",
".",
"getState",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"status",
".",
"put",
"(",
"\"interrupted\"",
",",
"thread",
".",
"isInterrupted",
"(",
")",
")",
";",
"status",
".",
"put",
"(",
"\"priority\"",
",",
"thread",
".",
"getPriority",
"(",
")",
")",
";",
"final",
"List",
"<",
"String",
">",
"stack",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
"thread",
".",
"getStackTrace",
"(",
")",
".",
"length",
")",
";",
"for",
"(",
"final",
"StackTraceElement",
"element",
":",
"thread",
".",
"getStackTrace",
"(",
")",
")",
"{",
"stack",
".",
"add",
"(",
"element",
".",
"toString",
"(",
")",
")",
";",
"}",
"status",
".",
"put",
"(",
"\"stack\"",
",",
"stack",
")",
";",
"output",
".",
"add",
"(",
"status",
")",
";",
"}",
"query",
".",
"sendReply",
"(",
"query",
".",
"serializer",
"(",
")",
".",
"formatThreadStatsV1",
"(",
"output",
")",
")",
";",
"}"
] |
Grabs a snapshot of all JVM thread states and formats it in a manner to
be displayed via API.
@param query The query to respond to
|
[
"Grabs",
"a",
"snapshot",
"of",
"all",
"JVM",
"thread",
"states",
"and",
"formats",
"it",
"in",
"a",
"manner",
"to",
"be",
"displayed",
"via",
"API",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/StatsRpc.java#L184-L205
|
13,502
|
OpenTSDB/opentsdb
|
src/tsd/StatsRpc.java
|
StatsRpc.collectThreadStats
|
private void collectThreadStats(final StatsCollector collector) {
final Set<Thread> threads = Thread.getAllStackTraces().keySet();
final Map<String, Integer> states = new HashMap<String, Integer>(6);
states.put("new", 0);
states.put("runnable", 0);
states.put("blocked", 0);
states.put("waiting", 0);
states.put("timed_waiting", 0);
states.put("terminated", 0);
for (final Thread thread : threads) {
int state_count = states.get(thread.getState().toString().toLowerCase());
state_count++;
states.put(thread.getState().toString().toLowerCase(), state_count);
}
for (final Map.Entry<String, Integer> entry : states.entrySet()) {
collector.record("jvm.thread.states", entry.getValue(), "state=" +
entry.getKey());
}
collector.record("jvm.thread.count", threads.size());
}
|
java
|
private void collectThreadStats(final StatsCollector collector) {
final Set<Thread> threads = Thread.getAllStackTraces().keySet();
final Map<String, Integer> states = new HashMap<String, Integer>(6);
states.put("new", 0);
states.put("runnable", 0);
states.put("blocked", 0);
states.put("waiting", 0);
states.put("timed_waiting", 0);
states.put("terminated", 0);
for (final Thread thread : threads) {
int state_count = states.get(thread.getState().toString().toLowerCase());
state_count++;
states.put(thread.getState().toString().toLowerCase(), state_count);
}
for (final Map.Entry<String, Integer> entry : states.entrySet()) {
collector.record("jvm.thread.states", entry.getValue(), "state=" +
entry.getKey());
}
collector.record("jvm.thread.count", threads.size());
}
|
[
"private",
"void",
"collectThreadStats",
"(",
"final",
"StatsCollector",
"collector",
")",
"{",
"final",
"Set",
"<",
"Thread",
">",
"threads",
"=",
"Thread",
".",
"getAllStackTraces",
"(",
")",
".",
"keySet",
"(",
")",
";",
"final",
"Map",
"<",
"String",
",",
"Integer",
">",
"states",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Integer",
">",
"(",
"6",
")",
";",
"states",
".",
"put",
"(",
"\"new\"",
",",
"0",
")",
";",
"states",
".",
"put",
"(",
"\"runnable\"",
",",
"0",
")",
";",
"states",
".",
"put",
"(",
"\"blocked\"",
",",
"0",
")",
";",
"states",
".",
"put",
"(",
"\"waiting\"",
",",
"0",
")",
";",
"states",
".",
"put",
"(",
"\"timed_waiting\"",
",",
"0",
")",
";",
"states",
".",
"put",
"(",
"\"terminated\"",
",",
"0",
")",
";",
"for",
"(",
"final",
"Thread",
"thread",
":",
"threads",
")",
"{",
"int",
"state_count",
"=",
"states",
".",
"get",
"(",
"thread",
".",
"getState",
"(",
")",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
")",
";",
"state_count",
"++",
";",
"states",
".",
"put",
"(",
"thread",
".",
"getState",
"(",
")",
".",
"toString",
"(",
")",
".",
"toLowerCase",
"(",
")",
",",
"state_count",
")",
";",
"}",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"Integer",
">",
"entry",
":",
"states",
".",
"entrySet",
"(",
")",
")",
"{",
"collector",
".",
"record",
"(",
"\"jvm.thread.states\"",
",",
"entry",
".",
"getValue",
"(",
")",
",",
"\"state=\"",
"+",
"entry",
".",
"getKey",
"(",
")",
")",
";",
"}",
"collector",
".",
"record",
"(",
"\"jvm.thread.count\"",
",",
"threads",
".",
"size",
"(",
")",
")",
";",
"}"
] |
Runs through the live threads and counts captures a coune of their
states for dumping in the stats page.
@param collector The collector to write to
|
[
"Runs",
"through",
"the",
"live",
"threads",
"and",
"counts",
"captures",
"a",
"coune",
"of",
"their",
"states",
"for",
"dumping",
"in",
"the",
"stats",
"page",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/StatsRpc.java#L288-L307
|
13,503
|
OpenTSDB/opentsdb
|
src/tsd/StatsRpc.java
|
StatsRpc.formatStatName
|
private static String formatStatName(final String stat) {
if (stat == null || stat.isEmpty()) {
return stat;
}
String name = stat.replace(" ", "");
return name.substring(0, 1).toLowerCase() + name.substring(1);
}
|
java
|
private static String formatStatName(final String stat) {
if (stat == null || stat.isEmpty()) {
return stat;
}
String name = stat.replace(" ", "");
return name.substring(0, 1).toLowerCase() + name.substring(1);
}
|
[
"private",
"static",
"String",
"formatStatName",
"(",
"final",
"String",
"stat",
")",
"{",
"if",
"(",
"stat",
"==",
"null",
"||",
"stat",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"stat",
";",
"}",
"String",
"name",
"=",
"stat",
".",
"replace",
"(",
"\" \"",
",",
"\"\"",
")",
";",
"return",
"name",
".",
"substring",
"(",
"0",
",",
"1",
")",
".",
"toLowerCase",
"(",
")",
"+",
"name",
".",
"substring",
"(",
"1",
")",
";",
"}"
] |
Little helper to convert the first character to lowercase and remove any
spaces
@param stat The name to cleanup
@return a clean name or null if the original string was null or empty
|
[
"Little",
"helper",
"to",
"convert",
"the",
"first",
"character",
"to",
"lowercase",
"and",
"remove",
"any",
"spaces"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/StatsRpc.java#L315-L321
|
13,504
|
OpenTSDB/opentsdb
|
src/tsd/StatsRpc.java
|
StatsRpc.printQueryStats
|
private void printQueryStats(final HttpQuery query) {
switch (query.apiVersion()) {
case 0:
case 1:
query.sendReply(query.serializer().formatQueryStatsV1(
QueryStats.getRunningAndCompleteStats()));
break;
default:
throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED,
"Requested API version not implemented", "Version " +
query.apiVersion() + " is not implemented");
}
}
|
java
|
private void printQueryStats(final HttpQuery query) {
switch (query.apiVersion()) {
case 0:
case 1:
query.sendReply(query.serializer().formatQueryStatsV1(
QueryStats.getRunningAndCompleteStats()));
break;
default:
throw new BadRequestException(HttpResponseStatus.NOT_IMPLEMENTED,
"Requested API version not implemented", "Version " +
query.apiVersion() + " is not implemented");
}
}
|
[
"private",
"void",
"printQueryStats",
"(",
"final",
"HttpQuery",
"query",
")",
"{",
"switch",
"(",
"query",
".",
"apiVersion",
"(",
")",
")",
"{",
"case",
"0",
":",
"case",
"1",
":",
"query",
".",
"sendReply",
"(",
"query",
".",
"serializer",
"(",
")",
".",
"formatQueryStatsV1",
"(",
"QueryStats",
".",
"getRunningAndCompleteStats",
"(",
")",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"NOT_IMPLEMENTED",
",",
"\"Requested API version not implemented\"",
",",
"\"Version \"",
"+",
"query",
".",
"apiVersion",
"(",
")",
"+",
"\" is not implemented\"",
")",
";",
"}",
"}"
] |
Print the detailed query stats to the caller using the proper serializer
@param query The query to answer to
@throws BadRequestException if the API version hasn't been implemented
yet
|
[
"Print",
"the",
"detailed",
"query",
"stats",
"to",
"the",
"caller",
"using",
"the",
"proper",
"serializer"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/StatsRpc.java#L329-L341
|
13,505
|
OpenTSDB/opentsdb
|
src/tsd/DropCachesRpc.java
|
DropCachesRpc.dropCaches
|
private void dropCaches(final TSDB tsdb, final Channel chan) {
LOG.warn(chan + " Dropping all in-memory caches.");
tsdb.dropCaches();
}
|
java
|
private void dropCaches(final TSDB tsdb, final Channel chan) {
LOG.warn(chan + " Dropping all in-memory caches.");
tsdb.dropCaches();
}
|
[
"private",
"void",
"dropCaches",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"Channel",
"chan",
")",
"{",
"LOG",
".",
"warn",
"(",
"chan",
"+",
"\" Dropping all in-memory caches.\"",
")",
";",
"tsdb",
".",
"dropCaches",
"(",
")",
";",
"}"
] |
Drops in memory caches.
|
[
"Drops",
"in",
"memory",
"caches",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/DropCachesRpc.java#L84-L87
|
13,506
|
OpenTSDB/opentsdb
|
src/core/WriteableDataPointFilterPlugin.java
|
WriteableDataPointFilterPlugin.allowHistogramPoint
|
public Deferred<Boolean> allowHistogramPoint(
final String metric,
final long timestamp,
final byte[] value,
final Map<String, String> tags) {
throw new UnsupportedOperationException("Not yet implemented.");
}
|
java
|
public Deferred<Boolean> allowHistogramPoint(
final String metric,
final long timestamp,
final byte[] value,
final Map<String, String> tags) {
throw new UnsupportedOperationException("Not yet implemented.");
}
|
[
"public",
"Deferred",
"<",
"Boolean",
">",
"allowHistogramPoint",
"(",
"final",
"String",
"metric",
",",
"final",
"long",
"timestamp",
",",
"final",
"byte",
"[",
"]",
"value",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"throw",
"new",
"UnsupportedOperationException",
"(",
"\"Not yet implemented.\"",
")",
";",
"}"
] |
Determine whether or not the data point should be stored.
If the data should not be stored, the implementation can return false or an
exception in the deferred object. Otherwise it should return true and the
data point will be written to storage.
@param metric The metric name for the data point
@param timestamp The timestamp of the data
@param value The value encoded as either an integer or floating point value
@param tags The tags associated with the data point
@return True if the data should be written, false if it should be rejected.
|
[
"Determine",
"whether",
"or",
"not",
"the",
"data",
"point",
"should",
"be",
"stored",
".",
"If",
"the",
"data",
"should",
"not",
"be",
"stored",
"the",
"implementation",
"can",
"return",
"false",
"or",
"an",
"exception",
"in",
"the",
"deferred",
"object",
".",
"Otherwise",
"it",
"should",
"return",
"true",
"and",
"the",
"data",
"point",
"will",
"be",
"written",
"to",
"storage",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/WriteableDataPointFilterPlugin.java#L104-L110
|
13,507
|
OpenTSDB/opentsdb
|
src/query/filter/TagVFilter.java
|
TagVFilter.getFilter
|
public static TagVFilter getFilter(final String tagk, final String filter) {
if (tagk == null || tagk.isEmpty()) {
throw new IllegalArgumentException("Tagk cannot be null or empty");
}
if (filter == null || filter.isEmpty()) {
throw new IllegalArgumentException("Filter cannot be null or empty");
}
if (filter.length() == 1 && filter.charAt(0) == '*') {
return null; // group by filter
}
final int paren = filter.indexOf('(');
if (paren > -1) {
final String prefix = filter.substring(0, paren).toLowerCase();
return new Builder().setTagk(tagk)
.setFilter(stripParentheses(filter))
.setType(prefix)
.build();
} else if (filter.contains("*")) {
// a shortcut for wildcards since we don't allow asterisks to be stored
// in strings at this time.
return new TagVWildcardFilter(tagk, filter, true);
} else {
return null; // likely a literal or unknown
}
}
|
java
|
public static TagVFilter getFilter(final String tagk, final String filter) {
if (tagk == null || tagk.isEmpty()) {
throw new IllegalArgumentException("Tagk cannot be null or empty");
}
if (filter == null || filter.isEmpty()) {
throw new IllegalArgumentException("Filter cannot be null or empty");
}
if (filter.length() == 1 && filter.charAt(0) == '*') {
return null; // group by filter
}
final int paren = filter.indexOf('(');
if (paren > -1) {
final String prefix = filter.substring(0, paren).toLowerCase();
return new Builder().setTagk(tagk)
.setFilter(stripParentheses(filter))
.setType(prefix)
.build();
} else if (filter.contains("*")) {
// a shortcut for wildcards since we don't allow asterisks to be stored
// in strings at this time.
return new TagVWildcardFilter(tagk, filter, true);
} else {
return null; // likely a literal or unknown
}
}
|
[
"public",
"static",
"TagVFilter",
"getFilter",
"(",
"final",
"String",
"tagk",
",",
"final",
"String",
"filter",
")",
"{",
"if",
"(",
"tagk",
"==",
"null",
"||",
"tagk",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Tagk cannot be null or empty\"",
")",
";",
"}",
"if",
"(",
"filter",
"==",
"null",
"||",
"filter",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Filter cannot be null or empty\"",
")",
";",
"}",
"if",
"(",
"filter",
".",
"length",
"(",
")",
"==",
"1",
"&&",
"filter",
".",
"charAt",
"(",
"0",
")",
"==",
"'",
"'",
")",
"{",
"return",
"null",
";",
"// group by filter",
"}",
"final",
"int",
"paren",
"=",
"filter",
".",
"indexOf",
"(",
"'",
"'",
")",
";",
"if",
"(",
"paren",
">",
"-",
"1",
")",
"{",
"final",
"String",
"prefix",
"=",
"filter",
".",
"substring",
"(",
"0",
",",
"paren",
")",
".",
"toLowerCase",
"(",
")",
";",
"return",
"new",
"Builder",
"(",
")",
".",
"setTagk",
"(",
"tagk",
")",
".",
"setFilter",
"(",
"stripParentheses",
"(",
"filter",
")",
")",
".",
"setType",
"(",
"prefix",
")",
".",
"build",
"(",
")",
";",
"}",
"else",
"if",
"(",
"filter",
".",
"contains",
"(",
"\"*\"",
")",
")",
"{",
"// a shortcut for wildcards since we don't allow asterisks to be stored",
"// in strings at this time.",
"return",
"new",
"TagVWildcardFilter",
"(",
"tagk",
",",
"filter",
",",
"true",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"// likely a literal or unknown",
"}",
"}"
] |
Parses the tag value and determines if it's a group by, a literal or a filter.
@param tagk The tag key associated with this value
@param filter The tag value, possibly a filter
@return Null if the value was a group by or a literal, a valid filter object
if it looked to be a filter.
@throws IllegalArgumentException if the tag key or filter was null, empty
or if the filter was malformed, e.g. a bad regular expression.
|
[
"Parses",
"the",
"tag",
"value",
"and",
"determines",
"if",
"it",
"s",
"a",
"group",
"by",
"a",
"literal",
"or",
"a",
"filter",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/filter/TagVFilter.java#L199-L224
|
13,508
|
OpenTSDB/opentsdb
|
src/query/filter/TagVFilter.java
|
TagVFilter.initializeFilterMap
|
public static void initializeFilterMap(final TSDB tsdb)
throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException,
IllegalArgumentException, SecurityException, IllegalAccessException,
InvocationTargetException {
final List<TagVFilter> filter_plugins =
PluginLoader.loadPlugins(TagVFilter.class);
if (filter_plugins != null) {
for (final TagVFilter filter : filter_plugins) {
// validate required fields and methods
filter.getClass().getDeclaredMethod("description");
filter.getClass().getDeclaredMethod("examples");
filter.getClass().getDeclaredField("FILTER_NAME");
final Method initialize = filter.getClass()
.getDeclaredMethod("initialize", TSDB.class);
initialize.invoke(null, tsdb);
final Constructor<? extends TagVFilter> ctor =
filter.getClass().getDeclaredConstructor(String.class, String.class);
final Pair<Class<?>, Constructor<? extends TagVFilter>> existing =
tagv_filter_map.get(filter.getType());
if (existing != null) {
LOG.warn("Overloading existing filter " +
existing.getClass().getCanonicalName() +
" with new filter " + filter.getClass().getCanonicalName());
}
tagv_filter_map.put(filter.getType().toLowerCase(),
new Pair<Class<?>, Constructor<? extends TagVFilter>>(
filter.getClass(), ctor));
LOG.info("Successfully loaded TagVFilter plugin: " +
filter.getClass().getCanonicalName());
}
LOG.info("Loaded " + tagv_filter_map.size() + " filters");
}
}
|
java
|
public static void initializeFilterMap(final TSDB tsdb)
throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException,
IllegalArgumentException, SecurityException, IllegalAccessException,
InvocationTargetException {
final List<TagVFilter> filter_plugins =
PluginLoader.loadPlugins(TagVFilter.class);
if (filter_plugins != null) {
for (final TagVFilter filter : filter_plugins) {
// validate required fields and methods
filter.getClass().getDeclaredMethod("description");
filter.getClass().getDeclaredMethod("examples");
filter.getClass().getDeclaredField("FILTER_NAME");
final Method initialize = filter.getClass()
.getDeclaredMethod("initialize", TSDB.class);
initialize.invoke(null, tsdb);
final Constructor<? extends TagVFilter> ctor =
filter.getClass().getDeclaredConstructor(String.class, String.class);
final Pair<Class<?>, Constructor<? extends TagVFilter>> existing =
tagv_filter_map.get(filter.getType());
if (existing != null) {
LOG.warn("Overloading existing filter " +
existing.getClass().getCanonicalName() +
" with new filter " + filter.getClass().getCanonicalName());
}
tagv_filter_map.put(filter.getType().toLowerCase(),
new Pair<Class<?>, Constructor<? extends TagVFilter>>(
filter.getClass(), ctor));
LOG.info("Successfully loaded TagVFilter plugin: " +
filter.getClass().getCanonicalName());
}
LOG.info("Loaded " + tagv_filter_map.size() + " filters");
}
}
|
[
"public",
"static",
"void",
"initializeFilterMap",
"(",
"final",
"TSDB",
"tsdb",
")",
"throws",
"ClassNotFoundException",
",",
"NoSuchMethodException",
",",
"NoSuchFieldException",
",",
"IllegalArgumentException",
",",
"SecurityException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"final",
"List",
"<",
"TagVFilter",
">",
"filter_plugins",
"=",
"PluginLoader",
".",
"loadPlugins",
"(",
"TagVFilter",
".",
"class",
")",
";",
"if",
"(",
"filter_plugins",
"!=",
"null",
")",
"{",
"for",
"(",
"final",
"TagVFilter",
"filter",
":",
"filter_plugins",
")",
"{",
"// validate required fields and methods",
"filter",
".",
"getClass",
"(",
")",
".",
"getDeclaredMethod",
"(",
"\"description\"",
")",
";",
"filter",
".",
"getClass",
"(",
")",
".",
"getDeclaredMethod",
"(",
"\"examples\"",
")",
";",
"filter",
".",
"getClass",
"(",
")",
".",
"getDeclaredField",
"(",
"\"FILTER_NAME\"",
")",
";",
"final",
"Method",
"initialize",
"=",
"filter",
".",
"getClass",
"(",
")",
".",
"getDeclaredMethod",
"(",
"\"initialize\"",
",",
"TSDB",
".",
"class",
")",
";",
"initialize",
".",
"invoke",
"(",
"null",
",",
"tsdb",
")",
";",
"final",
"Constructor",
"<",
"?",
"extends",
"TagVFilter",
">",
"ctor",
"=",
"filter",
".",
"getClass",
"(",
")",
".",
"getDeclaredConstructor",
"(",
"String",
".",
"class",
",",
"String",
".",
"class",
")",
";",
"final",
"Pair",
"<",
"Class",
"<",
"?",
">",
",",
"Constructor",
"<",
"?",
"extends",
"TagVFilter",
">",
">",
"existing",
"=",
"tagv_filter_map",
".",
"get",
"(",
"filter",
".",
"getType",
"(",
")",
")",
";",
"if",
"(",
"existing",
"!=",
"null",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Overloading existing filter \"",
"+",
"existing",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
"+",
"\" with new filter \"",
"+",
"filter",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
")",
";",
"}",
"tagv_filter_map",
".",
"put",
"(",
"filter",
".",
"getType",
"(",
")",
".",
"toLowerCase",
"(",
")",
",",
"new",
"Pair",
"<",
"Class",
"<",
"?",
">",
",",
"Constructor",
"<",
"?",
"extends",
"TagVFilter",
">",
">",
"(",
"filter",
".",
"getClass",
"(",
")",
",",
"ctor",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Successfully loaded TagVFilter plugin: \"",
"+",
"filter",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
")",
";",
"}",
"LOG",
".",
"info",
"(",
"\"Loaded \"",
"+",
"tagv_filter_map",
".",
"size",
"(",
")",
"+",
"\" filters\"",
")",
";",
"}",
"}"
] |
Loads plugins from the plugin directory and loads them into the map.
Built-in filters don't need to go through this process.
@param tsdb A TSDB to use to initialize plugins
@throws ClassNotFoundException If we found a class that we didn't... find?
@throws NoSuchMethodException If the discovered plugin didn't have the
proper (tagk, filter) ctor
@throws InvocationTargetException if the static "initialize(tsdb)" method
doesn't exist.
@throws IllegalAccessException if something went really pear shaped
@throws SecurityException if the JVM is really unhappy with the user
@throws IllegalArgumentException really shouldn't happen but you know,
checked exceptions...
|
[
"Loads",
"plugins",
"from",
"the",
"plugin",
"directory",
"and",
"loads",
"them",
"into",
"the",
"map",
".",
"Built",
"-",
"in",
"filters",
"don",
"t",
"need",
"to",
"go",
"through",
"this",
"process",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/filter/TagVFilter.java#L260-L295
|
13,509
|
OpenTSDB/opentsdb
|
src/query/filter/TagVFilter.java
|
TagVFilter.tagsToFilters
|
public static void tagsToFilters(final Map<String, String> tags,
final List<TagVFilter> filters) {
mapToFilters(tags, filters, true);
}
|
java
|
public static void tagsToFilters(final Map<String, String> tags,
final List<TagVFilter> filters) {
mapToFilters(tags, filters, true);
}
|
[
"public",
"static",
"void",
"tagsToFilters",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
",",
"final",
"List",
"<",
"TagVFilter",
">",
"filters",
")",
"{",
"mapToFilters",
"(",
"tags",
",",
"filters",
",",
"true",
")",
";",
"}"
] |
Converts the tag map to a filter list. If a filter already exists for a
tag group by, then the duplicate is skipped.
@param tags A set of tag keys and values. May be null or empty.
@param filters A set of filters to add the converted filters to. This may
not be null.
|
[
"Converts",
"the",
"tag",
"map",
"to",
"a",
"filter",
"list",
".",
"If",
"a",
"filter",
"already",
"exists",
"for",
"a",
"tag",
"group",
"by",
"then",
"the",
"duplicate",
"is",
"skipped",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/filter/TagVFilter.java#L304-L307
|
13,510
|
OpenTSDB/opentsdb
|
src/query/filter/TagVFilter.java
|
TagVFilter.mapToFilters
|
public static void mapToFilters(final Map<String, String> map,
final List<TagVFilter> filters, final boolean group_by) {
if (map == null || map.isEmpty()) {
return;
}
for (final Map.Entry<String, String> entry : map.entrySet()) {
TagVFilter filter = getFilter(entry.getKey(), entry.getValue());
if (filter == null && entry.getValue().equals("*")) {
filter = new TagVWildcardFilter(entry.getKey(), "*", true);
} else if (filter == null) {
filter = new TagVLiteralOrFilter(entry.getKey(), entry.getValue());
}
if (group_by) {
filter.setGroupBy(true);
boolean duplicate = false;
for (final TagVFilter existing : filters) {
if (filter.equals(existing)) {
LOG.debug("Skipping duplicate filter: " + existing);
existing.setGroupBy(true);
duplicate = true;
break;
}
}
if (!duplicate) {
filters.add(filter);
}
} else {
filters.add(filter);
}
}
}
|
java
|
public static void mapToFilters(final Map<String, String> map,
final List<TagVFilter> filters, final boolean group_by) {
if (map == null || map.isEmpty()) {
return;
}
for (final Map.Entry<String, String> entry : map.entrySet()) {
TagVFilter filter = getFilter(entry.getKey(), entry.getValue());
if (filter == null && entry.getValue().equals("*")) {
filter = new TagVWildcardFilter(entry.getKey(), "*", true);
} else if (filter == null) {
filter = new TagVLiteralOrFilter(entry.getKey(), entry.getValue());
}
if (group_by) {
filter.setGroupBy(true);
boolean duplicate = false;
for (final TagVFilter existing : filters) {
if (filter.equals(existing)) {
LOG.debug("Skipping duplicate filter: " + existing);
existing.setGroupBy(true);
duplicate = true;
break;
}
}
if (!duplicate) {
filters.add(filter);
}
} else {
filters.add(filter);
}
}
}
|
[
"public",
"static",
"void",
"mapToFilters",
"(",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"map",
",",
"final",
"List",
"<",
"TagVFilter",
">",
"filters",
",",
"final",
"boolean",
"group_by",
")",
"{",
"if",
"(",
"map",
"==",
"null",
"||",
"map",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
";",
"}",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"TagVFilter",
"filter",
"=",
"getFilter",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"filter",
"==",
"null",
"&&",
"entry",
".",
"getValue",
"(",
")",
".",
"equals",
"(",
"\"*\"",
")",
")",
"{",
"filter",
"=",
"new",
"TagVWildcardFilter",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"\"*\"",
",",
"true",
")",
";",
"}",
"else",
"if",
"(",
"filter",
"==",
"null",
")",
"{",
"filter",
"=",
"new",
"TagVLiteralOrFilter",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"entry",
".",
"getValue",
"(",
")",
")",
";",
"}",
"if",
"(",
"group_by",
")",
"{",
"filter",
".",
"setGroupBy",
"(",
"true",
")",
";",
"boolean",
"duplicate",
"=",
"false",
";",
"for",
"(",
"final",
"TagVFilter",
"existing",
":",
"filters",
")",
"{",
"if",
"(",
"filter",
".",
"equals",
"(",
"existing",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Skipping duplicate filter: \"",
"+",
"existing",
")",
";",
"existing",
".",
"setGroupBy",
"(",
"true",
")",
";",
"duplicate",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"duplicate",
")",
"{",
"filters",
".",
"add",
"(",
"filter",
")",
";",
"}",
"}",
"else",
"{",
"filters",
".",
"add",
"(",
"filter",
")",
";",
"}",
"}",
"}"
] |
Converts the map to a filter list. If a filter already exists for a
tag group by and we're told to process group bys, then the duplicate
is skipped.
@param map A set of tag keys and values. May be null or empty.
@param filters A set of filters to add the converted filters to. This may
not be null.
@param group_by Whether or not to set the group by flag and kick dupes
|
[
"Converts",
"the",
"map",
"to",
"a",
"filter",
"list",
".",
"If",
"a",
"filter",
"already",
"exists",
"for",
"a",
"tag",
"group",
"by",
"and",
"we",
"re",
"told",
"to",
"process",
"group",
"bys",
"then",
"the",
"duplicate",
"is",
"skipped",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/filter/TagVFilter.java#L318-L352
|
13,511
|
OpenTSDB/opentsdb
|
src/query/filter/TagVFilter.java
|
TagVFilter.loadedFilters
|
public static Map<String, Map<String, String>> loadedFilters() {
final Map<String, Map<String, String>> filters =
new HashMap<String, Map<String, String>>(tagv_filter_map.size());
for (final Pair<Class<?>, Constructor<? extends TagVFilter>> pair :
tagv_filter_map.values()) {
final Map<String, String> filter_meta = new HashMap<String, String>(1);
try {
Method method = pair.getKey().getDeclaredMethod("description");
filter_meta.put("description", (String)method.invoke(null));
method = pair.getKey().getDeclaredMethod("examples");
filter_meta.put("examples", (String)method.invoke(null));
final Field filter_name = pair.getKey().getDeclaredField("FILTER_NAME");
filters.put((String)filter_name.get(null), filter_meta);
} catch (SecurityException e) {
throw new RuntimeException("Unexpected security exception", e);
} catch (NoSuchMethodException e) {
LOG.error("Filter plugin " + pair.getClass().getCanonicalName() +
" did not implement one of the \"description\" or \"examples\" methods");
} catch (NoSuchFieldException e) {
LOG.error("Filter plugin " + pair.getClass().getCanonicalName() +
" did not have the \"FILTER_NAME\" field");
} catch (IllegalArgumentException e) {
throw new RuntimeException("Unexpected exception", e);
} catch (IllegalAccessException e) {
throw new RuntimeException("Unexpected security exception", e);
} catch (InvocationTargetException e) {
throw new RuntimeException("Unexpected security exception", e);
}
}
return filters;
}
|
java
|
public static Map<String, Map<String, String>> loadedFilters() {
final Map<String, Map<String, String>> filters =
new HashMap<String, Map<String, String>>(tagv_filter_map.size());
for (final Pair<Class<?>, Constructor<? extends TagVFilter>> pair :
tagv_filter_map.values()) {
final Map<String, String> filter_meta = new HashMap<String, String>(1);
try {
Method method = pair.getKey().getDeclaredMethod("description");
filter_meta.put("description", (String)method.invoke(null));
method = pair.getKey().getDeclaredMethod("examples");
filter_meta.put("examples", (String)method.invoke(null));
final Field filter_name = pair.getKey().getDeclaredField("FILTER_NAME");
filters.put((String)filter_name.get(null), filter_meta);
} catch (SecurityException e) {
throw new RuntimeException("Unexpected security exception", e);
} catch (NoSuchMethodException e) {
LOG.error("Filter plugin " + pair.getClass().getCanonicalName() +
" did not implement one of the \"description\" or \"examples\" methods");
} catch (NoSuchFieldException e) {
LOG.error("Filter plugin " + pair.getClass().getCanonicalName() +
" did not have the \"FILTER_NAME\" field");
} catch (IllegalArgumentException e) {
throw new RuntimeException("Unexpected exception", e);
} catch (IllegalAccessException e) {
throw new RuntimeException("Unexpected security exception", e);
} catch (InvocationTargetException e) {
throw new RuntimeException("Unexpected security exception", e);
}
}
return filters;
}
|
[
"public",
"static",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"loadedFilters",
"(",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"filters",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"(",
"tagv_filter_map",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"final",
"Pair",
"<",
"Class",
"<",
"?",
">",
",",
"Constructor",
"<",
"?",
"extends",
"TagVFilter",
">",
">",
"pair",
":",
"tagv_filter_map",
".",
"values",
"(",
")",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"filter_meta",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
"1",
")",
";",
"try",
"{",
"Method",
"method",
"=",
"pair",
".",
"getKey",
"(",
")",
".",
"getDeclaredMethod",
"(",
"\"description\"",
")",
";",
"filter_meta",
".",
"put",
"(",
"\"description\"",
",",
"(",
"String",
")",
"method",
".",
"invoke",
"(",
"null",
")",
")",
";",
"method",
"=",
"pair",
".",
"getKey",
"(",
")",
".",
"getDeclaredMethod",
"(",
"\"examples\"",
")",
";",
"filter_meta",
".",
"put",
"(",
"\"examples\"",
",",
"(",
"String",
")",
"method",
".",
"invoke",
"(",
"null",
")",
")",
";",
"final",
"Field",
"filter_name",
"=",
"pair",
".",
"getKey",
"(",
")",
".",
"getDeclaredField",
"(",
"\"FILTER_NAME\"",
")",
";",
"filters",
".",
"put",
"(",
"(",
"String",
")",
"filter_name",
".",
"get",
"(",
"null",
")",
",",
"filter_meta",
")",
";",
"}",
"catch",
"(",
"SecurityException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected security exception\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"NoSuchMethodException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Filter plugin \"",
"+",
"pair",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
"+",
"\" did not implement one of the \\\"description\\\" or \\\"examples\\\" methods\"",
")",
";",
"}",
"catch",
"(",
"NoSuchFieldException",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Filter plugin \"",
"+",
"pair",
".",
"getClass",
"(",
")",
".",
"getCanonicalName",
"(",
")",
"+",
"\" did not have the \\\"FILTER_NAME\\\" field\"",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected exception\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IllegalAccessException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected security exception\"",
",",
"e",
")",
";",
"}",
"catch",
"(",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected security exception\"",
",",
"e",
")",
";",
"}",
"}",
"return",
"filters",
";",
"}"
] |
Runs through the loaded plugin map and dumps the names, description and
examples into a map to serialize via the API.
@return A map of filter meta data.
|
[
"Runs",
"through",
"the",
"loaded",
"plugin",
"map",
"and",
"dumps",
"the",
"names",
"description",
"and",
"examples",
"into",
"a",
"map",
"to",
"serialize",
"via",
"the",
"API",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/filter/TagVFilter.java#L359-L392
|
13,512
|
OpenTSDB/opentsdb
|
src/tools/Fsck.java
|
Fsck.runQueries
|
public void runQueries(final List<Query> queries) throws Exception {
final long start_time = System.currentTimeMillis() / 1000;
// TODO - threadify it. We *could* have hundreds of queries and we don't
// want to create that many threads. For now we'll just execute each one
// serially
final Thread reporter = new ProgressReporter();
reporter.start();
for (final Query query : queries) {
final List<Scanner> scanners = Internal.getScanners(query);
final List<Thread> threads = new ArrayList<Thread>(scanners.size());
int i = 0;
for (final Scanner scanner : scanners) {
final FsckWorker worker = new FsckWorker(scanner, i++, this.options);
worker.setName("Fsck #" + i);
worker.start();
threads.add(worker);
}
for (final Thread thread : threads) {
thread.join();
LOG.info("Thread [" + thread + "] Finished");
}
}
reporter.interrupt();
logResults();
final long duration = (System.currentTimeMillis() / 1000) - start_time;
LOG.info("Completed fsck in [" + duration + "] seconds");
}
|
java
|
public void runQueries(final List<Query> queries) throws Exception {
final long start_time = System.currentTimeMillis() / 1000;
// TODO - threadify it. We *could* have hundreds of queries and we don't
// want to create that many threads. For now we'll just execute each one
// serially
final Thread reporter = new ProgressReporter();
reporter.start();
for (final Query query : queries) {
final List<Scanner> scanners = Internal.getScanners(query);
final List<Thread> threads = new ArrayList<Thread>(scanners.size());
int i = 0;
for (final Scanner scanner : scanners) {
final FsckWorker worker = new FsckWorker(scanner, i++, this.options);
worker.setName("Fsck #" + i);
worker.start();
threads.add(worker);
}
for (final Thread thread : threads) {
thread.join();
LOG.info("Thread [" + thread + "] Finished");
}
}
reporter.interrupt();
logResults();
final long duration = (System.currentTimeMillis() / 1000) - start_time;
LOG.info("Completed fsck in [" + duration + "] seconds");
}
|
[
"public",
"void",
"runQueries",
"(",
"final",
"List",
"<",
"Query",
">",
"queries",
")",
"throws",
"Exception",
"{",
"final",
"long",
"start_time",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"/",
"1000",
";",
"// TODO - threadify it. We *could* have hundreds of queries and we don't",
"// want to create that many threads. For now we'll just execute each one",
"// serially",
"final",
"Thread",
"reporter",
"=",
"new",
"ProgressReporter",
"(",
")",
";",
"reporter",
".",
"start",
"(",
")",
";",
"for",
"(",
"final",
"Query",
"query",
":",
"queries",
")",
"{",
"final",
"List",
"<",
"Scanner",
">",
"scanners",
"=",
"Internal",
".",
"getScanners",
"(",
"query",
")",
";",
"final",
"List",
"<",
"Thread",
">",
"threads",
"=",
"new",
"ArrayList",
"<",
"Thread",
">",
"(",
"scanners",
".",
"size",
"(",
")",
")",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"final",
"Scanner",
"scanner",
":",
"scanners",
")",
"{",
"final",
"FsckWorker",
"worker",
"=",
"new",
"FsckWorker",
"(",
"scanner",
",",
"i",
"++",
",",
"this",
".",
"options",
")",
";",
"worker",
".",
"setName",
"(",
"\"Fsck #\"",
"+",
"i",
")",
";",
"worker",
".",
"start",
"(",
")",
";",
"threads",
".",
"add",
"(",
"worker",
")",
";",
"}",
"for",
"(",
"final",
"Thread",
"thread",
":",
"threads",
")",
"{",
"thread",
".",
"join",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Thread [\"",
"+",
"thread",
"+",
"\"] Finished\"",
")",
";",
"}",
"}",
"reporter",
".",
"interrupt",
"(",
")",
";",
"logResults",
"(",
")",
";",
"final",
"long",
"duration",
"=",
"(",
"System",
".",
"currentTimeMillis",
"(",
")",
"/",
"1000",
")",
"-",
"start_time",
";",
"LOG",
".",
"info",
"(",
"\"Completed fsck in [\"",
"+",
"duration",
"+",
"\"] seconds\"",
")",
";",
"}"
] |
Scans the rows matching one or more standard queries. An aggregator is still
required though it's ignored.
@param queries The queries to execute
@throws Exception If something goes pear shaped.
|
[
"Scans",
"the",
"rows",
"matching",
"one",
"or",
"more",
"standard",
"queries",
".",
"An",
"aggregator",
"is",
"still",
"required",
"though",
"it",
"s",
"ignored",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/Fsck.java#L183-L213
|
13,513
|
OpenTSDB/opentsdb
|
src/tools/Fsck.java
|
Fsck.usage
|
private static void usage(final ArgP argp, final String errmsg,
final int retval) {
System.err.println(errmsg);
System.err.println("Usage: fsck"
+ " [flags] [START-DATE [END-DATE] query [queries...]] \n"
+ "Scans the OpenTSDB data table for errors. Use the --full-scan flag\n"
+ "to scan the entire data table or specify a command line query to "
+ "scan a subset.\n"
+ "To see the format in which queries should be written, see the help"
+ " of the 'query' command.\n"
+ "The --fix or --fix-all flags will attempt to fix errors,"
+ " but be careful when using them.\n");
System.err.print(argp.usage());
System.exit(retval);
}
|
java
|
private static void usage(final ArgP argp, final String errmsg,
final int retval) {
System.err.println(errmsg);
System.err.println("Usage: fsck"
+ " [flags] [START-DATE [END-DATE] query [queries...]] \n"
+ "Scans the OpenTSDB data table for errors. Use the --full-scan flag\n"
+ "to scan the entire data table or specify a command line query to "
+ "scan a subset.\n"
+ "To see the format in which queries should be written, see the help"
+ " of the 'query' command.\n"
+ "The --fix or --fix-all flags will attempt to fix errors,"
+ " but be careful when using them.\n");
System.err.print(argp.usage());
System.exit(retval);
}
|
[
"private",
"static",
"void",
"usage",
"(",
"final",
"ArgP",
"argp",
",",
"final",
"String",
"errmsg",
",",
"final",
"int",
"retval",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"errmsg",
")",
";",
"System",
".",
"err",
".",
"println",
"(",
"\"Usage: fsck\"",
"+",
"\" [flags] [START-DATE [END-DATE] query [queries...]] \\n\"",
"+",
"\"Scans the OpenTSDB data table for errors. Use the --full-scan flag\\n\"",
"+",
"\"to scan the entire data table or specify a command line query to \"",
"+",
"\"scan a subset.\\n\"",
"+",
"\"To see the format in which queries should be written, see the help\"",
"+",
"\" of the 'query' command.\\n\"",
"+",
"\"The --fix or --fix-all flags will attempt to fix errors,\"",
"+",
"\" but be careful when using them.\\n\"",
")",
";",
"System",
".",
"err",
".",
"print",
"(",
"argp",
".",
"usage",
"(",
")",
")",
";",
"System",
".",
"exit",
"(",
"retval",
")",
";",
"}"
] |
Prints usage and exits with the given retval.
|
[
"Prints",
"usage",
"and",
"exits",
"with",
"the",
"given",
"retval",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/Fsck.java#L1216-L1230
|
13,514
|
OpenTSDB/opentsdb
|
src/tools/Fsck.java
|
Fsck.logResults
|
private void logResults() {
LOG.info("Key Values Processed: " + kvs_processed.get());
LOG.info("Rows Processed: " + rows_processed.get());
LOG.info("Valid Datapoints: " + valid_datapoints.get());
LOG.info("Annotations: " + annotations.get());
LOG.info("Invalid Row Keys Found: " + bad_key.get());
LOG.info("Invalid Rows Deleted: " + bad_key_fixed.get());
LOG.info("Duplicate Datapoints: " + duplicates.get());
LOG.info("Duplicate Datapoints Resolved: " + duplicates_fixed.get());
LOG.info("Orphaned UID Rows: " + orphans.get());
LOG.info("Orphaned UID Rows Deleted: " + orphans_fixed.get());
LOG.info("Possible Future Objects: " + future.get());
LOG.info("Unknown Objects: " + unknown.get());
LOG.info("Unknown Objects Deleted: " + unknown_fixed.get());
LOG.info("Unparseable Datapoint Values: " + bad_values.get());
LOG.info("Unparseable Datapoint Values Deleted: " + bad_values_deleted.get());
LOG.info("Improperly Encoded Floating Point Values: " + value_encoding.get());
LOG.info("Improperly Encoded Floating Point Values Fixed: " +
value_encoding_fixed.get());
LOG.info("Unparseable Compacted Columns: " + bad_compacted_columns.get());
LOG.info("Unparseable Compacted Columns Deleted: " +
bad_compacted_columns_deleted.get());
LOG.info("Datapoints Qualified for VLE : " + vle.get());
LOG.info("Datapoints Compressed with VLE: " + vle_fixed.get());
LOG.info("Bytes Saved with VLE: " + vle_bytes.get());
LOG.info("Total Errors: " + totalErrors());
LOG.info("Total Correctable Errors: " + correctable());
LOG.info("Total Errors Fixed: " + totalFixed());
}
|
java
|
private void logResults() {
LOG.info("Key Values Processed: " + kvs_processed.get());
LOG.info("Rows Processed: " + rows_processed.get());
LOG.info("Valid Datapoints: " + valid_datapoints.get());
LOG.info("Annotations: " + annotations.get());
LOG.info("Invalid Row Keys Found: " + bad_key.get());
LOG.info("Invalid Rows Deleted: " + bad_key_fixed.get());
LOG.info("Duplicate Datapoints: " + duplicates.get());
LOG.info("Duplicate Datapoints Resolved: " + duplicates_fixed.get());
LOG.info("Orphaned UID Rows: " + orphans.get());
LOG.info("Orphaned UID Rows Deleted: " + orphans_fixed.get());
LOG.info("Possible Future Objects: " + future.get());
LOG.info("Unknown Objects: " + unknown.get());
LOG.info("Unknown Objects Deleted: " + unknown_fixed.get());
LOG.info("Unparseable Datapoint Values: " + bad_values.get());
LOG.info("Unparseable Datapoint Values Deleted: " + bad_values_deleted.get());
LOG.info("Improperly Encoded Floating Point Values: " + value_encoding.get());
LOG.info("Improperly Encoded Floating Point Values Fixed: " +
value_encoding_fixed.get());
LOG.info("Unparseable Compacted Columns: " + bad_compacted_columns.get());
LOG.info("Unparseable Compacted Columns Deleted: " +
bad_compacted_columns_deleted.get());
LOG.info("Datapoints Qualified for VLE : " + vle.get());
LOG.info("Datapoints Compressed with VLE: " + vle_fixed.get());
LOG.info("Bytes Saved with VLE: " + vle_bytes.get());
LOG.info("Total Errors: " + totalErrors());
LOG.info("Total Correctable Errors: " + correctable());
LOG.info("Total Errors Fixed: " + totalFixed());
}
|
[
"private",
"void",
"logResults",
"(",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Key Values Processed: \"",
"+",
"kvs_processed",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Rows Processed: \"",
"+",
"rows_processed",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Valid Datapoints: \"",
"+",
"valid_datapoints",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Annotations: \"",
"+",
"annotations",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Invalid Row Keys Found: \"",
"+",
"bad_key",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Invalid Rows Deleted: \"",
"+",
"bad_key_fixed",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Duplicate Datapoints: \"",
"+",
"duplicates",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Duplicate Datapoints Resolved: \"",
"+",
"duplicates_fixed",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Orphaned UID Rows: \"",
"+",
"orphans",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Orphaned UID Rows Deleted: \"",
"+",
"orphans_fixed",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Possible Future Objects: \"",
"+",
"future",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Unknown Objects: \"",
"+",
"unknown",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Unknown Objects Deleted: \"",
"+",
"unknown_fixed",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Unparseable Datapoint Values: \"",
"+",
"bad_values",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Unparseable Datapoint Values Deleted: \"",
"+",
"bad_values_deleted",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Improperly Encoded Floating Point Values: \"",
"+",
"value_encoding",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Improperly Encoded Floating Point Values Fixed: \"",
"+",
"value_encoding_fixed",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Unparseable Compacted Columns: \"",
"+",
"bad_compacted_columns",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Unparseable Compacted Columns Deleted: \"",
"+",
"bad_compacted_columns_deleted",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Datapoints Qualified for VLE : \"",
"+",
"vle",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Datapoints Compressed with VLE: \"",
"+",
"vle_fixed",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Bytes Saved with VLE: \"",
"+",
"vle_bytes",
".",
"get",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Total Errors: \"",
"+",
"totalErrors",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Total Correctable Errors: \"",
"+",
"correctable",
"(",
")",
")",
";",
"LOG",
".",
"info",
"(",
"\"Total Errors Fixed: \"",
"+",
"totalFixed",
"(",
")",
")",
";",
"}"
] |
Helper to dump the atomic counters to the log after a completed FSCK
|
[
"Helper",
"to",
"dump",
"the",
"atomic",
"counters",
"to",
"the",
"log",
"after",
"a",
"completed",
"FSCK"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/Fsck.java#L1235-L1263
|
13,515
|
OpenTSDB/opentsdb
|
src/tools/Fsck.java
|
Fsck.main
|
public static void main(String[] args) throws Exception {
ArgP argp = new ArgP();
argp.addOption("--help", "Print help information.");
CliOptions.addCommon(argp);
FsckOptions.addDataOptions(argp);
args = CliOptions.parse(argp, args);
if (argp.has("--help")) {
usage(argp, "", 0);
}
Config config = CliOptions.getConfig(argp);
final FsckOptions options = new FsckOptions(argp, config);
final TSDB tsdb = new TSDB(config);
final ArrayList<Query> queries = new ArrayList<Query>();
if (args != null && args.length > 0) {
CliQuery.parseCommandLineQuery(args, tsdb, queries, null, null);
}
if (queries.isEmpty() && !argp.has("--full-scan")) {
usage(argp, "Must supply a query or use the '--full-scan' flag", 1);
}
tsdb.checkNecessaryTablesExist().joinUninterruptibly();
argp = null;
final Fsck fsck = new Fsck(tsdb, options);
try {
if (!queries.isEmpty()) {
fsck.runQueries(queries);
} else {
fsck.runFullTable();
}
} finally {
tsdb.shutdown().joinUninterruptibly();
}
System.exit(fsck.totalErrors() == 0 ? 0 : 1);
}
|
java
|
public static void main(String[] args) throws Exception {
ArgP argp = new ArgP();
argp.addOption("--help", "Print help information.");
CliOptions.addCommon(argp);
FsckOptions.addDataOptions(argp);
args = CliOptions.parse(argp, args);
if (argp.has("--help")) {
usage(argp, "", 0);
}
Config config = CliOptions.getConfig(argp);
final FsckOptions options = new FsckOptions(argp, config);
final TSDB tsdb = new TSDB(config);
final ArrayList<Query> queries = new ArrayList<Query>();
if (args != null && args.length > 0) {
CliQuery.parseCommandLineQuery(args, tsdb, queries, null, null);
}
if (queries.isEmpty() && !argp.has("--full-scan")) {
usage(argp, "Must supply a query or use the '--full-scan' flag", 1);
}
tsdb.checkNecessaryTablesExist().joinUninterruptibly();
argp = null;
final Fsck fsck = new Fsck(tsdb, options);
try {
if (!queries.isEmpty()) {
fsck.runQueries(queries);
} else {
fsck.runFullTable();
}
} finally {
tsdb.shutdown().joinUninterruptibly();
}
System.exit(fsck.totalErrors() == 0 ? 0 : 1);
}
|
[
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"throws",
"Exception",
"{",
"ArgP",
"argp",
"=",
"new",
"ArgP",
"(",
")",
";",
"argp",
".",
"addOption",
"(",
"\"--help\"",
",",
"\"Print help information.\"",
")",
";",
"CliOptions",
".",
"addCommon",
"(",
"argp",
")",
";",
"FsckOptions",
".",
"addDataOptions",
"(",
"argp",
")",
";",
"args",
"=",
"CliOptions",
".",
"parse",
"(",
"argp",
",",
"args",
")",
";",
"if",
"(",
"argp",
".",
"has",
"(",
"\"--help\"",
")",
")",
"{",
"usage",
"(",
"argp",
",",
"\"\"",
",",
"0",
")",
";",
"}",
"Config",
"config",
"=",
"CliOptions",
".",
"getConfig",
"(",
"argp",
")",
";",
"final",
"FsckOptions",
"options",
"=",
"new",
"FsckOptions",
"(",
"argp",
",",
"config",
")",
";",
"final",
"TSDB",
"tsdb",
"=",
"new",
"TSDB",
"(",
"config",
")",
";",
"final",
"ArrayList",
"<",
"Query",
">",
"queries",
"=",
"new",
"ArrayList",
"<",
"Query",
">",
"(",
")",
";",
"if",
"(",
"args",
"!=",
"null",
"&&",
"args",
".",
"length",
">",
"0",
")",
"{",
"CliQuery",
".",
"parseCommandLineQuery",
"(",
"args",
",",
"tsdb",
",",
"queries",
",",
"null",
",",
"null",
")",
";",
"}",
"if",
"(",
"queries",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"argp",
".",
"has",
"(",
"\"--full-scan\"",
")",
")",
"{",
"usage",
"(",
"argp",
",",
"\"Must supply a query or use the '--full-scan' flag\"",
",",
"1",
")",
";",
"}",
"tsdb",
".",
"checkNecessaryTablesExist",
"(",
")",
".",
"joinUninterruptibly",
"(",
")",
";",
"argp",
"=",
"null",
";",
"final",
"Fsck",
"fsck",
"=",
"new",
"Fsck",
"(",
"tsdb",
",",
"options",
")",
";",
"try",
"{",
"if",
"(",
"!",
"queries",
".",
"isEmpty",
"(",
")",
")",
"{",
"fsck",
".",
"runQueries",
"(",
"queries",
")",
";",
"}",
"else",
"{",
"fsck",
".",
"runFullTable",
"(",
")",
";",
"}",
"}",
"finally",
"{",
"tsdb",
".",
"shutdown",
"(",
")",
".",
"joinUninterruptibly",
"(",
")",
";",
"}",
"System",
".",
"exit",
"(",
"fsck",
".",
"totalErrors",
"(",
")",
"==",
"0",
"?",
"0",
":",
"1",
")",
";",
"}"
] |
The main class executed from the "tsdb" script
@param args Command line arguments to parse
@throws Exception If something goes pear shaped
|
[
"The",
"main",
"class",
"executed",
"from",
"the",
"tsdb",
"script"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/Fsck.java#L1270-L1305
|
13,516
|
OpenTSDB/opentsdb
|
src/query/filter/TagVLiteralOrFilter.java
|
TagVLiteralOrFilter.resolveTagkName
|
@Override
public Deferred<byte[]> resolveTagkName(final TSDB tsdb) {
final Config config = tsdb.getConfig();
// resolve tag values if the filter is NOT case insensitive and there are
// fewer literals than the expansion limit
if (!case_insensitive &&
literals.size() <= config.getInt("tsd.query.filter.expansion_limit")) {
return resolveTags(tsdb, literals);
} else {
return super.resolveTagkName(tsdb);
}
}
|
java
|
@Override
public Deferred<byte[]> resolveTagkName(final TSDB tsdb) {
final Config config = tsdb.getConfig();
// resolve tag values if the filter is NOT case insensitive and there are
// fewer literals than the expansion limit
if (!case_insensitive &&
literals.size() <= config.getInt("tsd.query.filter.expansion_limit")) {
return resolveTags(tsdb, literals);
} else {
return super.resolveTagkName(tsdb);
}
}
|
[
"@",
"Override",
"public",
"Deferred",
"<",
"byte",
"[",
"]",
">",
"resolveTagkName",
"(",
"final",
"TSDB",
"tsdb",
")",
"{",
"final",
"Config",
"config",
"=",
"tsdb",
".",
"getConfig",
"(",
")",
";",
"// resolve tag values if the filter is NOT case insensitive and there are ",
"// fewer literals than the expansion limit",
"if",
"(",
"!",
"case_insensitive",
"&&",
"literals",
".",
"size",
"(",
")",
"<=",
"config",
".",
"getInt",
"(",
"\"tsd.query.filter.expansion_limit\"",
")",
")",
"{",
"return",
"resolveTags",
"(",
"tsdb",
",",
"literals",
")",
";",
"}",
"else",
"{",
"return",
"super",
".",
"resolveTagkName",
"(",
"tsdb",
")",
";",
"}",
"}"
] |
Overridden here so that we can resolve the literal values if we don't have
too many of them AND we're not searching with case insensitivity.
|
[
"Overridden",
"here",
"so",
"that",
"we",
"can",
"resolve",
"the",
"literal",
"values",
"if",
"we",
"don",
"t",
"have",
"too",
"many",
"of",
"them",
"AND",
"we",
"re",
"not",
"searching",
"with",
"case",
"insensitivity",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/filter/TagVLiteralOrFilter.java#L100-L112
|
13,517
|
OpenTSDB/opentsdb
|
src/tools/GnuplotInstaller.java
|
GnuplotInstaller.installMyGnuPlot
|
public static void installMyGnuPlot() {
if(!FOUND_GP) {
LOG.warn("Skipping Gnuplot Shell Script Install since Gnuplot executable was not found");
return;
}
if(!GP_FILE.exists()) {
if(!GP_FILE.getParentFile().exists()) {
GP_FILE.getParentFile().mkdirs();
}
InputStream is = null;
FileOutputStream fos = null;
try {
is = GnuplotInstaller.class.getClassLoader().getResourceAsStream(GP_BATCH_FILE_NAME);
ChannelBuffer buff = new DynamicChannelBuffer(is.available());
buff.writeBytes(is, is.available());
is.close(); is = null;
fos = new FileOutputStream(GP_FILE);
buff.readBytes(fos, buff.readableBytes());
fos.close(); fos = null;
GP_FILE.setExecutable(true);
} catch (Exception ex) {
throw new IllegalArgumentException("Failed to install mygnuplot", ex);
} finally {
if( is!=null ) try { is.close(); } catch (Exception x) { /* No Op */ }
if( fos!=null ) try { fos.close(); } catch (Exception x) { /* No Op */ }
}
}
}
|
java
|
public static void installMyGnuPlot() {
if(!FOUND_GP) {
LOG.warn("Skipping Gnuplot Shell Script Install since Gnuplot executable was not found");
return;
}
if(!GP_FILE.exists()) {
if(!GP_FILE.getParentFile().exists()) {
GP_FILE.getParentFile().mkdirs();
}
InputStream is = null;
FileOutputStream fos = null;
try {
is = GnuplotInstaller.class.getClassLoader().getResourceAsStream(GP_BATCH_FILE_NAME);
ChannelBuffer buff = new DynamicChannelBuffer(is.available());
buff.writeBytes(is, is.available());
is.close(); is = null;
fos = new FileOutputStream(GP_FILE);
buff.readBytes(fos, buff.readableBytes());
fos.close(); fos = null;
GP_FILE.setExecutable(true);
} catch (Exception ex) {
throw new IllegalArgumentException("Failed to install mygnuplot", ex);
} finally {
if( is!=null ) try { is.close(); } catch (Exception x) { /* No Op */ }
if( fos!=null ) try { fos.close(); } catch (Exception x) { /* No Op */ }
}
}
}
|
[
"public",
"static",
"void",
"installMyGnuPlot",
"(",
")",
"{",
"if",
"(",
"!",
"FOUND_GP",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Skipping Gnuplot Shell Script Install since Gnuplot executable was not found\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"!",
"GP_FILE",
".",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"!",
"GP_FILE",
".",
"getParentFile",
"(",
")",
".",
"exists",
"(",
")",
")",
"{",
"GP_FILE",
".",
"getParentFile",
"(",
")",
".",
"mkdirs",
"(",
")",
";",
"}",
"InputStream",
"is",
"=",
"null",
";",
"FileOutputStream",
"fos",
"=",
"null",
";",
"try",
"{",
"is",
"=",
"GnuplotInstaller",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResourceAsStream",
"(",
"GP_BATCH_FILE_NAME",
")",
";",
"ChannelBuffer",
"buff",
"=",
"new",
"DynamicChannelBuffer",
"(",
"is",
".",
"available",
"(",
")",
")",
";",
"buff",
".",
"writeBytes",
"(",
"is",
",",
"is",
".",
"available",
"(",
")",
")",
";",
"is",
".",
"close",
"(",
")",
";",
"is",
"=",
"null",
";",
"fos",
"=",
"new",
"FileOutputStream",
"(",
"GP_FILE",
")",
";",
"buff",
".",
"readBytes",
"(",
"fos",
",",
"buff",
".",
"readableBytes",
"(",
")",
")",
";",
"fos",
".",
"close",
"(",
")",
";",
"fos",
"=",
"null",
";",
"GP_FILE",
".",
"setExecutable",
"(",
"true",
")",
";",
"}",
"catch",
"(",
"Exception",
"ex",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Failed to install mygnuplot\"",
",",
"ex",
")",
";",
"}",
"finally",
"{",
"if",
"(",
"is",
"!=",
"null",
")",
"try",
"{",
"is",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"x",
")",
"{",
"/* No Op */",
"}",
"if",
"(",
"fos",
"!=",
"null",
")",
"try",
"{",
"fos",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"x",
")",
"{",
"/* No Op */",
"}",
"}",
"}",
"}"
] |
Installs the mygnuplot shell file
|
[
"Installs",
"the",
"mygnuplot",
"shell",
"file"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/GnuplotInstaller.java#L78-L105
|
13,518
|
OpenTSDB/opentsdb
|
src/core/IncomingDataPoint.java
|
IncomingDataPoint.validate
|
public boolean validate(final List<Map<String, Object>> details) {
if (this.getMetric() == null || this.getMetric().isEmpty()) {
if (details != null) {
details.add(getHttpDetails("Metric name was empty"));
}
LOG.warn("Metric name was empty: " + this);
return false;
}
//TODO add blacklisted metric validatin here too
if (this.getTimestamp() <= 0) {
if (details != null) {
details.add(getHttpDetails("Invalid timestamp"));
}
LOG.warn("Invalid timestamp: " + this);
return false;
}
if (this.getValue() == null || this.getValue().isEmpty()) {
if (details != null) {
details.add(getHttpDetails("Empty value"));
}
LOG.warn("Empty value: " + this);
return false;
}
if (this.getTags() == null || this.getTags().size() < 1) {
if (details != null) {
details.add(getHttpDetails("Missing tags"));
}
LOG.warn("Missing tags: " + this);
return false;
}
return true;
}
|
java
|
public boolean validate(final List<Map<String, Object>> details) {
if (this.getMetric() == null || this.getMetric().isEmpty()) {
if (details != null) {
details.add(getHttpDetails("Metric name was empty"));
}
LOG.warn("Metric name was empty: " + this);
return false;
}
//TODO add blacklisted metric validatin here too
if (this.getTimestamp() <= 0) {
if (details != null) {
details.add(getHttpDetails("Invalid timestamp"));
}
LOG.warn("Invalid timestamp: " + this);
return false;
}
if (this.getValue() == null || this.getValue().isEmpty()) {
if (details != null) {
details.add(getHttpDetails("Empty value"));
}
LOG.warn("Empty value: " + this);
return false;
}
if (this.getTags() == null || this.getTags().size() < 1) {
if (details != null) {
details.add(getHttpDetails("Missing tags"));
}
LOG.warn("Missing tags: " + this);
return false;
}
return true;
}
|
[
"public",
"boolean",
"validate",
"(",
"final",
"List",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"details",
")",
"{",
"if",
"(",
"this",
".",
"getMetric",
"(",
")",
"==",
"null",
"||",
"this",
".",
"getMetric",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"details",
"!=",
"null",
")",
"{",
"details",
".",
"add",
"(",
"getHttpDetails",
"(",
"\"Metric name was empty\"",
")",
")",
";",
"}",
"LOG",
".",
"warn",
"(",
"\"Metric name was empty: \"",
"+",
"this",
")",
";",
"return",
"false",
";",
"}",
"//TODO add blacklisted metric validatin here too",
"if",
"(",
"this",
".",
"getTimestamp",
"(",
")",
"<=",
"0",
")",
"{",
"if",
"(",
"details",
"!=",
"null",
")",
"{",
"details",
".",
"add",
"(",
"getHttpDetails",
"(",
"\"Invalid timestamp\"",
")",
")",
";",
"}",
"LOG",
".",
"warn",
"(",
"\"Invalid timestamp: \"",
"+",
"this",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"getValue",
"(",
")",
"==",
"null",
"||",
"this",
".",
"getValue",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"details",
"!=",
"null",
")",
"{",
"details",
".",
"add",
"(",
"getHttpDetails",
"(",
"\"Empty value\"",
")",
")",
";",
"}",
"LOG",
".",
"warn",
"(",
"\"Empty value: \"",
"+",
"this",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"this",
".",
"getTags",
"(",
")",
"==",
"null",
"||",
"this",
".",
"getTags",
"(",
")",
".",
"size",
"(",
")",
"<",
"1",
")",
"{",
"if",
"(",
"details",
"!=",
"null",
")",
"{",
"details",
".",
"add",
"(",
"getHttpDetails",
"(",
"\"Missing tags\"",
")",
")",
";",
"}",
"LOG",
".",
"warn",
"(",
"\"Missing tags: \"",
"+",
"this",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Pre-validation of the various fields to make sure they're valid
@param details a map to hold detailed error message. If null then
the errors will be logged
@return true if data point is valid, otherwise false
|
[
"Pre",
"-",
"validation",
"of",
"the",
"various",
"fields",
"to",
"make",
"sure",
"they",
"re",
"valid"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/IncomingDataPoint.java#L175-L210
|
13,519
|
OpenTSDB/opentsdb
|
src/core/IncomingDataPoint.java
|
IncomingDataPoint.getHttpDetails
|
protected final Map<String, Object> getHttpDetails(final String message) {
final Map<String, Object> map = new HashMap<String, Object>();
map.put("error", message);
map.put("datapoint", this);
return map;
}
|
java
|
protected final Map<String, Object> getHttpDetails(final String message) {
final Map<String, Object> map = new HashMap<String, Object>();
map.put("error", message);
map.put("datapoint", this);
return map;
}
|
[
"protected",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"getHttpDetails",
"(",
"final",
"String",
"message",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"map",
".",
"put",
"(",
"\"error\"",
",",
"message",
")",
";",
"map",
".",
"put",
"(",
"\"datapoint\"",
",",
"this",
")",
";",
"return",
"map",
";",
"}"
] |
Creates a map with an error message and this data point to return
to the HTTP put data point RPC handler
@param message The message to log
@return A map to append to the HTTP response
|
[
"Creates",
"a",
"map",
"with",
"an",
"error",
"message",
"and",
"this",
"data",
"point",
"to",
"return",
"to",
"the",
"HTTP",
"put",
"data",
"point",
"RPC",
"handler"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/IncomingDataPoint.java#L218-L223
|
13,520
|
OpenTSDB/opentsdb
|
src/stats/Histogram.java
|
Histogram.printAsciiBucket
|
final void printAsciiBucket(final StringBuilder out, final int i) {
out.append('[')
.append(bucketLowInterval(i))
.append('-')
.append(i == buckets.length - 1 ? "Inf" : bucketHighInterval(i))
.append("): ")
.append(buckets[i])
.append('\n');
}
|
java
|
final void printAsciiBucket(final StringBuilder out, final int i) {
out.append('[')
.append(bucketLowInterval(i))
.append('-')
.append(i == buckets.length - 1 ? "Inf" : bucketHighInterval(i))
.append("): ")
.append(buckets[i])
.append('\n');
}
|
[
"final",
"void",
"printAsciiBucket",
"(",
"final",
"StringBuilder",
"out",
",",
"final",
"int",
"i",
")",
"{",
"out",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"bucketLowInterval",
"(",
"i",
")",
")",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"i",
"==",
"buckets",
".",
"length",
"-",
"1",
"?",
"\"Inf\"",
":",
"bucketHighInterval",
"(",
"i",
")",
")",
".",
"append",
"(",
"\"): \"",
")",
".",
"append",
"(",
"buckets",
"[",
"i",
"]",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"}"
] |
Prints a bucket of this histogram in a human readable ASCII format.
@param out The buffer to which to write the output.
@see #printAscii
|
[
"Prints",
"a",
"bucket",
"of",
"this",
"histogram",
"in",
"a",
"human",
"readable",
"ASCII",
"format",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/stats/Histogram.java#L216-L224
|
13,521
|
OpenTSDB/opentsdb
|
src/stats/Histogram.java
|
Histogram.bucketIndexFor
|
private int bucketIndexFor(final int value) {
if (value < cutoff) {
return value / interval;
}
int bucket = num_linear_buckets // Skip all linear buckets.
// And find which bucket the rest (after `cutoff') should be in.
// Reminder: the first exponential bucket ends at 2^exp_bucket_shift.
+ log2rounddown((value - cutoff) >> exp_bucket_shift);
if (bucket >= buckets.length) {
return buckets.length - 1;
}
return bucket;
}
|
java
|
private int bucketIndexFor(final int value) {
if (value < cutoff) {
return value / interval;
}
int bucket = num_linear_buckets // Skip all linear buckets.
// And find which bucket the rest (after `cutoff') should be in.
// Reminder: the first exponential bucket ends at 2^exp_bucket_shift.
+ log2rounddown((value - cutoff) >> exp_bucket_shift);
if (bucket >= buckets.length) {
return buckets.length - 1;
}
return bucket;
}
|
[
"private",
"int",
"bucketIndexFor",
"(",
"final",
"int",
"value",
")",
"{",
"if",
"(",
"value",
"<",
"cutoff",
")",
"{",
"return",
"value",
"/",
"interval",
";",
"}",
"int",
"bucket",
"=",
"num_linear_buckets",
"// Skip all linear buckets.",
"// And find which bucket the rest (after `cutoff') should be in.",
"// Reminder: the first exponential bucket ends at 2^exp_bucket_shift.",
"+",
"log2rounddown",
"(",
"(",
"value",
"-",
"cutoff",
")",
">>",
"exp_bucket_shift",
")",
";",
"if",
"(",
"bucket",
">=",
"buckets",
".",
"length",
")",
"{",
"return",
"buckets",
".",
"length",
"-",
"1",
";",
"}",
"return",
"bucket",
";",
"}"
] |
Finds the index of the bucket in which the given value should be.
|
[
"Finds",
"the",
"index",
"of",
"the",
"bucket",
"in",
"which",
"the",
"given",
"value",
"should",
"be",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/stats/Histogram.java#L232-L244
|
13,522
|
OpenTSDB/opentsdb
|
src/query/expression/TimeSyncedIterator.java
|
TimeSyncedIterator.setupEmitters
|
private void setupEmitters() {
// set the iterators
for (int i = 0; i < dps.length; i++) {
iterators[i] = dps[i].iterator();
if (!iterators[i].hasNext()) {
current_values[i] = null;
emitter_values[i] = null;
} else {
current_values[i] = iterators[i].next();
emitter_values[i] = new ExpressionDataPoint(dps[i]);
emitter_values[i].setIndex(i);
}
}
}
|
java
|
private void setupEmitters() {
// set the iterators
for (int i = 0; i < dps.length; i++) {
iterators[i] = dps[i].iterator();
if (!iterators[i].hasNext()) {
current_values[i] = null;
emitter_values[i] = null;
} else {
current_values[i] = iterators[i].next();
emitter_values[i] = new ExpressionDataPoint(dps[i]);
emitter_values[i].setIndex(i);
}
}
}
|
[
"private",
"void",
"setupEmitters",
"(",
")",
"{",
"// set the iterators",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"dps",
".",
"length",
";",
"i",
"++",
")",
"{",
"iterators",
"[",
"i",
"]",
"=",
"dps",
"[",
"i",
"]",
".",
"iterator",
"(",
")",
";",
"if",
"(",
"!",
"iterators",
"[",
"i",
"]",
".",
"hasNext",
"(",
")",
")",
"{",
"current_values",
"[",
"i",
"]",
"=",
"null",
";",
"emitter_values",
"[",
"i",
"]",
"=",
"null",
";",
"}",
"else",
"{",
"current_values",
"[",
"i",
"]",
"=",
"iterators",
"[",
"i",
"]",
".",
"next",
"(",
")",
";",
"emitter_values",
"[",
"i",
"]",
"=",
"new",
"ExpressionDataPoint",
"(",
"dps",
"[",
"i",
"]",
")",
";",
"emitter_values",
"[",
"i",
"]",
".",
"setIndex",
"(",
"i",
")",
";",
"}",
"}",
"}"
] |
Iterates over the values and sets up the current and emitter values
|
[
"Iterates",
"over",
"the",
"values",
"and",
"sets",
"up",
"the",
"current",
"and",
"emitter",
"values"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/expression/TimeSyncedIterator.java#L234-L247
|
13,523
|
OpenTSDB/opentsdb
|
src/query/pojo/Validatable.java
|
Validatable.validateCollection
|
<T extends Validatable> void validateCollection(final Collection<T> collection,
final String name) {
Iterator<T> iterator = collection.iterator();
int i = 0;
while (iterator.hasNext()) {
try {
iterator.next().validate();
} catch (final IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid " + name +
" at index " + i, e);
}
i++;
}
}
|
java
|
<T extends Validatable> void validateCollection(final Collection<T> collection,
final String name) {
Iterator<T> iterator = collection.iterator();
int i = 0;
while (iterator.hasNext()) {
try {
iterator.next().validate();
} catch (final IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid " + name +
" at index " + i, e);
}
i++;
}
}
|
[
"<",
"T",
"extends",
"Validatable",
">",
"void",
"validateCollection",
"(",
"final",
"Collection",
"<",
"T",
">",
"collection",
",",
"final",
"String",
"name",
")",
"{",
"Iterator",
"<",
"T",
">",
"iterator",
"=",
"collection",
".",
"iterator",
"(",
")",
";",
"int",
"i",
"=",
"0",
";",
"while",
"(",
"iterator",
".",
"hasNext",
"(",
")",
")",
"{",
"try",
"{",
"iterator",
".",
"next",
"(",
")",
".",
"validate",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"name",
"+",
"\" at index \"",
"+",
"i",
",",
"e",
")",
";",
"}",
"i",
"++",
";",
"}",
"}"
] |
Iterate through a field that is a collection of POJOs and validate each of
them. Inherit member POJO's error message.
@param collection the validatable POJO collection
@param name name of the field
|
[
"Iterate",
"through",
"a",
"field",
"that",
"is",
"a",
"collection",
"of",
"POJOs",
"and",
"validate",
"each",
"of",
"them",
".",
"Inherit",
"member",
"POJO",
"s",
"error",
"message",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/pojo/Validatable.java#L32-L45
|
13,524
|
OpenTSDB/opentsdb
|
src/query/pojo/Validatable.java
|
Validatable.validatePOJO
|
<T extends Validatable> void validatePOJO(final T pojo, final String name) {
try {
pojo.validate();
} catch (final IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid " + name, e);
}
}
|
java
|
<T extends Validatable> void validatePOJO(final T pojo, final String name) {
try {
pojo.validate();
} catch (final IllegalArgumentException e) {
throw new IllegalArgumentException("Invalid " + name, e);
}
}
|
[
"<",
"T",
"extends",
"Validatable",
">",
"void",
"validatePOJO",
"(",
"final",
"T",
"pojo",
",",
"final",
"String",
"name",
")",
"{",
"try",
"{",
"pojo",
".",
"validate",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid \"",
"+",
"name",
",",
"e",
")",
";",
"}",
"}"
] |
Validate a single POJO validate
@param pojo The POJO object to validate
@param name name of the field
|
[
"Validate",
"a",
"single",
"POJO",
"validate"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/pojo/Validatable.java#L52-L58
|
13,525
|
OpenTSDB/opentsdb
|
src/tsd/RpcManager.java
|
RpcManager.shutdown
|
public Deferred<ArrayList<Object>> shutdown() {
// Clear shared instance.
INSTANCE.set(null);
final Collection<Deferred<Object>> deferreds = Lists.newArrayList();
if (http_plugin_commands != null) {
for (final Map.Entry<String, HttpRpcPlugin> entry : http_plugin_commands.entrySet()) {
deferreds.add(entry.getValue().shutdown());
}
}
if (rpc_plugins != null) {
for (final RpcPlugin rpc : rpc_plugins) {
deferreds.add(rpc.shutdown());
}
}
return Deferred.groupInOrder(deferreds);
}
|
java
|
public Deferred<ArrayList<Object>> shutdown() {
// Clear shared instance.
INSTANCE.set(null);
final Collection<Deferred<Object>> deferreds = Lists.newArrayList();
if (http_plugin_commands != null) {
for (final Map.Entry<String, HttpRpcPlugin> entry : http_plugin_commands.entrySet()) {
deferreds.add(entry.getValue().shutdown());
}
}
if (rpc_plugins != null) {
for (final RpcPlugin rpc : rpc_plugins) {
deferreds.add(rpc.shutdown());
}
}
return Deferred.groupInOrder(deferreds);
}
|
[
"public",
"Deferred",
"<",
"ArrayList",
"<",
"Object",
">",
">",
"shutdown",
"(",
")",
"{",
"// Clear shared instance.",
"INSTANCE",
".",
"set",
"(",
"null",
")",
";",
"final",
"Collection",
"<",
"Deferred",
"<",
"Object",
">",
">",
"deferreds",
"=",
"Lists",
".",
"newArrayList",
"(",
")",
";",
"if",
"(",
"http_plugin_commands",
"!=",
"null",
")",
"{",
"for",
"(",
"final",
"Map",
".",
"Entry",
"<",
"String",
",",
"HttpRpcPlugin",
">",
"entry",
":",
"http_plugin_commands",
".",
"entrySet",
"(",
")",
")",
"{",
"deferreds",
".",
"add",
"(",
"entry",
".",
"getValue",
"(",
")",
".",
"shutdown",
"(",
")",
")",
";",
"}",
"}",
"if",
"(",
"rpc_plugins",
"!=",
"null",
")",
"{",
"for",
"(",
"final",
"RpcPlugin",
"rpc",
":",
"rpc_plugins",
")",
"{",
"deferreds",
".",
"add",
"(",
"rpc",
".",
"shutdown",
"(",
")",
")",
";",
"}",
"}",
"return",
"Deferred",
".",
"groupInOrder",
"(",
"deferreds",
")",
";",
"}"
] |
Called to gracefully shutdown the plugin. Implementations should close
any IO they have open
@return A deferred object that indicates the completion of the request.
The {@link Object} has not special meaning and can be {@code null}
(think of it as {@code Deferred<Void>}).
|
[
"Called",
"to",
"gracefully",
"shutdown",
"the",
"plugin",
".",
"Implementations",
"should",
"close",
"any",
"IO",
"they",
"have",
"open"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/RpcManager.java#L482-L501
|
13,526
|
OpenTSDB/opentsdb
|
src/tsd/RpcHandler.java
|
RpcHandler.handleTelnetRpc
|
private void handleTelnetRpc(final Channel chan, final String[] command) {
TelnetRpc rpc = rpc_manager.lookupTelnetRpc(command[0]);
if (rpc == null) {
rpc = unknown_cmd;
}
telnet_rpcs_received.incrementAndGet();
rpc.execute(tsdb, chan, command);
}
|
java
|
private void handleTelnetRpc(final Channel chan, final String[] command) {
TelnetRpc rpc = rpc_manager.lookupTelnetRpc(command[0]);
if (rpc == null) {
rpc = unknown_cmd;
}
telnet_rpcs_received.incrementAndGet();
rpc.execute(tsdb, chan, command);
}
|
[
"private",
"void",
"handleTelnetRpc",
"(",
"final",
"Channel",
"chan",
",",
"final",
"String",
"[",
"]",
"command",
")",
"{",
"TelnetRpc",
"rpc",
"=",
"rpc_manager",
".",
"lookupTelnetRpc",
"(",
"command",
"[",
"0",
"]",
")",
";",
"if",
"(",
"rpc",
"==",
"null",
")",
"{",
"rpc",
"=",
"unknown_cmd",
";",
"}",
"telnet_rpcs_received",
".",
"incrementAndGet",
"(",
")",
";",
"rpc",
".",
"execute",
"(",
"tsdb",
",",
"chan",
",",
"command",
")",
";",
"}"
] |
Finds the right handler for a telnet-style RPC and executes it.
@param chan The channel on which the RPC was received.
@param command The split telnet-style command.
|
[
"Finds",
"the",
"right",
"handler",
"for",
"a",
"telnet",
"-",
"style",
"RPC",
"and",
"executes",
"it",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/RpcHandler.java#L155-L162
|
13,527
|
OpenTSDB/opentsdb
|
src/tsd/RpcHandler.java
|
RpcHandler.createQueryInstance
|
private AbstractHttpQuery createQueryInstance(final TSDB tsdb,
final HttpRequest request,
final Channel chan)
throws BadRequestException {
final String uri = request.getUri();
if (Strings.isNullOrEmpty(uri)) {
throw new BadRequestException("Request URI is empty");
} else if (uri.charAt(0) != '/') {
throw new BadRequestException("Request URI doesn't start with a slash");
} else if (rpc_manager.isHttpRpcPluginPath(uri)) {
http_plugin_rpcs_received.incrementAndGet();
return new HttpRpcPluginQuery(tsdb, request, chan);
} else {
http_rpcs_received.incrementAndGet();
HttpQuery builtinQuery = new HttpQuery(tsdb, request, chan);
return builtinQuery;
}
}
|
java
|
private AbstractHttpQuery createQueryInstance(final TSDB tsdb,
final HttpRequest request,
final Channel chan)
throws BadRequestException {
final String uri = request.getUri();
if (Strings.isNullOrEmpty(uri)) {
throw new BadRequestException("Request URI is empty");
} else if (uri.charAt(0) != '/') {
throw new BadRequestException("Request URI doesn't start with a slash");
} else if (rpc_manager.isHttpRpcPluginPath(uri)) {
http_plugin_rpcs_received.incrementAndGet();
return new HttpRpcPluginQuery(tsdb, request, chan);
} else {
http_rpcs_received.incrementAndGet();
HttpQuery builtinQuery = new HttpQuery(tsdb, request, chan);
return builtinQuery;
}
}
|
[
"private",
"AbstractHttpQuery",
"createQueryInstance",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"HttpRequest",
"request",
",",
"final",
"Channel",
"chan",
")",
"throws",
"BadRequestException",
"{",
"final",
"String",
"uri",
"=",
"request",
".",
"getUri",
"(",
")",
";",
"if",
"(",
"Strings",
".",
"isNullOrEmpty",
"(",
"uri",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"\"Request URI is empty\"",
")",
";",
"}",
"else",
"if",
"(",
"uri",
".",
"charAt",
"(",
"0",
")",
"!=",
"'",
"'",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"\"Request URI doesn't start with a slash\"",
")",
";",
"}",
"else",
"if",
"(",
"rpc_manager",
".",
"isHttpRpcPluginPath",
"(",
"uri",
")",
")",
"{",
"http_plugin_rpcs_received",
".",
"incrementAndGet",
"(",
")",
";",
"return",
"new",
"HttpRpcPluginQuery",
"(",
"tsdb",
",",
"request",
",",
"chan",
")",
";",
"}",
"else",
"{",
"http_rpcs_received",
".",
"incrementAndGet",
"(",
")",
";",
"HttpQuery",
"builtinQuery",
"=",
"new",
"HttpQuery",
"(",
"tsdb",
",",
"request",
",",
"chan",
")",
";",
"return",
"builtinQuery",
";",
"}",
"}"
] |
Using the request URI, creates a query instance capable of handling
the given request.
@param tsdb the TSDB instance we are running within
@param request the incoming HTTP request
@param chan the {@link Channel} the request came in on.
@return a subclass of {@link AbstractHttpQuery}
@throws BadRequestException if the request is invalid in a way that
can be detected early, here.
|
[
"Using",
"the",
"request",
"URI",
"creates",
"a",
"query",
"instance",
"capable",
"of",
"handling",
"the",
"given",
"request",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/RpcHandler.java#L174-L191
|
13,528
|
OpenTSDB/opentsdb
|
src/tsd/RpcHandler.java
|
RpcHandler.applyCorsConfig
|
private boolean applyCorsConfig(final HttpRequest req, final AbstractHttpQuery query)
throws BadRequestException {
final String domain = req.headers().get("Origin");
// catch CORS requests and add the header or refuse them if the domain
// list has been configured
if (query.method() == HttpMethod.OPTIONS ||
(cors_domains != null && domain != null && !domain.isEmpty())) {
if (cors_domains == null || domain == null || domain.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.METHOD_NOT_ALLOWED,
"Method not allowed", "The HTTP method [" +
query.method().getName() + "] is not permitted");
}
if (cors_domains.contains("*") ||
cors_domains.contains(domain.toUpperCase())) {
// when a domain has matched successfully, we need to add the header
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN,
domain);
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS,
"GET, POST, PUT, DELETE");
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS,
cors_headers);
// if the method requested was for OPTIONS then we'll return an OK
// here and no further processing is needed.
if (query.method() == HttpMethod.OPTIONS) {
query.sendStatusOnly(HttpResponseStatus.OK);
return true;
}
} else {
// You'd think that they would want the server to return a 403 if
// the Origin wasn't in the CORS domain list, but they want a 200
// without the allow origin header. We'll return an error in the
// body though.
throw new BadRequestException(HttpResponseStatus.OK,
"CORS domain not allowed", "The domain [" + domain +
"] is not permitted access");
}
}
return false;
}
|
java
|
private boolean applyCorsConfig(final HttpRequest req, final AbstractHttpQuery query)
throws BadRequestException {
final String domain = req.headers().get("Origin");
// catch CORS requests and add the header or refuse them if the domain
// list has been configured
if (query.method() == HttpMethod.OPTIONS ||
(cors_domains != null && domain != null && !domain.isEmpty())) {
if (cors_domains == null || domain == null || domain.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.METHOD_NOT_ALLOWED,
"Method not allowed", "The HTTP method [" +
query.method().getName() + "] is not permitted");
}
if (cors_domains.contains("*") ||
cors_domains.contains(domain.toUpperCase())) {
// when a domain has matched successfully, we need to add the header
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_ORIGIN,
domain);
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_METHODS,
"GET, POST, PUT, DELETE");
query.response().headers().add(HttpHeaders.ACCESS_CONTROL_ALLOW_HEADERS,
cors_headers);
// if the method requested was for OPTIONS then we'll return an OK
// here and no further processing is needed.
if (query.method() == HttpMethod.OPTIONS) {
query.sendStatusOnly(HttpResponseStatus.OK);
return true;
}
} else {
// You'd think that they would want the server to return a 403 if
// the Origin wasn't in the CORS domain list, but they want a 200
// without the allow origin header. We'll return an error in the
// body though.
throw new BadRequestException(HttpResponseStatus.OK,
"CORS domain not allowed", "The domain [" + domain +
"] is not permitted access");
}
}
return false;
}
|
[
"private",
"boolean",
"applyCorsConfig",
"(",
"final",
"HttpRequest",
"req",
",",
"final",
"AbstractHttpQuery",
"query",
")",
"throws",
"BadRequestException",
"{",
"final",
"String",
"domain",
"=",
"req",
".",
"headers",
"(",
")",
".",
"get",
"(",
"\"Origin\"",
")",
";",
"// catch CORS requests and add the header or refuse them if the domain",
"// list has been configured",
"if",
"(",
"query",
".",
"method",
"(",
")",
"==",
"HttpMethod",
".",
"OPTIONS",
"||",
"(",
"cors_domains",
"!=",
"null",
"&&",
"domain",
"!=",
"null",
"&&",
"!",
"domain",
".",
"isEmpty",
"(",
")",
")",
")",
"{",
"if",
"(",
"cors_domains",
"==",
"null",
"||",
"domain",
"==",
"null",
"||",
"domain",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"METHOD_NOT_ALLOWED",
",",
"\"Method not allowed\"",
",",
"\"The HTTP method [\"",
"+",
"query",
".",
"method",
"(",
")",
".",
"getName",
"(",
")",
"+",
"\"] is not permitted\"",
")",
";",
"}",
"if",
"(",
"cors_domains",
".",
"contains",
"(",
"\"*\"",
")",
"||",
"cors_domains",
".",
"contains",
"(",
"domain",
".",
"toUpperCase",
"(",
")",
")",
")",
"{",
"// when a domain has matched successfully, we need to add the header",
"query",
".",
"response",
"(",
")",
".",
"headers",
"(",
")",
".",
"add",
"(",
"HttpHeaders",
".",
"ACCESS_CONTROL_ALLOW_ORIGIN",
",",
"domain",
")",
";",
"query",
".",
"response",
"(",
")",
".",
"headers",
"(",
")",
".",
"add",
"(",
"HttpHeaders",
".",
"ACCESS_CONTROL_ALLOW_METHODS",
",",
"\"GET, POST, PUT, DELETE\"",
")",
";",
"query",
".",
"response",
"(",
")",
".",
"headers",
"(",
")",
".",
"add",
"(",
"HttpHeaders",
".",
"ACCESS_CONTROL_ALLOW_HEADERS",
",",
"cors_headers",
")",
";",
"// if the method requested was for OPTIONS then we'll return an OK",
"// here and no further processing is needed.",
"if",
"(",
"query",
".",
"method",
"(",
")",
"==",
"HttpMethod",
".",
"OPTIONS",
")",
"{",
"query",
".",
"sendStatusOnly",
"(",
"HttpResponseStatus",
".",
"OK",
")",
";",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"// You'd think that they would want the server to return a 403 if",
"// the Origin wasn't in the CORS domain list, but they want a 200",
"// without the allow origin header. We'll return an error in the",
"// body though.",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"OK",
",",
"\"CORS domain not allowed\"",
",",
"\"The domain [\"",
"+",
"domain",
"+",
"\"] is not permitted access\"",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Helper method to apply CORS configuration to a request, either a built-in
RPC or a user plugin.
@return <code>true</code> if a status reply was sent (in the the case of
certain HTTP methods); <code>false</code> otherwise.
|
[
"Helper",
"method",
"to",
"apply",
"CORS",
"configuration",
"to",
"a",
"request",
"either",
"a",
"built",
"-",
"in",
"RPC",
"or",
"a",
"user",
"plugin",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/RpcHandler.java#L199-L241
|
13,529
|
OpenTSDB/opentsdb
|
src/tsd/RpcHandler.java
|
RpcHandler.getDirectoryFromSystemProp
|
static String getDirectoryFromSystemProp(final String prop) {
final String dir = System.getProperty(prop);
String err = null;
if (dir == null) {
err = "' is not set.";
} else if (dir.isEmpty()) {
err = "' is empty.";
} else if (dir.charAt(dir.length() - 1) != '/') { // Screw Windows.
err = "' is not terminated with `/'.";
}
if (err != null) {
throw new IllegalStateException("System property `" + prop + err);
}
return dir;
}
|
java
|
static String getDirectoryFromSystemProp(final String prop) {
final String dir = System.getProperty(prop);
String err = null;
if (dir == null) {
err = "' is not set.";
} else if (dir.isEmpty()) {
err = "' is empty.";
} else if (dir.charAt(dir.length() - 1) != '/') { // Screw Windows.
err = "' is not terminated with `/'.";
}
if (err != null) {
throw new IllegalStateException("System property `" + prop + err);
}
return dir;
}
|
[
"static",
"String",
"getDirectoryFromSystemProp",
"(",
"final",
"String",
"prop",
")",
"{",
"final",
"String",
"dir",
"=",
"System",
".",
"getProperty",
"(",
"prop",
")",
";",
"String",
"err",
"=",
"null",
";",
"if",
"(",
"dir",
"==",
"null",
")",
"{",
"err",
"=",
"\"' is not set.\"",
";",
"}",
"else",
"if",
"(",
"dir",
".",
"isEmpty",
"(",
")",
")",
"{",
"err",
"=",
"\"' is empty.\"",
";",
"}",
"else",
"if",
"(",
"dir",
".",
"charAt",
"(",
"dir",
".",
"length",
"(",
")",
"-",
"1",
")",
"!=",
"'",
"'",
")",
"{",
"// Screw Windows.",
"err",
"=",
"\"' is not terminated with `/'.\"",
";",
"}",
"if",
"(",
"err",
"!=",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"System property `\"",
"+",
"prop",
"+",
"err",
")",
";",
"}",
"return",
"dir",
";",
"}"
] |
Returns the directory path stored in the given system property.
@param prop The name of the system property.
@return The directory path.
@throws IllegalStateException if the system property is not set
or has an invalid value.
|
[
"Returns",
"the",
"directory",
"path",
"stored",
"in",
"the",
"given",
"system",
"property",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/RpcHandler.java#L343-L357
|
13,530
|
OpenTSDB/opentsdb
|
src/tree/Branch.java
|
Branch.addChild
|
public boolean addChild(final Branch branch) {
if (branch == null) {
throw new IllegalArgumentException("Null branches are not allowed");
}
if (branches == null) {
branches = new TreeSet<Branch>();
branches.add(branch);
return true;
}
if (branches.contains(branch)) {
return false;
}
branches.add(branch);
return true;
}
|
java
|
public boolean addChild(final Branch branch) {
if (branch == null) {
throw new IllegalArgumentException("Null branches are not allowed");
}
if (branches == null) {
branches = new TreeSet<Branch>();
branches.add(branch);
return true;
}
if (branches.contains(branch)) {
return false;
}
branches.add(branch);
return true;
}
|
[
"public",
"boolean",
"addChild",
"(",
"final",
"Branch",
"branch",
")",
"{",
"if",
"(",
"branch",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Null branches are not allowed\"",
")",
";",
"}",
"if",
"(",
"branches",
"==",
"null",
")",
"{",
"branches",
"=",
"new",
"TreeSet",
"<",
"Branch",
">",
"(",
")",
";",
"branches",
".",
"add",
"(",
"branch",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"branches",
".",
"contains",
"(",
"branch",
")",
")",
"{",
"return",
"false",
";",
"}",
"branches",
".",
"add",
"(",
"branch",
")",
";",
"return",
"true",
";",
"}"
] |
Adds a child branch to the local branch set if it doesn't exist. Also
initializes the set if it hasn't been initialized yet
@param branch The branch to add
@return True if the branch did not exist in the set previously
@throws IllegalArgumentException if the incoming branch is null
|
[
"Adds",
"a",
"child",
"branch",
"to",
"the",
"local",
"branch",
"set",
"if",
"it",
"doesn",
"t",
"exist",
".",
"Also",
"initializes",
"the",
"set",
"if",
"it",
"hasn",
"t",
"been",
"initialized",
"yet"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tree/Branch.java#L203-L218
|
13,531
|
OpenTSDB/opentsdb
|
src/tree/Branch.java
|
Branch.addLeaf
|
public boolean addLeaf(final Leaf leaf, final Tree tree) {
if (leaf == null) {
throw new IllegalArgumentException("Null leaves are not allowed");
}
if (leaves == null) {
leaves = new HashMap<Integer, Leaf>();
leaves.put(leaf.hashCode(), leaf);
return true;
}
if (leaves.containsKey(leaf.hashCode())) {
// if we try to sync a leaf with the same hash of an existing key
// but a different TSUID, it's a collision, so mark it
if (!leaves.get(leaf.hashCode()).getTsuid().equals(leaf.getTsuid())) {
final Leaf collision = leaves.get(leaf.hashCode());
if (tree != null) {
tree.addCollision(leaf.getTsuid(), collision.getTsuid());
}
// log at info or lower since it's not a system error, rather it's
// a user issue with the rules or naming schema
LOG.warn("Incoming TSUID [" + leaf.getTsuid() +
"] collided with existing TSUID [" + collision.getTsuid() +
"] on display name [" + collision.getDisplayName() + "]");
}
return false;
} else {
leaves.put(leaf.hashCode(), leaf);
return true;
}
}
|
java
|
public boolean addLeaf(final Leaf leaf, final Tree tree) {
if (leaf == null) {
throw new IllegalArgumentException("Null leaves are not allowed");
}
if (leaves == null) {
leaves = new HashMap<Integer, Leaf>();
leaves.put(leaf.hashCode(), leaf);
return true;
}
if (leaves.containsKey(leaf.hashCode())) {
// if we try to sync a leaf with the same hash of an existing key
// but a different TSUID, it's a collision, so mark it
if (!leaves.get(leaf.hashCode()).getTsuid().equals(leaf.getTsuid())) {
final Leaf collision = leaves.get(leaf.hashCode());
if (tree != null) {
tree.addCollision(leaf.getTsuid(), collision.getTsuid());
}
// log at info or lower since it's not a system error, rather it's
// a user issue with the rules or naming schema
LOG.warn("Incoming TSUID [" + leaf.getTsuid() +
"] collided with existing TSUID [" + collision.getTsuid() +
"] on display name [" + collision.getDisplayName() + "]");
}
return false;
} else {
leaves.put(leaf.hashCode(), leaf);
return true;
}
}
|
[
"public",
"boolean",
"addLeaf",
"(",
"final",
"Leaf",
"leaf",
",",
"final",
"Tree",
"tree",
")",
"{",
"if",
"(",
"leaf",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Null leaves are not allowed\"",
")",
";",
"}",
"if",
"(",
"leaves",
"==",
"null",
")",
"{",
"leaves",
"=",
"new",
"HashMap",
"<",
"Integer",
",",
"Leaf",
">",
"(",
")",
";",
"leaves",
".",
"put",
"(",
"leaf",
".",
"hashCode",
"(",
")",
",",
"leaf",
")",
";",
"return",
"true",
";",
"}",
"if",
"(",
"leaves",
".",
"containsKey",
"(",
"leaf",
".",
"hashCode",
"(",
")",
")",
")",
"{",
"// if we try to sync a leaf with the same hash of an existing key",
"// but a different TSUID, it's a collision, so mark it",
"if",
"(",
"!",
"leaves",
".",
"get",
"(",
"leaf",
".",
"hashCode",
"(",
")",
")",
".",
"getTsuid",
"(",
")",
".",
"equals",
"(",
"leaf",
".",
"getTsuid",
"(",
")",
")",
")",
"{",
"final",
"Leaf",
"collision",
"=",
"leaves",
".",
"get",
"(",
"leaf",
".",
"hashCode",
"(",
")",
")",
";",
"if",
"(",
"tree",
"!=",
"null",
")",
"{",
"tree",
".",
"addCollision",
"(",
"leaf",
".",
"getTsuid",
"(",
")",
",",
"collision",
".",
"getTsuid",
"(",
")",
")",
";",
"}",
"// log at info or lower since it's not a system error, rather it's",
"// a user issue with the rules or naming schema",
"LOG",
".",
"warn",
"(",
"\"Incoming TSUID [\"",
"+",
"leaf",
".",
"getTsuid",
"(",
")",
"+",
"\"] collided with existing TSUID [\"",
"+",
"collision",
".",
"getTsuid",
"(",
")",
"+",
"\"] on display name [\"",
"+",
"collision",
".",
"getDisplayName",
"(",
")",
"+",
"\"]\"",
")",
";",
"}",
"return",
"false",
";",
"}",
"else",
"{",
"leaves",
".",
"put",
"(",
"leaf",
".",
"hashCode",
"(",
")",
",",
"leaf",
")",
";",
"return",
"true",
";",
"}",
"}"
] |
Adds a leaf to the local branch, looking for collisions
@param leaf The leaf to add
@param tree The tree to report to with collisions
@return True if the leaf was new, false if the leaf already exists or
would cause a collision
@throws IllegalArgumentException if the incoming leaf is null
|
[
"Adds",
"a",
"leaf",
"to",
"the",
"local",
"branch",
"looking",
"for",
"collisions"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tree/Branch.java#L228-L258
|
13,532
|
OpenTSDB/opentsdb
|
src/tree/Branch.java
|
Branch.storeBranch
|
public Deferred<ArrayList<Boolean>> storeBranch(final TSDB tsdb,
final Tree tree, final boolean store_leaves) {
if (tree_id < 1 || tree_id > 65535) {
throw new IllegalArgumentException("Missing or invalid tree ID");
}
final ArrayList<Deferred<Boolean>> storage_results =
new ArrayList<Deferred<Boolean>>(leaves != null ? leaves.size() + 1 : 1);
// compile the row key by making sure the display_name is in the path set
// row ID = <treeID>[<parent.display_name.hashCode()>...]
final byte[] row = this.compileBranchId();
// compile the object for storage, this will toss exceptions if we are
// missing anything important
final byte[] storage_data = toStorageJson();
final PutRequest put = new PutRequest(tsdb.treeTable(), row, Tree.TREE_FAMILY(),
BRANCH_QUALIFIER, storage_data);
put.setBufferable(true);
storage_results.add(tsdb.getClient().compareAndSet(put, new byte[0]));
// store leaves if told to and put the storage calls in our deferred group
if (store_leaves && leaves != null && !leaves.isEmpty()) {
for (final Leaf leaf : leaves.values()) {
storage_results.add(leaf.storeLeaf(tsdb, row, tree));
}
}
return Deferred.group(storage_results);
}
|
java
|
public Deferred<ArrayList<Boolean>> storeBranch(final TSDB tsdb,
final Tree tree, final boolean store_leaves) {
if (tree_id < 1 || tree_id > 65535) {
throw new IllegalArgumentException("Missing or invalid tree ID");
}
final ArrayList<Deferred<Boolean>> storage_results =
new ArrayList<Deferred<Boolean>>(leaves != null ? leaves.size() + 1 : 1);
// compile the row key by making sure the display_name is in the path set
// row ID = <treeID>[<parent.display_name.hashCode()>...]
final byte[] row = this.compileBranchId();
// compile the object for storage, this will toss exceptions if we are
// missing anything important
final byte[] storage_data = toStorageJson();
final PutRequest put = new PutRequest(tsdb.treeTable(), row, Tree.TREE_FAMILY(),
BRANCH_QUALIFIER, storage_data);
put.setBufferable(true);
storage_results.add(tsdb.getClient().compareAndSet(put, new byte[0]));
// store leaves if told to and put the storage calls in our deferred group
if (store_leaves && leaves != null && !leaves.isEmpty()) {
for (final Leaf leaf : leaves.values()) {
storage_results.add(leaf.storeLeaf(tsdb, row, tree));
}
}
return Deferred.group(storage_results);
}
|
[
"public",
"Deferred",
"<",
"ArrayList",
"<",
"Boolean",
">",
">",
"storeBranch",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"Tree",
"tree",
",",
"final",
"boolean",
"store_leaves",
")",
"{",
"if",
"(",
"tree_id",
"<",
"1",
"||",
"tree_id",
">",
"65535",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Missing or invalid tree ID\"",
")",
";",
"}",
"final",
"ArrayList",
"<",
"Deferred",
"<",
"Boolean",
">",
">",
"storage_results",
"=",
"new",
"ArrayList",
"<",
"Deferred",
"<",
"Boolean",
">",
">",
"(",
"leaves",
"!=",
"null",
"?",
"leaves",
".",
"size",
"(",
")",
"+",
"1",
":",
"1",
")",
";",
"// compile the row key by making sure the display_name is in the path set",
"// row ID = <treeID>[<parent.display_name.hashCode()>...]",
"final",
"byte",
"[",
"]",
"row",
"=",
"this",
".",
"compileBranchId",
"(",
")",
";",
"// compile the object for storage, this will toss exceptions if we are",
"// missing anything important",
"final",
"byte",
"[",
"]",
"storage_data",
"=",
"toStorageJson",
"(",
")",
";",
"final",
"PutRequest",
"put",
"=",
"new",
"PutRequest",
"(",
"tsdb",
".",
"treeTable",
"(",
")",
",",
"row",
",",
"Tree",
".",
"TREE_FAMILY",
"(",
")",
",",
"BRANCH_QUALIFIER",
",",
"storage_data",
")",
";",
"put",
".",
"setBufferable",
"(",
"true",
")",
";",
"storage_results",
".",
"add",
"(",
"tsdb",
".",
"getClient",
"(",
")",
".",
"compareAndSet",
"(",
"put",
",",
"new",
"byte",
"[",
"0",
"]",
")",
")",
";",
"// store leaves if told to and put the storage calls in our deferred group",
"if",
"(",
"store_leaves",
"&&",
"leaves",
"!=",
"null",
"&&",
"!",
"leaves",
".",
"isEmpty",
"(",
")",
")",
"{",
"for",
"(",
"final",
"Leaf",
"leaf",
":",
"leaves",
".",
"values",
"(",
")",
")",
"{",
"storage_results",
".",
"add",
"(",
"leaf",
".",
"storeLeaf",
"(",
"tsdb",
",",
"row",
",",
"tree",
")",
")",
";",
"}",
"}",
"return",
"Deferred",
".",
"group",
"(",
"storage_results",
")",
";",
"}"
] |
Attempts to write the branch definition and optionally child leaves to
storage via CompareAndSets.
Each returned deferred will be a boolean regarding whether the CAS call
was successful or not. This will be a mix of the branch call and leaves.
Some of these may be false, which is OK, because if the branch
definition already exists, we don't need to re-write it. Leaves will
return false if there was a collision.
@param tsdb The TSDB to use for access
@param tree The tree to record collisions to
@param store_leaves Whether or not child leaves should be written to
storage
@return A list of deferreds to wait on for completion.
@throws HBaseException if there was an issue
@throws IllegalArgumentException if the tree ID was missing or data was
missing
|
[
"Attempts",
"to",
"write",
"the",
"branch",
"definition",
"and",
"optionally",
"child",
"leaves",
"to",
"storage",
"via",
"CompareAndSets",
".",
"Each",
"returned",
"deferred",
"will",
"be",
"a",
"boolean",
"regarding",
"whether",
"the",
"CAS",
"call",
"was",
"successful",
"or",
"not",
".",
"This",
"will",
"be",
"a",
"mix",
"of",
"the",
"branch",
"call",
"and",
"leaves",
".",
"Some",
"of",
"these",
"may",
"be",
"false",
"which",
"is",
"OK",
"because",
"if",
"the",
"branch",
"definition",
"already",
"exists",
"we",
"don",
"t",
"need",
"to",
"re",
"-",
"write",
"it",
".",
"Leaves",
"will",
"return",
"false",
"if",
"there",
"was",
"a",
"collision",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tree/Branch.java#L342-L372
|
13,533
|
OpenTSDB/opentsdb
|
src/tree/Branch.java
|
Branch.setupBranchScanner
|
private static Scanner setupBranchScanner(final TSDB tsdb,
final byte[] branch_id) {
final byte[] start = branch_id;
final byte[] end = Arrays.copyOf(branch_id, branch_id.length);
final Scanner scanner = tsdb.getClient().newScanner(tsdb.treeTable());
scanner.setStartKey(start);
// increment the tree ID so we scan the whole tree
byte[] tree_id = new byte[INT_WIDTH];
for (int i = 0; i < Tree.TREE_ID_WIDTH(); i++) {
tree_id[i + (INT_WIDTH - Tree.TREE_ID_WIDTH())] = end[i];
}
int id = Bytes.getInt(tree_id) + 1;
tree_id = Bytes.fromInt(id);
for (int i = 0; i < Tree.TREE_ID_WIDTH(); i++) {
end[i] = tree_id[i + (INT_WIDTH - Tree.TREE_ID_WIDTH())];
}
scanner.setStopKey(end);
scanner.setFamily(Tree.TREE_FAMILY());
// TODO - use the column filter to fetch only branches and leaves, ignore
// collisions, no matches and other meta
// set the regex filter
// we want one branch below the current ID so we want something like:
// {0, 1, 1, 2, 3, 4 } where { 0, 1 } is the tree ID, { 1, 2, 3, 4 } is the
// branch
// "^\\Q\000\001\001\002\003\004\\E(?:.{4})$"
final StringBuilder buf = new StringBuilder((start.length * 6) + 20);
buf.append("(?s)" // Ensure we use the DOTALL flag.
+ "^\\Q");
for (final byte b : start) {
buf.append((char) (b & 0xFF));
}
buf.append("\\E(?:.{").append(INT_WIDTH).append("})?$");
scanner.setKeyRegexp(buf.toString(), CHARSET);
return scanner;
}
|
java
|
private static Scanner setupBranchScanner(final TSDB tsdb,
final byte[] branch_id) {
final byte[] start = branch_id;
final byte[] end = Arrays.copyOf(branch_id, branch_id.length);
final Scanner scanner = tsdb.getClient().newScanner(tsdb.treeTable());
scanner.setStartKey(start);
// increment the tree ID so we scan the whole tree
byte[] tree_id = new byte[INT_WIDTH];
for (int i = 0; i < Tree.TREE_ID_WIDTH(); i++) {
tree_id[i + (INT_WIDTH - Tree.TREE_ID_WIDTH())] = end[i];
}
int id = Bytes.getInt(tree_id) + 1;
tree_id = Bytes.fromInt(id);
for (int i = 0; i < Tree.TREE_ID_WIDTH(); i++) {
end[i] = tree_id[i + (INT_WIDTH - Tree.TREE_ID_WIDTH())];
}
scanner.setStopKey(end);
scanner.setFamily(Tree.TREE_FAMILY());
// TODO - use the column filter to fetch only branches and leaves, ignore
// collisions, no matches and other meta
// set the regex filter
// we want one branch below the current ID so we want something like:
// {0, 1, 1, 2, 3, 4 } where { 0, 1 } is the tree ID, { 1, 2, 3, 4 } is the
// branch
// "^\\Q\000\001\001\002\003\004\\E(?:.{4})$"
final StringBuilder buf = new StringBuilder((start.length * 6) + 20);
buf.append("(?s)" // Ensure we use the DOTALL flag.
+ "^\\Q");
for (final byte b : start) {
buf.append((char) (b & 0xFF));
}
buf.append("\\E(?:.{").append(INT_WIDTH).append("})?$");
scanner.setKeyRegexp(buf.toString(), CHARSET);
return scanner;
}
|
[
"private",
"static",
"Scanner",
"setupBranchScanner",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"byte",
"[",
"]",
"branch_id",
")",
"{",
"final",
"byte",
"[",
"]",
"start",
"=",
"branch_id",
";",
"final",
"byte",
"[",
"]",
"end",
"=",
"Arrays",
".",
"copyOf",
"(",
"branch_id",
",",
"branch_id",
".",
"length",
")",
";",
"final",
"Scanner",
"scanner",
"=",
"tsdb",
".",
"getClient",
"(",
")",
".",
"newScanner",
"(",
"tsdb",
".",
"treeTable",
"(",
")",
")",
";",
"scanner",
".",
"setStartKey",
"(",
"start",
")",
";",
"// increment the tree ID so we scan the whole tree",
"byte",
"[",
"]",
"tree_id",
"=",
"new",
"byte",
"[",
"INT_WIDTH",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"Tree",
".",
"TREE_ID_WIDTH",
"(",
")",
";",
"i",
"++",
")",
"{",
"tree_id",
"[",
"i",
"+",
"(",
"INT_WIDTH",
"-",
"Tree",
".",
"TREE_ID_WIDTH",
"(",
")",
")",
"]",
"=",
"end",
"[",
"i",
"]",
";",
"}",
"int",
"id",
"=",
"Bytes",
".",
"getInt",
"(",
"tree_id",
")",
"+",
"1",
";",
"tree_id",
"=",
"Bytes",
".",
"fromInt",
"(",
"id",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"Tree",
".",
"TREE_ID_WIDTH",
"(",
")",
";",
"i",
"++",
")",
"{",
"end",
"[",
"i",
"]",
"=",
"tree_id",
"[",
"i",
"+",
"(",
"INT_WIDTH",
"-",
"Tree",
".",
"TREE_ID_WIDTH",
"(",
")",
")",
"]",
";",
"}",
"scanner",
".",
"setStopKey",
"(",
"end",
")",
";",
"scanner",
".",
"setFamily",
"(",
"Tree",
".",
"TREE_FAMILY",
"(",
")",
")",
";",
"// TODO - use the column filter to fetch only branches and leaves, ignore",
"// collisions, no matches and other meta",
"// set the regex filter",
"// we want one branch below the current ID so we want something like:",
"// {0, 1, 1, 2, 3, 4 } where { 0, 1 } is the tree ID, { 1, 2, 3, 4 } is the ",
"// branch",
"// \"^\\\\Q\\000\\001\\001\\002\\003\\004\\\\E(?:.{4})$\"",
"final",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
"(",
"start",
".",
"length",
"*",
"6",
")",
"+",
"20",
")",
";",
"buf",
".",
"append",
"(",
"\"(?s)\"",
"// Ensure we use the DOTALL flag.",
"+",
"\"^\\\\Q\"",
")",
";",
"for",
"(",
"final",
"byte",
"b",
":",
"start",
")",
"{",
"buf",
".",
"append",
"(",
"(",
"char",
")",
"(",
"b",
"&",
"0xFF",
")",
")",
";",
"}",
"buf",
".",
"append",
"(",
"\"\\\\E(?:.{\"",
")",
".",
"append",
"(",
"INT_WIDTH",
")",
".",
"append",
"(",
"\"})?$\"",
")",
";",
"scanner",
".",
"setKeyRegexp",
"(",
"buf",
".",
"toString",
"(",
")",
",",
"CHARSET",
")",
";",
"return",
"scanner",
";",
"}"
] |
Configures an HBase scanner to fetch the requested branch and all child
branches. It uses a row key regex filter to match any rows starting with
the given branch and another INT_WIDTH bytes deep. Deeper branches are
ignored.
@param tsdb The TSDB to use for storage access
@param branch_id ID of the branch to fetch
@return An HBase scanner ready for scanning
|
[
"Configures",
"an",
"HBase",
"scanner",
"to",
"fetch",
"the",
"requested",
"branch",
"and",
"all",
"child",
"branches",
".",
"It",
"uses",
"a",
"row",
"key",
"regex",
"filter",
"to",
"match",
"any",
"rows",
"starting",
"with",
"the",
"given",
"branch",
"and",
"another",
"INT_WIDTH",
"bytes",
"deep",
".",
"Deeper",
"branches",
"are",
"ignored",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tree/Branch.java#L651-L690
|
13,534
|
OpenTSDB/opentsdb
|
src/tools/TreeSync.java
|
TreeSync.purgeTree
|
public int purgeTree(final int tree_id, final boolean delete_definition)
throws Exception {
if (delete_definition) {
LOG.info("Deleting tree branches and definition for: " + tree_id);
} else {
LOG.info("Deleting tree branches for: " + tree_id);
}
Tree.deleteTree(tsdb, tree_id, delete_definition).joinUninterruptibly();
LOG.info("Completed tree deletion for: " + tree_id);
return 0;
}
|
java
|
public int purgeTree(final int tree_id, final boolean delete_definition)
throws Exception {
if (delete_definition) {
LOG.info("Deleting tree branches and definition for: " + tree_id);
} else {
LOG.info("Deleting tree branches for: " + tree_id);
}
Tree.deleteTree(tsdb, tree_id, delete_definition).joinUninterruptibly();
LOG.info("Completed tree deletion for: " + tree_id);
return 0;
}
|
[
"public",
"int",
"purgeTree",
"(",
"final",
"int",
"tree_id",
",",
"final",
"boolean",
"delete_definition",
")",
"throws",
"Exception",
"{",
"if",
"(",
"delete_definition",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Deleting tree branches and definition for: \"",
"+",
"tree_id",
")",
";",
"}",
"else",
"{",
"LOG",
".",
"info",
"(",
"\"Deleting tree branches for: \"",
"+",
"tree_id",
")",
";",
"}",
"Tree",
".",
"deleteTree",
"(",
"tsdb",
",",
"tree_id",
",",
"delete_definition",
")",
".",
"joinUninterruptibly",
"(",
")",
";",
"LOG",
".",
"info",
"(",
"\"Completed tree deletion for: \"",
"+",
"tree_id",
")",
";",
"return",
"0",
";",
"}"
] |
Attempts to delete all data generated by the given tree, and optionally,
the tree definition itself.
@param tree_id The tree with data to delete
@param delete_definition Whether or not the tree definition itself should
be removed from the system
@return 0 if completed successfully, something else if an error occurred
|
[
"Attempts",
"to",
"delete",
"all",
"data",
"generated",
"by",
"the",
"given",
"tree",
"and",
"optionally",
"the",
"tree",
"definition",
"itself",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/TreeSync.java#L324-L334
|
13,535
|
OpenTSDB/opentsdb
|
src/tools/TreeSync.java
|
TreeSync.getScanner
|
private Scanner getScanner() throws HBaseException {
final short metric_width = TSDB.metrics_width();
final byte[] start_row =
Arrays.copyOfRange(Bytes.fromLong(start_id), 8 - metric_width, 8);
final byte[] end_row =
Arrays.copyOfRange(Bytes.fromLong(end_id), 8 - metric_width, 8);
LOG.debug("[" + thread_id + "] Start row: " + UniqueId.uidToString(start_row));
LOG.debug("[" + thread_id + "] End row: " + UniqueId.uidToString(end_row));
final Scanner scanner = tsdb.getClient().newScanner(tsdb.metaTable());
scanner.setStartKey(start_row);
scanner.setStopKey(end_row);
scanner.setFamily("name".getBytes(CHARSET));
scanner.setQualifier("ts_meta".getBytes(CHARSET));
return scanner;
}
|
java
|
private Scanner getScanner() throws HBaseException {
final short metric_width = TSDB.metrics_width();
final byte[] start_row =
Arrays.copyOfRange(Bytes.fromLong(start_id), 8 - metric_width, 8);
final byte[] end_row =
Arrays.copyOfRange(Bytes.fromLong(end_id), 8 - metric_width, 8);
LOG.debug("[" + thread_id + "] Start row: " + UniqueId.uidToString(start_row));
LOG.debug("[" + thread_id + "] End row: " + UniqueId.uidToString(end_row));
final Scanner scanner = tsdb.getClient().newScanner(tsdb.metaTable());
scanner.setStartKey(start_row);
scanner.setStopKey(end_row);
scanner.setFamily("name".getBytes(CHARSET));
scanner.setQualifier("ts_meta".getBytes(CHARSET));
return scanner;
}
|
[
"private",
"Scanner",
"getScanner",
"(",
")",
"throws",
"HBaseException",
"{",
"final",
"short",
"metric_width",
"=",
"TSDB",
".",
"metrics_width",
"(",
")",
";",
"final",
"byte",
"[",
"]",
"start_row",
"=",
"Arrays",
".",
"copyOfRange",
"(",
"Bytes",
".",
"fromLong",
"(",
"start_id",
")",
",",
"8",
"-",
"metric_width",
",",
"8",
")",
";",
"final",
"byte",
"[",
"]",
"end_row",
"=",
"Arrays",
".",
"copyOfRange",
"(",
"Bytes",
".",
"fromLong",
"(",
"end_id",
")",
",",
"8",
"-",
"metric_width",
",",
"8",
")",
";",
"LOG",
".",
"debug",
"(",
"\"[\"",
"+",
"thread_id",
"+",
"\"] Start row: \"",
"+",
"UniqueId",
".",
"uidToString",
"(",
"start_row",
")",
")",
";",
"LOG",
".",
"debug",
"(",
"\"[\"",
"+",
"thread_id",
"+",
"\"] End row: \"",
"+",
"UniqueId",
".",
"uidToString",
"(",
"end_row",
")",
")",
";",
"final",
"Scanner",
"scanner",
"=",
"tsdb",
".",
"getClient",
"(",
")",
".",
"newScanner",
"(",
"tsdb",
".",
"metaTable",
"(",
")",
")",
";",
"scanner",
".",
"setStartKey",
"(",
"start_row",
")",
";",
"scanner",
".",
"setStopKey",
"(",
"end_row",
")",
";",
"scanner",
".",
"setFamily",
"(",
"\"name\"",
".",
"getBytes",
"(",
"CHARSET",
")",
")",
";",
"scanner",
".",
"setQualifier",
"(",
"\"ts_meta\"",
".",
"getBytes",
"(",
"CHARSET",
")",
")",
";",
"return",
"scanner",
";",
"}"
] |
Returns a scanner set to scan the range configured for this thread
@return A scanner on the "name" CF configured for the specified range
@throws HBaseException if something goes boom
|
[
"Returns",
"a",
"scanner",
"set",
"to",
"scan",
"the",
"range",
"configured",
"for",
"this",
"thread"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tools/TreeSync.java#L341-L356
|
13,536
|
OpenTSDB/opentsdb
|
src/rollup/RollupConfig.java
|
RollupConfig.getRollupInterval
|
public RollupInterval getRollupInterval(final String interval) {
if (interval == null || interval.isEmpty()) {
throw new IllegalArgumentException("Interval cannot be null or empty");
}
final RollupInterval rollup = forward_intervals.get(interval);
if (rollup == null) {
throw new NoSuchRollupForIntervalException(interval);
}
return rollup;
}
|
java
|
public RollupInterval getRollupInterval(final String interval) {
if (interval == null || interval.isEmpty()) {
throw new IllegalArgumentException("Interval cannot be null or empty");
}
final RollupInterval rollup = forward_intervals.get(interval);
if (rollup == null) {
throw new NoSuchRollupForIntervalException(interval);
}
return rollup;
}
|
[
"public",
"RollupInterval",
"getRollupInterval",
"(",
"final",
"String",
"interval",
")",
"{",
"if",
"(",
"interval",
"==",
"null",
"||",
"interval",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Interval cannot be null or empty\"",
")",
";",
"}",
"final",
"RollupInterval",
"rollup",
"=",
"forward_intervals",
".",
"get",
"(",
"interval",
")",
";",
"if",
"(",
"rollup",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchRollupForIntervalException",
"(",
"interval",
")",
";",
"}",
"return",
"rollup",
";",
"}"
] |
Fetches the RollupInterval corresponding to the forward interval string map
@param interval The interval to lookup
@return The RollupInterval object configured for the given interval
@throws IllegalArgumentException if the interval is null or empty
@throws NoSuchRollupForIntervalException if the interval was not configured
|
[
"Fetches",
"the",
"RollupInterval",
"corresponding",
"to",
"the",
"forward",
"interval",
"string",
"map"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/rollup/RollupConfig.java#L140-L149
|
13,537
|
OpenTSDB/opentsdb
|
src/rollup/RollupConfig.java
|
RollupConfig.getRollupInterval
|
public List<RollupInterval> getRollupInterval(final long interval,
final String str_interval) {
if (interval <= 0) {
throw new IllegalArgumentException("Interval cannot be null or empty");
}
final Map<Long, RollupInterval> rollups =
new TreeMap<Long, RollupInterval>(Collections.reverseOrder());
boolean right_match = false;
for (RollupInterval rollup: forward_intervals.values()) {
if (rollup.getIntervalSeconds() == interval) {
rollups.put((long) rollup.getIntervalSeconds(), rollup);
right_match = true;
}
else if (interval % rollup.getIntervalSeconds() == 0) {
rollups.put((long) rollup.getIntervalSeconds(), rollup);
}
}
if (rollups.isEmpty()) {
throw new NoSuchRollupForIntervalException(Long.toString(interval));
}
List<RollupInterval> best_matches =
new ArrayList<RollupInterval>(rollups.values());
if (!right_match) {
LOG.warn("No such rollup interval found, " + str_interval + ". So falling "
+ "back to the next best match " + best_matches.get(0).
getInterval());
}
return best_matches;
}
|
java
|
public List<RollupInterval> getRollupInterval(final long interval,
final String str_interval) {
if (interval <= 0) {
throw new IllegalArgumentException("Interval cannot be null or empty");
}
final Map<Long, RollupInterval> rollups =
new TreeMap<Long, RollupInterval>(Collections.reverseOrder());
boolean right_match = false;
for (RollupInterval rollup: forward_intervals.values()) {
if (rollup.getIntervalSeconds() == interval) {
rollups.put((long) rollup.getIntervalSeconds(), rollup);
right_match = true;
}
else if (interval % rollup.getIntervalSeconds() == 0) {
rollups.put((long) rollup.getIntervalSeconds(), rollup);
}
}
if (rollups.isEmpty()) {
throw new NoSuchRollupForIntervalException(Long.toString(interval));
}
List<RollupInterval> best_matches =
new ArrayList<RollupInterval>(rollups.values());
if (!right_match) {
LOG.warn("No such rollup interval found, " + str_interval + ". So falling "
+ "back to the next best match " + best_matches.get(0).
getInterval());
}
return best_matches;
}
|
[
"public",
"List",
"<",
"RollupInterval",
">",
"getRollupInterval",
"(",
"final",
"long",
"interval",
",",
"final",
"String",
"str_interval",
")",
"{",
"if",
"(",
"interval",
"<=",
"0",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Interval cannot be null or empty\"",
")",
";",
"}",
"final",
"Map",
"<",
"Long",
",",
"RollupInterval",
">",
"rollups",
"=",
"new",
"TreeMap",
"<",
"Long",
",",
"RollupInterval",
">",
"(",
"Collections",
".",
"reverseOrder",
"(",
")",
")",
";",
"boolean",
"right_match",
"=",
"false",
";",
"for",
"(",
"RollupInterval",
"rollup",
":",
"forward_intervals",
".",
"values",
"(",
")",
")",
"{",
"if",
"(",
"rollup",
".",
"getIntervalSeconds",
"(",
")",
"==",
"interval",
")",
"{",
"rollups",
".",
"put",
"(",
"(",
"long",
")",
"rollup",
".",
"getIntervalSeconds",
"(",
")",
",",
"rollup",
")",
";",
"right_match",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"interval",
"%",
"rollup",
".",
"getIntervalSeconds",
"(",
")",
"==",
"0",
")",
"{",
"rollups",
".",
"put",
"(",
"(",
"long",
")",
"rollup",
".",
"getIntervalSeconds",
"(",
")",
",",
"rollup",
")",
";",
"}",
"}",
"if",
"(",
"rollups",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"NoSuchRollupForIntervalException",
"(",
"Long",
".",
"toString",
"(",
"interval",
")",
")",
";",
"}",
"List",
"<",
"RollupInterval",
">",
"best_matches",
"=",
"new",
"ArrayList",
"<",
"RollupInterval",
">",
"(",
"rollups",
".",
"values",
"(",
")",
")",
";",
"if",
"(",
"!",
"right_match",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"No such rollup interval found, \"",
"+",
"str_interval",
"+",
"\". So falling \"",
"+",
"\"back to the next best match \"",
"+",
"best_matches",
".",
"get",
"(",
"0",
")",
".",
"getInterval",
"(",
")",
")",
";",
"}",
"return",
"best_matches",
";",
"}"
] |
Fetches the RollupInterval corresponding to the integer interval in seconds.
It returns a list of matching RollupInterval and best next matches in the
order. It will help to search on the next best rollup tables.
It is guaranteed that it return a non-empty list
For example if the interval is 1 day
then it may return RollupInterval objects in the order
1 day, 1 hour, 10 minutes, 1 minute
@param interval The interval in seconds to lookup
@param str_interval String representation of the interval, for logging
@return The RollupInterval object configured for the given interval
@throws IllegalArgumentException if the interval is null or empty
@throws NoSuchRollupForIntervalException if the interval was not configured
|
[
"Fetches",
"the",
"RollupInterval",
"corresponding",
"to",
"the",
"integer",
"interval",
"in",
"seconds",
".",
"It",
"returns",
"a",
"list",
"of",
"matching",
"RollupInterval",
"and",
"best",
"next",
"matches",
"in",
"the",
"order",
".",
"It",
"will",
"help",
"to",
"search",
"on",
"the",
"next",
"best",
"rollup",
"tables",
".",
"It",
"is",
"guaranteed",
"that",
"it",
"return",
"a",
"non",
"-",
"empty",
"list",
"For",
"example",
"if",
"the",
"interval",
"is",
"1",
"day",
"then",
"it",
"may",
"return",
"RollupInterval",
"objects",
"in",
"the",
"order",
"1",
"day",
"1",
"hour",
"10",
"minutes",
"1",
"minute"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/rollup/RollupConfig.java#L165-L200
|
13,538
|
OpenTSDB/opentsdb
|
src/rollup/RollupConfig.java
|
RollupConfig.getRollupIntervalForTable
|
public RollupInterval getRollupIntervalForTable(final String table) {
if (table == null || table.isEmpty()) {
throw new IllegalArgumentException("The table name cannot be null or empty");
}
final RollupInterval rollup = reverse_intervals.get(table);
if (rollup == null) {
throw new NoSuchRollupForTableException(table);
}
return rollup;
}
|
java
|
public RollupInterval getRollupIntervalForTable(final String table) {
if (table == null || table.isEmpty()) {
throw new IllegalArgumentException("The table name cannot be null or empty");
}
final RollupInterval rollup = reverse_intervals.get(table);
if (rollup == null) {
throw new NoSuchRollupForTableException(table);
}
return rollup;
}
|
[
"public",
"RollupInterval",
"getRollupIntervalForTable",
"(",
"final",
"String",
"table",
")",
"{",
"if",
"(",
"table",
"==",
"null",
"||",
"table",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The table name cannot be null or empty\"",
")",
";",
"}",
"final",
"RollupInterval",
"rollup",
"=",
"reverse_intervals",
".",
"get",
"(",
"table",
")",
";",
"if",
"(",
"rollup",
"==",
"null",
")",
"{",
"throw",
"new",
"NoSuchRollupForTableException",
"(",
"table",
")",
";",
"}",
"return",
"rollup",
";",
"}"
] |
Fetches the RollupInterval corresponding to the rollup or pre-agg table
name.
@param table The name of the table to fetch
@return The RollupInterval object matching the table
@throws IllegalArgumentException if the table is null or empty
@throws NoSuchRollupForTableException if the interval was not configured
for the given table
|
[
"Fetches",
"the",
"RollupInterval",
"corresponding",
"to",
"the",
"rollup",
"or",
"pre",
"-",
"agg",
"table",
"name",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/rollup/RollupConfig.java#L211-L220
|
13,539
|
OpenTSDB/opentsdb
|
src/rollup/RollupConfig.java
|
RollupConfig.ensureTablesExist
|
public void ensureTablesExist(final TSDB tsdb) {
final List<Deferred<Object>> deferreds =
new ArrayList<Deferred<Object>>(forward_intervals.size() * 2);
for (RollupInterval interval : forward_intervals.values()) {
deferreds.add(tsdb.getClient()
.ensureTableExists(interval.getTemporalTable()));
deferreds.add(tsdb.getClient()
.ensureTableExists(interval.getGroupbyTable()));
}
try {
Deferred.group(deferreds).joinUninterruptibly();
} catch (DeferredGroupException e) {
throw new RuntimeException(e.getCause());
} catch (InterruptedException e) {
LOG.warn("Interrupted", e);
Thread.currentThread().interrupt();
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
}
|
java
|
public void ensureTablesExist(final TSDB tsdb) {
final List<Deferred<Object>> deferreds =
new ArrayList<Deferred<Object>>(forward_intervals.size() * 2);
for (RollupInterval interval : forward_intervals.values()) {
deferreds.add(tsdb.getClient()
.ensureTableExists(interval.getTemporalTable()));
deferreds.add(tsdb.getClient()
.ensureTableExists(interval.getGroupbyTable()));
}
try {
Deferred.group(deferreds).joinUninterruptibly();
} catch (DeferredGroupException e) {
throw new RuntimeException(e.getCause());
} catch (InterruptedException e) {
LOG.warn("Interrupted", e);
Thread.currentThread().interrupt();
} catch (Exception e) {
throw new RuntimeException("Unexpected exception", e);
}
}
|
[
"public",
"void",
"ensureTablesExist",
"(",
"final",
"TSDB",
"tsdb",
")",
"{",
"final",
"List",
"<",
"Deferred",
"<",
"Object",
">",
">",
"deferreds",
"=",
"new",
"ArrayList",
"<",
"Deferred",
"<",
"Object",
">",
">",
"(",
"forward_intervals",
".",
"size",
"(",
")",
"*",
"2",
")",
";",
"for",
"(",
"RollupInterval",
"interval",
":",
"forward_intervals",
".",
"values",
"(",
")",
")",
"{",
"deferreds",
".",
"add",
"(",
"tsdb",
".",
"getClient",
"(",
")",
".",
"ensureTableExists",
"(",
"interval",
".",
"getTemporalTable",
"(",
")",
")",
")",
";",
"deferreds",
".",
"add",
"(",
"tsdb",
".",
"getClient",
"(",
")",
".",
"ensureTableExists",
"(",
"interval",
".",
"getGroupbyTable",
"(",
")",
")",
")",
";",
"}",
"try",
"{",
"Deferred",
".",
"group",
"(",
"deferreds",
")",
".",
"joinUninterruptibly",
"(",
")",
";",
"}",
"catch",
"(",
"DeferredGroupException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
".",
"getCause",
"(",
")",
")",
";",
"}",
"catch",
"(",
"InterruptedException",
"e",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Interrupted\"",
",",
"e",
")",
";",
"Thread",
".",
"currentThread",
"(",
")",
".",
"interrupt",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Unexpected exception\"",
",",
"e",
")",
";",
"}",
"}"
] |
Makes sure each of the rollup tables exists
@param tsdb The TSDB to use for fetching the HBase client
|
[
"Makes",
"sure",
"each",
"of",
"the",
"rollup",
"tables",
"exists"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/rollup/RollupConfig.java#L226-L247
|
13,540
|
OpenTSDB/opentsdb
|
src/utils/FileSystem.java
|
FileSystem.checkDirectory
|
public static void checkDirectory(final String dir,
final boolean need_write, final boolean create) {
if (dir.isEmpty())
throw new IllegalArgumentException("Directory path is empty");
final File f = new File(dir);
if (!f.exists() && !(create && f.mkdirs())) {
throw new IllegalArgumentException("No such directory [" + dir + "]");
} else if (!f.isDirectory()) {
throw new IllegalArgumentException("Not a directory [" + dir + "]");
} else if (need_write && !f.canWrite()) {
throw new IllegalArgumentException("Cannot write to directory [" + dir
+ "]");
}
}
|
java
|
public static void checkDirectory(final String dir,
final boolean need_write, final boolean create) {
if (dir.isEmpty())
throw new IllegalArgumentException("Directory path is empty");
final File f = new File(dir);
if (!f.exists() && !(create && f.mkdirs())) {
throw new IllegalArgumentException("No such directory [" + dir + "]");
} else if (!f.isDirectory()) {
throw new IllegalArgumentException("Not a directory [" + dir + "]");
} else if (need_write && !f.canWrite()) {
throw new IllegalArgumentException("Cannot write to directory [" + dir
+ "]");
}
}
|
[
"public",
"static",
"void",
"checkDirectory",
"(",
"final",
"String",
"dir",
",",
"final",
"boolean",
"need_write",
",",
"final",
"boolean",
"create",
")",
"{",
"if",
"(",
"dir",
".",
"isEmpty",
"(",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Directory path is empty\"",
")",
";",
"final",
"File",
"f",
"=",
"new",
"File",
"(",
"dir",
")",
";",
"if",
"(",
"!",
"f",
".",
"exists",
"(",
")",
"&&",
"!",
"(",
"create",
"&&",
"f",
".",
"mkdirs",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No such directory [\"",
"+",
"dir",
"+",
"\"]\"",
")",
";",
"}",
"else",
"if",
"(",
"!",
"f",
".",
"isDirectory",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Not a directory [\"",
"+",
"dir",
"+",
"\"]\"",
")",
";",
"}",
"else",
"if",
"(",
"need_write",
"&&",
"!",
"f",
".",
"canWrite",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Cannot write to directory [\"",
"+",
"dir",
"+",
"\"]\"",
")",
";",
"}",
"}"
] |
Verifies a directory and checks to see if it's writeable or not if
configured
@param dir The path to check on
@param need_write Set to true if the path needs write access
@param create Set to true if the directory should be created if it does not
exist
@throws IllegalArgumentException if the path is empty, if it's not there
and told not to create it or if it needs write access and can't
be written to
|
[
"Verifies",
"a",
"directory",
"and",
"checks",
"to",
"see",
"if",
"it",
"s",
"writeable",
"or",
"not",
"if",
"configured"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/utils/FileSystem.java#L29-L42
|
13,541
|
OpenTSDB/opentsdb
|
src/utils/JSON.java
|
JSON.parseToObject
|
@SuppressWarnings("unchecked")
public static final <T> T parseToObject(final String json,
final TypeReference<T> type) {
if (json == null || json.isEmpty())
throw new IllegalArgumentException("Incoming data was null or empty");
if (type == null)
throw new IllegalArgumentException("Missing type reference");
try {
return (T)jsonMapper.readValue(json, type);
} catch (JsonParseException e) {
throw new IllegalArgumentException(e);
} catch (JsonMappingException e) {
throw new IllegalArgumentException(e);
} catch (IOException e) {
throw new JSONException(e);
}
}
|
java
|
@SuppressWarnings("unchecked")
public static final <T> T parseToObject(final String json,
final TypeReference<T> type) {
if (json == null || json.isEmpty())
throw new IllegalArgumentException("Incoming data was null or empty");
if (type == null)
throw new IllegalArgumentException("Missing type reference");
try {
return (T)jsonMapper.readValue(json, type);
} catch (JsonParseException e) {
throw new IllegalArgumentException(e);
} catch (JsonMappingException e) {
throw new IllegalArgumentException(e);
} catch (IOException e) {
throw new JSONException(e);
}
}
|
[
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"static",
"final",
"<",
"T",
">",
"T",
"parseToObject",
"(",
"final",
"String",
"json",
",",
"final",
"TypeReference",
"<",
"T",
">",
"type",
")",
"{",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Incoming data was null or empty\"",
")",
";",
"if",
"(",
"type",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Missing type reference\"",
")",
";",
"try",
"{",
"return",
"(",
"T",
")",
"jsonMapper",
".",
"readValue",
"(",
"json",
",",
"type",
")",
";",
"}",
"catch",
"(",
"JsonParseException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"JsonMappingException",
"e",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",
"new",
"JSONException",
"(",
"e",
")",
";",
"}",
"}"
] |
Deserializes a JSON formatted string to a specific class type
@param json The string to deserialize
@param type A type definition for a complex object
@return An object of the {@code pojo} type
@throws IllegalArgumentException if the data or type was null or parsing
failed
@throws JSONException if the data could not be parsed
|
[
"Deserializes",
"a",
"JSON",
"formatted",
"string",
"to",
"a",
"specific",
"class",
"type"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/utils/JSON.java#L155-L171
|
13,542
|
OpenTSDB/opentsdb
|
src/utils/JSON.java
|
JSON.serializeToString
|
public static final String serializeToString(final Object object) {
if (object == null)
throw new IllegalArgumentException("Object was null");
try {
return jsonMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new JSONException(e);
}
}
|
java
|
public static final String serializeToString(final Object object) {
if (object == null)
throw new IllegalArgumentException("Object was null");
try {
return jsonMapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
throw new JSONException(e);
}
}
|
[
"public",
"static",
"final",
"String",
"serializeToString",
"(",
"final",
"Object",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Object was null\"",
")",
";",
"try",
"{",
"return",
"jsonMapper",
".",
"writeValueAsString",
"(",
"object",
")",
";",
"}",
"catch",
"(",
"JsonProcessingException",
"e",
")",
"{",
"throw",
"new",
"JSONException",
"(",
"e",
")",
";",
"}",
"}"
] |
Serializes the given object to a JSON string
@param object The object to serialize
@return A JSON formatted string
@throws IllegalArgumentException if the object was null
@throws JSONException if the object could not be serialized
|
[
"Serializes",
"the",
"given",
"object",
"to",
"a",
"JSON",
"string"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/utils/JSON.java#L273-L281
|
13,543
|
OpenTSDB/opentsdb
|
src/utils/JSON.java
|
JSON.serializeToBytes
|
public static final byte[] serializeToBytes(final Object object) {
if (object == null)
throw new IllegalArgumentException("Object was null");
try {
return jsonMapper.writeValueAsBytes(object);
} catch (JsonProcessingException e) {
throw new JSONException(e);
}
}
|
java
|
public static final byte[] serializeToBytes(final Object object) {
if (object == null)
throw new IllegalArgumentException("Object was null");
try {
return jsonMapper.writeValueAsBytes(object);
} catch (JsonProcessingException e) {
throw new JSONException(e);
}
}
|
[
"public",
"static",
"final",
"byte",
"[",
"]",
"serializeToBytes",
"(",
"final",
"Object",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"null",
")",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Object was null\"",
")",
";",
"try",
"{",
"return",
"jsonMapper",
".",
"writeValueAsBytes",
"(",
"object",
")",
";",
"}",
"catch",
"(",
"JsonProcessingException",
"e",
")",
"{",
"throw",
"new",
"JSONException",
"(",
"e",
")",
";",
"}",
"}"
] |
Serializes the given object to a JSON byte array
@param object The object to serialize
@return A JSON formatted byte array
@throws IllegalArgumentException if the object was null
@throws JSONException if the object could not be serialized
|
[
"Serializes",
"the",
"given",
"object",
"to",
"a",
"JSON",
"byte",
"array"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/utils/JSON.java#L290-L298
|
13,544
|
OpenTSDB/opentsdb
|
src/query/expression/ExpressionIterator.java
|
ExpressionIterator.compile
|
public void compile() {
if (LOG.isDebugEnabled()) {
LOG.debug("Compiling " + this);
}
if (results.size() < 1) {
throw new IllegalArgumentException("No results for any variables in "
+ "the expression: " + this);
}
if (results.size() < names.size()) {
throw new IllegalArgumentException("Not enough query results ["
+ results.size() + " total results found] for the expression variables ["
+ names.size() + " expected] " + this);
}
// don't care if we have extra results, but we had darned well better make
// sure we have a result set for each variable
for (final String variable : names) {
// validation
final ITimeSyncedIterator it = results.get(variable.toLowerCase());
if (it == null) {
throw new IllegalArgumentException("Missing results for variable " + variable);
}
if (it instanceof ExpressionIterator) {
((ExpressionIterator)it).compile();
}
if (LOG.isDebugEnabled()) {
LOG.debug("Matched variable " + variable + " to " + it);
}
}
// TODO implement other set functions
switch (set_operator) {
case INTERSECTION:
iterator = new IntersectionIterator(id, results, intersect_on_query_tagks,
include_agg_tags);
break;
case UNION:
iterator = new UnionIterator(id, results, intersect_on_query_tagks,
include_agg_tags);
}
iteration_results = iterator.getResults();
dps = new ExpressionDataPoint[iterator.getSeriesSize()];
for (int i = 0; i < iterator.getSeriesSize(); i++) {
final Iterator<Entry<String, ExpressionDataPoint[]>> it =
iteration_results.entrySet().iterator();
Entry<String, ExpressionDataPoint[]> entry = it.next();
if (entry.getValue() == null || entry.getValue()[i] == null) {
dps[i] = new ExpressionDataPoint();
} else {
dps[i] = new ExpressionDataPoint(entry.getValue()[i]);
}
while (it.hasNext()) {
entry = it.next();
if (entry.getValue() != null && entry.getValue()[i] != null) {
dps[i].add(entry.getValue()[i]);
}
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Finished compiling " + this);
}
}
|
java
|
public void compile() {
if (LOG.isDebugEnabled()) {
LOG.debug("Compiling " + this);
}
if (results.size() < 1) {
throw new IllegalArgumentException("No results for any variables in "
+ "the expression: " + this);
}
if (results.size() < names.size()) {
throw new IllegalArgumentException("Not enough query results ["
+ results.size() + " total results found] for the expression variables ["
+ names.size() + " expected] " + this);
}
// don't care if we have extra results, but we had darned well better make
// sure we have a result set for each variable
for (final String variable : names) {
// validation
final ITimeSyncedIterator it = results.get(variable.toLowerCase());
if (it == null) {
throw new IllegalArgumentException("Missing results for variable " + variable);
}
if (it instanceof ExpressionIterator) {
((ExpressionIterator)it).compile();
}
if (LOG.isDebugEnabled()) {
LOG.debug("Matched variable " + variable + " to " + it);
}
}
// TODO implement other set functions
switch (set_operator) {
case INTERSECTION:
iterator = new IntersectionIterator(id, results, intersect_on_query_tagks,
include_agg_tags);
break;
case UNION:
iterator = new UnionIterator(id, results, intersect_on_query_tagks,
include_agg_tags);
}
iteration_results = iterator.getResults();
dps = new ExpressionDataPoint[iterator.getSeriesSize()];
for (int i = 0; i < iterator.getSeriesSize(); i++) {
final Iterator<Entry<String, ExpressionDataPoint[]>> it =
iteration_results.entrySet().iterator();
Entry<String, ExpressionDataPoint[]> entry = it.next();
if (entry.getValue() == null || entry.getValue()[i] == null) {
dps[i] = new ExpressionDataPoint();
} else {
dps[i] = new ExpressionDataPoint(entry.getValue()[i]);
}
while (it.hasNext()) {
entry = it.next();
if (entry.getValue() != null && entry.getValue()[i] != null) {
dps[i].add(entry.getValue()[i]);
}
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Finished compiling " + this);
}
}
|
[
"public",
"void",
"compile",
"(",
")",
"{",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Compiling \"",
"+",
"this",
")",
";",
"}",
"if",
"(",
"results",
".",
"size",
"(",
")",
"<",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No results for any variables in \"",
"+",
"\"the expression: \"",
"+",
"this",
")",
";",
"}",
"if",
"(",
"results",
".",
"size",
"(",
")",
"<",
"names",
".",
"size",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Not enough query results [\"",
"+",
"results",
".",
"size",
"(",
")",
"+",
"\" total results found] for the expression variables [\"",
"+",
"names",
".",
"size",
"(",
")",
"+",
"\" expected] \"",
"+",
"this",
")",
";",
"}",
"// don't care if we have extra results, but we had darned well better make",
"// sure we have a result set for each variable ",
"for",
"(",
"final",
"String",
"variable",
":",
"names",
")",
"{",
"// validation",
"final",
"ITimeSyncedIterator",
"it",
"=",
"results",
".",
"get",
"(",
"variable",
".",
"toLowerCase",
"(",
")",
")",
";",
"if",
"(",
"it",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Missing results for variable \"",
"+",
"variable",
")",
";",
"}",
"if",
"(",
"it",
"instanceof",
"ExpressionIterator",
")",
"{",
"(",
"(",
"ExpressionIterator",
")",
"it",
")",
".",
"compile",
"(",
")",
";",
"}",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Matched variable \"",
"+",
"variable",
"+",
"\" to \"",
"+",
"it",
")",
";",
"}",
"}",
"// TODO implement other set functions",
"switch",
"(",
"set_operator",
")",
"{",
"case",
"INTERSECTION",
":",
"iterator",
"=",
"new",
"IntersectionIterator",
"(",
"id",
",",
"results",
",",
"intersect_on_query_tagks",
",",
"include_agg_tags",
")",
";",
"break",
";",
"case",
"UNION",
":",
"iterator",
"=",
"new",
"UnionIterator",
"(",
"id",
",",
"results",
",",
"intersect_on_query_tagks",
",",
"include_agg_tags",
")",
";",
"}",
"iteration_results",
"=",
"iterator",
".",
"getResults",
"(",
")",
";",
"dps",
"=",
"new",
"ExpressionDataPoint",
"[",
"iterator",
".",
"getSeriesSize",
"(",
")",
"]",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"iterator",
".",
"getSeriesSize",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"Iterator",
"<",
"Entry",
"<",
"String",
",",
"ExpressionDataPoint",
"[",
"]",
">",
">",
"it",
"=",
"iteration_results",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
";",
"Entry",
"<",
"String",
",",
"ExpressionDataPoint",
"[",
"]",
">",
"entry",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
"==",
"null",
"||",
"entry",
".",
"getValue",
"(",
")",
"[",
"i",
"]",
"==",
"null",
")",
"{",
"dps",
"[",
"i",
"]",
"=",
"new",
"ExpressionDataPoint",
"(",
")",
";",
"}",
"else",
"{",
"dps",
"[",
"i",
"]",
"=",
"new",
"ExpressionDataPoint",
"(",
"entry",
".",
"getValue",
"(",
")",
"[",
"i",
"]",
")",
";",
"}",
"while",
"(",
"it",
".",
"hasNext",
"(",
")",
")",
"{",
"entry",
"=",
"it",
".",
"next",
"(",
")",
";",
"if",
"(",
"entry",
".",
"getValue",
"(",
")",
"!=",
"null",
"&&",
"entry",
".",
"getValue",
"(",
")",
"[",
"i",
"]",
"!=",
"null",
")",
"{",
"dps",
"[",
"i",
"]",
".",
"add",
"(",
"entry",
".",
"getValue",
"(",
")",
"[",
"i",
"]",
")",
";",
"}",
"}",
"}",
"if",
"(",
"LOG",
".",
"isDebugEnabled",
"(",
")",
")",
"{",
"LOG",
".",
"debug",
"(",
"\"Finished compiling \"",
"+",
"this",
")",
";",
"}",
"}"
] |
Builds the iterator by computing the intersection of all series in all sets
and sets up the output.
@throws IllegalArgumentException if there aren't any results, or we don't
have a result for each variable, or something else is wrong.
@throws IllegalDataException if no series were left after computing the
intersection.
|
[
"Builds",
"the",
"iterator",
"by",
"computing",
"the",
"intersection",
"of",
"all",
"series",
"in",
"all",
"sets",
"and",
"sets",
"up",
"the",
"output",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/expression/ExpressionIterator.java#L237-L302
|
13,545
|
OpenTSDB/opentsdb
|
src/utils/PluginLoader.java
|
PluginLoader.loadJAR
|
public static void loadJAR(String jar) throws IOException, SecurityException,
IllegalArgumentException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
if (!jar.toLowerCase().endsWith(".jar")) {
throw new IllegalArgumentException(
"File specified did not end with .jar");
}
File file = new File(jar);
if (!file.exists()) {
throw new FileNotFoundException(jar);
}
addFile(file);
}
|
java
|
public static void loadJAR(String jar) throws IOException, SecurityException,
IllegalArgumentException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
if (!jar.toLowerCase().endsWith(".jar")) {
throw new IllegalArgumentException(
"File specified did not end with .jar");
}
File file = new File(jar);
if (!file.exists()) {
throw new FileNotFoundException(jar);
}
addFile(file);
}
|
[
"public",
"static",
"void",
"loadJAR",
"(",
"String",
"jar",
")",
"throws",
"IOException",
",",
"SecurityException",
",",
"IllegalArgumentException",
",",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"if",
"(",
"!",
"jar",
".",
"toLowerCase",
"(",
")",
".",
"endsWith",
"(",
"\".jar\"",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"File specified did not end with .jar\"",
")",
";",
"}",
"File",
"file",
"=",
"new",
"File",
"(",
"jar",
")",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"jar",
")",
";",
"}",
"addFile",
"(",
"file",
")",
";",
"}"
] |
Attempts to load the given jar into the class path
@param jar Full path to a .jar file
@throws IOException if the file does not exist or cannot be accessed
@throws SecurityException if there is a security manager present and the
operation is denied
@throws IllegalArgumentException if the filename did not end with .jar
@throws NoSuchMethodException if there is an error with the class loader
@throws IllegalAccessException if a security manager is present and the
operation was denied
@throws InvocationTargetException if there is an issue loading the jar
|
[
"Attempts",
"to",
"load",
"the",
"given",
"jar",
"into",
"the",
"class",
"path"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/utils/PluginLoader.java#L168-L180
|
13,546
|
OpenTSDB/opentsdb
|
src/utils/PluginLoader.java
|
PluginLoader.searchForJars
|
private static void searchForJars(final File file, List<File> jars) {
if (file.isFile()) {
if (file.getAbsolutePath().toLowerCase().endsWith(".jar")) {
jars.add(file);
LOG.debug("Found a jar: " + file.getAbsolutePath());
}
} else if (file.isDirectory()) {
File[] files = file.listFiles();
if (files == null) {
// if this is null, it's due to a security issue
LOG.warn("Access denied to directory: " + file.getAbsolutePath());
} else {
for (File f : files) {
searchForJars(f, jars);
}
}
}
}
|
java
|
private static void searchForJars(final File file, List<File> jars) {
if (file.isFile()) {
if (file.getAbsolutePath().toLowerCase().endsWith(".jar")) {
jars.add(file);
LOG.debug("Found a jar: " + file.getAbsolutePath());
}
} else if (file.isDirectory()) {
File[] files = file.listFiles();
if (files == null) {
// if this is null, it's due to a security issue
LOG.warn("Access denied to directory: " + file.getAbsolutePath());
} else {
for (File f : files) {
searchForJars(f, jars);
}
}
}
}
|
[
"private",
"static",
"void",
"searchForJars",
"(",
"final",
"File",
"file",
",",
"List",
"<",
"File",
">",
"jars",
")",
"{",
"if",
"(",
"file",
".",
"isFile",
"(",
")",
")",
"{",
"if",
"(",
"file",
".",
"getAbsolutePath",
"(",
")",
".",
"toLowerCase",
"(",
")",
".",
"endsWith",
"(",
"\".jar\"",
")",
")",
"{",
"jars",
".",
"add",
"(",
"file",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Found a jar: \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"}",
"else",
"if",
"(",
"file",
".",
"isDirectory",
"(",
")",
")",
"{",
"File",
"[",
"]",
"files",
"=",
"file",
".",
"listFiles",
"(",
")",
";",
"if",
"(",
"files",
"==",
"null",
")",
"{",
"// if this is null, it's due to a security issue",
"LOG",
".",
"warn",
"(",
"\"Access denied to directory: \"",
"+",
"file",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"}",
"else",
"{",
"for",
"(",
"File",
"f",
":",
"files",
")",
"{",
"searchForJars",
"(",
"f",
",",
"jars",
")",
";",
"}",
"}",
"}",
"}"
] |
Recursive method to search for JAR files starting at a given level
@param file The directory to search in
@param jars A list of file objects that will be loaded with discovered
jar files
@throws SecurityException if a security manager exists and prevents reading
|
[
"Recursive",
"method",
"to",
"search",
"for",
"JAR",
"files",
"starting",
"at",
"a",
"given",
"level"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/utils/PluginLoader.java#L227-L244
|
13,547
|
OpenTSDB/opentsdb
|
src/utils/PluginLoader.java
|
PluginLoader.addFile
|
private static void addFile(File f) throws IOException, SecurityException,
IllegalArgumentException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
addURL(f.toURI().toURL());
}
|
java
|
private static void addFile(File f) throws IOException, SecurityException,
IllegalArgumentException, NoSuchMethodException, IllegalAccessException,
InvocationTargetException {
addURL(f.toURI().toURL());
}
|
[
"private",
"static",
"void",
"addFile",
"(",
"File",
"f",
")",
"throws",
"IOException",
",",
"SecurityException",
",",
"IllegalArgumentException",
",",
"NoSuchMethodException",
",",
"IllegalAccessException",
",",
"InvocationTargetException",
"{",
"addURL",
"(",
"f",
".",
"toURI",
"(",
")",
".",
"toURL",
"(",
")",
")",
";",
"}"
] |
Attempts to add the given file object to the class loader
@param f The JAR file object to load
@throws IOException if the file does not exist or cannot be accessed
@throws SecurityException if there is a security manager present and the
operation is denied
@throws IllegalArgumentException if the file was invalid
@throws NoSuchMethodException if there is an error with the class loader
@throws IllegalAccessException if a security manager is present and the
operation was denied
@throws InvocationTargetException if there is an issue loading the jar
|
[
"Attempts",
"to",
"add",
"the",
"given",
"file",
"object",
"to",
"the",
"class",
"loader"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/utils/PluginLoader.java#L258-L262
|
13,548
|
OpenTSDB/opentsdb
|
src/query/expression/Scale.java
|
Scale.scale
|
private DataPoints scale(final DataPoints points, final double scale_factor) {
// TODO(cl) - Using an array as the size function may not return the exact
// results and we should figure a way to avoid copying data anyway.
final List<DataPoint> dps = new ArrayList<DataPoint>();
final boolean scale_is_int = (scale_factor == Math.floor(scale_factor)) &&
!Double.isInfinite(scale_factor);
final SeekableView view = points.iterator();
while (view.hasNext()) {
DataPoint pt = view.next();
if (pt.isInteger() && scale_is_int) {
dps.add(MutableDataPoint.ofLongValue(pt.timestamp(),
(long)scale_factor * pt.longValue()));
} else {
// NaNs are fine here, they'll just be re-computed as NaN
dps.add(MutableDataPoint.ofDoubleValue(pt.timestamp(),
scale_factor * pt.toDouble()));
}
}
final DataPoint[] results = new DataPoint[dps.size()];
dps.toArray(results);
return new PostAggregatedDataPoints(points, results);
}
|
java
|
private DataPoints scale(final DataPoints points, final double scale_factor) {
// TODO(cl) - Using an array as the size function may not return the exact
// results and we should figure a way to avoid copying data anyway.
final List<DataPoint> dps = new ArrayList<DataPoint>();
final boolean scale_is_int = (scale_factor == Math.floor(scale_factor)) &&
!Double.isInfinite(scale_factor);
final SeekableView view = points.iterator();
while (view.hasNext()) {
DataPoint pt = view.next();
if (pt.isInteger() && scale_is_int) {
dps.add(MutableDataPoint.ofLongValue(pt.timestamp(),
(long)scale_factor * pt.longValue()));
} else {
// NaNs are fine here, they'll just be re-computed as NaN
dps.add(MutableDataPoint.ofDoubleValue(pt.timestamp(),
scale_factor * pt.toDouble()));
}
}
final DataPoint[] results = new DataPoint[dps.size()];
dps.toArray(results);
return new PostAggregatedDataPoints(points, results);
}
|
[
"private",
"DataPoints",
"scale",
"(",
"final",
"DataPoints",
"points",
",",
"final",
"double",
"scale_factor",
")",
"{",
"// TODO(cl) - Using an array as the size function may not return the exact",
"// results and we should figure a way to avoid copying data anyway.",
"final",
"List",
"<",
"DataPoint",
">",
"dps",
"=",
"new",
"ArrayList",
"<",
"DataPoint",
">",
"(",
")",
";",
"final",
"boolean",
"scale_is_int",
"=",
"(",
"scale_factor",
"==",
"Math",
".",
"floor",
"(",
"scale_factor",
")",
")",
"&&",
"!",
"Double",
".",
"isInfinite",
"(",
"scale_factor",
")",
";",
"final",
"SeekableView",
"view",
"=",
"points",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"view",
".",
"hasNext",
"(",
")",
")",
"{",
"DataPoint",
"pt",
"=",
"view",
".",
"next",
"(",
")",
";",
"if",
"(",
"pt",
".",
"isInteger",
"(",
")",
"&&",
"scale_is_int",
")",
"{",
"dps",
".",
"add",
"(",
"MutableDataPoint",
".",
"ofLongValue",
"(",
"pt",
".",
"timestamp",
"(",
")",
",",
"(",
"long",
")",
"scale_factor",
"*",
"pt",
".",
"longValue",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"// NaNs are fine here, they'll just be re-computed as NaN",
"dps",
".",
"add",
"(",
"MutableDataPoint",
".",
"ofDoubleValue",
"(",
"pt",
".",
"timestamp",
"(",
")",
",",
"scale_factor",
"*",
"pt",
".",
"toDouble",
"(",
")",
")",
")",
";",
"}",
"}",
"final",
"DataPoint",
"[",
"]",
"results",
"=",
"new",
"DataPoint",
"[",
"dps",
".",
"size",
"(",
")",
"]",
";",
"dps",
".",
"toArray",
"(",
"results",
")",
";",
"return",
"new",
"PostAggregatedDataPoints",
"(",
"points",
",",
"results",
")",
";",
"}"
] |
Multiplies each data point in the series by the scale factor, maintaining
integers if both the data point and scale are integers.
@param points The data points to factor
@param scale_factor The factor to multiply by
@return The resulting data points
|
[
"Multiplies",
"each",
"data",
"point",
"in",
"the",
"series",
"by",
"the",
"scale",
"factor",
"maintaining",
"integers",
"if",
"both",
"the",
"data",
"point",
"and",
"scale",
"are",
"integers",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/expression/Scale.java#L81-L102
|
13,549
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseSuggestV1
|
@Override
public HashMap<String, String> parseSuggestV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
return JSON.parseToObject(query.getContent(),
new TypeReference<HashMap<String, String>>(){});
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
java
|
@Override
public HashMap<String, String> parseSuggestV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
return JSON.parseToObject(query.getContent(),
new TypeReference<HashMap<String, String>>(){});
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
[
"@",
"Override",
"public",
"HashMap",
"<",
"String",
",",
"String",
">",
"parseSuggestV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"try",
"{",
"return",
"JSON",
".",
"parseToObject",
"(",
"query",
".",
"getContent",
"(",
")",
",",
"new",
"TypeReference",
"<",
"HashMap",
"<",
"String",
",",
"String",
">",
">",
"(",
")",
"{",
"}",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"iae",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"\"Unable to parse the given JSON\"",
",",
"iae",
")",
";",
"}",
"}"
] |
Parses a suggestion query
@return a hash map of key/value pairs
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"a",
"suggestion",
"query"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L202-L216
|
13,550
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseUidRenameV1
|
public HashMap<String, String> parseUidRenameV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
return JSON.parseToObject(json, TR_HASH_MAP);
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
java
|
public HashMap<String, String> parseUidRenameV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
return JSON.parseToObject(json, TR_HASH_MAP);
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
[
"public",
"HashMap",
"<",
"String",
",",
"String",
">",
"parseUidRenameV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"try",
"{",
"return",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"TR_HASH_MAP",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"iae",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"\"Unable to parse the given JSON\"",
",",
"iae",
")",
";",
"}",
"}"
] |
Parses metric, tagk or tagv, and name to rename UID
@return as hash map of type and name
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"metric",
"tagk",
"or",
"tagv",
"and",
"name",
"to",
"rename",
"UID"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L244-L256
|
13,551
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseQueryV1
|
public TSQuery parseQueryV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
TSQuery data_query = JSON.parseToObject(json, TSQuery.class);
// Filter out duplicate queries
Set<TSSubQuery> query_set = new LinkedHashSet<TSSubQuery>(data_query.getQueries());
data_query.getQueries().clear();
data_query.getQueries().addAll(query_set);
return data_query;
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
java
|
public TSQuery parseQueryV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
TSQuery data_query = JSON.parseToObject(json, TSQuery.class);
// Filter out duplicate queries
Set<TSSubQuery> query_set = new LinkedHashSet<TSSubQuery>(data_query.getQueries());
data_query.getQueries().clear();
data_query.getQueries().addAll(query_set);
return data_query;
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
[
"public",
"TSQuery",
"parseQueryV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"try",
"{",
"TSQuery",
"data_query",
"=",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"TSQuery",
".",
"class",
")",
";",
"// Filter out duplicate queries",
"Set",
"<",
"TSSubQuery",
">",
"query_set",
"=",
"new",
"LinkedHashSet",
"<",
"TSSubQuery",
">",
"(",
"data_query",
".",
"getQueries",
"(",
")",
")",
";",
"data_query",
".",
"getQueries",
"(",
")",
".",
"clear",
"(",
")",
";",
"data_query",
".",
"getQueries",
"(",
")",
".",
"addAll",
"(",
"query_set",
")",
";",
"return",
"data_query",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"iae",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"\"Unable to parse the given JSON\"",
",",
"iae",
")",
";",
"}",
"}"
] |
Parses a timeseries data query
@return A TSQuery with data ready to validate
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"a",
"timeseries",
"data",
"query"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L264-L281
|
13,552
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseLastPointQueryV1
|
public LastPointQuery parseLastPointQueryV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
return JSON.parseToObject(json, LastPointQuery.class);
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
java
|
public LastPointQuery parseLastPointQueryV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
return JSON.parseToObject(json, LastPointQuery.class);
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
[
"public",
"LastPointQuery",
"parseLastPointQueryV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"try",
"{",
"return",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"LastPointQuery",
".",
"class",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"iae",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"\"Unable to parse the given JSON\"",
",",
"iae",
")",
";",
"}",
"}"
] |
Parses a last data point query
@return A LastPointQuery to work with
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"a",
"last",
"data",
"point",
"query"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L289-L301
|
13,553
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseUidMetaV1
|
public UIDMeta parseUidMetaV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
return JSON.parseToObject(json, UIDMeta.class);
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
java
|
public UIDMeta parseUidMetaV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
return JSON.parseToObject(json, UIDMeta.class);
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
[
"public",
"UIDMeta",
"parseUidMetaV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"try",
"{",
"return",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"UIDMeta",
".",
"class",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"iae",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"\"Unable to parse the given JSON\"",
",",
"iae",
")",
";",
"}",
"}"
] |
Parses a single UIDMeta object
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"a",
"single",
"UIDMeta",
"object"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L308-L320
|
13,554
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseTSMetaV1
|
public TSMeta parseTSMetaV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
return JSON.parseToObject(json, TSMeta.class);
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
java
|
public TSMeta parseTSMetaV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
try {
return JSON.parseToObject(json, TSMeta.class);
} catch (IllegalArgumentException iae) {
throw new BadRequestException("Unable to parse the given JSON", iae);
}
}
|
[
"public",
"TSMeta",
"parseTSMetaV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"try",
"{",
"return",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"TSMeta",
".",
"class",
")",
";",
"}",
"catch",
"(",
"IllegalArgumentException",
"iae",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"\"Unable to parse the given JSON\"",
",",
"iae",
")",
";",
"}",
"}"
] |
Parses a single TSMeta object
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"a",
"single",
"TSMeta",
"object"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L327-L339
|
13,555
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseTreeRuleV1
|
public TreeRule parseTreeRuleV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, TreeRule.class);
}
|
java
|
public TreeRule parseTreeRuleV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, TreeRule.class);
}
|
[
"public",
"TreeRule",
"parseTreeRuleV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"return",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"TreeRule",
".",
"class",
")",
";",
"}"
] |
Parses a single TreeRule object
@return A parsed tree rule
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"a",
"single",
"TreeRule",
"object"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L410-L419
|
13,556
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseTreeRulesV1
|
public List<TreeRule> parseTreeRulesV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, TR_TREE_RULES);
}
|
java
|
public List<TreeRule> parseTreeRulesV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, TR_TREE_RULES);
}
|
[
"public",
"List",
"<",
"TreeRule",
">",
"parseTreeRulesV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"return",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"TR_TREE_RULES",
")",
";",
"}"
] |
Parses one or more tree rules
@return A list of one or more rules
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"one",
"or",
"more",
"tree",
"rules"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L427-L436
|
13,557
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseTreeTSUIDsListV1
|
public Map<String, Object> parseTreeTSUIDsListV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, TR_HASH_MAP_OBJ);
}
|
java
|
public Map<String, Object> parseTreeTSUIDsListV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, TR_HASH_MAP_OBJ);
}
|
[
"public",
"Map",
"<",
"String",
",",
"Object",
">",
"parseTreeTSUIDsListV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"return",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"TR_HASH_MAP_OBJ",
")",
";",
"}"
] |
Parses a tree ID and optional list of TSUIDs to search for collisions or
not matched TSUIDs.
@return A map with "treeId" as an integer and optionally "tsuids" as a
List<String>
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"a",
"tree",
"ID",
"and",
"optional",
"list",
"of",
"TSUIDs",
"to",
"search",
"for",
"collisions",
"or",
"not",
"matched",
"TSUIDs",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L446-L455
|
13,558
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseAnnotationV1
|
public Annotation parseAnnotationV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, Annotation.class);
}
|
java
|
public Annotation parseAnnotationV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, Annotation.class);
}
|
[
"public",
"Annotation",
"parseAnnotationV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"return",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"Annotation",
".",
"class",
")",
";",
"}"
] |
Parses an annotation object
@return An annotation object
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"an",
"annotation",
"object"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L463-L472
|
13,559
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseAnnotationsV1
|
public List<Annotation> parseAnnotationsV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, TR_ANNOTATIONS);
}
|
java
|
public List<Annotation> parseAnnotationsV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, TR_ANNOTATIONS);
}
|
[
"public",
"List",
"<",
"Annotation",
">",
"parseAnnotationsV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"return",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"TR_ANNOTATIONS",
")",
";",
"}"
] |
Parses a list of annotation objects
@return A list of annotation object
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"a",
"list",
"of",
"annotation",
"objects"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L480-L489
|
13,560
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseAnnotationBulkDeleteV1
|
public AnnotationBulkDelete parseAnnotationBulkDeleteV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, AnnotationBulkDelete.class);
}
|
java
|
public AnnotationBulkDelete parseAnnotationBulkDeleteV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, AnnotationBulkDelete.class);
}
|
[
"public",
"AnnotationBulkDelete",
"parseAnnotationBulkDeleteV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"return",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"AnnotationBulkDelete",
".",
"class",
")",
";",
"}"
] |
Parses a bulk annotation deletion query object
@return Settings used to bulk delete annotations
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"a",
"bulk",
"annotation",
"deletion",
"query",
"object"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L497-L506
|
13,561
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.parseSearchQueryV1
|
public SearchQuery parseSearchQueryV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, SearchQuery.class);
}
|
java
|
public SearchQuery parseSearchQueryV1() {
final String json = query.getContent();
if (json == null || json.isEmpty()) {
throw new BadRequestException(HttpResponseStatus.BAD_REQUEST,
"Missing message content",
"Supply valid JSON formatted data in the body of your request");
}
return JSON.parseToObject(json, SearchQuery.class);
}
|
[
"public",
"SearchQuery",
"parseSearchQueryV1",
"(",
")",
"{",
"final",
"String",
"json",
"=",
"query",
".",
"getContent",
"(",
")",
";",
"if",
"(",
"json",
"==",
"null",
"||",
"json",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"HttpResponseStatus",
".",
"BAD_REQUEST",
",",
"\"Missing message content\"",
",",
"\"Supply valid JSON formatted data in the body of your request\"",
")",
";",
"}",
"return",
"JSON",
".",
"parseToObject",
"(",
"json",
",",
"SearchQuery",
".",
"class",
")",
";",
"}"
] |
Parses a SearchQuery request
@return The parsed search query
@throws JSONException if parsing failed
@throws BadRequestException if the content was missing or parsing failed
|
[
"Parses",
"a",
"SearchQuery",
"request"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L514-L523
|
13,562
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.formatConfigV1
|
public ChannelBuffer formatConfigV1(final Config config) {
TreeMap<String, String> map = new TreeMap<String, String>(config.getMap());
for (Map.Entry<String, String> entry : map.entrySet()) {
if (entry.getKey().toUpperCase().contains("PASS")) {
map.put(entry.getKey(), "********");
}
}
return serializeJSON(map);
}
|
java
|
public ChannelBuffer formatConfigV1(final Config config) {
TreeMap<String, String> map = new TreeMap<String, String>(config.getMap());
for (Map.Entry<String, String> entry : map.entrySet()) {
if (entry.getKey().toUpperCase().contains("PASS")) {
map.put(entry.getKey(), "********");
}
}
return serializeJSON(map);
}
|
[
"public",
"ChannelBuffer",
"formatConfigV1",
"(",
"final",
"Config",
"config",
")",
"{",
"TreeMap",
"<",
"String",
",",
"String",
">",
"map",
"=",
"new",
"TreeMap",
"<",
"String",
",",
"String",
">",
"(",
"config",
".",
"getMap",
"(",
")",
")",
";",
"for",
"(",
"Map",
".",
"Entry",
"<",
"String",
",",
"String",
">",
"entry",
":",
"map",
".",
"entrySet",
"(",
")",
")",
"{",
"if",
"(",
"entry",
".",
"getKey",
"(",
")",
".",
"toUpperCase",
"(",
")",
".",
"contains",
"(",
"\"PASS\"",
")",
")",
"{",
"map",
".",
"put",
"(",
"entry",
".",
"getKey",
"(",
")",
",",
"\"********\"",
")",
";",
"}",
"}",
"return",
"serializeJSON",
"(",
"map",
")",
";",
"}"
] |
Format the running configuration
@param config The running config to serialize
@return A ChannelBuffer object to pass on to the caller
@throws JSONException if serialization failed
|
[
"Format",
"the",
"running",
"configuration"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L1190-L1198
|
13,563
|
OpenTSDB/opentsdb
|
src/tsd/HttpJsonSerializer.java
|
HttpJsonSerializer.serializeJSON
|
private ChannelBuffer serializeJSON(final Object obj) {
if (query.hasQueryStringParam("jsonp")) {
return ChannelBuffers.wrappedBuffer(
JSON.serializeToJSONPBytes(query.getQueryStringParam("jsonp"),
obj));
}
return ChannelBuffers.wrappedBuffer(JSON.serializeToBytes(obj));
}
|
java
|
private ChannelBuffer serializeJSON(final Object obj) {
if (query.hasQueryStringParam("jsonp")) {
return ChannelBuffers.wrappedBuffer(
JSON.serializeToJSONPBytes(query.getQueryStringParam("jsonp"),
obj));
}
return ChannelBuffers.wrappedBuffer(JSON.serializeToBytes(obj));
}
|
[
"private",
"ChannelBuffer",
"serializeJSON",
"(",
"final",
"Object",
"obj",
")",
"{",
"if",
"(",
"query",
".",
"hasQueryStringParam",
"(",
"\"jsonp\"",
")",
")",
"{",
"return",
"ChannelBuffers",
".",
"wrappedBuffer",
"(",
"JSON",
".",
"serializeToJSONPBytes",
"(",
"query",
".",
"getQueryStringParam",
"(",
"\"jsonp\"",
")",
",",
"obj",
")",
")",
";",
"}",
"return",
"ChannelBuffers",
".",
"wrappedBuffer",
"(",
"JSON",
".",
"serializeToBytes",
"(",
"obj",
")",
")",
";",
"}"
] |
Helper object for the format calls to wrap the JSON response in a JSONP
function if requested. Used for code dedupe.
@param obj The object to serialize
@return A ChannelBuffer to pass on to the query
@throws JSONException if serialization failed
|
[
"Helper",
"object",
"for",
"the",
"format",
"calls",
"to",
"wrap",
"the",
"JSON",
"response",
"in",
"a",
"JSONP",
"function",
"if",
"requested",
".",
"Used",
"for",
"code",
"dedupe",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/HttpJsonSerializer.java#L1218-L1225
|
13,564
|
OpenTSDB/opentsdb
|
src/core/SaltScanner.java
|
SaltScanner.scan
|
public Deferred<TreeMap<byte[], Span>> scan() {
start_time = System.currentTimeMillis();
int i = 0;
for (final Scanner scanner: scanners) {
new ScannerCB(scanner, i++).scan();
}
return results;
}
|
java
|
public Deferred<TreeMap<byte[], Span>> scan() {
start_time = System.currentTimeMillis();
int i = 0;
for (final Scanner scanner: scanners) {
new ScannerCB(scanner, i++).scan();
}
return results;
}
|
[
"public",
"Deferred",
"<",
"TreeMap",
"<",
"byte",
"[",
"]",
",",
"Span",
">",
">",
"scan",
"(",
")",
"{",
"start_time",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"int",
"i",
"=",
"0",
";",
"for",
"(",
"final",
"Scanner",
"scanner",
":",
"scanners",
")",
"{",
"new",
"ScannerCB",
"(",
"scanner",
",",
"i",
"++",
")",
".",
"scan",
"(",
")",
";",
"}",
"return",
"results",
";",
"}"
] |
Starts all of the scanners asynchronously and returns the data fetched
once all of the scanners have completed. Note that the result may be an
exception if one or more of the scanners encountered an exception. The
first error will be returned, others will be logged.
@return A deferred to wait on for results.
|
[
"Starts",
"all",
"of",
"the",
"scanners",
"asynchronously",
"and",
"returns",
"the",
"data",
"fetched",
"once",
"all",
"of",
"the",
"scanners",
"have",
"completed",
".",
"Note",
"that",
"the",
"result",
"may",
"be",
"an",
"exception",
"if",
"one",
"or",
"more",
"of",
"the",
"scanners",
"encountered",
"an",
"exception",
".",
"The",
"first",
"error",
"will",
"be",
"returned",
"others",
"will",
"be",
"logged",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/SaltScanner.java#L267-L274
|
13,565
|
OpenTSDB/opentsdb
|
src/core/SaltScanner.java
|
SaltScanner.validateAndTriggerCallback
|
private void validateAndTriggerCallback(
final List<KeyValue> kvs,
final Map<byte[], List<Annotation>> annotations,
final List<SimpleEntry<byte[], List<HistogramDataPoint>>> histograms) {
countdown.countDown();
final long count = countdown.getCount();
if (kvs.size() > 0) {
kv_map.put((int) count, kvs);
}
for (final byte[] key : annotations.keySet()) {
final List<Annotation> notes = annotations.get(key);
if (notes.size() > 0) {
// Optimistic write, expecting unique row keys
annotation_map.put(key, notes);
}
}
if (histograms.size() > 0) {
histMap.put((int) count, histograms);
}
if (countdown.getCount() <= 0) {
try {
mergeAndReturnResults();
} catch (final Exception ex) {
results.callback(ex);
}
}
}
|
java
|
private void validateAndTriggerCallback(
final List<KeyValue> kvs,
final Map<byte[], List<Annotation>> annotations,
final List<SimpleEntry<byte[], List<HistogramDataPoint>>> histograms) {
countdown.countDown();
final long count = countdown.getCount();
if (kvs.size() > 0) {
kv_map.put((int) count, kvs);
}
for (final byte[] key : annotations.keySet()) {
final List<Annotation> notes = annotations.get(key);
if (notes.size() > 0) {
// Optimistic write, expecting unique row keys
annotation_map.put(key, notes);
}
}
if (histograms.size() > 0) {
histMap.put((int) count, histograms);
}
if (countdown.getCount() <= 0) {
try {
mergeAndReturnResults();
} catch (final Exception ex) {
results.callback(ex);
}
}
}
|
[
"private",
"void",
"validateAndTriggerCallback",
"(",
"final",
"List",
"<",
"KeyValue",
">",
"kvs",
",",
"final",
"Map",
"<",
"byte",
"[",
"]",
",",
"List",
"<",
"Annotation",
">",
">",
"annotations",
",",
"final",
"List",
"<",
"SimpleEntry",
"<",
"byte",
"[",
"]",
",",
"List",
"<",
"HistogramDataPoint",
">",
">",
">",
"histograms",
")",
"{",
"countdown",
".",
"countDown",
"(",
")",
";",
"final",
"long",
"count",
"=",
"countdown",
".",
"getCount",
"(",
")",
";",
"if",
"(",
"kvs",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"kv_map",
".",
"put",
"(",
"(",
"int",
")",
"count",
",",
"kvs",
")",
";",
"}",
"for",
"(",
"final",
"byte",
"[",
"]",
"key",
":",
"annotations",
".",
"keySet",
"(",
")",
")",
"{",
"final",
"List",
"<",
"Annotation",
">",
"notes",
"=",
"annotations",
".",
"get",
"(",
"key",
")",
";",
"if",
"(",
"notes",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"// Optimistic write, expecting unique row keys",
"annotation_map",
".",
"put",
"(",
"key",
",",
"notes",
")",
";",
"}",
"}",
"if",
"(",
"histograms",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"histMap",
".",
"put",
"(",
"(",
"int",
")",
"count",
",",
"histograms",
")",
";",
"}",
"if",
"(",
"countdown",
".",
"getCount",
"(",
")",
"<=",
"0",
")",
"{",
"try",
"{",
"mergeAndReturnResults",
"(",
")",
";",
"}",
"catch",
"(",
"final",
"Exception",
"ex",
")",
"{",
"results",
".",
"callback",
"(",
"ex",
")",
";",
"}",
"}",
"}"
] |
Called each time a scanner completes with valid or empty data.
@param kvs The compacted columns fetched by the scanner
@param annotations The annotations fetched by the scanners
|
[
"Called",
"each",
"time",
"a",
"scanner",
"completes",
"with",
"valid",
"or",
"empty",
"data",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/SaltScanner.java#L922-L952
|
13,566
|
OpenTSDB/opentsdb
|
src/tsd/GraphHandler.java
|
GraphHandler.getGnuplotBasePath
|
private String getGnuplotBasePath(final TSDB tsdb, final HttpQuery query) {
final Map<String, List<String>> q = query.getQueryString();
q.remove("ignore");
// Super cheap caching mechanism: hash the query string.
final HashMap<String, List<String>> qs =
new HashMap<String, List<String>>(q);
// But first remove the parameters that don't influence the output.
qs.remove("png");
qs.remove("json");
qs.remove("ascii");
return tsdb.getConfig().getDirectoryName("tsd.http.cachedir") +
Integer.toHexString(qs.hashCode());
}
|
java
|
private String getGnuplotBasePath(final TSDB tsdb, final HttpQuery query) {
final Map<String, List<String>> q = query.getQueryString();
q.remove("ignore");
// Super cheap caching mechanism: hash the query string.
final HashMap<String, List<String>> qs =
new HashMap<String, List<String>>(q);
// But first remove the parameters that don't influence the output.
qs.remove("png");
qs.remove("json");
qs.remove("ascii");
return tsdb.getConfig().getDirectoryName("tsd.http.cachedir") +
Integer.toHexString(qs.hashCode());
}
|
[
"private",
"String",
"getGnuplotBasePath",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"HttpQuery",
"query",
")",
"{",
"final",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"q",
"=",
"query",
".",
"getQueryString",
"(",
")",
";",
"q",
".",
"remove",
"(",
"\"ignore\"",
")",
";",
"// Super cheap caching mechanism: hash the query string.",
"final",
"HashMap",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"qs",
"=",
"new",
"HashMap",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"(",
"q",
")",
";",
"// But first remove the parameters that don't influence the output.",
"qs",
".",
"remove",
"(",
"\"png\"",
")",
";",
"qs",
".",
"remove",
"(",
"\"json\"",
")",
";",
"qs",
".",
"remove",
"(",
"\"ascii\"",
")",
";",
"return",
"tsdb",
".",
"getConfig",
"(",
")",
".",
"getDirectoryName",
"(",
"\"tsd.http.cachedir\"",
")",
"+",
"Integer",
".",
"toHexString",
"(",
"qs",
".",
"hashCode",
"(",
")",
")",
";",
"}"
] |
Returns the base path to use for the Gnuplot files.
|
[
"Returns",
"the",
"base",
"path",
"to",
"use",
"for",
"the",
"Gnuplot",
"files",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/GraphHandler.java#L398-L410
|
13,567
|
OpenTSDB/opentsdb
|
src/tsd/GraphHandler.java
|
GraphHandler.isDiskCacheHit
|
private boolean isDiskCacheHit(final HttpQuery query,
final long end_time,
final int max_age,
final String basepath) throws IOException {
final String cachepath = basepath + (query.hasQueryStringParam("ascii")
? ".txt" : ".png");
final File cachedfile = new File(cachepath);
if (cachedfile.exists()) {
final long bytes = cachedfile.length();
if (bytes < 21) { // Minimum possible size for a PNG: 21 bytes.
// For .txt files, <21 bytes is almost impossible.
logWarn(query, "Cached " + cachepath + " is too small ("
+ bytes + " bytes) to be valid. Ignoring it.");
return false;
}
if (staleCacheFile(query, end_time, max_age, cachedfile)) {
return false;
}
if (query.hasQueryStringParam("json")) {
HashMap<String, Object> map = loadCachedJson(query, end_time,
max_age, basepath);
if (map == null) {
map = new HashMap<String, Object>();
}
map.put("timing", query.processingTimeMillis());
map.put("cachehit", "disk");
query.sendReply(JSON.serializeToBytes(map));
} else if (query.hasQueryStringParam("png")
|| query.hasQueryStringParam("ascii")) {
query.sendFile(cachepath, max_age);
} else {
query.sendReply(HttpQuery.makePage("TSDB Query", "Your graph is ready",
"<img src=\"" + query.request().getUri() + "&png\"/><br/>"
+ "<small>(served from disk cache)</small>"));
}
graphs_diskcache_hit.incrementAndGet();
return true;
}
// We didn't find an image. Do a negative cache check. If we've seen
// this query before but there was no result, we at least wrote the JSON.
final HashMap<String, Object> map = loadCachedJson(query, end_time,
max_age, basepath);
// If we don't have a JSON file it's a complete cache miss. If we have
// one, and it says 0 data points were plotted, it's a negative cache hit.
if (map == null || !map.containsKey("plotted") ||
((Integer)map.get("plotted")) == 0) {
return false;
}
if (query.hasQueryStringParam("json")) {
map.put("timing", query.processingTimeMillis());
map.put("cachehit", "disk");
query.sendReply(JSON.serializeToBytes(map));
} else if (query.hasQueryStringParam("png")) {
query.sendReply(" "); // Send back an empty response...
} else {
query.sendReply(HttpQuery.makePage("TSDB Query", "No results",
"Sorry, your query didn't return anything.<br/>"
+ "<small>(served from disk cache)</small>"));
}
graphs_diskcache_hit.incrementAndGet();
return true;
}
|
java
|
private boolean isDiskCacheHit(final HttpQuery query,
final long end_time,
final int max_age,
final String basepath) throws IOException {
final String cachepath = basepath + (query.hasQueryStringParam("ascii")
? ".txt" : ".png");
final File cachedfile = new File(cachepath);
if (cachedfile.exists()) {
final long bytes = cachedfile.length();
if (bytes < 21) { // Minimum possible size for a PNG: 21 bytes.
// For .txt files, <21 bytes is almost impossible.
logWarn(query, "Cached " + cachepath + " is too small ("
+ bytes + " bytes) to be valid. Ignoring it.");
return false;
}
if (staleCacheFile(query, end_time, max_age, cachedfile)) {
return false;
}
if (query.hasQueryStringParam("json")) {
HashMap<String, Object> map = loadCachedJson(query, end_time,
max_age, basepath);
if (map == null) {
map = new HashMap<String, Object>();
}
map.put("timing", query.processingTimeMillis());
map.put("cachehit", "disk");
query.sendReply(JSON.serializeToBytes(map));
} else if (query.hasQueryStringParam("png")
|| query.hasQueryStringParam("ascii")) {
query.sendFile(cachepath, max_age);
} else {
query.sendReply(HttpQuery.makePage("TSDB Query", "Your graph is ready",
"<img src=\"" + query.request().getUri() + "&png\"/><br/>"
+ "<small>(served from disk cache)</small>"));
}
graphs_diskcache_hit.incrementAndGet();
return true;
}
// We didn't find an image. Do a negative cache check. If we've seen
// this query before but there was no result, we at least wrote the JSON.
final HashMap<String, Object> map = loadCachedJson(query, end_time,
max_age, basepath);
// If we don't have a JSON file it's a complete cache miss. If we have
// one, and it says 0 data points were plotted, it's a negative cache hit.
if (map == null || !map.containsKey("plotted") ||
((Integer)map.get("plotted")) == 0) {
return false;
}
if (query.hasQueryStringParam("json")) {
map.put("timing", query.processingTimeMillis());
map.put("cachehit", "disk");
query.sendReply(JSON.serializeToBytes(map));
} else if (query.hasQueryStringParam("png")) {
query.sendReply(" "); // Send back an empty response...
} else {
query.sendReply(HttpQuery.makePage("TSDB Query", "No results",
"Sorry, your query didn't return anything.<br/>"
+ "<small>(served from disk cache)</small>"));
}
graphs_diskcache_hit.incrementAndGet();
return true;
}
|
[
"private",
"boolean",
"isDiskCacheHit",
"(",
"final",
"HttpQuery",
"query",
",",
"final",
"long",
"end_time",
",",
"final",
"int",
"max_age",
",",
"final",
"String",
"basepath",
")",
"throws",
"IOException",
"{",
"final",
"String",
"cachepath",
"=",
"basepath",
"+",
"(",
"query",
".",
"hasQueryStringParam",
"(",
"\"ascii\"",
")",
"?",
"\".txt\"",
":",
"\".png\"",
")",
";",
"final",
"File",
"cachedfile",
"=",
"new",
"File",
"(",
"cachepath",
")",
";",
"if",
"(",
"cachedfile",
".",
"exists",
"(",
")",
")",
"{",
"final",
"long",
"bytes",
"=",
"cachedfile",
".",
"length",
"(",
")",
";",
"if",
"(",
"bytes",
"<",
"21",
")",
"{",
"// Minimum possible size for a PNG: 21 bytes.",
"// For .txt files, <21 bytes is almost impossible.",
"logWarn",
"(",
"query",
",",
"\"Cached \"",
"+",
"cachepath",
"+",
"\" is too small (\"",
"+",
"bytes",
"+",
"\" bytes) to be valid. Ignoring it.\"",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"staleCacheFile",
"(",
"query",
",",
"end_time",
",",
"max_age",
",",
"cachedfile",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"query",
".",
"hasQueryStringParam",
"(",
"\"json\"",
")",
")",
"{",
"HashMap",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"loadCachedJson",
"(",
"query",
",",
"end_time",
",",
"max_age",
",",
"basepath",
")",
";",
"if",
"(",
"map",
"==",
"null",
")",
"{",
"map",
"=",
"new",
"HashMap",
"<",
"String",
",",
"Object",
">",
"(",
")",
";",
"}",
"map",
".",
"put",
"(",
"\"timing\"",
",",
"query",
".",
"processingTimeMillis",
"(",
")",
")",
";",
"map",
".",
"put",
"(",
"\"cachehit\"",
",",
"\"disk\"",
")",
";",
"query",
".",
"sendReply",
"(",
"JSON",
".",
"serializeToBytes",
"(",
"map",
")",
")",
";",
"}",
"else",
"if",
"(",
"query",
".",
"hasQueryStringParam",
"(",
"\"png\"",
")",
"||",
"query",
".",
"hasQueryStringParam",
"(",
"\"ascii\"",
")",
")",
"{",
"query",
".",
"sendFile",
"(",
"cachepath",
",",
"max_age",
")",
";",
"}",
"else",
"{",
"query",
".",
"sendReply",
"(",
"HttpQuery",
".",
"makePage",
"(",
"\"TSDB Query\"",
",",
"\"Your graph is ready\"",
",",
"\"<img src=\\\"\"",
"+",
"query",
".",
"request",
"(",
")",
".",
"getUri",
"(",
")",
"+",
"\"&png\\\"/><br/>\"",
"+",
"\"<small>(served from disk cache)</small>\"",
")",
")",
";",
"}",
"graphs_diskcache_hit",
".",
"incrementAndGet",
"(",
")",
";",
"return",
"true",
";",
"}",
"// We didn't find an image. Do a negative cache check. If we've seen",
"// this query before but there was no result, we at least wrote the JSON.",
"final",
"HashMap",
"<",
"String",
",",
"Object",
">",
"map",
"=",
"loadCachedJson",
"(",
"query",
",",
"end_time",
",",
"max_age",
",",
"basepath",
")",
";",
"// If we don't have a JSON file it's a complete cache miss. If we have",
"// one, and it says 0 data points were plotted, it's a negative cache hit.",
"if",
"(",
"map",
"==",
"null",
"||",
"!",
"map",
".",
"containsKey",
"(",
"\"plotted\"",
")",
"||",
"(",
"(",
"Integer",
")",
"map",
".",
"get",
"(",
"\"plotted\"",
")",
")",
"==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"query",
".",
"hasQueryStringParam",
"(",
"\"json\"",
")",
")",
"{",
"map",
".",
"put",
"(",
"\"timing\"",
",",
"query",
".",
"processingTimeMillis",
"(",
")",
")",
";",
"map",
".",
"put",
"(",
"\"cachehit\"",
",",
"\"disk\"",
")",
";",
"query",
".",
"sendReply",
"(",
"JSON",
".",
"serializeToBytes",
"(",
"map",
")",
")",
";",
"}",
"else",
"if",
"(",
"query",
".",
"hasQueryStringParam",
"(",
"\"png\"",
")",
")",
"{",
"query",
".",
"sendReply",
"(",
"\" \"",
")",
";",
"// Send back an empty response...",
"}",
"else",
"{",
"query",
".",
"sendReply",
"(",
"HttpQuery",
".",
"makePage",
"(",
"\"TSDB Query\"",
",",
"\"No results\"",
",",
"\"Sorry, your query didn't return anything.<br/>\"",
"+",
"\"<small>(served from disk cache)</small>\"",
")",
")",
";",
"}",
"graphs_diskcache_hit",
".",
"incrementAndGet",
"(",
")",
";",
"return",
"true",
";",
"}"
] |
Checks whether or not it's possible to re-serve this query from disk.
@param query The query to serve.
@param end_time The end time on the query (32-bit unsigned int, seconds).
@param max_age The maximum time (in seconds) we wanna allow clients to
cache the result in case of a cache hit.
@param basepath The base path used for the Gnuplot files.
@return {@code true} if this request was served from disk (in which
case processing can stop here), {@code false} otherwise (in which case
the query needs to be processed).
|
[
"Checks",
"whether",
"or",
"not",
"it",
"s",
"possible",
"to",
"re",
"-",
"serve",
"this",
"query",
"from",
"disk",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/GraphHandler.java#L423-L484
|
13,568
|
OpenTSDB/opentsdb
|
src/tsd/GraphHandler.java
|
GraphHandler.staleCacheFile
|
private static boolean staleCacheFile(final HttpQuery query,
final long end_time,
final long max_age,
final File cachedfile) {
final long mtime = cachedfile.lastModified() / 1000;
if (mtime <= 0) {
return true; // File doesn't exist, or can't be read.
}
final long now = System.currentTimeMillis() / 1000;
// How old is the cached file, in seconds?
final long staleness = now - mtime;
if (staleness < 0) { // Can happen if the mtime is "in the future".
logWarn(query, "Not using file @ " + cachedfile + " with weird"
+ " mtime in the future: " + mtime);
return true; // Play it safe, pretend we can't use this file.
}
// Case 1: The end time is an absolute point in the past.
// We might be able to re-use the cached file.
if (0 < end_time && end_time < now) {
// If the file was created prior to the end time, maybe we first
// executed this query while the result was uncacheable. We can
// tell by looking at the mtime on the file. If the file was created
// before the query end time, then it contains partial results that
// shouldn't be served again.
return mtime < end_time;
}
// Case 2: The end time of the query is now or in the future.
// The cached file contains partial data and can only be re-used if it's
// not too old.
if (staleness > max_age) {
logInfo(query, "Cached file @ " + cachedfile.getPath() + " is "
+ staleness + "s stale, which is more than its limit of "
+ max_age + "s, and needs to be regenerated.");
return true;
}
return false;
}
|
java
|
private static boolean staleCacheFile(final HttpQuery query,
final long end_time,
final long max_age,
final File cachedfile) {
final long mtime = cachedfile.lastModified() / 1000;
if (mtime <= 0) {
return true; // File doesn't exist, or can't be read.
}
final long now = System.currentTimeMillis() / 1000;
// How old is the cached file, in seconds?
final long staleness = now - mtime;
if (staleness < 0) { // Can happen if the mtime is "in the future".
logWarn(query, "Not using file @ " + cachedfile + " with weird"
+ " mtime in the future: " + mtime);
return true; // Play it safe, pretend we can't use this file.
}
// Case 1: The end time is an absolute point in the past.
// We might be able to re-use the cached file.
if (0 < end_time && end_time < now) {
// If the file was created prior to the end time, maybe we first
// executed this query while the result was uncacheable. We can
// tell by looking at the mtime on the file. If the file was created
// before the query end time, then it contains partial results that
// shouldn't be served again.
return mtime < end_time;
}
// Case 2: The end time of the query is now or in the future.
// The cached file contains partial data and can only be re-used if it's
// not too old.
if (staleness > max_age) {
logInfo(query, "Cached file @ " + cachedfile.getPath() + " is "
+ staleness + "s stale, which is more than its limit of "
+ max_age + "s, and needs to be regenerated.");
return true;
}
return false;
}
|
[
"private",
"static",
"boolean",
"staleCacheFile",
"(",
"final",
"HttpQuery",
"query",
",",
"final",
"long",
"end_time",
",",
"final",
"long",
"max_age",
",",
"final",
"File",
"cachedfile",
")",
"{",
"final",
"long",
"mtime",
"=",
"cachedfile",
".",
"lastModified",
"(",
")",
"/",
"1000",
";",
"if",
"(",
"mtime",
"<=",
"0",
")",
"{",
"return",
"true",
";",
"// File doesn't exist, or can't be read.",
"}",
"final",
"long",
"now",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
"/",
"1000",
";",
"// How old is the cached file, in seconds?",
"final",
"long",
"staleness",
"=",
"now",
"-",
"mtime",
";",
"if",
"(",
"staleness",
"<",
"0",
")",
"{",
"// Can happen if the mtime is \"in the future\".",
"logWarn",
"(",
"query",
",",
"\"Not using file @ \"",
"+",
"cachedfile",
"+",
"\" with weird\"",
"+",
"\" mtime in the future: \"",
"+",
"mtime",
")",
";",
"return",
"true",
";",
"// Play it safe, pretend we can't use this file.",
"}",
"// Case 1: The end time is an absolute point in the past.",
"// We might be able to re-use the cached file.",
"if",
"(",
"0",
"<",
"end_time",
"&&",
"end_time",
"<",
"now",
")",
"{",
"// If the file was created prior to the end time, maybe we first",
"// executed this query while the result was uncacheable. We can",
"// tell by looking at the mtime on the file. If the file was created",
"// before the query end time, then it contains partial results that",
"// shouldn't be served again.",
"return",
"mtime",
"<",
"end_time",
";",
"}",
"// Case 2: The end time of the query is now or in the future.",
"// The cached file contains partial data and can only be re-used if it's",
"// not too old.",
"if",
"(",
"staleness",
">",
"max_age",
")",
"{",
"logInfo",
"(",
"query",
",",
"\"Cached file @ \"",
"+",
"cachedfile",
".",
"getPath",
"(",
")",
"+",
"\" is \"",
"+",
"staleness",
"+",
"\"s stale, which is more than its limit of \"",
"+",
"max_age",
"+",
"\"s, and needs to be regenerated.\"",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Returns whether or not the given cache file can be used or is stale.
@param query The query to serve.
@param end_time The end time on the query (32-bit unsigned int, seconds).
@param max_age The maximum time (in seconds) we wanna allow clients to
cache the result in case of a cache hit. If the file is exactly that
old, it is not considered stale.
@param cachedfile The file to check for staleness.
|
[
"Returns",
"whether",
"or",
"not",
"the",
"given",
"cache",
"file",
"can",
"be",
"used",
"or",
"is",
"stale",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/GraphHandler.java#L495-L534
|
13,569
|
OpenTSDB/opentsdb
|
src/tsd/GraphHandler.java
|
GraphHandler.writeFile
|
private static void writeFile(final HttpQuery query,
final String path,
final byte[] contents) {
try {
final FileOutputStream out = new FileOutputStream(path);
try {
out.write(contents);
} finally {
out.close();
}
} catch (FileNotFoundException e) {
logError(query, "Failed to create file " + path, e);
} catch (IOException e) {
logError(query, "Failed to write file " + path, e);
}
}
|
java
|
private static void writeFile(final HttpQuery query,
final String path,
final byte[] contents) {
try {
final FileOutputStream out = new FileOutputStream(path);
try {
out.write(contents);
} finally {
out.close();
}
} catch (FileNotFoundException e) {
logError(query, "Failed to create file " + path, e);
} catch (IOException e) {
logError(query, "Failed to write file " + path, e);
}
}
|
[
"private",
"static",
"void",
"writeFile",
"(",
"final",
"HttpQuery",
"query",
",",
"final",
"String",
"path",
",",
"final",
"byte",
"[",
"]",
"contents",
")",
"{",
"try",
"{",
"final",
"FileOutputStream",
"out",
"=",
"new",
"FileOutputStream",
"(",
"path",
")",
";",
"try",
"{",
"out",
".",
"write",
"(",
"contents",
")",
";",
"}",
"finally",
"{",
"out",
".",
"close",
"(",
")",
";",
"}",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"logError",
"(",
"query",
",",
"\"Failed to create file \"",
"+",
"path",
",",
"e",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logError",
"(",
"query",
",",
"\"Failed to write file \"",
"+",
"path",
",",
"e",
")",
";",
"}",
"}"
] |
Writes the given byte array into a file.
This function logs an error but doesn't throw if it fails.
@param query The query being handled (for logging purposes).
@param path The path to write to.
@param contents The contents to write into the file.
|
[
"Writes",
"the",
"given",
"byte",
"array",
"into",
"a",
"file",
".",
"This",
"function",
"logs",
"an",
"error",
"but",
"doesn",
"t",
"throw",
"if",
"it",
"fails",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/GraphHandler.java#L543-L558
|
13,570
|
OpenTSDB/opentsdb
|
src/tsd/GraphHandler.java
|
GraphHandler.readFile
|
private static byte[] readFile(final HttpQuery query,
final File file,
final int max_length) {
final int length = (int) file.length();
if (length <= 0) {
return null;
}
FileInputStream in;
try {
in = new FileInputStream(file.getPath());
} catch (FileNotFoundException e) {
return null;
}
try {
final byte[] buf = new byte[Math.min(length, max_length)];
final int read = in.read(buf);
if (read != buf.length) {
logError(query, "When reading " + file + ": read only "
+ read + " bytes instead of " + buf.length);
return null;
}
return buf;
} catch (IOException e) {
logError(query, "Error while reading " + file, e);
return null;
} finally {
try {
in.close();
} catch (IOException e) {
logError(query, "Error while closing " + file, e);
}
}
}
|
java
|
private static byte[] readFile(final HttpQuery query,
final File file,
final int max_length) {
final int length = (int) file.length();
if (length <= 0) {
return null;
}
FileInputStream in;
try {
in = new FileInputStream(file.getPath());
} catch (FileNotFoundException e) {
return null;
}
try {
final byte[] buf = new byte[Math.min(length, max_length)];
final int read = in.read(buf);
if (read != buf.length) {
logError(query, "When reading " + file + ": read only "
+ read + " bytes instead of " + buf.length);
return null;
}
return buf;
} catch (IOException e) {
logError(query, "Error while reading " + file, e);
return null;
} finally {
try {
in.close();
} catch (IOException e) {
logError(query, "Error while closing " + file, e);
}
}
}
|
[
"private",
"static",
"byte",
"[",
"]",
"readFile",
"(",
"final",
"HttpQuery",
"query",
",",
"final",
"File",
"file",
",",
"final",
"int",
"max_length",
")",
"{",
"final",
"int",
"length",
"=",
"(",
"int",
")",
"file",
".",
"length",
"(",
")",
";",
"if",
"(",
"length",
"<=",
"0",
")",
"{",
"return",
"null",
";",
"}",
"FileInputStream",
"in",
";",
"try",
"{",
"in",
"=",
"new",
"FileInputStream",
"(",
"file",
".",
"getPath",
"(",
")",
")",
";",
"}",
"catch",
"(",
"FileNotFoundException",
"e",
")",
"{",
"return",
"null",
";",
"}",
"try",
"{",
"final",
"byte",
"[",
"]",
"buf",
"=",
"new",
"byte",
"[",
"Math",
".",
"min",
"(",
"length",
",",
"max_length",
")",
"]",
";",
"final",
"int",
"read",
"=",
"in",
".",
"read",
"(",
"buf",
")",
";",
"if",
"(",
"read",
"!=",
"buf",
".",
"length",
")",
"{",
"logError",
"(",
"query",
",",
"\"When reading \"",
"+",
"file",
"+",
"\": read only \"",
"+",
"read",
"+",
"\" bytes instead of \"",
"+",
"buf",
".",
"length",
")",
";",
"return",
"null",
";",
"}",
"return",
"buf",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logError",
"(",
"query",
",",
"\"Error while reading \"",
"+",
"file",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"finally",
"{",
"try",
"{",
"in",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logError",
"(",
"query",
",",
"\"Error while closing \"",
"+",
"file",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Reads a file into a byte array.
@param query The query being handled (for logging purposes).
@param file The file to read.
@param max_length The maximum number of bytes to read from the file.
@return {@code null} if the file doesn't exist or is empty or couldn't be
read, otherwise a byte array of up to {@code max_length} bytes.
|
[
"Reads",
"a",
"file",
"into",
"a",
"byte",
"array",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/GraphHandler.java#L568-L600
|
13,571
|
OpenTSDB/opentsdb
|
src/tsd/GraphHandler.java
|
GraphHandler.stringify
|
private static String stringify(final String s) {
final StringBuilder buf = new StringBuilder(1 + s.length() + 1);
buf.append('"');
HttpQuery.escapeJson(s, buf); // Abusing this function gets the job done.
buf.append('"');
return buf.toString();
}
|
java
|
private static String stringify(final String s) {
final StringBuilder buf = new StringBuilder(1 + s.length() + 1);
buf.append('"');
HttpQuery.escapeJson(s, buf); // Abusing this function gets the job done.
buf.append('"');
return buf.toString();
}
|
[
"private",
"static",
"String",
"stringify",
"(",
"final",
"String",
"s",
")",
"{",
"final",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
"1",
"+",
"s",
".",
"length",
"(",
")",
"+",
"1",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"HttpQuery",
".",
"escapeJson",
"(",
"s",
",",
"buf",
")",
";",
"// Abusing this function gets the job done.",
"buf",
".",
"append",
"(",
"'",
"'",
")",
";",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] |
Formats and quotes the given string so it's a suitable Gnuplot string.
@param s The string to stringify.
@return A string suitable for use as a literal string in Gnuplot.
|
[
"Formats",
"and",
"quotes",
"the",
"given",
"string",
"so",
"it",
"s",
"a",
"suitable",
"Gnuplot",
"string",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/GraphHandler.java#L675-L681
|
13,572
|
OpenTSDB/opentsdb
|
src/tsd/GraphHandler.java
|
GraphHandler.popParam
|
private static String popParam(final Map<String, List<String>> querystring,
final String param) {
final List<String> params = querystring.remove(param);
if (params == null) {
return null;
}
final String given = params.get(params.size() - 1);
// TODO - far from perfect, should help a little.
if (given.contains("`") || given.contains("%60") ||
given.contains("`")) {
throw new BadRequestException("Parameter " + param + " contained a "
+ "back-tick. That's a no-no.");
}
return given;
}
|
java
|
private static String popParam(final Map<String, List<String>> querystring,
final String param) {
final List<String> params = querystring.remove(param);
if (params == null) {
return null;
}
final String given = params.get(params.size() - 1);
// TODO - far from perfect, should help a little.
if (given.contains("`") || given.contains("%60") ||
given.contains("`")) {
throw new BadRequestException("Parameter " + param + " contained a "
+ "back-tick. That's a no-no.");
}
return given;
}
|
[
"private",
"static",
"String",
"popParam",
"(",
"final",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"querystring",
",",
"final",
"String",
"param",
")",
"{",
"final",
"List",
"<",
"String",
">",
"params",
"=",
"querystring",
".",
"remove",
"(",
"param",
")",
";",
"if",
"(",
"params",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"final",
"String",
"given",
"=",
"params",
".",
"get",
"(",
"params",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"// TODO - far from perfect, should help a little.",
"if",
"(",
"given",
".",
"contains",
"(",
"\"`\"",
")",
"||",
"given",
".",
"contains",
"(",
"\"%60\"",
")",
"||",
"given",
".",
"contains",
"(",
"\"`\"",
")",
")",
"{",
"throw",
"new",
"BadRequestException",
"(",
"\"Parameter \"",
"+",
"param",
"+",
"\" contained a \"",
"+",
"\"back-tick. That's a no-no.\"",
")",
";",
"}",
"return",
"given",
";",
"}"
] |
Pops out of the query string the given parameter.
@param querystring The query string.
@param param The name of the parameter to pop out.
@return {@code null} if the parameter wasn't passed, otherwise the
value of the last occurrence of the parameter.
|
[
"Pops",
"out",
"of",
"the",
"query",
"string",
"the",
"given",
"parameter",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/GraphHandler.java#L690-L704
|
13,573
|
OpenTSDB/opentsdb
|
src/tsd/GraphHandler.java
|
GraphHandler.setPlotParams
|
static void setPlotParams(final HttpQuery query, final Plot plot) {
final HashMap<String, String> params = new HashMap<String, String>();
final Map<String, List<String>> querystring = query.getQueryString();
String value;
if ((value = popParam(querystring, "yrange")) != null) {
params.put("yrange", value);
}
if ((value = popParam(querystring, "y2range")) != null) {
params.put("y2range", value);
}
if ((value = popParam(querystring, "ylabel")) != null) {
params.put("ylabel", stringify(value));
}
if ((value = popParam(querystring, "y2label")) != null) {
params.put("y2label", stringify(value));
}
if ((value = popParam(querystring, "yformat")) != null) {
params.put("format y", stringify(value));
}
if ((value = popParam(querystring, "y2format")) != null) {
params.put("format y2", stringify(value));
}
if ((value = popParam(querystring, "xformat")) != null) {
params.put("format x", stringify(value));
}
if ((value = popParam(querystring, "ylog")) != null) {
params.put("logscale y", "");
}
if ((value = popParam(querystring, "y2log")) != null) {
params.put("logscale y2", "");
}
if ((value = popParam(querystring, "key")) != null) {
params.put("key", value);
}
if ((value = popParam(querystring, "title")) != null) {
params.put("title", stringify(value));
}
if ((value = popParam(querystring, "bgcolor")) != null) {
params.put("bgcolor", value);
}
if ((value = popParam(querystring, "fgcolor")) != null) {
params.put("fgcolor", value);
}
if ((value = popParam(querystring, "smooth")) != null) {
params.put("smooth", value);
}
if ((value = popParam(querystring, "style")) != null) {
params.put("style", value);
}
// This must remain after the previous `if' in order to properly override
// any previous `key' parameter if a `nokey' parameter is given.
if ((value = popParam(querystring, "nokey")) != null) {
params.put("key", null);
}
plot.setParams(params);
}
|
java
|
static void setPlotParams(final HttpQuery query, final Plot plot) {
final HashMap<String, String> params = new HashMap<String, String>();
final Map<String, List<String>> querystring = query.getQueryString();
String value;
if ((value = popParam(querystring, "yrange")) != null) {
params.put("yrange", value);
}
if ((value = popParam(querystring, "y2range")) != null) {
params.put("y2range", value);
}
if ((value = popParam(querystring, "ylabel")) != null) {
params.put("ylabel", stringify(value));
}
if ((value = popParam(querystring, "y2label")) != null) {
params.put("y2label", stringify(value));
}
if ((value = popParam(querystring, "yformat")) != null) {
params.put("format y", stringify(value));
}
if ((value = popParam(querystring, "y2format")) != null) {
params.put("format y2", stringify(value));
}
if ((value = popParam(querystring, "xformat")) != null) {
params.put("format x", stringify(value));
}
if ((value = popParam(querystring, "ylog")) != null) {
params.put("logscale y", "");
}
if ((value = popParam(querystring, "y2log")) != null) {
params.put("logscale y2", "");
}
if ((value = popParam(querystring, "key")) != null) {
params.put("key", value);
}
if ((value = popParam(querystring, "title")) != null) {
params.put("title", stringify(value));
}
if ((value = popParam(querystring, "bgcolor")) != null) {
params.put("bgcolor", value);
}
if ((value = popParam(querystring, "fgcolor")) != null) {
params.put("fgcolor", value);
}
if ((value = popParam(querystring, "smooth")) != null) {
params.put("smooth", value);
}
if ((value = popParam(querystring, "style")) != null) {
params.put("style", value);
}
// This must remain after the previous `if' in order to properly override
// any previous `key' parameter if a `nokey' parameter is given.
if ((value = popParam(querystring, "nokey")) != null) {
params.put("key", null);
}
plot.setParams(params);
}
|
[
"static",
"void",
"setPlotParams",
"(",
"final",
"HttpQuery",
"query",
",",
"final",
"Plot",
"plot",
")",
"{",
"final",
"HashMap",
"<",
"String",
",",
"String",
">",
"params",
"=",
"new",
"HashMap",
"<",
"String",
",",
"String",
">",
"(",
")",
";",
"final",
"Map",
"<",
"String",
",",
"List",
"<",
"String",
">",
">",
"querystring",
"=",
"query",
".",
"getQueryString",
"(",
")",
";",
"String",
"value",
";",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"yrange\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"yrange\"",
",",
"value",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"y2range\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"y2range\"",
",",
"value",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"ylabel\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"ylabel\"",
",",
"stringify",
"(",
"value",
")",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"y2label\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"y2label\"",
",",
"stringify",
"(",
"value",
")",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"yformat\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"format y\"",
",",
"stringify",
"(",
"value",
")",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"y2format\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"format y2\"",
",",
"stringify",
"(",
"value",
")",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"xformat\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"format x\"",
",",
"stringify",
"(",
"value",
")",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"ylog\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"logscale y\"",
",",
"\"\"",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"y2log\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"logscale y2\"",
",",
"\"\"",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"key\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"key\"",
",",
"value",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"title\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"title\"",
",",
"stringify",
"(",
"value",
")",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"bgcolor\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"bgcolor\"",
",",
"value",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"fgcolor\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"fgcolor\"",
",",
"value",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"smooth\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"smooth\"",
",",
"value",
")",
";",
"}",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"style\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"style\"",
",",
"value",
")",
";",
"}",
"// This must remain after the previous `if' in order to properly override",
"// any previous `key' parameter if a `nokey' parameter is given.",
"if",
"(",
"(",
"value",
"=",
"popParam",
"(",
"querystring",
",",
"\"nokey\"",
")",
")",
"!=",
"null",
")",
"{",
"params",
".",
"put",
"(",
"\"key\"",
",",
"null",
")",
";",
"}",
"plot",
".",
"setParams",
"(",
"params",
")",
";",
"}"
] |
Applies the plot parameters from the query to the given plot.
@param query The query from which to get the query string.
@param plot The plot on which to apply the parameters.
|
[
"Applies",
"the",
"plot",
"parameters",
"from",
"the",
"query",
"to",
"the",
"given",
"plot",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/GraphHandler.java#L711-L766
|
13,574
|
OpenTSDB/opentsdb
|
src/tsd/GraphHandler.java
|
GraphHandler.printMetricHeader
|
private static void printMetricHeader(final PrintWriter writer, final String metric,
final long timestamp) {
writer.print(metric);
writer.print(' ');
writer.print(timestamp / 1000L);
writer.print(' ');
}
|
java
|
private static void printMetricHeader(final PrintWriter writer, final String metric,
final long timestamp) {
writer.print(metric);
writer.print(' ');
writer.print(timestamp / 1000L);
writer.print(' ');
}
|
[
"private",
"static",
"void",
"printMetricHeader",
"(",
"final",
"PrintWriter",
"writer",
",",
"final",
"String",
"metric",
",",
"final",
"long",
"timestamp",
")",
"{",
"writer",
".",
"print",
"(",
"metric",
")",
";",
"writer",
".",
"print",
"(",
"'",
"'",
")",
";",
"writer",
".",
"print",
"(",
"timestamp",
"/",
"1000L",
")",
";",
"writer",
".",
"print",
"(",
"'",
"'",
")",
";",
"}"
] |
Helper method to write metric name and timestamp.
@param writer The writer to which to write.
@param metric The metric name.
@param timestamp The timestamp.
|
[
"Helper",
"method",
"to",
"write",
"metric",
"name",
"and",
"timestamp",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/GraphHandler.java#L901-L907
|
13,575
|
OpenTSDB/opentsdb
|
src/tsd/GraphHandler.java
|
GraphHandler.findGnuplotHelperScript
|
private static String findGnuplotHelperScript() {
if(!GnuplotInstaller.FOUND_GP) {
LOG.warn("Skipping Gnuplot Shell Script Install since Gnuplot executable was not found");
return null;
}
if(!GnuplotInstaller.GP_FILE.exists()) {
GnuplotInstaller.installMyGnuPlot();
}
if(GnuplotInstaller.GP_FILE.exists() && GnuplotInstaller.GP_FILE.canExecute()) {
LOG.info("Auto Installed Gnuplot Invoker at [{}]", GnuplotInstaller.GP_FILE.getAbsolutePath());
return GnuplotInstaller.GP_FILE.getAbsolutePath();
}
final URL url = GraphHandler.class.getClassLoader().getResource(WRAPPER);
if (url == null) {
throw new RuntimeException("Couldn't find " + WRAPPER + " on the"
+ " CLASSPATH: " + System.getProperty("java.class.path"));
}
final String path = url.getFile();
LOG.debug("Using Gnuplot wrapper at {}", path);
final File file = new File(path);
final String error;
if (!file.exists()) {
error = "non-existent";
} else if (!file.canExecute()) {
error = "non-executable";
} else if (!file.canRead()) {
error = "unreadable";
} else {
return path;
}
throw new RuntimeException("The " + WRAPPER + " found on the"
+ " CLASSPATH (" + path + ") is a " + error + " file... WTF?"
+ " CLASSPATH=" + System.getProperty("java.class.path"));
}
|
java
|
private static String findGnuplotHelperScript() {
if(!GnuplotInstaller.FOUND_GP) {
LOG.warn("Skipping Gnuplot Shell Script Install since Gnuplot executable was not found");
return null;
}
if(!GnuplotInstaller.GP_FILE.exists()) {
GnuplotInstaller.installMyGnuPlot();
}
if(GnuplotInstaller.GP_FILE.exists() && GnuplotInstaller.GP_FILE.canExecute()) {
LOG.info("Auto Installed Gnuplot Invoker at [{}]", GnuplotInstaller.GP_FILE.getAbsolutePath());
return GnuplotInstaller.GP_FILE.getAbsolutePath();
}
final URL url = GraphHandler.class.getClassLoader().getResource(WRAPPER);
if (url == null) {
throw new RuntimeException("Couldn't find " + WRAPPER + " on the"
+ " CLASSPATH: " + System.getProperty("java.class.path"));
}
final String path = url.getFile();
LOG.debug("Using Gnuplot wrapper at {}", path);
final File file = new File(path);
final String error;
if (!file.exists()) {
error = "non-existent";
} else if (!file.canExecute()) {
error = "non-executable";
} else if (!file.canRead()) {
error = "unreadable";
} else {
return path;
}
throw new RuntimeException("The " + WRAPPER + " found on the"
+ " CLASSPATH (" + path + ") is a " + error + " file... WTF?"
+ " CLASSPATH=" + System.getProperty("java.class.path"));
}
|
[
"private",
"static",
"String",
"findGnuplotHelperScript",
"(",
")",
"{",
"if",
"(",
"!",
"GnuplotInstaller",
".",
"FOUND_GP",
")",
"{",
"LOG",
".",
"warn",
"(",
"\"Skipping Gnuplot Shell Script Install since Gnuplot executable was not found\"",
")",
";",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"GnuplotInstaller",
".",
"GP_FILE",
".",
"exists",
"(",
")",
")",
"{",
"GnuplotInstaller",
".",
"installMyGnuPlot",
"(",
")",
";",
"}",
"if",
"(",
"GnuplotInstaller",
".",
"GP_FILE",
".",
"exists",
"(",
")",
"&&",
"GnuplotInstaller",
".",
"GP_FILE",
".",
"canExecute",
"(",
")",
")",
"{",
"LOG",
".",
"info",
"(",
"\"Auto Installed Gnuplot Invoker at [{}]\"",
",",
"GnuplotInstaller",
".",
"GP_FILE",
".",
"getAbsolutePath",
"(",
")",
")",
";",
"return",
"GnuplotInstaller",
".",
"GP_FILE",
".",
"getAbsolutePath",
"(",
")",
";",
"}",
"final",
"URL",
"url",
"=",
"GraphHandler",
".",
"class",
".",
"getClassLoader",
"(",
")",
".",
"getResource",
"(",
"WRAPPER",
")",
";",
"if",
"(",
"url",
"==",
"null",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Couldn't find \"",
"+",
"WRAPPER",
"+",
"\" on the\"",
"+",
"\" CLASSPATH: \"",
"+",
"System",
".",
"getProperty",
"(",
"\"java.class.path\"",
")",
")",
";",
"}",
"final",
"String",
"path",
"=",
"url",
".",
"getFile",
"(",
")",
";",
"LOG",
".",
"debug",
"(",
"\"Using Gnuplot wrapper at {}\"",
",",
"path",
")",
";",
"final",
"File",
"file",
"=",
"new",
"File",
"(",
"path",
")",
";",
"final",
"String",
"error",
";",
"if",
"(",
"!",
"file",
".",
"exists",
"(",
")",
")",
"{",
"error",
"=",
"\"non-existent\"",
";",
"}",
"else",
"if",
"(",
"!",
"file",
".",
"canExecute",
"(",
")",
")",
"{",
"error",
"=",
"\"non-executable\"",
";",
"}",
"else",
"if",
"(",
"!",
"file",
".",
"canRead",
"(",
")",
")",
"{",
"error",
"=",
"\"unreadable\"",
";",
"}",
"else",
"{",
"return",
"path",
";",
"}",
"throw",
"new",
"RuntimeException",
"(",
"\"The \"",
"+",
"WRAPPER",
"+",
"\" found on the\"",
"+",
"\" CLASSPATH (\"",
"+",
"path",
"+",
"\") is a \"",
"+",
"error",
"+",
"\" file... WTF?\"",
"+",
"\" CLASSPATH=\"",
"+",
"System",
".",
"getProperty",
"(",
"\"java.class.path\"",
")",
")",
";",
"}"
] |
Iterate through the class path and look for the Gnuplot helper script.
@return The path to the wrapper script.
|
[
"Iterate",
"through",
"the",
"class",
"path",
"and",
"look",
"for",
"the",
"Gnuplot",
"helper",
"script",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/tsd/GraphHandler.java#L933-L967
|
13,576
|
OpenTSDB/opentsdb
|
src/meta/TSMeta.java
|
TSMeta.parseFromColumn
|
public static Deferred<TSMeta> parseFromColumn(final TSDB tsdb,
final KeyValue column, final boolean load_uidmetas) {
if (column.value() == null || column.value().length < 1) {
throw new IllegalArgumentException("Empty column value");
}
final TSMeta parsed_meta = JSON.parseToObject(column.value(), TSMeta.class);
// fix in case the tsuid is missing
if (parsed_meta.tsuid == null || parsed_meta.tsuid.isEmpty()) {
parsed_meta.tsuid = UniqueId.uidToString(column.key());
}
Deferred<TSMeta> meta = getFromStorage(tsdb, UniqueId.stringToUid(parsed_meta.tsuid));
if (!load_uidmetas) {
return meta;
}
return meta.addCallbackDeferring(new LoadUIDs(tsdb, parsed_meta.tsuid));
}
|
java
|
public static Deferred<TSMeta> parseFromColumn(final TSDB tsdb,
final KeyValue column, final boolean load_uidmetas) {
if (column.value() == null || column.value().length < 1) {
throw new IllegalArgumentException("Empty column value");
}
final TSMeta parsed_meta = JSON.parseToObject(column.value(), TSMeta.class);
// fix in case the tsuid is missing
if (parsed_meta.tsuid == null || parsed_meta.tsuid.isEmpty()) {
parsed_meta.tsuid = UniqueId.uidToString(column.key());
}
Deferred<TSMeta> meta = getFromStorage(tsdb, UniqueId.stringToUid(parsed_meta.tsuid));
if (!load_uidmetas) {
return meta;
}
return meta.addCallbackDeferring(new LoadUIDs(tsdb, parsed_meta.tsuid));
}
|
[
"public",
"static",
"Deferred",
"<",
"TSMeta",
">",
"parseFromColumn",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"KeyValue",
"column",
",",
"final",
"boolean",
"load_uidmetas",
")",
"{",
"if",
"(",
"column",
".",
"value",
"(",
")",
"==",
"null",
"||",
"column",
".",
"value",
"(",
")",
".",
"length",
"<",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Empty column value\"",
")",
";",
"}",
"final",
"TSMeta",
"parsed_meta",
"=",
"JSON",
".",
"parseToObject",
"(",
"column",
".",
"value",
"(",
")",
",",
"TSMeta",
".",
"class",
")",
";",
"// fix in case the tsuid is missing",
"if",
"(",
"parsed_meta",
".",
"tsuid",
"==",
"null",
"||",
"parsed_meta",
".",
"tsuid",
".",
"isEmpty",
"(",
")",
")",
"{",
"parsed_meta",
".",
"tsuid",
"=",
"UniqueId",
".",
"uidToString",
"(",
"column",
".",
"key",
"(",
")",
")",
";",
"}",
"Deferred",
"<",
"TSMeta",
">",
"meta",
"=",
"getFromStorage",
"(",
"tsdb",
",",
"UniqueId",
".",
"stringToUid",
"(",
"parsed_meta",
".",
"tsuid",
")",
")",
";",
"if",
"(",
"!",
"load_uidmetas",
")",
"{",
"return",
"meta",
";",
"}",
"return",
"meta",
".",
"addCallbackDeferring",
"(",
"new",
"LoadUIDs",
"(",
"tsdb",
",",
"parsed_meta",
".",
"tsuid",
")",
")",
";",
"}"
] |
Parses a TSMeta object from the given column, optionally loading the
UIDMeta objects
@param tsdb The TSDB to use for storage access
@param column The KeyValue column to parse
@param load_uidmetas Whether or not UIDmeta objects should be loaded
@return A TSMeta if parsed successfully
@throws NoSuchUniqueName if one of the UIDMeta objects does not exist
@throws JSONException if the data was corrupted
|
[
"Parses",
"a",
"TSMeta",
"object",
"from",
"the",
"given",
"column",
"optionally",
"loading",
"the",
"UIDMeta",
"objects"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/meta/TSMeta.java#L404-L424
|
13,577
|
OpenTSDB/opentsdb
|
src/meta/TSMeta.java
|
TSMeta.metaExistsInStorage
|
public static Deferred<Boolean> metaExistsInStorage(final TSDB tsdb,
final String tsuid) {
final GetRequest get = new GetRequest(tsdb.metaTable(),
UniqueId.stringToUid(tsuid));
get.family(FAMILY);
get.qualifier(META_QUALIFIER);
/**
* Callback from the GetRequest that simply determines if the row is empty
* or not
*/
final class ExistsCB implements Callback<Boolean, ArrayList<KeyValue>> {
@Override
public Boolean call(ArrayList<KeyValue> row) throws Exception {
if (row == null || row.isEmpty() || row.get(0).value() == null) {
return false;
}
return true;
}
}
return tsdb.getClient().get(get).addCallback(new ExistsCB());
}
|
java
|
public static Deferred<Boolean> metaExistsInStorage(final TSDB tsdb,
final String tsuid) {
final GetRequest get = new GetRequest(tsdb.metaTable(),
UniqueId.stringToUid(tsuid));
get.family(FAMILY);
get.qualifier(META_QUALIFIER);
/**
* Callback from the GetRequest that simply determines if the row is empty
* or not
*/
final class ExistsCB implements Callback<Boolean, ArrayList<KeyValue>> {
@Override
public Boolean call(ArrayList<KeyValue> row) throws Exception {
if (row == null || row.isEmpty() || row.get(0).value() == null) {
return false;
}
return true;
}
}
return tsdb.getClient().get(get).addCallback(new ExistsCB());
}
|
[
"public",
"static",
"Deferred",
"<",
"Boolean",
">",
"metaExistsInStorage",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"String",
"tsuid",
")",
"{",
"final",
"GetRequest",
"get",
"=",
"new",
"GetRequest",
"(",
"tsdb",
".",
"metaTable",
"(",
")",
",",
"UniqueId",
".",
"stringToUid",
"(",
"tsuid",
")",
")",
";",
"get",
".",
"family",
"(",
"FAMILY",
")",
";",
"get",
".",
"qualifier",
"(",
"META_QUALIFIER",
")",
";",
"/**\n * Callback from the GetRequest that simply determines if the row is empty\n * or not\n */",
"final",
"class",
"ExistsCB",
"implements",
"Callback",
"<",
"Boolean",
",",
"ArrayList",
"<",
"KeyValue",
">",
">",
"{",
"@",
"Override",
"public",
"Boolean",
"call",
"(",
"ArrayList",
"<",
"KeyValue",
">",
"row",
")",
"throws",
"Exception",
"{",
"if",
"(",
"row",
"==",
"null",
"||",
"row",
".",
"isEmpty",
"(",
")",
"||",
"row",
".",
"get",
"(",
"0",
")",
".",
"value",
"(",
")",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"}",
"return",
"tsdb",
".",
"getClient",
"(",
")",
".",
"get",
"(",
"get",
")",
".",
"addCallback",
"(",
"new",
"ExistsCB",
"(",
")",
")",
";",
"}"
] |
Determines if an entry exists in storage or not.
This is used by the UID Manager tool to determine if we need to write a
new TSUID entry or not. It will not attempt to verify if the stored data is
valid, just checks to see if something is stored in the proper column.
@param tsdb The TSDB to use for storage access
@param tsuid The UID of the meta to verify
@return True if data was found, false if not
@throws HBaseException if there was an issue fetching
|
[
"Determines",
"if",
"an",
"entry",
"exists",
"in",
"storage",
"or",
"not",
".",
"This",
"is",
"used",
"by",
"the",
"UID",
"Manager",
"tool",
"to",
"determine",
"if",
"we",
"need",
"to",
"write",
"a",
"new",
"TSUID",
"entry",
"or",
"not",
".",
"It",
"will",
"not",
"attempt",
"to",
"verify",
"if",
"the",
"stored",
"data",
"is",
"valid",
"just",
"checks",
"to",
"see",
"if",
"something",
"is",
"stored",
"in",
"the",
"proper",
"column",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/meta/TSMeta.java#L436-L460
|
13,578
|
OpenTSDB/opentsdb
|
src/meta/TSMeta.java
|
TSMeta.counterExistsInStorage
|
public static Deferred<Boolean> counterExistsInStorage(final TSDB tsdb,
final byte[] tsuid) {
final GetRequest get = new GetRequest(tsdb.metaTable(), tsuid);
get.family(FAMILY);
get.qualifier(COUNTER_QUALIFIER);
/**
* Callback from the GetRequest that simply determines if the row is empty
* or not
*/
final class ExistsCB implements Callback<Boolean, ArrayList<KeyValue>> {
@Override
public Boolean call(ArrayList<KeyValue> row) throws Exception {
if (row == null || row.isEmpty() || row.get(0).value() == null) {
return false;
}
return true;
}
}
return tsdb.getClient().get(get).addCallback(new ExistsCB());
}
|
java
|
public static Deferred<Boolean> counterExistsInStorage(final TSDB tsdb,
final byte[] tsuid) {
final GetRequest get = new GetRequest(tsdb.metaTable(), tsuid);
get.family(FAMILY);
get.qualifier(COUNTER_QUALIFIER);
/**
* Callback from the GetRequest that simply determines if the row is empty
* or not
*/
final class ExistsCB implements Callback<Boolean, ArrayList<KeyValue>> {
@Override
public Boolean call(ArrayList<KeyValue> row) throws Exception {
if (row == null || row.isEmpty() || row.get(0).value() == null) {
return false;
}
return true;
}
}
return tsdb.getClient().get(get).addCallback(new ExistsCB());
}
|
[
"public",
"static",
"Deferred",
"<",
"Boolean",
">",
"counterExistsInStorage",
"(",
"final",
"TSDB",
"tsdb",
",",
"final",
"byte",
"[",
"]",
"tsuid",
")",
"{",
"final",
"GetRequest",
"get",
"=",
"new",
"GetRequest",
"(",
"tsdb",
".",
"metaTable",
"(",
")",
",",
"tsuid",
")",
";",
"get",
".",
"family",
"(",
"FAMILY",
")",
";",
"get",
".",
"qualifier",
"(",
"COUNTER_QUALIFIER",
")",
";",
"/**\n * Callback from the GetRequest that simply determines if the row is empty\n * or not\n */",
"final",
"class",
"ExistsCB",
"implements",
"Callback",
"<",
"Boolean",
",",
"ArrayList",
"<",
"KeyValue",
">",
">",
"{",
"@",
"Override",
"public",
"Boolean",
"call",
"(",
"ArrayList",
"<",
"KeyValue",
">",
"row",
")",
"throws",
"Exception",
"{",
"if",
"(",
"row",
"==",
"null",
"||",
"row",
".",
"isEmpty",
"(",
")",
"||",
"row",
".",
"get",
"(",
"0",
")",
".",
"value",
"(",
")",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}",
"}",
"return",
"tsdb",
".",
"getClient",
"(",
")",
".",
"get",
"(",
"get",
")",
".",
"addCallback",
"(",
"new",
"ExistsCB",
"(",
")",
")",
";",
"}"
] |
Determines if the counter column exists for the TSUID.
This is used by the UID Manager tool to determine if we need to write a
new TSUID entry or not. It will not attempt to verify if the stored data is
valid, just checks to see if something is stored in the proper column.
@param tsdb The TSDB to use for storage access
@param tsuid The UID of the meta to verify
@return True if data was found, false if not
@throws HBaseException if there was an issue fetching
|
[
"Determines",
"if",
"the",
"counter",
"column",
"exists",
"for",
"the",
"TSUID",
".",
"This",
"is",
"used",
"by",
"the",
"UID",
"Manager",
"tool",
"to",
"determine",
"if",
"we",
"need",
"to",
"write",
"a",
"new",
"TSUID",
"entry",
"or",
"not",
".",
"It",
"will",
"not",
"attempt",
"to",
"verify",
"if",
"the",
"stored",
"data",
"is",
"valid",
"just",
"checks",
"to",
"see",
"if",
"something",
"is",
"stored",
"in",
"the",
"proper",
"column",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/meta/TSMeta.java#L472-L495
|
13,579
|
OpenTSDB/opentsdb
|
src/query/pojo/Query.java
|
Query.validate
|
public void validate() {
if (time == null) {
throw new IllegalArgumentException("missing time");
}
validatePOJO(time, "time");
if (metrics == null || metrics.isEmpty()) {
throw new IllegalArgumentException("missing or empty metrics");
}
final Set<String> variable_ids = new HashSet<String>();
for (Metric metric : metrics) {
if (variable_ids.contains(metric.getId())) {
throw new IllegalArgumentException("duplicated metric id: "
+ metric.getId());
}
variable_ids.add(metric.getId());
}
final Set<String> filter_ids = new HashSet<String>();
for (Filter filter : filters) {
if (filter_ids.contains(filter.getId())) {
throw new IllegalArgumentException("duplicated filter id: "
+ filter.getId());
}
filter_ids.add(filter.getId());
}
for (Expression expression : expressions) {
if (variable_ids.contains(expression.getId())) {
throw new IllegalArgumentException("Duplicated variable or expression id: "
+ expression.getId());
}
variable_ids.add(expression.getId());
}
validateCollection(metrics, "metric");
if (filters != null) {
validateCollection(filters, "filter");
}
if (expressions != null) {
validateCollection(expressions, "expression");
}
validateFilters();
if (expressions != null) {
validateCollection(expressions, "expression");
for (final Expression exp : expressions) {
if (exp.getVariables() == null) {
throw new IllegalArgumentException("No variables found for an "
+ "expression?! " + JSON.serializeToString(exp));
}
for (final String var : exp.getVariables()) {
if (!variable_ids.contains(var)) {
throw new IllegalArgumentException("Expression [" + exp.getExpr()
+ "] was missing input " + var);
}
}
}
}
}
|
java
|
public void validate() {
if (time == null) {
throw new IllegalArgumentException("missing time");
}
validatePOJO(time, "time");
if (metrics == null || metrics.isEmpty()) {
throw new IllegalArgumentException("missing or empty metrics");
}
final Set<String> variable_ids = new HashSet<String>();
for (Metric metric : metrics) {
if (variable_ids.contains(metric.getId())) {
throw new IllegalArgumentException("duplicated metric id: "
+ metric.getId());
}
variable_ids.add(metric.getId());
}
final Set<String> filter_ids = new HashSet<String>();
for (Filter filter : filters) {
if (filter_ids.contains(filter.getId())) {
throw new IllegalArgumentException("duplicated filter id: "
+ filter.getId());
}
filter_ids.add(filter.getId());
}
for (Expression expression : expressions) {
if (variable_ids.contains(expression.getId())) {
throw new IllegalArgumentException("Duplicated variable or expression id: "
+ expression.getId());
}
variable_ids.add(expression.getId());
}
validateCollection(metrics, "metric");
if (filters != null) {
validateCollection(filters, "filter");
}
if (expressions != null) {
validateCollection(expressions, "expression");
}
validateFilters();
if (expressions != null) {
validateCollection(expressions, "expression");
for (final Expression exp : expressions) {
if (exp.getVariables() == null) {
throw new IllegalArgumentException("No variables found for an "
+ "expression?! " + JSON.serializeToString(exp));
}
for (final String var : exp.getVariables()) {
if (!variable_ids.contains(var)) {
throw new IllegalArgumentException("Expression [" + exp.getExpr()
+ "] was missing input " + var);
}
}
}
}
}
|
[
"public",
"void",
"validate",
"(",
")",
"{",
"if",
"(",
"time",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"missing time\"",
")",
";",
"}",
"validatePOJO",
"(",
"time",
",",
"\"time\"",
")",
";",
"if",
"(",
"metrics",
"==",
"null",
"||",
"metrics",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"missing or empty metrics\"",
")",
";",
"}",
"final",
"Set",
"<",
"String",
">",
"variable_ids",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"Metric",
"metric",
":",
"metrics",
")",
"{",
"if",
"(",
"variable_ids",
".",
"contains",
"(",
"metric",
".",
"getId",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"duplicated metric id: \"",
"+",
"metric",
".",
"getId",
"(",
")",
")",
";",
"}",
"variable_ids",
".",
"add",
"(",
"metric",
".",
"getId",
"(",
")",
")",
";",
"}",
"final",
"Set",
"<",
"String",
">",
"filter_ids",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"Filter",
"filter",
":",
"filters",
")",
"{",
"if",
"(",
"filter_ids",
".",
"contains",
"(",
"filter",
".",
"getId",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"duplicated filter id: \"",
"+",
"filter",
".",
"getId",
"(",
")",
")",
";",
"}",
"filter_ids",
".",
"add",
"(",
"filter",
".",
"getId",
"(",
")",
")",
";",
"}",
"for",
"(",
"Expression",
"expression",
":",
"expressions",
")",
"{",
"if",
"(",
"variable_ids",
".",
"contains",
"(",
"expression",
".",
"getId",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Duplicated variable or expression id: \"",
"+",
"expression",
".",
"getId",
"(",
")",
")",
";",
"}",
"variable_ids",
".",
"add",
"(",
"expression",
".",
"getId",
"(",
")",
")",
";",
"}",
"validateCollection",
"(",
"metrics",
",",
"\"metric\"",
")",
";",
"if",
"(",
"filters",
"!=",
"null",
")",
"{",
"validateCollection",
"(",
"filters",
",",
"\"filter\"",
")",
";",
"}",
"if",
"(",
"expressions",
"!=",
"null",
")",
"{",
"validateCollection",
"(",
"expressions",
",",
"\"expression\"",
")",
";",
"}",
"validateFilters",
"(",
")",
";",
"if",
"(",
"expressions",
"!=",
"null",
")",
"{",
"validateCollection",
"(",
"expressions",
",",
"\"expression\"",
")",
";",
"for",
"(",
"final",
"Expression",
"exp",
":",
"expressions",
")",
"{",
"if",
"(",
"exp",
".",
"getVariables",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"No variables found for an \"",
"+",
"\"expression?! \"",
"+",
"JSON",
".",
"serializeToString",
"(",
"exp",
")",
")",
";",
"}",
"for",
"(",
"final",
"String",
"var",
":",
"exp",
".",
"getVariables",
"(",
")",
")",
"{",
"if",
"(",
"!",
"variable_ids",
".",
"contains",
"(",
"var",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Expression [\"",
"+",
"exp",
".",
"getExpr",
"(",
")",
"+",
"\"] was missing input \"",
"+",
"var",
")",
";",
"}",
"}",
"}",
"}",
"}"
] |
Validates the query
@throws IllegalArgumentException if one or more parameters were invalid
|
[
"Validates",
"the",
"query"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/pojo/Query.java#L103-L169
|
13,580
|
OpenTSDB/opentsdb
|
src/query/pojo/Query.java
|
Query.validateFilters
|
private void validateFilters() {
Set<String> ids = new HashSet<String>();
for (Filter filter : filters) {
ids.add(filter.getId());
}
for(Metric metric : metrics) {
if (metric.getFilter() != null &&
!metric.getFilter().isEmpty() &&
!ids.contains(metric.getFilter())) {
throw new IllegalArgumentException(
String.format("unrecognized filter id %s in metric %s",
metric.getFilter(), metric.getId()));
}
}
}
|
java
|
private void validateFilters() {
Set<String> ids = new HashSet<String>();
for (Filter filter : filters) {
ids.add(filter.getId());
}
for(Metric metric : metrics) {
if (metric.getFilter() != null &&
!metric.getFilter().isEmpty() &&
!ids.contains(metric.getFilter())) {
throw new IllegalArgumentException(
String.format("unrecognized filter id %s in metric %s",
metric.getFilter(), metric.getId()));
}
}
}
|
[
"private",
"void",
"validateFilters",
"(",
")",
"{",
"Set",
"<",
"String",
">",
"ids",
"=",
"new",
"HashSet",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"Filter",
"filter",
":",
"filters",
")",
"{",
"ids",
".",
"add",
"(",
"filter",
".",
"getId",
"(",
")",
")",
";",
"}",
"for",
"(",
"Metric",
"metric",
":",
"metrics",
")",
"{",
"if",
"(",
"metric",
".",
"getFilter",
"(",
")",
"!=",
"null",
"&&",
"!",
"metric",
".",
"getFilter",
"(",
")",
".",
"isEmpty",
"(",
")",
"&&",
"!",
"ids",
".",
"contains",
"(",
"metric",
".",
"getFilter",
"(",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"String",
".",
"format",
"(",
"\"unrecognized filter id %s in metric %s\"",
",",
"metric",
".",
"getFilter",
"(",
")",
",",
"metric",
".",
"getId",
"(",
")",
")",
")",
";",
"}",
"}",
"}"
] |
Validates the filters, making sure each metric has a filter
@throws IllegalArgumentException if one or more parameters were invalid
|
[
"Validates",
"the",
"filters",
"making",
"sure",
"each",
"metric",
"has",
"a",
"filter"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/pojo/Query.java#L174-L189
|
13,581
|
OpenTSDB/opentsdb
|
src/query/pojo/Query.java
|
Query.validateId
|
public static void validateId(final String id) {
if (id == null || id.isEmpty()) {
throw new IllegalArgumentException("The ID cannot be null or empty");
}
for (int i = 0; i < id.length(); i++) {
final char c = id.charAt(i);
if (!(Character.isLetterOrDigit(c))) {
throw new IllegalArgumentException("Invalid id (\"" + id +
"\"): illegal character: " + c);
}
}
if (id.length() == 1) {
if (Character.isDigit(id.charAt(0))) {
throw new IllegalArgumentException("The ID cannot be an integer");
}
}
}
|
java
|
public static void validateId(final String id) {
if (id == null || id.isEmpty()) {
throw new IllegalArgumentException("The ID cannot be null or empty");
}
for (int i = 0; i < id.length(); i++) {
final char c = id.charAt(i);
if (!(Character.isLetterOrDigit(c))) {
throw new IllegalArgumentException("Invalid id (\"" + id +
"\"): illegal character: " + c);
}
}
if (id.length() == 1) {
if (Character.isDigit(id.charAt(0))) {
throw new IllegalArgumentException("The ID cannot be an integer");
}
}
}
|
[
"public",
"static",
"void",
"validateId",
"(",
"final",
"String",
"id",
")",
"{",
"if",
"(",
"id",
"==",
"null",
"||",
"id",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The ID cannot be null or empty\"",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"id",
".",
"length",
"(",
")",
";",
"i",
"++",
")",
"{",
"final",
"char",
"c",
"=",
"id",
".",
"charAt",
"(",
"i",
")",
";",
"if",
"(",
"!",
"(",
"Character",
".",
"isLetterOrDigit",
"(",
"c",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Invalid id (\\\"\"",
"+",
"id",
"+",
"\"\\\"): illegal character: \"",
"+",
"c",
")",
";",
"}",
"}",
"if",
"(",
"id",
".",
"length",
"(",
")",
"==",
"1",
")",
"{",
"if",
"(",
"Character",
".",
"isDigit",
"(",
"id",
".",
"charAt",
"(",
"0",
")",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"The ID cannot be an integer\"",
")",
";",
"}",
"}",
"}"
] |
Makes sure the ID has only letters and characters
@param id The ID to parse
@throws IllegalArgumentException if the ID is invalid
|
[
"Makes",
"sure",
"the",
"ID",
"has",
"only",
"letters",
"and",
"characters"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/query/pojo/Query.java#L196-L212
|
13,582
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.loadPluginPath
|
public static void loadPluginPath(final String plugin_path) {
if (plugin_path != null && !plugin_path.isEmpty()) {
try {
PluginLoader.loadJARs(plugin_path);
} catch (Exception e) {
LOG.error("Error loading plugins from plugin path: " + plugin_path, e);
throw new RuntimeException("Error loading plugins from plugin path: " +
plugin_path, e);
}
}
}
|
java
|
public static void loadPluginPath(final String plugin_path) {
if (plugin_path != null && !plugin_path.isEmpty()) {
try {
PluginLoader.loadJARs(plugin_path);
} catch (Exception e) {
LOG.error("Error loading plugins from plugin path: " + plugin_path, e);
throw new RuntimeException("Error loading plugins from plugin path: " +
plugin_path, e);
}
}
}
|
[
"public",
"static",
"void",
"loadPluginPath",
"(",
"final",
"String",
"plugin_path",
")",
"{",
"if",
"(",
"plugin_path",
"!=",
"null",
"&&",
"!",
"plugin_path",
".",
"isEmpty",
"(",
")",
")",
"{",
"try",
"{",
"PluginLoader",
".",
"loadJARs",
"(",
"plugin_path",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOG",
".",
"error",
"(",
"\"Error loading plugins from plugin path: \"",
"+",
"plugin_path",
",",
"e",
")",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Error loading plugins from plugin path: \"",
"+",
"plugin_path",
",",
"e",
")",
";",
"}",
"}",
"}"
] |
Called by initializePlugins, also used to load startup plugins.
@since 2.3
|
[
"Called",
"by",
"initializePlugins",
"also",
"used",
"to",
"load",
"startup",
"plugins",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L368-L378
|
13,583
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.getUidName
|
public Deferred<String> getUidName(final UniqueIdType type, final byte[] uid) {
if (uid == null) {
throw new IllegalArgumentException("Missing UID");
}
switch (type) {
case METRIC:
return this.metrics.getNameAsync(uid);
case TAGK:
return this.tag_names.getNameAsync(uid);
case TAGV:
return this.tag_values.getNameAsync(uid);
default:
throw new IllegalArgumentException("Unrecognized UID type");
}
}
|
java
|
public Deferred<String> getUidName(final UniqueIdType type, final byte[] uid) {
if (uid == null) {
throw new IllegalArgumentException("Missing UID");
}
switch (type) {
case METRIC:
return this.metrics.getNameAsync(uid);
case TAGK:
return this.tag_names.getNameAsync(uid);
case TAGV:
return this.tag_values.getNameAsync(uid);
default:
throw new IllegalArgumentException("Unrecognized UID type");
}
}
|
[
"public",
"Deferred",
"<",
"String",
">",
"getUidName",
"(",
"final",
"UniqueIdType",
"type",
",",
"final",
"byte",
"[",
"]",
"uid",
")",
"{",
"if",
"(",
"uid",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Missing UID\"",
")",
";",
"}",
"switch",
"(",
"type",
")",
"{",
"case",
"METRIC",
":",
"return",
"this",
".",
"metrics",
".",
"getNameAsync",
"(",
"uid",
")",
";",
"case",
"TAGK",
":",
"return",
"this",
".",
"tag_names",
".",
"getNameAsync",
"(",
"uid",
")",
";",
"case",
"TAGV",
":",
"return",
"this",
".",
"tag_values",
".",
"getNameAsync",
"(",
"uid",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unrecognized UID type\"",
")",
";",
"}",
"}"
] |
Attempts to find the name for a unique identifier given a type
@param type The type of UID
@param uid The UID to search for
@return The name of the UID object if found
@throws IllegalArgumentException if the type is not valid
@throws NoSuchUniqueId if the UID was not found
@since 2.0
|
[
"Attempts",
"to",
"find",
"the",
"name",
"for",
"a",
"unique",
"identifier",
"given",
"a",
"type"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L642-L657
|
13,584
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.checkNecessaryTablesExist
|
public Deferred<ArrayList<Object>> checkNecessaryTablesExist() {
final ArrayList<Deferred<Object>> checks =
new ArrayList<Deferred<Object>>(2);
checks.add(client.ensureTableExists(
config.getString("tsd.storage.hbase.data_table")));
checks.add(client.ensureTableExists(
config.getString("tsd.storage.hbase.uid_table")));
if (config.enable_tree_processing()) {
checks.add(client.ensureTableExists(
config.getString("tsd.storage.hbase.tree_table")));
}
if (config.enable_realtime_ts() || config.enable_realtime_uid() ||
config.enable_tsuid_incrementing()) {
checks.add(client.ensureTableExists(
config.getString("tsd.storage.hbase.meta_table")));
}
return Deferred.group(checks);
}
|
java
|
public Deferred<ArrayList<Object>> checkNecessaryTablesExist() {
final ArrayList<Deferred<Object>> checks =
new ArrayList<Deferred<Object>>(2);
checks.add(client.ensureTableExists(
config.getString("tsd.storage.hbase.data_table")));
checks.add(client.ensureTableExists(
config.getString("tsd.storage.hbase.uid_table")));
if (config.enable_tree_processing()) {
checks.add(client.ensureTableExists(
config.getString("tsd.storage.hbase.tree_table")));
}
if (config.enable_realtime_ts() || config.enable_realtime_uid() ||
config.enable_tsuid_incrementing()) {
checks.add(client.ensureTableExists(
config.getString("tsd.storage.hbase.meta_table")));
}
return Deferred.group(checks);
}
|
[
"public",
"Deferred",
"<",
"ArrayList",
"<",
"Object",
">",
">",
"checkNecessaryTablesExist",
"(",
")",
"{",
"final",
"ArrayList",
"<",
"Deferred",
"<",
"Object",
">",
">",
"checks",
"=",
"new",
"ArrayList",
"<",
"Deferred",
"<",
"Object",
">",
">",
"(",
"2",
")",
";",
"checks",
".",
"add",
"(",
"client",
".",
"ensureTableExists",
"(",
"config",
".",
"getString",
"(",
"\"tsd.storage.hbase.data_table\"",
")",
")",
")",
";",
"checks",
".",
"add",
"(",
"client",
".",
"ensureTableExists",
"(",
"config",
".",
"getString",
"(",
"\"tsd.storage.hbase.uid_table\"",
")",
")",
")",
";",
"if",
"(",
"config",
".",
"enable_tree_processing",
"(",
")",
")",
"{",
"checks",
".",
"add",
"(",
"client",
".",
"ensureTableExists",
"(",
"config",
".",
"getString",
"(",
"\"tsd.storage.hbase.tree_table\"",
")",
")",
")",
";",
"}",
"if",
"(",
"config",
".",
"enable_realtime_ts",
"(",
")",
"||",
"config",
".",
"enable_realtime_uid",
"(",
")",
"||",
"config",
".",
"enable_tsuid_incrementing",
"(",
")",
")",
"{",
"checks",
".",
"add",
"(",
"client",
".",
"ensureTableExists",
"(",
"config",
".",
"getString",
"(",
"\"tsd.storage.hbase.meta_table\"",
")",
")",
")",
";",
"}",
"return",
"Deferred",
".",
"group",
"(",
"checks",
")",
";",
"}"
] |
Verifies that the data and UID tables exist in HBase and optionally the
tree and meta data tables if the user has enabled meta tracking or tree
building
@return An ArrayList of objects to wait for
@throws TableNotFoundException
@since 2.0
|
[
"Verifies",
"that",
"the",
"data",
"and",
"UID",
"tables",
"exist",
"in",
"HBase",
"and",
"optionally",
"the",
"tree",
"and",
"meta",
"data",
"tables",
"if",
"the",
"user",
"has",
"enabled",
"meta",
"tracking",
"or",
"tree",
"building"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L712-L729
|
13,585
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.addHistogramPoint
|
public Deferred<Object> addHistogramPoint(final String metric,
final long timestamp,
final byte[] raw_data,
final Map<String, String> tags) {
if (raw_data == null || raw_data.length < MIN_HISTOGRAM_BYTES) {
return Deferred.fromError(new IllegalArgumentException(
"The histogram raw data is invalid: " + Bytes.pretty(raw_data)));
}
checkTimestampAndTags(metric, timestamp, raw_data, tags, (short) 0);
final byte[] row = IncomingDataPoints.rowKeyTemplate(this, metric, tags);
final byte[] qualifier = Internal.getQualifier(timestamp,
HistogramDataPoint.PREFIX);
return storeIntoDB(metric, timestamp, raw_data, tags, (short) 0, row, qualifier);
}
|
java
|
public Deferred<Object> addHistogramPoint(final String metric,
final long timestamp,
final byte[] raw_data,
final Map<String, String> tags) {
if (raw_data == null || raw_data.length < MIN_HISTOGRAM_BYTES) {
return Deferred.fromError(new IllegalArgumentException(
"The histogram raw data is invalid: " + Bytes.pretty(raw_data)));
}
checkTimestampAndTags(metric, timestamp, raw_data, tags, (short) 0);
final byte[] row = IncomingDataPoints.rowKeyTemplate(this, metric, tags);
final byte[] qualifier = Internal.getQualifier(timestamp,
HistogramDataPoint.PREFIX);
return storeIntoDB(metric, timestamp, raw_data, tags, (short) 0, row, qualifier);
}
|
[
"public",
"Deferred",
"<",
"Object",
">",
"addHistogramPoint",
"(",
"final",
"String",
"metric",
",",
"final",
"long",
"timestamp",
",",
"final",
"byte",
"[",
"]",
"raw_data",
",",
"final",
"Map",
"<",
"String",
",",
"String",
">",
"tags",
")",
"{",
"if",
"(",
"raw_data",
"==",
"null",
"||",
"raw_data",
".",
"length",
"<",
"MIN_HISTOGRAM_BYTES",
")",
"{",
"return",
"Deferred",
".",
"fromError",
"(",
"new",
"IllegalArgumentException",
"(",
"\"The histogram raw data is invalid: \"",
"+",
"Bytes",
".",
"pretty",
"(",
"raw_data",
")",
")",
")",
";",
"}",
"checkTimestampAndTags",
"(",
"metric",
",",
"timestamp",
",",
"raw_data",
",",
"tags",
",",
"(",
"short",
")",
"0",
")",
";",
"final",
"byte",
"[",
"]",
"row",
"=",
"IncomingDataPoints",
".",
"rowKeyTemplate",
"(",
"this",
",",
"metric",
",",
"tags",
")",
";",
"final",
"byte",
"[",
"]",
"qualifier",
"=",
"Internal",
".",
"getQualifier",
"(",
"timestamp",
",",
"HistogramDataPoint",
".",
"PREFIX",
")",
";",
"return",
"storeIntoDB",
"(",
"metric",
",",
"timestamp",
",",
"raw_data",
",",
"tags",
",",
"(",
"short",
")",
"0",
",",
"row",
",",
"qualifier",
")",
";",
"}"
] |
Adds an encoded Histogram data point in the TSDB.
@param metric A non-empty string.
@param timestamp The timestamp associated with the value.
@param raw_data The encoded data blob of the Histogram point.
@param tags The tags on this series. This map must be non-empty.
@return A deferred object that indicates the completion of the request.
The {@link Object} has not special meaning and can be {@code null} (think
of it as {@code Deferred<Void>}). But you probably want to attach at
least an errback to this {@code Deferred} to handle failures.
@throws IllegalArgumentException if the timestamp is less than or equal
to the previous timestamp added or 0 for the first timestamp, or if the
difference with the previous timestamp is too large.
@throws IllegalArgumentException if the metric name is empty or contains
illegal characters.
@throws IllegalArgumentException if the tags list is empty or one of the
elements contains illegal characters.
@throws HBaseException (deferred) if there was a problem while persisting
data.
|
[
"Adds",
"an",
"encoded",
"Histogram",
"data",
"point",
"in",
"the",
"TSDB",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L1124-L1140
|
13,586
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.suggestMetrics
|
public List<String> suggestMetrics(final String search,
final int max_results) {
return metrics.suggest(search, max_results);
}
|
java
|
public List<String> suggestMetrics(final String search,
final int max_results) {
return metrics.suggest(search, max_results);
}
|
[
"public",
"List",
"<",
"String",
">",
"suggestMetrics",
"(",
"final",
"String",
"search",
",",
"final",
"int",
"max_results",
")",
"{",
"return",
"metrics",
".",
"suggest",
"(",
"search",
",",
"max_results",
")",
";",
"}"
] |
Given a prefix search, returns matching metric names.
@param search A prefix to search.
@param max_results Maximum number of results to return.
@since 2.0
|
[
"Given",
"a",
"prefix",
"search",
"returns",
"matching",
"metric",
"names",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L1764-L1767
|
13,587
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.suggestTagNames
|
public List<String> suggestTagNames(final String search,
final int max_results) {
return tag_names.suggest(search, max_results);
}
|
java
|
public List<String> suggestTagNames(final String search,
final int max_results) {
return tag_names.suggest(search, max_results);
}
|
[
"public",
"List",
"<",
"String",
">",
"suggestTagNames",
"(",
"final",
"String",
"search",
",",
"final",
"int",
"max_results",
")",
"{",
"return",
"tag_names",
".",
"suggest",
"(",
"search",
",",
"max_results",
")",
";",
"}"
] |
Given a prefix search, returns matching tagk names.
@param search A prefix to search.
@param max_results Maximum number of results to return.
@since 2.0
|
[
"Given",
"a",
"prefix",
"search",
"returns",
"matching",
"tagk",
"names",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L1783-L1786
|
13,588
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.suggestTagValues
|
public List<String> suggestTagValues(final String search,
final int max_results) {
return tag_values.suggest(search, max_results);
}
|
java
|
public List<String> suggestTagValues(final String search,
final int max_results) {
return tag_values.suggest(search, max_results);
}
|
[
"public",
"List",
"<",
"String",
">",
"suggestTagValues",
"(",
"final",
"String",
"search",
",",
"final",
"int",
"max_results",
")",
"{",
"return",
"tag_values",
".",
"suggest",
"(",
"search",
",",
"max_results",
")",
";",
"}"
] |
Given a prefix search, returns matching tag values.
@param search A prefix to search.
@param max_results Maximum number of results to return.
@since 2.0
|
[
"Given",
"a",
"prefix",
"search",
"returns",
"matching",
"tag",
"values",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L1802-L1805
|
13,589
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.assignUid
|
public byte[] assignUid(final String type, final String name) {
Tags.validateString(type, name);
if (type.toLowerCase().equals("metric")) {
try {
final byte[] uid = this.metrics.getId(name);
throw new IllegalArgumentException("Name already exists with UID: " +
UniqueId.uidToString(uid));
} catch (NoSuchUniqueName nsue) {
return this.metrics.getOrCreateId(name);
}
} else if (type.toLowerCase().equals("tagk")) {
try {
final byte[] uid = this.tag_names.getId(name);
throw new IllegalArgumentException("Name already exists with UID: " +
UniqueId.uidToString(uid));
} catch (NoSuchUniqueName nsue) {
return this.tag_names.getOrCreateId(name);
}
} else if (type.toLowerCase().equals("tagv")) {
try {
final byte[] uid = this.tag_values.getId(name);
throw new IllegalArgumentException("Name already exists with UID: " +
UniqueId.uidToString(uid));
} catch (NoSuchUniqueName nsue) {
return this.tag_values.getOrCreateId(name);
}
} else {
LOG.warn("Unknown type name: " + type);
throw new IllegalArgumentException("Unknown type name");
}
}
|
java
|
public byte[] assignUid(final String type, final String name) {
Tags.validateString(type, name);
if (type.toLowerCase().equals("metric")) {
try {
final byte[] uid = this.metrics.getId(name);
throw new IllegalArgumentException("Name already exists with UID: " +
UniqueId.uidToString(uid));
} catch (NoSuchUniqueName nsue) {
return this.metrics.getOrCreateId(name);
}
} else if (type.toLowerCase().equals("tagk")) {
try {
final byte[] uid = this.tag_names.getId(name);
throw new IllegalArgumentException("Name already exists with UID: " +
UniqueId.uidToString(uid));
} catch (NoSuchUniqueName nsue) {
return this.tag_names.getOrCreateId(name);
}
} else if (type.toLowerCase().equals("tagv")) {
try {
final byte[] uid = this.tag_values.getId(name);
throw new IllegalArgumentException("Name already exists with UID: " +
UniqueId.uidToString(uid));
} catch (NoSuchUniqueName nsue) {
return this.tag_values.getOrCreateId(name);
}
} else {
LOG.warn("Unknown type name: " + type);
throw new IllegalArgumentException("Unknown type name");
}
}
|
[
"public",
"byte",
"[",
"]",
"assignUid",
"(",
"final",
"String",
"type",
",",
"final",
"String",
"name",
")",
"{",
"Tags",
".",
"validateString",
"(",
"type",
",",
"name",
")",
";",
"if",
"(",
"type",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"metric\"",
")",
")",
"{",
"try",
"{",
"final",
"byte",
"[",
"]",
"uid",
"=",
"this",
".",
"metrics",
".",
"getId",
"(",
"name",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Name already exists with UID: \"",
"+",
"UniqueId",
".",
"uidToString",
"(",
"uid",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchUniqueName",
"nsue",
")",
"{",
"return",
"this",
".",
"metrics",
".",
"getOrCreateId",
"(",
"name",
")",
";",
"}",
"}",
"else",
"if",
"(",
"type",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"tagk\"",
")",
")",
"{",
"try",
"{",
"final",
"byte",
"[",
"]",
"uid",
"=",
"this",
".",
"tag_names",
".",
"getId",
"(",
"name",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Name already exists with UID: \"",
"+",
"UniqueId",
".",
"uidToString",
"(",
"uid",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchUniqueName",
"nsue",
")",
"{",
"return",
"this",
".",
"tag_names",
".",
"getOrCreateId",
"(",
"name",
")",
";",
"}",
"}",
"else",
"if",
"(",
"type",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"tagv\"",
")",
")",
"{",
"try",
"{",
"final",
"byte",
"[",
"]",
"uid",
"=",
"this",
".",
"tag_values",
".",
"getId",
"(",
"name",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Name already exists with UID: \"",
"+",
"UniqueId",
".",
"uidToString",
"(",
"uid",
")",
")",
";",
"}",
"catch",
"(",
"NoSuchUniqueName",
"nsue",
")",
"{",
"return",
"this",
".",
"tag_values",
".",
"getOrCreateId",
"(",
"name",
")",
";",
"}",
"}",
"else",
"{",
"LOG",
".",
"warn",
"(",
"\"Unknown type name: \"",
"+",
"type",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown type name\"",
")",
";",
"}",
"}"
] |
Attempts to assign a UID to a name for the given type
Used by the UniqueIdRpc call to generate IDs for new metrics, tagks or
tagvs. The name must pass validation and if it's already assigned a UID,
this method will throw an error with the proper UID. Otherwise if it can
create the UID, it will be returned
@param type The type of uid to assign, metric, tagk or tagv
@param name The name of the uid object
@return A byte array with the UID if the assignment was successful
@throws IllegalArgumentException if the name is invalid or it already
exists
@since 2.0
|
[
"Attempts",
"to",
"assign",
"a",
"UID",
"to",
"a",
"name",
"for",
"the",
"given",
"type",
"Used",
"by",
"the",
"UniqueIdRpc",
"call",
"to",
"generate",
"IDs",
"for",
"new",
"metrics",
"tagks",
"or",
"tagvs",
".",
"The",
"name",
"must",
"pass",
"validation",
"and",
"if",
"it",
"s",
"already",
"assigned",
"a",
"UID",
"this",
"method",
"will",
"throw",
"an",
"error",
"with",
"the",
"proper",
"UID",
".",
"Otherwise",
"if",
"it",
"can",
"create",
"the",
"UID",
"it",
"will",
"be",
"returned"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L1830-L1860
|
13,590
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.deleteUidAsync
|
public Deferred<Object> deleteUidAsync(final String type, final String name) {
final UniqueIdType uid_type = UniqueId.stringToUniqueIdType(type);
switch (uid_type) {
case METRIC:
return metrics.deleteAsync(name);
case TAGK:
return tag_names.deleteAsync(name);
case TAGV:
return tag_values.deleteAsync(name);
default:
throw new IllegalArgumentException("Unrecognized UID type: " + uid_type);
}
}
|
java
|
public Deferred<Object> deleteUidAsync(final String type, final String name) {
final UniqueIdType uid_type = UniqueId.stringToUniqueIdType(type);
switch (uid_type) {
case METRIC:
return metrics.deleteAsync(name);
case TAGK:
return tag_names.deleteAsync(name);
case TAGV:
return tag_values.deleteAsync(name);
default:
throw new IllegalArgumentException("Unrecognized UID type: " + uid_type);
}
}
|
[
"public",
"Deferred",
"<",
"Object",
">",
"deleteUidAsync",
"(",
"final",
"String",
"type",
",",
"final",
"String",
"name",
")",
"{",
"final",
"UniqueIdType",
"uid_type",
"=",
"UniqueId",
".",
"stringToUniqueIdType",
"(",
"type",
")",
";",
"switch",
"(",
"uid_type",
")",
"{",
"case",
"METRIC",
":",
"return",
"metrics",
".",
"deleteAsync",
"(",
"name",
")",
";",
"case",
"TAGK",
":",
"return",
"tag_names",
".",
"deleteAsync",
"(",
"name",
")",
";",
"case",
"TAGV",
":",
"return",
"tag_values",
".",
"deleteAsync",
"(",
"name",
")",
";",
"default",
":",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unrecognized UID type: \"",
"+",
"uid_type",
")",
";",
"}",
"}"
] |
Attempts to delete the given UID name mapping from the storage table as
well as the local cache.
@param type The type of UID to delete. Must be "metrics", "tagk" or "tagv"
@param name The name of the UID to delete
@return A deferred to wait on for completion, or an exception if thrown
@throws IllegalArgumentException if the type is invalid
@since 2.2
|
[
"Attempts",
"to",
"delete",
"the",
"given",
"UID",
"name",
"mapping",
"from",
"the",
"storage",
"table",
"as",
"well",
"as",
"the",
"local",
"cache",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L1871-L1883
|
13,591
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.renameUid
|
public void renameUid(final String type, final String oldname,
final String newname) {
Tags.validateString(type, oldname);
Tags.validateString(type, newname);
if (type.toLowerCase().equals("metric")) {
try {
this.metrics.getId(oldname);
this.metrics.rename(oldname, newname);
} catch (NoSuchUniqueName nsue) {
throw new IllegalArgumentException("Name(\"" + oldname +
"\") does not exist");
}
} else if (type.toLowerCase().equals("tagk")) {
try {
this.tag_names.getId(oldname);
this.tag_names.rename(oldname, newname);
} catch (NoSuchUniqueName nsue) {
throw new IllegalArgumentException("Name(\"" + oldname +
"\") does not exist");
}
} else if (type.toLowerCase().equals("tagv")) {
try {
this.tag_values.getId(oldname);
this.tag_values.rename(oldname, newname);
} catch (NoSuchUniqueName nsue) {
throw new IllegalArgumentException("Name(\"" + oldname +
"\") does not exist");
}
} else {
LOG.warn("Unknown type name: " + type);
throw new IllegalArgumentException("Unknown type name");
}
}
|
java
|
public void renameUid(final String type, final String oldname,
final String newname) {
Tags.validateString(type, oldname);
Tags.validateString(type, newname);
if (type.toLowerCase().equals("metric")) {
try {
this.metrics.getId(oldname);
this.metrics.rename(oldname, newname);
} catch (NoSuchUniqueName nsue) {
throw new IllegalArgumentException("Name(\"" + oldname +
"\") does not exist");
}
} else if (type.toLowerCase().equals("tagk")) {
try {
this.tag_names.getId(oldname);
this.tag_names.rename(oldname, newname);
} catch (NoSuchUniqueName nsue) {
throw new IllegalArgumentException("Name(\"" + oldname +
"\") does not exist");
}
} else if (type.toLowerCase().equals("tagv")) {
try {
this.tag_values.getId(oldname);
this.tag_values.rename(oldname, newname);
} catch (NoSuchUniqueName nsue) {
throw new IllegalArgumentException("Name(\"" + oldname +
"\") does not exist");
}
} else {
LOG.warn("Unknown type name: " + type);
throw new IllegalArgumentException("Unknown type name");
}
}
|
[
"public",
"void",
"renameUid",
"(",
"final",
"String",
"type",
",",
"final",
"String",
"oldname",
",",
"final",
"String",
"newname",
")",
"{",
"Tags",
".",
"validateString",
"(",
"type",
",",
"oldname",
")",
";",
"Tags",
".",
"validateString",
"(",
"type",
",",
"newname",
")",
";",
"if",
"(",
"type",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"metric\"",
")",
")",
"{",
"try",
"{",
"this",
".",
"metrics",
".",
"getId",
"(",
"oldname",
")",
";",
"this",
".",
"metrics",
".",
"rename",
"(",
"oldname",
",",
"newname",
")",
";",
"}",
"catch",
"(",
"NoSuchUniqueName",
"nsue",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Name(\\\"\"",
"+",
"oldname",
"+",
"\"\\\") does not exist\"",
")",
";",
"}",
"}",
"else",
"if",
"(",
"type",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"tagk\"",
")",
")",
"{",
"try",
"{",
"this",
".",
"tag_names",
".",
"getId",
"(",
"oldname",
")",
";",
"this",
".",
"tag_names",
".",
"rename",
"(",
"oldname",
",",
"newname",
")",
";",
"}",
"catch",
"(",
"NoSuchUniqueName",
"nsue",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Name(\\\"\"",
"+",
"oldname",
"+",
"\"\\\") does not exist\"",
")",
";",
"}",
"}",
"else",
"if",
"(",
"type",
".",
"toLowerCase",
"(",
")",
".",
"equals",
"(",
"\"tagv\"",
")",
")",
"{",
"try",
"{",
"this",
".",
"tag_values",
".",
"getId",
"(",
"oldname",
")",
";",
"this",
".",
"tag_values",
".",
"rename",
"(",
"oldname",
",",
"newname",
")",
";",
"}",
"catch",
"(",
"NoSuchUniqueName",
"nsue",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Name(\\\"\"",
"+",
"oldname",
"+",
"\"\\\") does not exist\"",
")",
";",
"}",
"}",
"else",
"{",
"LOG",
".",
"warn",
"(",
"\"Unknown type name: \"",
"+",
"type",
")",
";",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"Unknown type name\"",
")",
";",
"}",
"}"
] |
Attempts to rename a UID from existing name to the given name
Used by the UniqueIdRpc call to rename name of existing metrics, tagks or
tagvs. The name must pass validation. If the UID doesn't exist, the method
will throw an error. Chained IllegalArgumentException is directly exposed
to caller. If the rename was successful, this method returns.
@param type The type of uid to rename, one of metric, tagk and tagv
@param oldname The existing name of the uid object
@param newname The new name to be used on the uid object
@throws IllegalArgumentException if error happened
@since 2.2
|
[
"Attempts",
"to",
"rename",
"a",
"UID",
"from",
"existing",
"name",
"to",
"the",
"given",
"name",
"Used",
"by",
"the",
"UniqueIdRpc",
"call",
"to",
"rename",
"name",
"of",
"existing",
"metrics",
"tagks",
"or",
"tagvs",
".",
"The",
"name",
"must",
"pass",
"validation",
".",
"If",
"the",
"UID",
"doesn",
"t",
"exist",
"the",
"method",
"will",
"throw",
"an",
"error",
".",
"Chained",
"IllegalArgumentException",
"is",
"directly",
"exposed",
"to",
"caller",
".",
"If",
"the",
"rename",
"was",
"successful",
"this",
"method",
"returns",
"."
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L1897-L1929
|
13,592
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.indexTSMeta
|
public void indexTSMeta(final TSMeta meta) {
if (search != null) {
search.indexTSMeta(meta).addErrback(new PluginError());
}
}
|
java
|
public void indexTSMeta(final TSMeta meta) {
if (search != null) {
search.indexTSMeta(meta).addErrback(new PluginError());
}
}
|
[
"public",
"void",
"indexTSMeta",
"(",
"final",
"TSMeta",
"meta",
")",
"{",
"if",
"(",
"search",
"!=",
"null",
")",
"{",
"search",
".",
"indexTSMeta",
"(",
"meta",
")",
".",
"addErrback",
"(",
"new",
"PluginError",
"(",
")",
")",
";",
"}",
"}"
] |
Index the given timeseries meta object via the configured search plugin
@param meta The meta data object to index
@since 2.0
|
[
"Index",
"the",
"given",
"timeseries",
"meta",
"object",
"via",
"the",
"configured",
"search",
"plugin"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L1956-L1960
|
13,593
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.deleteTSMeta
|
public void deleteTSMeta(final String tsuid) {
if (search != null) {
search.deleteTSMeta(tsuid).addErrback(new PluginError());
}
}
|
java
|
public void deleteTSMeta(final String tsuid) {
if (search != null) {
search.deleteTSMeta(tsuid).addErrback(new PluginError());
}
}
|
[
"public",
"void",
"deleteTSMeta",
"(",
"final",
"String",
"tsuid",
")",
"{",
"if",
"(",
"search",
"!=",
"null",
")",
"{",
"search",
".",
"deleteTSMeta",
"(",
"tsuid",
")",
".",
"addErrback",
"(",
"new",
"PluginError",
"(",
")",
")",
";",
"}",
"}"
] |
Delete the timeseries meta object from the search index
@param tsuid The TSUID to delete
@since 2.0
|
[
"Delete",
"the",
"timeseries",
"meta",
"object",
"from",
"the",
"search",
"index"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L1967-L1971
|
13,594
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.indexUIDMeta
|
public void indexUIDMeta(final UIDMeta meta) {
if (search != null) {
search.indexUIDMeta(meta).addErrback(new PluginError());
}
}
|
java
|
public void indexUIDMeta(final UIDMeta meta) {
if (search != null) {
search.indexUIDMeta(meta).addErrback(new PluginError());
}
}
|
[
"public",
"void",
"indexUIDMeta",
"(",
"final",
"UIDMeta",
"meta",
")",
"{",
"if",
"(",
"search",
"!=",
"null",
")",
"{",
"search",
".",
"indexUIDMeta",
"(",
"meta",
")",
".",
"addErrback",
"(",
"new",
"PluginError",
"(",
")",
")",
";",
"}",
"}"
] |
Index the given UID meta object via the configured search plugin
@param meta The meta data object to index
@since 2.0
|
[
"Index",
"the",
"given",
"UID",
"meta",
"object",
"via",
"the",
"configured",
"search",
"plugin"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L1978-L1982
|
13,595
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.deleteUIDMeta
|
public void deleteUIDMeta(final UIDMeta meta) {
if (search != null) {
search.deleteUIDMeta(meta).addErrback(new PluginError());
}
}
|
java
|
public void deleteUIDMeta(final UIDMeta meta) {
if (search != null) {
search.deleteUIDMeta(meta).addErrback(new PluginError());
}
}
|
[
"public",
"void",
"deleteUIDMeta",
"(",
"final",
"UIDMeta",
"meta",
")",
"{",
"if",
"(",
"search",
"!=",
"null",
")",
"{",
"search",
".",
"deleteUIDMeta",
"(",
"meta",
")",
".",
"addErrback",
"(",
"new",
"PluginError",
"(",
")",
")",
";",
"}",
"}"
] |
Delete the UID meta object from the search index
@param meta The UID meta object to delete
@since 2.0
|
[
"Delete",
"the",
"UID",
"meta",
"object",
"from",
"the",
"search",
"index"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L1989-L1993
|
13,596
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.indexAnnotation
|
public void indexAnnotation(final Annotation note) {
if (search != null) {
search.indexAnnotation(note).addErrback(new PluginError());
}
if( rt_publisher != null ) {
rt_publisher.publishAnnotation(note);
}
}
|
java
|
public void indexAnnotation(final Annotation note) {
if (search != null) {
search.indexAnnotation(note).addErrback(new PluginError());
}
if( rt_publisher != null ) {
rt_publisher.publishAnnotation(note);
}
}
|
[
"public",
"void",
"indexAnnotation",
"(",
"final",
"Annotation",
"note",
")",
"{",
"if",
"(",
"search",
"!=",
"null",
")",
"{",
"search",
".",
"indexAnnotation",
"(",
"note",
")",
".",
"addErrback",
"(",
"new",
"PluginError",
"(",
")",
")",
";",
"}",
"if",
"(",
"rt_publisher",
"!=",
"null",
")",
"{",
"rt_publisher",
".",
"publishAnnotation",
"(",
"note",
")",
";",
"}",
"}"
] |
Index the given Annotation object via the configured search plugin
@param note The annotation object to index
@since 2.0
|
[
"Index",
"the",
"given",
"Annotation",
"object",
"via",
"the",
"configured",
"search",
"plugin"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L2000-L2007
|
13,597
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.deleteAnnotation
|
public void deleteAnnotation(final Annotation note) {
if (search != null) {
search.deleteAnnotation(note).addErrback(new PluginError());
}
}
|
java
|
public void deleteAnnotation(final Annotation note) {
if (search != null) {
search.deleteAnnotation(note).addErrback(new PluginError());
}
}
|
[
"public",
"void",
"deleteAnnotation",
"(",
"final",
"Annotation",
"note",
")",
"{",
"if",
"(",
"search",
"!=",
"null",
")",
"{",
"search",
".",
"deleteAnnotation",
"(",
"note",
")",
".",
"addErrback",
"(",
"new",
"PluginError",
"(",
")",
")",
";",
"}",
"}"
] |
Delete the annotation object from the search index
@param note The annotation object to delete
@since 2.0
|
[
"Delete",
"the",
"annotation",
"object",
"from",
"the",
"search",
"index"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L2014-L2018
|
13,598
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.processTSMetaThroughTrees
|
public Deferred<Boolean> processTSMetaThroughTrees(final TSMeta meta) {
if (config.enable_tree_processing()) {
return TreeBuilder.processAllTrees(this, meta);
}
return Deferred.fromResult(false);
}
|
java
|
public Deferred<Boolean> processTSMetaThroughTrees(final TSMeta meta) {
if (config.enable_tree_processing()) {
return TreeBuilder.processAllTrees(this, meta);
}
return Deferred.fromResult(false);
}
|
[
"public",
"Deferred",
"<",
"Boolean",
">",
"processTSMetaThroughTrees",
"(",
"final",
"TSMeta",
"meta",
")",
"{",
"if",
"(",
"config",
".",
"enable_tree_processing",
"(",
")",
")",
"{",
"return",
"TreeBuilder",
".",
"processAllTrees",
"(",
"this",
",",
"meta",
")",
";",
"}",
"return",
"Deferred",
".",
"fromResult",
"(",
"false",
")",
";",
"}"
] |
Processes the TSMeta through all of the trees if configured to do so
@param meta The meta data to process
@since 2.0
|
[
"Processes",
"the",
"TSMeta",
"through",
"all",
"of",
"the",
"trees",
"if",
"configured",
"to",
"do",
"so"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L2025-L2030
|
13,599
|
OpenTSDB/opentsdb
|
src/core/TSDB.java
|
TSDB.executeSearch
|
public Deferred<SearchQuery> executeSearch(final SearchQuery query) {
if (search == null) {
throw new IllegalStateException(
"Searching has not been enabled on this TSD");
}
return search.executeQuery(query);
}
|
java
|
public Deferred<SearchQuery> executeSearch(final SearchQuery query) {
if (search == null) {
throw new IllegalStateException(
"Searching has not been enabled on this TSD");
}
return search.executeQuery(query);
}
|
[
"public",
"Deferred",
"<",
"SearchQuery",
">",
"executeSearch",
"(",
"final",
"SearchQuery",
"query",
")",
"{",
"if",
"(",
"search",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Searching has not been enabled on this TSD\"",
")",
";",
"}",
"return",
"search",
".",
"executeQuery",
"(",
"query",
")",
";",
"}"
] |
Executes a search query using the search plugin
@param query The query to execute
@return A deferred object to wait on for the results to be fetched
@throws IllegalStateException if the search plugin has not been enabled or
configured
@since 2.0
|
[
"Executes",
"a",
"search",
"query",
"using",
"the",
"search",
"plugin"
] |
3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3
|
https://github.com/OpenTSDB/opentsdb/blob/3fc2d491c3c1ad397252c0a80203a69a3f9e3ef3/src/core/TSDB.java#L2040-L2047
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.