├── src ├── .gitignore ├── META-INF │ ├── MANIFEST.MF │ └── services │ │ └── net.opentsdb.uid.UniqueIdFilterPlugin ├── mygnuplot.bat ├── tsd │ ├── static │ │ ├── favicon.ico │ │ └── opentsdb_header.jpg │ ├── QueryUi.gwt.xml │ ├── client │ │ ├── GotJsonCallback.java │ │ └── ValidatedTextBox.java │ ├── HttpRpc.java │ ├── GnuplotException.java │ ├── TelnetRpc.java │ ├── WordSplitter.java │ ├── RpcUtil.java │ ├── HttpRpcPluginQuery.java │ └── StaticFileRpc.java ├── mygnuplot.sh ├── normalize │ └── NormalizePlugin.java ├── core │ ├── HistogramAggregation.java │ ├── HistogramAggregator.java │ ├── GroupCallback.java │ ├── Histogram.java │ ├── IllegalDataException.java │ ├── RequestBuilder.java │ ├── HistogramDataPointCodec.java │ ├── FillPolicy.java │ ├── HistogramSeekableView.java │ ├── SimpleHistogramDecoder.java │ ├── DataPoint.java │ ├── iHistogramRowSeq.java │ ├── iRowSeq.java │ ├── QueryException.java │ └── AbstractQuery.java ├── auth │ ├── Permissions.java │ └── Roles.java ├── tools │ └── ArgValueValidator.java ├── upgrade_1to2.sh ├── rollup │ ├── NoSuchRollupForTableException.java │ └── NoSuchRollupForIntervalException.java ├── utils │ ├── Exceptions.java │ ├── JSONException.java │ └── FileSystem.java ├── query │ ├── expression │ │ └── Expression.java │ ├── filter │ │ └── TagVNotKeyFilter.java │ └── pojo │ │ └── Validatable.java ├── uid │ ├── NoSuchUniqueId.java │ ├── NoSuchUniqueName.java │ └── FailedToAssignUniqueIdException.java ├── create_table.sh └── opentsdb.conf ├── test ├── resources │ └── logback-test.xml ├── META-INF │ ├── MANIFEST.MF │ └── services │ │ ├── net.opentsdb.tsd.RpcPlugin │ │ ├── net.opentsdb.search.SearchPlugin │ │ ├── net.opentsdb.tsd.HttpRpcPlugin │ │ ├── net.opentsdb.tsd.RTPublisher │ │ ├── net.opentsdb.tsd.HttpSerializer │ │ ├── net.opentsdb.tsd.StorageExceptionHandler │ │ └── net.opentsdb.plugin.DummyPlugin ├── plugin │ ├── DummyPlugin.java │ ├── DummyPluginA.java │ └── DummyPluginB.java ├── core │ ├── TestTsdbQueryAppend.java │ ├── TestTsdbQueryHistogramQueriesSalted.java │ ├── LongHistogramDataPointForTestDecoder.java │ ├── TestTsdbQuerySaltedAppend.java │ ├── TestTsdbQuerySalted.java │ ├── TestSaltScannerHistogramSalted.java │ ├── TestTsdbQueryDownsampleSalted.java │ ├── TestTsdbQueryAggregatorsSalted.java │ ├── TestTSDBAddPointSalted.java │ ├── TestHistogramPojo.java │ ├── TestRollupSpanSalted.java │ ├── TestRpcResponsder.java │ └── TestSaltScannerSalted.java ├── uid │ └── TestNoSuchUniqueId.java ├── query │ ├── filter │ │ └── TestTagVNotKeyFilter.java │ └── pojo │ │ ├── TestOutput.java │ │ └── TestJoin.java ├── search │ ├── TestTimeSeriesLookupSalted.java │ └── TestSearchQuery.java ├── tsd │ ├── DummyHttpRpcPlugin.java │ ├── DummyHttpSerializer.java │ ├── DummyRpcPlugin.java │ ├── DummySEHPlugin.java │ ├── DummyRTPublisher.java │ └── TestHttpRpcPluginQuery.java └── utils │ ├── TestFileSystem.java │ ├── TestByteSet.java │ └── TestExceptions.java ├── third_party ├── kryo │ ├── asm-4.0.jar.md5.1 │ ├── kryo-3.0.0.jar.md5 │ ├── kryo-4.0.0.jar.md5 │ ├── minlog-1.3.jar.md5 │ ├── asm-4.0.jar.md5 │ ├── kryo-2.21.1.jar.md5 │ ├── minlog-1.2.jar.md5 │ ├── reflectasm-1.10.0-shaded.jar.md5 │ ├── reflectasm-1.07-shaded.jar.md5 │ └── include.mk ├── guava │ ├── guava-17.0.jar.md5 │ ├── guava-18.0.jar.md5 │ └── include.mk ├── junit │ ├── junit-4.10.jar.md5 │ ├── junit-4.11.jar.md5 │ └── include.mk ├── slf4j │ ├── slf4j-api-2.0.6.jar.md5 │ ├── slf4j-api-1.7.7.jar.md5 │ ├── log4j-over-slf4j-2.0.6.jar.md5 │ ├── log4j-over-slf4j-1.7.7.jar.md5 │ └── include.mk ├── apache │ ├── commons-math3-3.4.1.jar.md5 │ ├── commons-math3-3.6.1.jar.md5 │ └── include.mk ├── gwt │ ├── gwt-dev-2.6.0.jar.md5 │ ├── gwt-dev-2.6.1.jar.md5 │ ├── gwt-user-2.6.0.jar.md5 │ ├── gwt-user-2.6.1.jar.md5 │ ├── opentsdb-gwt-theme-1.0.0.jar.md5 │ └── include.mk ├── hbase │ ├── asynchbase-1.8.2.jar.md5 │ ├── asynchbase-1.8.0.jar.md5 │ ├── asynchbase-1.8.0-20161103.193100-4.jar.md5 │ └── include.mk ├── javacc │ ├── javacc-6.1.2.jar.md5 │ └── include.mk ├── jexl │ ├── commons-logging-1.2.jar.md5 │ ├── commons-jexl-2.1.1.jar.md5 │ ├── commons-logging-1.1.1.jar.md5 │ └── include.mk ├── logback │ ├── logback-core-1.2.9.jar.md5 │ ├── logback-core-1.3.4.jar.md5 │ ├── logback-classic-1.2.9.jar.md5 │ ├── logback-classic-1.3.4.jar.md5 │ └── include.mk ├── suasync │ ├── async-1.4.0.jar.md5 │ └── include.mk ├── zookeeper │ ├── zookeeper-3.4.6.jar.md5 │ ├── zookeeper-3.3.4.jar.md5 │ ├── zookeeper-3.3.6.jar.md5 │ ├── zookeeper-3.4.5.jar.md5 │ └── include.mk ├── hamcrest │ ├── hamcrest-core-1.3.jar.md5 │ └── include.mk ├── jackson │ ├── jackson-core-2.14.1.jar.md5 │ ├── jackson-core-2.9.10.jar.md5 │ ├── jackson-core-2.9.5.jar.md5 │ ├── jackson-databind-2.9.10.jar.md5 │ ├── jackson-annotations-2.9.10.jar.md5 │ ├── jackson-databind-2.14.1.jar.md5 │ ├── jackson-databind-2.9.5.jar.md5 │ ├── jackson-annotations-2.14.1.jar.md5 │ ├── jackson-annotations-2.9.5.jar.md5 │ └── include.mk ├── javassist │ ├── javassist-3.21.0-GA.jar.md5 │ ├── javassist-3.17.1-GA.jar.md5 │ ├── javassist-3.18.1-GA.jar.md5 │ └── include.mk ├── jgrapht │ ├── jgrapht-core-0.9.1.jar.md5 │ └── include.mk ├── mockito │ ├── mockito-core-1.9.0.jar.md5 │ ├── mockito-core-1.9.5.jar.md5 │ └── include.mk ├── netty │ ├── netty-3.10.6.Final.jar.md5 │ ├── netty-3.9.4.Final.jar.md5 │ └── include.mk ├── objenesis │ ├── objenesis-1.3.jar.md5 │ ├── objenesis-2.1.jar.md5 │ └── include.mk ├── powermock │ ├── powermock-mockito-1.5.jar.md5 │ ├── powermock-mockito-release-full-1.5.4-full.jar.md5 │ └── include.mk ├── protobuf │ ├── protobuf-java-2.5.0.jar.md5 │ └── include.mk ├── validation-api │ ├── validation-api-1.0.0.GA.jar.md5 │ ├── validation-api-1.0.0.GA-sources.jar.md5 │ └── include.mk ├── asyncbigtable │ ├── asyncbigtable-0.4.3-jar-with-dependencies.jar.md5 │ ├── asyncbigtable-0.3.1-20170903.031804-2-jar-with-dependencies.jar.md5 │ └── include.mk ├── asynccassandra │ ├── asynccassandra-0.0.1-20151104.191228-3-jar-with-dependencies.jar.md5 │ ├── asynccassandra-0.0.1-20160229.001338-4-jar-with-dependencies.jar.md5 │ └── include.mk └── include.mk ├── .dir-locals.el ├── tools ├── clean_cache.sh ├── docker │ ├── docker.sh │ └── Dockerfile ├── opentsdb_restart.py └── tsddrain.py ├── screwdriver.yaml ├── .gitignore ├── bootstrap ├── AUTHORS ├── fat-jar ├── create-src-dir-overlay.sh ├── test-logback.xml └── logback.xml ├── README └── configure.ac /src/.gitignore: -------------------------------------------------------------------------------- 1 | BuildData.java 2 | -------------------------------------------------------------------------------- /src/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 -------------------------------------------------------------------------------- /test/resources/logback-test.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /test/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | 3 | -------------------------------------------------------------------------------- /third_party/kryo/asm-4.0.jar.md5.1: -------------------------------------------------------------------------------- 1 | 322d8f88c5111af612df838c0191cd7e -------------------------------------------------------------------------------- /third_party/kryo/kryo-3.0.0.jar.md5: -------------------------------------------------------------------------------- 1 | 720adc0fa9b1ebfa789c6ceda3ffa990 -------------------------------------------------------------------------------- /third_party/kryo/kryo-4.0.0.jar.md5: -------------------------------------------------------------------------------- 1 | e817940f2e49280c3e5ad063f38e7884 -------------------------------------------------------------------------------- /third_party/kryo/minlog-1.3.jar.md5: -------------------------------------------------------------------------------- 1 | b4e9b84eaea9750fe58ac3e196c7ed9b -------------------------------------------------------------------------------- /third_party/guava/guava-17.0.jar.md5: -------------------------------------------------------------------------------- 1 | 89fef81c2adfa9b50a64ed5cd5d8c155 2 | -------------------------------------------------------------------------------- /third_party/guava/guava-18.0.jar.md5: -------------------------------------------------------------------------------- 1 | 947641f6bb535b1d942d1bc387c45290 2 | -------------------------------------------------------------------------------- /third_party/junit/junit-4.10.jar.md5: -------------------------------------------------------------------------------- 1 | 972c3b8fb2cc26008cbceb01ff889ec4 2 | -------------------------------------------------------------------------------- /third_party/junit/junit-4.11.jar.md5: -------------------------------------------------------------------------------- 1 | 3c42be5ea7cbf3635716abbb429cb90d 2 | -------------------------------------------------------------------------------- /third_party/kryo/asm-4.0.jar.md5: -------------------------------------------------------------------------------- 1 | 322d8f88c5111af612df838c0191cd7e 2 | -------------------------------------------------------------------------------- /third_party/kryo/kryo-2.21.1.jar.md5: -------------------------------------------------------------------------------- 1 | aa44f411a986ed6130dee951766bbba6 2 | -------------------------------------------------------------------------------- /third_party/kryo/minlog-1.2.jar.md5: -------------------------------------------------------------------------------- 1 | f7cfbdf63b67df0bbfa4c7cb260885bc 2 | -------------------------------------------------------------------------------- /third_party/slf4j/slf4j-api-2.0.6.jar.md5: -------------------------------------------------------------------------------- 1 | 0dd65c386e8c5f4e6e014de3f7a7ae60 -------------------------------------------------------------------------------- /third_party/apache/commons-math3-3.4.1.jar.md5: -------------------------------------------------------------------------------- 1 | 14a218d0ee57907dd2c7ef944b6c0afd -------------------------------------------------------------------------------- /third_party/gwt/gwt-dev-2.6.0.jar.md5: -------------------------------------------------------------------------------- 1 | 23d8bf52709230c2c7e6dd817261f9ee 2 | -------------------------------------------------------------------------------- /third_party/gwt/gwt-dev-2.6.1.jar.md5: -------------------------------------------------------------------------------- 1 | 2f8df1f3b021315775506a1e0a4ee4b8 2 | -------------------------------------------------------------------------------- /third_party/gwt/gwt-user-2.6.0.jar.md5: -------------------------------------------------------------------------------- 1 | 99226fc2764f2b8fd6db6e05d0847659 2 | -------------------------------------------------------------------------------- /third_party/gwt/gwt-user-2.6.1.jar.md5: -------------------------------------------------------------------------------- 1 | ce17f82bb92e3a7416a9be5659cbcc89 2 | -------------------------------------------------------------------------------- /third_party/hbase/asynchbase-1.8.2.jar.md5: -------------------------------------------------------------------------------- 1 | aa7df5b8b3c77d3671eff8bfa12a87c4 -------------------------------------------------------------------------------- /third_party/javacc/javacc-6.1.2.jar.md5: -------------------------------------------------------------------------------- 1 | c74b2df75b4c46209d6da22bf4dad976 2 | -------------------------------------------------------------------------------- /third_party/jexl/commons-logging-1.2.jar.md5: -------------------------------------------------------------------------------- 1 | 040b4b4d8eac886f6b4a2a3bd2f31b00 -------------------------------------------------------------------------------- /third_party/logback/logback-core-1.2.9.jar.md5: -------------------------------------------------------------------------------- 1 | e0e576b4001e1c99e551655b3fcbacbf -------------------------------------------------------------------------------- /third_party/logback/logback-core-1.3.4.jar.md5: -------------------------------------------------------------------------------- 1 | bbb33326f538cfd28186d5b4310b44fa -------------------------------------------------------------------------------- /third_party/slf4j/slf4j-api-1.7.7.jar.md5: -------------------------------------------------------------------------------- 1 | ca4280bf93d64367723ae5c8d42dd0b9 2 | -------------------------------------------------------------------------------- /third_party/suasync/async-1.4.0.jar.md5: -------------------------------------------------------------------------------- 1 | 90aa9cc566423f12af88e205804d5161 2 | -------------------------------------------------------------------------------- /third_party/zookeeper/zookeeper-3.4.6.jar.md5: -------------------------------------------------------------------------------- 1 | 7d01d317c717268725896cfb81b18152 -------------------------------------------------------------------------------- /test/META-INF/services/net.opentsdb.tsd.RpcPlugin: -------------------------------------------------------------------------------- 1 | net.opentsdb.tsd.DummyRpcPlugin -------------------------------------------------------------------------------- /third_party/apache/commons-math3-3.6.1.jar.md5: -------------------------------------------------------------------------------- 1 | 5b730d97e4e6368069de1983937c508e 2 | -------------------------------------------------------------------------------- /third_party/hamcrest/hamcrest-core-1.3.jar.md5: -------------------------------------------------------------------------------- 1 | 6393363b47ddcbba82321110c3e07519 2 | -------------------------------------------------------------------------------- /third_party/hbase/asynchbase-1.8.0.jar.md5: -------------------------------------------------------------------------------- 1 | 84ce0ce7f048a80755105f001352e14e 2 | -------------------------------------------------------------------------------- /third_party/jackson/jackson-core-2.14.1.jar.md5: -------------------------------------------------------------------------------- 1 | f9604a5f31129cdb7db4bdec90111850 -------------------------------------------------------------------------------- /third_party/jackson/jackson-core-2.9.10.jar.md5: -------------------------------------------------------------------------------- 1 | d62d9b1d1d83dd553e678bc8fce8f809 -------------------------------------------------------------------------------- /third_party/jackson/jackson-core-2.9.5.jar.md5: -------------------------------------------------------------------------------- 1 | ec59f24f7f8d9acf53301c562722adf2 2 | -------------------------------------------------------------------------------- /third_party/jackson/jackson-databind-2.9.10.jar.md5: -------------------------------------------------------------------------------- 1 | ff43d79c624b0f7d465542fee6648474 -------------------------------------------------------------------------------- /third_party/javassist/javassist-3.21.0-GA.jar.md5: -------------------------------------------------------------------------------- 1 | 3dba2305f842c2891df0a0926e18bcfa -------------------------------------------------------------------------------- /third_party/jexl/commons-jexl-2.1.1.jar.md5: -------------------------------------------------------------------------------- 1 | 4ad8f5c161dd3a50e190334555675db9 2 | -------------------------------------------------------------------------------- /third_party/jexl/commons-logging-1.1.1.jar.md5: -------------------------------------------------------------------------------- 1 | ed448347fc0104034aa14c8189bf37de 2 | -------------------------------------------------------------------------------- /third_party/jgrapht/jgrapht-core-0.9.1.jar.md5: -------------------------------------------------------------------------------- 1 | 86e15da146c96430aef3e1de36df52c8 2 | -------------------------------------------------------------------------------- /third_party/kryo/reflectasm-1.10.0-shaded.jar.md5: -------------------------------------------------------------------------------- 1 | 779472dd799c5e9b1469e14b13c73061 -------------------------------------------------------------------------------- /third_party/logback/logback-classic-1.2.9.jar.md5: -------------------------------------------------------------------------------- 1 | de212f6deebb4cf8b5c91853602db5ec -------------------------------------------------------------------------------- /third_party/logback/logback-classic-1.3.4.jar.md5: -------------------------------------------------------------------------------- 1 | 0b98f1f2ad1caa97556b979598038d3d -------------------------------------------------------------------------------- /third_party/mockito/mockito-core-1.9.0.jar.md5: -------------------------------------------------------------------------------- 1 | cab21b44958a173a5b1d55a6aff0ab54 2 | -------------------------------------------------------------------------------- /third_party/mockito/mockito-core-1.9.5.jar.md5: -------------------------------------------------------------------------------- 1 | 6f73cf04a56eb60aaa996506e7c10fc7 2 | -------------------------------------------------------------------------------- /third_party/netty/netty-3.10.6.Final.jar.md5: -------------------------------------------------------------------------------- 1 | e9cdf01138257f48d796fb2cf67af53e 2 | -------------------------------------------------------------------------------- /third_party/netty/netty-3.9.4.Final.jar.md5: -------------------------------------------------------------------------------- 1 | b3701ef46c7518d0d63705e2f092dbe5 2 | -------------------------------------------------------------------------------- /third_party/objenesis/objenesis-1.3.jar.md5: -------------------------------------------------------------------------------- 1 | 2d649907bd6203f2661f70d430a6ade8 2 | -------------------------------------------------------------------------------- /third_party/objenesis/objenesis-2.1.jar.md5: -------------------------------------------------------------------------------- 1 | 32ccb1d20a42b5aaaceb90c9082a2efa 2 | -------------------------------------------------------------------------------- /third_party/slf4j/log4j-over-slf4j-2.0.6.jar.md5: -------------------------------------------------------------------------------- 1 | a5ccd131feef393a926dcdfc80436d08 -------------------------------------------------------------------------------- /third_party/zookeeper/zookeeper-3.3.4.jar.md5: -------------------------------------------------------------------------------- 1 | f922a4d30df717ca3fcab8198c53d659 2 | -------------------------------------------------------------------------------- /third_party/zookeeper/zookeeper-3.3.6.jar.md5: -------------------------------------------------------------------------------- 1 | a4425412297adf88c157a263d61e2cf1 2 | -------------------------------------------------------------------------------- /third_party/zookeeper/zookeeper-3.4.5.jar.md5: -------------------------------------------------------------------------------- 1 | 00b9db19ad7f18681761edc6db524ceb 2 | -------------------------------------------------------------------------------- /third_party/gwt/opentsdb-gwt-theme-1.0.0.jar.md5: -------------------------------------------------------------------------------- 1 | 458540cf39138f1ad566c2eabf930699 2 | -------------------------------------------------------------------------------- /third_party/jackson/jackson-annotations-2.9.10.jar.md5: -------------------------------------------------------------------------------- 1 | 26c2b6f7bc704ccadc64c83995e0ff7f -------------------------------------------------------------------------------- /third_party/jackson/jackson-databind-2.14.1.jar.md5: -------------------------------------------------------------------------------- 1 | 3e3e7aab8799ccc169b10f244e6fb5b4 2 | -------------------------------------------------------------------------------- /third_party/jackson/jackson-databind-2.9.5.jar.md5: -------------------------------------------------------------------------------- 1 | 34b37affbf74f5d199be10622ddc83cd 2 | -------------------------------------------------------------------------------- /third_party/javassist/javassist-3.17.1-GA.jar.md5: -------------------------------------------------------------------------------- 1 | d6a8586b96f0a0fb5f6100371759fa17 2 | -------------------------------------------------------------------------------- /third_party/javassist/javassist-3.18.1-GA.jar.md5: -------------------------------------------------------------------------------- 1 | 5bb83868c87334320562af7eded65cc2 2 | -------------------------------------------------------------------------------- /third_party/kryo/reflectasm-1.07-shaded.jar.md5: -------------------------------------------------------------------------------- 1 | 2042c222840fb21e3d13cef7c3965831 2 | -------------------------------------------------------------------------------- /third_party/powermock/powermock-mockito-1.5.jar.md5: -------------------------------------------------------------------------------- 1 | da9e7012d0e13f90c71829f2ac7d5462 2 | -------------------------------------------------------------------------------- /third_party/protobuf/protobuf-java-2.5.0.jar.md5: -------------------------------------------------------------------------------- 1 | a44473b98947e2a54c54e0db1387d137 2 | -------------------------------------------------------------------------------- /third_party/slf4j/log4j-over-slf4j-1.7.7.jar.md5: -------------------------------------------------------------------------------- 1 | 93ab42a5216afd683c35988c6b6fc3d8 2 | -------------------------------------------------------------------------------- /test/META-INF/services/net.opentsdb.search.SearchPlugin: -------------------------------------------------------------------------------- 1 | net.opentsdb.search.DummySearchPlugin -------------------------------------------------------------------------------- /test/META-INF/services/net.opentsdb.tsd.HttpRpcPlugin: -------------------------------------------------------------------------------- 1 | net.opentsdb.tsd.DummyHttpRpcPlugin 2 | -------------------------------------------------------------------------------- /test/META-INF/services/net.opentsdb.tsd.RTPublisher: -------------------------------------------------------------------------------- 1 | net.opentsdb.tsd.DummyRTPublisher 2 | -------------------------------------------------------------------------------- /third_party/hbase/asynchbase-1.8.0-20161103.193100-4.jar.md5: -------------------------------------------------------------------------------- 1 | f4cd05231ee2604e59f65667e4cc7634 -------------------------------------------------------------------------------- /third_party/jackson/jackson-annotations-2.14.1.jar.md5: -------------------------------------------------------------------------------- 1 | da4742ba6aeb24bf1bd29382fd95647b 2 | -------------------------------------------------------------------------------- /third_party/jackson/jackson-annotations-2.9.5.jar.md5: -------------------------------------------------------------------------------- 1 | 93ff99082f89beba3dd7b594a478df10 2 | -------------------------------------------------------------------------------- /src/mygnuplot.bat: -------------------------------------------------------------------------------- 1 | set -e 2 | stdout=$1 3 | shift 4 | stderr=$1 5 | shift 6 | gnuplot %1 2>&1 7 | -------------------------------------------------------------------------------- /test/META-INF/services/net.opentsdb.tsd.HttpSerializer: -------------------------------------------------------------------------------- 1 | net.opentsdb.tsd.DummyHttpSerializer 2 | -------------------------------------------------------------------------------- /third_party/validation-api/validation-api-1.0.0.GA.jar.md5: -------------------------------------------------------------------------------- 1 | 40c1ee909493066397a6d4d9f8d375d8 2 | -------------------------------------------------------------------------------- /src/META-INF/services/net.opentsdb.uid.UniqueIdFilterPlugin: -------------------------------------------------------------------------------- 1 | net.opentsdb.uid.UniqueIdWhitelistFilter -------------------------------------------------------------------------------- /test/META-INF/services/net.opentsdb.tsd.StorageExceptionHandler: -------------------------------------------------------------------------------- 1 | net.opentsdb.tsd.DummySEHPlugin 2 | -------------------------------------------------------------------------------- /third_party/validation-api/validation-api-1.0.0.GA-sources.jar.md5: -------------------------------------------------------------------------------- 1 | f816682933b59c5ffe32bdb4ab4bf628 2 | -------------------------------------------------------------------------------- /src/tsd/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenTSDB/opentsdb/HEAD/src/tsd/static/favicon.ico -------------------------------------------------------------------------------- /third_party/asyncbigtable/asyncbigtable-0.4.3-jar-with-dependencies.jar.md5: -------------------------------------------------------------------------------- 1 | 0e8c09c99998241ce539f8a500692d50 -------------------------------------------------------------------------------- /third_party/powermock/powermock-mockito-release-full-1.5.4-full.jar.md5: -------------------------------------------------------------------------------- 1 | 5dee1dce6952bb7338d4d053157ae647 2 | -------------------------------------------------------------------------------- /src/tsd/static/opentsdb_header.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenTSDB/opentsdb/HEAD/src/tsd/static/opentsdb_header.jpg -------------------------------------------------------------------------------- /test/META-INF/services/net.opentsdb.plugin.DummyPlugin: -------------------------------------------------------------------------------- 1 | net.opentsdb.plugin.DummyPluginA 2 | net.opentsdb.plugin.DummyPluginB -------------------------------------------------------------------------------- /third_party/asyncbigtable/asyncbigtable-0.3.1-20170903.031804-2-jar-with-dependencies.jar.md5: -------------------------------------------------------------------------------- 1 | 0c3d205142ae73fd2b72614fa4d7fde0 -------------------------------------------------------------------------------- /third_party/asynccassandra/asynccassandra-0.0.1-20151104.191228-3-jar-with-dependencies.jar.md5: -------------------------------------------------------------------------------- 1 | 0dd29195cdb9ca4467d0fc32bfffb98c -------------------------------------------------------------------------------- /third_party/asynccassandra/asynccassandra-0.0.1-20160229.001338-4-jar-with-dependencies.jar.md5: -------------------------------------------------------------------------------- 1 | cb857f54223905d744fafa475d82623f -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;;; Directory Local Variables 2 | ;;; See Info node `(emacs) Directory Variables' for more information. 3 | 4 | ((java-mode 5 | (c-basic-offset . 2) 6 | (indent-tabs-mode . nil))) 7 | )) 8 | -------------------------------------------------------------------------------- /src/mygnuplot.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Because !@#$%^ Java can't fucking do this without a bazillion lines of codes. 3 | set -e 4 | stdout=$1 5 | shift 6 | stderr=$1 7 | shift 8 | exec nice gnuplot "$@" >"$stdout" 2>"$stderr" 9 | -------------------------------------------------------------------------------- /tools/clean_cache.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | CACHE_DIR=/tmp/tsd 4 | 5 | diskSpaceIsShort() { 6 | df -h "$CACHE_DIR" \ 7 | | awk 'NR==2{pct=$5; sub(/%/, "", pct); if (pct < 90) exit 1; exit 0;}' 8 | } 9 | 10 | if diskSpaceIsShort; then 11 | ( cd ${CACHE_DIR} && find . -type f -exec rm {} \; ) 12 | fi 13 | -------------------------------------------------------------------------------- /screwdriver.yaml: -------------------------------------------------------------------------------- 1 | shared: 2 | image: maven 3 | 4 | jobs: 5 | pr: 6 | steps: 7 | - run_arbitrary_script: apt-get update && apt-get install autoconf make python -y && ./build.sh pom.xml && mvn clean test --quiet 8 | main: 9 | steps: 10 | - run_arbitrary_script: apt-get update && apt-get install autoconf make python -y && ./build.sh pom.xml && mvn clean test --quiet 11 | -------------------------------------------------------------------------------- /src/tsd/QueryUi.gwt.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /tools/docker/docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | BUILDROOT=./build; 3 | TOOLS=./tools 4 | DOCKER=$BUILDROOT/docker; 5 | rm -r $DOCKER; 6 | mkdir -p $DOCKER; 7 | SOURCE_PATH=$BUILDROOT; 8 | DEST_PATH=$DOCKER/libs; 9 | mkdir -p $DEST_PATH; 10 | cp ${TOOLS}/docker/Dockerfile ${DOCKER}; 11 | cp ${BUILDROOT}/../src/opentsdb.conf ${DOCKER}; 12 | cp ${BUILDROOT}/../src/logback.xml ${DOCKER}; 13 | #cp ${BUILDROOT}/../src/mygnuplot.sh ${DOCKER}; 14 | cp ${SOURCE_PATH}/tsdb-2.3.0-RC1.jar ${DOCKER}; 15 | cp ${SOURCE_PATH}/third_party/*/*.jar ${DEST_PATH}; 16 | docker build -t opentsdb/opentsdb $DOCKER 17 | -------------------------------------------------------------------------------- /src/normalize/NormalizePlugin.java: -------------------------------------------------------------------------------- 1 | package net.opentsdb.normalize; 2 | 3 | import com.stumbleupon.async.Deferred; 4 | import net.opentsdb.core.TSDB; 5 | import net.opentsdb.stats.StatsCollector; 6 | 7 | import java.util.Map; 8 | 9 | public abstract class NormalizePlugin { 10 | 11 | public abstract void initialize(final TSDB tsdb); 12 | 13 | public abstract Deferred shutdown(); 14 | 15 | public abstract String version(); 16 | 17 | public abstract void collectStats(final StatsCollector collector); 18 | 19 | public abstract Map normalizeTags(Map tags); 20 | 21 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | INSTALL 2 | Makefile 3 | Makefile.in 4 | aclocal.m4 5 | autom4te.cache 6 | build 7 | target 8 | config.log 9 | config.status 10 | configure 11 | pom.xml 12 | *.pyc 13 | .*.swp 14 | *.rrd 15 | *.class 16 | */target/* 17 | *.orig 18 | *.log 19 | 20 | #for Intellij 21 | \.idea 22 | *.iml 23 | 24 | #for guava rpm maker 25 | guava-rpm-maker/\.project 26 | 27 | # for mac finder 28 | .DS_Store 29 | 30 | # for eclipse 31 | .pydevproject 32 | .metadata 33 | .project 34 | .classpath 35 | .settings 36 | 37 | # maven 38 | src-main 39 | src-test 40 | plugin_test.jar 41 | bin/ 42 | 43 | #Docker 44 | tools/docker/libs 45 | tools/docker/*.jar 46 | tools/docker/logback.xml 47 | tools/docker/opentsdb.conf 48 | 49 | # FatJar 50 | fat-jar-pom.xml 51 | src-resources/ 52 | test-resources/ 53 | third_party/*/*.jar 54 | -------------------------------------------------------------------------------- /bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (C) 2011-2012 The OpenTSDB Authors. 3 | # 4 | # This library is free software: you can redistribute it and/or modify it 5 | # under the terms of the GNU Lesser General Public License as published 6 | # by the Free Software Foundation, either version 2.1 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This library is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU Lesser General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU Lesser General Public License 15 | # along with this library. If not, see . 16 | 17 | exec autoreconf -fvi 18 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | The OpenTSDB Authors 2 | -------------------- 3 | 4 | OpenTSDB was originally written by Benoit Sigoure. 5 | 6 | The following organizations and people have made significant code 7 | contributions to OpenTSDB. Note that all contributors are required 8 | to sign a standard Contribution License Agreement to ensure that the 9 | code remains free & open-source. 10 | (Please keep both lists sorted alphabetically.) 11 | 12 | 13 | Arista Networks, Inc. 14 | Betfair Group plc 15 | Box, Inc. 16 | Bump Technologies, Inc. 17 | Limelight Networks, Inc. 18 | StumbleUpon, Inc. 19 | Yahoo, Inc. 20 | 21 | 22 | Benoit Sigoure 23 | Chris Larsen 24 | David Bainbridge 25 | Geoffrey Anderson 26 | Ion Savin 27 | Jonathan Creasy 28 | Nicholas Whitehead 29 | Will Moss 30 | -------------------------------------------------------------------------------- /tools/opentsdb_restart.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Restart opentsdb. Called using -XX:OnOutOfMemoryError= 3 | 4 | Because it's calling the 'systemctl *action* opentsdb' command, should be run as root. 5 | 6 | This is known to work with python2.6 and above. 7 | """ 8 | import os 9 | import subprocess 10 | 11 | service_name = "opentsdb" 12 | if 'NAME' in os.environ: 13 | service_name = os.environ['NAME'] 14 | 15 | subprocess.call(["systemctl", "stop", service_name]) 16 | # Close any file handles we inherited from our parent JVM. We need 17 | # to do this before restarting so that the socket isn't held open. 18 | openfiles = [int(f) for f in os.listdir("/proc/self/fd")] 19 | # Don't need to close stdout/stderr/stdin, leave them open so 20 | # that there is less chance of errors with those standard streams. 21 | # Other files start at fd 3. 22 | os.closerange(3, max(openfiles)) 23 | subprocess.call(["systemctl", "start", service_name]) 24 | -------------------------------------------------------------------------------- /src/tsd/client/GotJsonCallback.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package tsd.client; 14 | 15 | import com.google.gwt.json.client.JSONValue; 16 | 17 | interface GotJsonCallback { 18 | 19 | void got(JSONValue json); 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/core/HistogramAggregation.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | /** 16 | * Aggregator functions for histogram data points. 17 | * 18 | * @since 2.4 19 | */ 20 | public enum HistogramAggregation { 21 | SUM; 22 | } 23 | -------------------------------------------------------------------------------- /fat-jar/create-src-dir-overlay.sh: -------------------------------------------------------------------------------- 1 | # Creates directory structure overlay on top of original source directories so 2 | # that the overlay matches Java package hierarchy. 3 | #!/usr/bin/env bash 4 | 5 | if [ ! -d src-main ]; then 6 | mkdir src-main 7 | mkdir src-main/net 8 | mkdir src-main/tsd 9 | (cd src-main/net && ln -s ../../src opentsdb) 10 | (cd src-main/tsd && ln -s ../../src/tsd/QueryUi.gwt.xml QueryUi.gwt.xml) 11 | (cd src-main/tsd && ln -s ../../src/tsd/client client) 12 | fi 13 | if [ ! -d src-test ]; then 14 | mkdir src-test 15 | mkdir src-test/net 16 | (cd src-test/net && ln -s ../../test opentsdb) 17 | fi 18 | if [ ! -d src-resources ]; then 19 | mkdir src-resources 20 | (cd src-resources && ln -s ../fat-jar/logback.xml) 21 | (cd src-resources && ln -s ../fat-jar/file-logback.xml) 22 | (cd src-resources && ln -s ../fat-jar/opentsdb.conf.json) 23 | fi 24 | if [ ! -d test-resources ]; then 25 | mkdir test-resources 26 | (cd test-resources && ln -s ../fat-jar/test-logback.xml) 27 | (cd test-resources && ln -s ../fat-jar/opentsdb.conf.json) 28 | fi 29 | 30 | -------------------------------------------------------------------------------- /third_party/junit/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | JUNIT_VERSION := 4.11 17 | JUNIT := third_party/junit/junit-$(JUNIT_VERSION).jar 18 | JUNIT_BASE_URL := https://repo1.maven.org/maven2/junit/junit/$(JUNIT_VERSION) 19 | 20 | $(JUNIT): $(JUNIT).md5 21 | set dummy "$(JUNIT_BASE_URL)" "$(JUNIT)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(JUNIT) 24 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ___ _____ ____ ____ ____ 2 | / _ \ _ __ ___ _ _|_ _/ ___|| _ \| __ ) 3 | | | | | '_ \ / _ \ '_ \| | \___ \| | | | _ \ 4 | | |_| | |_) | __/ | | | | ___) | |_| | |_) | 5 | \___/| .__/ \___|_| |_|_| |____/|____/|____/ 6 | |_| The modern time series database. 7 | 8 | OpenTSDB is a distributed, scalable Time Series Database (TSDB) written on 9 | top of HBase. OpenTSDB was written to address a common need: store, index 10 | and serve metrics collected from computer systems (network gear, operating 11 | systems, applications) at a large scale, and make this data easily accessible 12 | and graphable. 13 | 14 | Thanks to HBase's scalability, OpenTSDB allows you to collect thousands of 15 | metrics from tens of thousands of hosts and applications, at a high rate 16 | (every few seconds). OpenTSDB will never delete or downsample data and can 17 | easily store hundreds of billions of data points. 18 | 19 | OpenTSDB is free software and is available under both LGPLv2.1+ and GPLv3+. 20 | Find more about OpenTSDB at http://opentsdb.net 21 | -------------------------------------------------------------------------------- /third_party/javacc/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | JAVACC_VERSION := 6.1.2 17 | JAVACC := third_party/javacc/javacc-$(JAVACC_VERSION).jar 18 | JAVACC_BASE_URL := https://repo1.maven.org/maven2/net/java/dev/javacc/javacc/$(JAVACC_VERSION) 19 | 20 | $(JAVACC): $(JAVACC).md5 21 | set dummy "$(JAVACC_BASE_URL)" "$(JAVACC)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(JAVACC) 24 | -------------------------------------------------------------------------------- /third_party/suasync/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | SUASYNC_VERSION := 1.4.0 17 | SUASYNC := third_party/suasync/async-$(SUASYNC_VERSION).jar 18 | SUASYNC_BASE_URL := https://repo1.maven.org/maven2/com/stumbleupon/async/$(SUASYNC_VERSION) 19 | 20 | $(SUASYNC): $(SUASYNC).md5 21 | set dummy "$(SUASYNC_BASE_URL)" "$(SUASYNC)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(SUASYNC) 24 | -------------------------------------------------------------------------------- /third_party/jgrapht/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | JGRAPHT_VERSION := 0.9.1 17 | JGRAPHT := third_party/jgrapht/jgrapht-core-$(JGRAPHT_VERSION).jar 18 | JGRAPHT_BASE_URL := https://repo1.maven.org/maven2/org/jgrapht/jgrapht-core/$(JGRAPHT_VERSION) 19 | 20 | $(JGRAPHT): $(JGRAPHT).md5 21 | set dummy "$(JGRAPHT_BASE_URL)" "$(JGRAPHT)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(JGRAPHT) 24 | -------------------------------------------------------------------------------- /third_party/mockito/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | MOCKITO_VERSION := 1.9.5 17 | MOCKITO := third_party/mockito/mockito-core-$(MOCKITO_VERSION).jar 18 | MOCKITO_BASE_URL := https://repo1.maven.org/maven2/org/mockito/mockito-core/$(MOCKITO_VERSION) 19 | 20 | $(MOCKITO): $(MOCKITO).md5 21 | set dummy "$(MOCKITO_BASE_URL)" "$(MOCKITO)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(MOCKITO) 24 | -------------------------------------------------------------------------------- /src/core/HistogramAggregator.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | /** 16 | * Aggregator for histogram data points. 17 | * 18 | * @since 2.4 19 | */ 20 | public class HistogramAggregator { 21 | 22 | public interface Histograms { 23 | boolean hasNextValue(); 24 | 25 | HistogramDataPoint nextHistogramValue(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /third_party/hamcrest/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | HAMCREST_VERSION := 1.3 17 | HAMCREST := third_party/hamcrest/hamcrest-core-$(HAMCREST_VERSION).jar 18 | HAMCREST_BASE_URL := https://repo1.maven.org/maven2/org/hamcrest/hamcrest-core/$(HAMCREST_VERSION) 19 | 20 | $(HAMCREST): $(HAMCREST).md5 21 | set dummy "$(HAMCREST_BASE_URL)" "$(HAMCREST)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(HAMCREST) 24 | -------------------------------------------------------------------------------- /third_party/objenesis/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2013 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | OBJENESIS_VERSION := 1.3 17 | OBJENESIS := third_party/objenesis/objenesis-$(OBJENESIS_VERSION).jar 18 | OBJENESIS_BASE_URL := https://repo1.maven.org/maven2/org/objenesis/objenesis/$(OBJENESIS_VERSION) 19 | 20 | $(OBJENESIS): $(OBJENESIS).md5 21 | set dummy "$(OBJENESIS_BASE_URL)" "$(OBJENESIS)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(OBJENESIS) 24 | -------------------------------------------------------------------------------- /third_party/protobuf/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2014 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | PROTOBUF_VERSION := 2.5.0 17 | PROTOBUF := third_party/protobuf/protobuf-java-$(PROTOBUF_VERSION).jar 18 | PROTOBUF_BASE_URL := https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/$(PROTOBUF_VERSION) 19 | 20 | $(PROTOBUF): $(PROTOBUF).md5 21 | set dummy "$(PROTOBUF_BASE_URL)" "$(PROTOBUF)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(PROTOBUF) 24 | -------------------------------------------------------------------------------- /third_party/zookeeper/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | ZOOKEEPER_VERSION := 3.4.6 17 | ZOOKEEPER := third_party/zookeeper/zookeeper-$(ZOOKEEPER_VERSION).jar 18 | ZOOKEEPER_BASE_URL := https://repo1.maven.org/maven2/org/apache/zookeeper/zookeeper/$(ZOOKEEPER_VERSION) 19 | 20 | $(ZOOKEEPER): $(ZOOKEEPER).md5 21 | set dummy "$(ZOOKEEPER_BASE_URL)" "$(ZOOKEEPER)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(ZOOKEEPER) 24 | -------------------------------------------------------------------------------- /test/plugin/DummyPlugin.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2013-2014 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.plugin; 14 | 15 | import org.junit.Ignore; 16 | 17 | // need to ignore this class so JUnit doesn't try to run tests on it 18 | @Ignore 19 | public abstract class DummyPlugin { 20 | public String myname; 21 | 22 | public DummyPlugin() { 23 | myname = ""; 24 | } 25 | 26 | public abstract String mustImplement(); 27 | } 28 | -------------------------------------------------------------------------------- /test/core/TestTsdbQueryAppend.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.junit.Before; 16 | import org.powermock.reflect.Whitebox; 17 | 18 | public class TestTsdbQueryAppend extends TestTsdbQueryQueries { 19 | 20 | @Before 21 | public void beforeLocal() { 22 | Whitebox.setInternalState(config, "enable_appends", true); 23 | query = new TsdbQuery(tsdb); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /third_party/hbase/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2017 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | ASYNCHBASE_VERSION := 1.8.2 17 | ASYNCHBASE := third_party/hbase/asynchbase-$(ASYNCHBASE_VERSION).jar 18 | ASYNCHBASE_BASE_URL := https://repo1.maven.org/maven2/org/hbase/asynchbase/$(ASYNCHBASE_VERSION) 19 | 20 | $(ASYNCHBASE): $(ASYNCHBASE).md5 21 | set dummy "$(ASYNCHBASE_BASE_URL)" "$(ASYNCHBASE)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(ASYNCHBASE) 24 | -------------------------------------------------------------------------------- /test/plugin/DummyPluginA.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2013-2014 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.plugin; 14 | 15 | import org.junit.Ignore; 16 | 17 | // need to ignore this class so JUnit doesn't try to run tests on it 18 | @Ignore 19 | public class DummyPluginA extends DummyPlugin { 20 | 21 | public DummyPluginA() { 22 | this.myname = "Dummy Plugin A"; 23 | } 24 | 25 | public String mustImplement() { 26 | return this.myname; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /test/plugin/DummyPluginB.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2013-2014 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.plugin; 14 | 15 | import org.junit.Ignore; 16 | 17 | // need to ignore this class so JUnit doesn't try to run tests on it 18 | @Ignore 19 | public class DummyPluginB extends DummyPlugin { 20 | 21 | public DummyPluginB() { 22 | this.myname = "Dummy Plugin B"; 23 | } 24 | 25 | public String mustImplement() { 26 | return this.myname; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /third_party/asyncbigtable/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015-2021 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | ASYNCBIGTABLE_VERSION := 0.4.3 17 | ASYNCBIGTABLE := third_party/asyncbigtable/asyncbigtable-$(ASYNCBIGTABLE_VERSION)-jar-with-dependencies.jar 18 | ASYNCBIGTABLE_BASE_URL := https://repo1.maven.org/maven2/com/pythian/opentsdb/asyncbigtable/$(ASYNCBIGTABLE_VERSION) 19 | 20 | $(ASYNCBIGTABLE): $(ASYNCBIGTABLE).md5 21 | set dummy "$(ASYNCBIGTABLE_BASE_URL)" "$(ASYNCBIGTABLE)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(ASYNCBIGTABLE) 24 | -------------------------------------------------------------------------------- /src/tsd/HttpRpc.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import java.io.IOException; 16 | 17 | import net.opentsdb.core.TSDB; 18 | 19 | /** 20 | * Base interface for all built-in HTTP query handlers. 21 | */ 22 | interface HttpRpc { 23 | 24 | /** 25 | * Executes this RPC. 26 | * @param tsdb The TSDB to use. 27 | * @param query The HTTP query to execute. 28 | */ 29 | void execute(TSDB tsdb, HttpQuery query) throws BadRequestException, IOException; 30 | 31 | } 32 | -------------------------------------------------------------------------------- /third_party/asynccassandra/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | ASYNCCASSANDRA_VERSION := 0.0.1-20160229.001338-4 17 | ASYNCCASSANDRA := third_party/asynccassandra/asynccassandra-$(ASYNCCASSANDRA_VERSION)-jar-with-dependencies.jar 18 | ASYNCCASSANDRA_BASE_URL := https://oss.sonatype.org/content/repositories/snapshots/net/opentsdb/asynccassandra/0.0.1-SNAPSHOT/ 19 | 20 | $(ASYNCCASSANDRA): $(ASYNCCASSANDRA).md5 21 | set dummy "$(ASYNCCASSANDRA_BASE_URL)" "$(ASYNCCASSANDRA)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(ASYNCCASSANDRA) 24 | -------------------------------------------------------------------------------- /src/auth/Permissions.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | 14 | package net.opentsdb.auth; 15 | 16 | /** 17 | * The Permissions used within the OpenTSDB Code. 18 | * Any authorization plugins need to be able to respond to inquiries on these permissions. Plugins and other 19 | * third-party code may implement additional permissions. 20 | * 21 | * @author jonathan.creasy 22 | * @since 2.4.0 23 | * 24 | */ 25 | public enum Permissions { 26 | TELNET_PUT, HTTP_PUT, HTTP_QUERY, 27 | CREATE_TAGK,CREATE_TAGV, CREATE_METRIC; 28 | } 29 | -------------------------------------------------------------------------------- /src/tsd/GnuplotException.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | /** 16 | * Exception thrown when Gnuplot fails. 17 | */ 18 | final class GnuplotException extends RuntimeException { 19 | 20 | public GnuplotException(final int gnuplot_return_value) { 21 | super("Gnuplot returned " + gnuplot_return_value); 22 | } 23 | 24 | public GnuplotException(final String gnuplot_stderr) { 25 | super("Gnuplot stderr:\n" + gnuplot_stderr); 26 | } 27 | 28 | static final long serialVersionUID = 1287770642; 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/core/GroupCallback.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import com.stumbleupon.async.Callback; 16 | 17 | import java.util.ArrayList; 18 | 19 | class GroupCallback implements Callback> { 20 | /** 21 | * We're only waiting for all callbacks to complete, ignoring their return values. 22 | * 23 | * @param ignored The return values of the individual callbacks - ignored 24 | * @return null 25 | */ 26 | @Override 27 | public Object call(ArrayList ignored) { 28 | return null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /test/core/TestTsdbQueryHistogramQueriesSalted.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | 14 | package net.opentsdb.core; 15 | 16 | import org.junit.Before; 17 | import org.powermock.api.mockito.PowerMockito; 18 | 19 | public class TestTsdbQueryHistogramQueriesSalted extends TestTsdbQueryHistogramQueries { 20 | 21 | @Before 22 | public void beforeLocal() throws Exception { 23 | PowerMockito.mockStatic(Const.class); 24 | PowerMockito.when(Const.SALT_WIDTH()).thenReturn(1); 25 | PowerMockito.when(Const.SALT_BUCKETS()).thenReturn(2); 26 | PowerMockito.when(Const.MAX_NUM_TAGS()).thenReturn((short) 8); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /src/tsd/TelnetRpc.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import com.stumbleupon.async.Deferred; 16 | 17 | import org.jboss.netty.channel.Channel; 18 | 19 | import net.opentsdb.core.TSDB; 20 | 21 | /** Base interface for all telnet-style RPC handlers. */ 22 | interface TelnetRpc { 23 | 24 | /** 25 | * Executes this RPC. 26 | * @param tsdb The TSDB to use. 27 | * @param chan The channel on which the RPC was received. 28 | * @param command The command received, split. 29 | * @return A deferred result. 30 | */ 31 | Deferred execute(TSDB tsdb, Channel chan, String[] command); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/tools/ArgValueValidator.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2016 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tools; 14 | 15 | import net.opentsdb.tools.ConfigArgP.ConfigurationItem; 16 | 17 | /** 18 | *

Title: ArgValueValidator

19 | *

Description: Defines a class that can validate a value instance of a declared ConfigMetaType

20 | */ 21 | public interface ArgValueValidator { 22 | /** 23 | * Validates the passed configuration item 24 | * @param citem The item to validate 25 | */ 26 | public void validate(ConfigurationItem citem); 27 | 28 | /** A static exception that needs no stack trace or whatever */ 29 | public static final Exception EX = new Exception(); 30 | } 31 | -------------------------------------------------------------------------------- /src/upgrade_1to2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Small script to setup the HBase tables used by OpenTSDB. 3 | 4 | test -n "$HBASE_HOME" || { 5 | echo >&2 'The environment variable HBASE_HOME must be set' 6 | exit 1 7 | } 8 | test -d "$HBASE_HOME" || { 9 | echo >&2 "No such directory: HBASE_HOME=$HBASE_HOME" 10 | exit 1 11 | } 12 | 13 | TREE_TABLE=${TREE_TABLE-'tsdb-tree'} 14 | META_TABLE=${META_TABLE-'tsdb-meta'} 15 | BLOOMFILTER=${BLOOMFILTER-'ROW'} 16 | # LZO requires lzo2 64bit to be installed + the hadoop-gpl-compression jar. 17 | COMPRESSION=${COMPRESSION-'LZO'} 18 | # All compression codec names are upper case (NONE, LZO, SNAPPY, etc). 19 | COMPRESSION=`echo "$COMPRESSION" | tr a-z A-Z` 20 | 21 | case $COMPRESSION in 22 | (NONE|LZO|GZIP|SNAPPY) :;; # Known good. 23 | (*) 24 | echo >&2 "warning: compression codec '$COMPRESSION' might not be supported." 25 | ;; 26 | esac 27 | 28 | # HBase scripts also use a variable named `HBASE_HOME', and having this 29 | # variable in the environment with a value somewhat different from what 30 | # they expect can confuse them in some cases. So rename the variable. 31 | hbh=$HBASE_HOME 32 | unset HBASE_HOME 33 | exec "$hbh/bin/hbase" shell < 't', VERSIONS => 1, COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'} 36 | 37 | create '$META_TABLE', 38 | {NAME => 'name', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER'} 39 | EOF 40 | -------------------------------------------------------------------------------- /test/core/LongHistogramDataPointForTestDecoder.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2023 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.junit.Ignore; 16 | 17 | @Ignore 18 | public class LongHistogramDataPointForTestDecoder extends HistogramDataPointCodec { 19 | 20 | @Override 21 | public Histogram decode(byte[] raw_data, final boolean includes_id) { 22 | final LongHistogramDataPointForTest dp = new LongHistogramDataPointForTest(id); 23 | dp.fromHistogram(raw_data, includes_id); 24 | return dp; 25 | } 26 | 27 | 28 | @Override 29 | public byte[] encode(Histogram data_point, final boolean include_id) { 30 | // TODO Auto-generated method stub 31 | return null; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /test/uid/TestNoSuchUniqueId.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.uid; 14 | 15 | import junit.framework.TestCase; 16 | 17 | public final class TestNoSuchUniqueId extends TestCase { 18 | 19 | public void testMessage() { 20 | final byte[] id = { 0, 'A', 'a' }; 21 | final NoSuchUniqueId e = new NoSuchUniqueId("Foo", id); 22 | assertEquals("No such unique ID for 'Foo': [0, 65, 97]", e.getMessage()); 23 | } 24 | 25 | public void testFields() { 26 | final String kind = "bar"; 27 | final byte[] id = { 42, '!' }; 28 | final NoSuchUniqueId e = new NoSuchUniqueId(kind, id); 29 | assertEquals(kind, e.kind()); 30 | assertEquals(id, e.id()); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /test/core/TestTsdbQuerySaltedAppend.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.junit.Before; 16 | import org.powermock.api.mockito.PowerMockito; 17 | import org.powermock.reflect.Whitebox; 18 | 19 | public class TestTsdbQuerySaltedAppend extends TestTsdbQueryQueries { 20 | 21 | @Before 22 | public void beforeLocal() { 23 | Whitebox.setInternalState(config, "enable_appends", true); 24 | PowerMockito.mockStatic(Const.class); 25 | PowerMockito.when(Const.SALT_WIDTH()).thenReturn(1); 26 | PowerMockito.when(Const.SALT_BUCKETS()).thenReturn(2); 27 | PowerMockito.when(Const.MAX_NUM_TAGS()).thenReturn((short) 8); 28 | query = new TsdbQuery(tsdb); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/core/Histogram.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import java.util.List; 16 | import java.util.Map; 17 | 18 | public interface Histogram { 19 | 20 | public byte[] histogram(final boolean include_id); 21 | 22 | public void fromHistogram(final byte[] raw, final boolean includes_id); 23 | 24 | public double percentile(final double p); 25 | 26 | public List percentiles(List p); 27 | 28 | public Map getHistogram(); 29 | 30 | public Histogram clone(); 31 | 32 | public int getId(); 33 | 34 | void aggregate(Histogram histo, HistogramAggregation func); 35 | 36 | void aggregate(List histos, HistogramAggregation func); 37 | } 38 | -------------------------------------------------------------------------------- /src/rollup/NoSuchRollupForTableException.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.rollup; 14 | 15 | import java.util.NoSuchElementException; 16 | 17 | /** 18 | * Exception thrown when a rollup couldn't be found in the table name to rollup 19 | * interval map 20 | * @since 2.4 21 | */ 22 | public class NoSuchRollupForTableException extends NoSuchElementException { 23 | 24 | /** 25 | * Ctor that builds the message based on a string table lookup 26 | * @param table The table name 27 | */ 28 | public NoSuchRollupForTableException(final String table) { 29 | super("No rollups configured for the table: " + table); 30 | } 31 | 32 | private static final long serialVersionUID = 6620255176637863260L; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/core/IllegalDataException.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2011-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | /** 16 | * Some illegal / malformed / corrupted data has been found in HBase. 17 | */ 18 | public final class IllegalDataException extends IllegalStateException { 19 | 20 | /** 21 | * Constructor. 22 | * 23 | * @param msg Message describing the problem. 24 | */ 25 | public IllegalDataException(final String msg) { 26 | super(msg); 27 | } 28 | 29 | /** 30 | * Constructor. 31 | * 32 | * @param msg Message describing the problem. 33 | */ 34 | public IllegalDataException(final String msg, final Throwable cause) { 35 | super(msg, cause); 36 | } 37 | 38 | static final long serialVersionUID = 1307719142; 39 | 40 | } 41 | -------------------------------------------------------------------------------- /test/query/filter/TestTagVNotKeyFilter.java: -------------------------------------------------------------------------------- 1 | package net.opentsdb.query.filter; 2 | 3 | import static org.junit.Assert.assertFalse; 4 | import static org.junit.Assert.assertNotNull; 5 | import static org.junit.Assert.assertTrue; 6 | 7 | import java.util.HashMap; 8 | import java.util.Map; 9 | 10 | import org.junit.Before; 11 | import org.junit.Test; 12 | 13 | public class TestTagVNotKeyFilter { 14 | private static final String TAGK = "host"; 15 | private static final String TAGK2 = "owner"; 16 | private Map tags; 17 | 18 | @Before 19 | public void before() throws Exception { 20 | tags = new HashMap(1); 21 | tags.put(TAGK, "ogg-01.ops.ankh.morpork.com"); 22 | tags.put(TAGK2, "Hrun"); 23 | } 24 | 25 | @Test 26 | public void matchHasKey() throws Exception { 27 | TagVFilter filter = new TagVNotKeyFilter(TAGK, ""); 28 | assertFalse(filter.match(tags).join()); 29 | } 30 | 31 | @Test 32 | public void matchDoesNotHaveKey() throws Exception { 33 | TagVFilter filter = new TagVNotKeyFilter("colo", ""); 34 | assertTrue(filter.match(tags).join()); 35 | } 36 | 37 | @Test 38 | public void ctorNullFilter() throws Exception { 39 | TagVFilter filter = new TagVNotKeyFilter(TAGK, null); 40 | assertTrue(filter.postScan()); 41 | } 42 | 43 | @Test (expected = IllegalArgumentException.class) 44 | public void ctorFilterHasValue() throws Exception { 45 | assertNotNull(new TagVNotKeyFilter(TAGK, "Evadne")); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/rollup/NoSuchRollupForIntervalException.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.rollup; 14 | 15 | import java.util.NoSuchElementException; 16 | 17 | /** 18 | * Exception thrown when a rollup couldn't be found in the interval to rollup 19 | * interval map 20 | * @since 2.4 21 | */ 22 | public class NoSuchRollupForIntervalException extends NoSuchElementException { 23 | 24 | /** 25 | * Ctor that builds the message based on a string interval lookup 26 | * @param interval The interval, e.g. "1m" 27 | */ 28 | public NoSuchRollupForIntervalException(final String interval) { 29 | super("No rollups configured for the interval: " + interval); 30 | } 31 | 32 | private static final long serialVersionUID = -8225702079229243161L; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /third_party/validation-api/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2014 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | VALIDATION_API_VERSION := 1.0.0.GA 17 | VALIDATION_API := third_party/validation-api/validation-api-$(VALIDATION_API_VERSION).jar 18 | VALIDATION_API_BASE_URL := https://repo1.maven.org/maven2/javax/validation/validation-api/$(VALIDATION_API_VERSION) 19 | 20 | $(VALIDATION_API): $(VALIDATION_API).md5 21 | set dummy "$(VALIDATION_API_BASE_URL)" "$(VALIDATION_API)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | 24 | VALIDATION_API_SOURCES := third_party/validation-api/validation-api-$(VALIDATION_API_VERSION)-sources.jar 25 | VALIDATION_API_SOURCES_BASE_URL := $(VALIDATION_API_BASE_URL) 26 | 27 | $(VALIDATION_API_SOURCES): $(VALIDATION_API_SOURCES).md5 28 | set dummy "$(VALIDATION_API_SOURCES_BASE_URL)" "$(VALIDATION_API_SOURCES)"; shift; $(FETCH_DEPENDENCY) 29 | 30 | THIRD_PARTY += $(VALIDATION_API) $(VALIDATION_API_SOURCES) 31 | -------------------------------------------------------------------------------- /third_party/jexl/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015-2023 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | JEXL_VERSION := 2.1.1 17 | JEXL := third_party/jexl/commons-jexl-$(JEXL_VERSION).jar 18 | JEXL_BASE_URL := https://repo1.maven.org/maven2/org/apache/commons/commons-jexl/$(JEXL_VERSION) 19 | 20 | $(JEXL): $(JEXL).md5 21 | set dummy "$(JEXL_BASE_URL)" "$(JEXL)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | THIRD_PARTY += $(JEXL) 24 | 25 | # In here as Jexl depends on it and no one else (for now, I hope) 26 | COMMONS_LOGGING_VERSION := 1.2 27 | COMMONS_LOGGING := third_party/jexl/commons-logging-$(COMMONS_LOGGING_VERSION).jar 28 | COMMONS_LOGGING_BASE_URL := https://repo1.maven.org/maven2/commons-logging/commons-logging/$(COMMONS_LOGGING_VERSION) 29 | 30 | $(COMMONS_LOGGING): $(COMMONS_LOGGING).md5 31 | set dummy "$(COMMONS_LOGGING_BASE_URL)" "$(COMMONS_LOGGING)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(COMMONS_LOGGING) 34 | -------------------------------------------------------------------------------- /tools/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM java:openjdk-8-alpine 2 | 3 | MAINTAINER jonathan.creasy@gmail.com 4 | 5 | ENV VERSION 2.3.0-RC1 6 | ENV WORKDIR /usr/share/opentsdb 7 | ENV LOGDIR /var/log/opentsdb 8 | ENV DATADIR /data/opentsdb 9 | ENV ETCDIR /etc/opentsdb 10 | 11 | RUN mkdir -p $WORKDIR/static 12 | RUN mkdir -p $WORKDIR/libs 13 | RUN mkdir -p $WORKDIR/third_party 14 | RUN mkdir -p $WORKDIR/resources 15 | RUN mkdir -p $DATADIR/cache 16 | RUN mkdir -p $LOGDIR 17 | RUN mkdir -p $ETCDIR 18 | 19 | ENV CONFIG $ETCDIR/opentsdb.conf 20 | ENV STATICROOT $WORKDIR/static 21 | ENV CACHEDIR $DATADIR/cache 22 | 23 | ENV CLASSPATH $WORKDIR:$WORKDIR/tsdb-$VERSION.jar:$WORKDIR/libs/*:$WORKDIR/logback.xml 24 | ENV CLASS net.opentsdb.tools.TSDMain 25 | 26 | # It is expected these might need to be passed in with the -e flag 27 | ENV JAVA_OPTS="-Xms512m -Xmx2048m" 28 | ENV ZKQUORUM zookeeper:2181 29 | ENV ZKBASEDIR /hbase 30 | ENV TSDB_OPTS "--read-only --disable-ui" 31 | ENV TSDB_PORT 4244 32 | 33 | WORKDIR $WORKDIR 34 | 35 | ADD libs $WORKDIR/libs 36 | ADD logback.xml $WORKDIR 37 | ADD tsdb-$VERSION.jar $WORKDIR 38 | ADD opentsdb.conf $ETCDIR/opentsdb.conf 39 | 40 | VOLUME ["/etc/openstsdb"] 41 | VOLUME ["/data/opentsdb"] 42 | 43 | ENTRYPOINT java -enableassertions -enablesystemassertions -classpath ${CLASSPATH} ${CLASS} --config=${CONFIG} --staticroot=${STATICROOT} --cachedir=${CACHEDIR} --port=${TSDB_PORT} --zkquorum=${ZKQUORUM} --zkbasedir=${ZKBASEDIR} ${TSDB_OPTS} 44 | -------------------------------------------------------------------------------- /third_party/slf4j/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2013 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | SLF4J_VERSION = 2.0.6 17 | 18 | 19 | LOG4J_OVER_SLF4J_VERSION := $(SLF4J_VERSION) 20 | LOG4J_OVER_SLF4J := third_party/slf4j/log4j-over-slf4j-$(LOG4J_OVER_SLF4J_VERSION).jar 21 | LOG4J_OVER_SLF4J_BASE_URL := https://repo1.maven.org/maven2/org/slf4j/log4j-over-slf4j/$(LOG4J_OVER_SLF4J_VERSION) 22 | 23 | $(LOG4J_OVER_SLF4J): $(LOG4J_OVER_SLF4J).md5 24 | set dummy "$(LOG4J_OVER_SLF4J_BASE_URL)" "$(LOG4J_OVER_SLF4J)"; shift; $(FETCH_DEPENDENCY) 25 | 26 | 27 | SLF4J_API_VERSION := $(SLF4J_VERSION) 28 | SLF4J_API := third_party/slf4j/slf4j-api-$(SLF4J_API_VERSION).jar 29 | SLF4J_API_BASE_URL := https://repo1.maven.org/maven2/org/slf4j/slf4j-api/$(SLF4J_API_VERSION) 30 | 31 | $(SLF4J_API): $(SLF4J_API).md5 32 | set dummy "$(SLF4J_API_BASE_URL)" "$(SLF4J_API)"; shift; $(FETCH_DEPENDENCY) 33 | 34 | THIRD_PARTY += $(LOG4J_OVER_SLF4J) $(SLF4J_API) 35 | -------------------------------------------------------------------------------- /test/core/TestTsdbQuerySalted.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.junit.Before; 16 | import org.junit.runner.RunWith; 17 | import org.powermock.api.mockito.PowerMockito; 18 | import org.powermock.modules.junit4.PowerMockRunner; 19 | 20 | /** 21 | * An integration test class that runs all of the tests in 22 | * {@see TestTsdbQueryAggregators} but with salting enabled. 23 | */ 24 | @RunWith(PowerMockRunner.class) 25 | public class TestTsdbQuerySalted extends TestTsdbQueryQueries { 26 | 27 | @Before 28 | public void beforeLocal() throws Exception { 29 | PowerMockito.mockStatic(Const.class); 30 | PowerMockito.when(Const.SALT_WIDTH()).thenReturn(1); 31 | PowerMockito.when(Const.SALT_BUCKETS()).thenReturn(2); 32 | PowerMockito.when(Const.MAX_NUM_TAGS()).thenReturn((short) 8); 33 | 34 | query = new TsdbQuery(tsdb); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /third_party/logback/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2015-2022 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | LOGBACK_VERSION := 1.3.4 16 | 17 | LOGBACK_CLASSIC_VERSION := $(LOGBACK_VERSION) 18 | LOGBACK_CLASSIC := third_party/logback/logback-classic-$(LOGBACK_CLASSIC_VERSION).jar 19 | LOGBACK_CLASSIC_BASE_URL := https://repo1.maven.org/maven2/ch/qos/logback/logback-classic/$(LOGBACK_VERSION) 20 | 21 | $(LOGBACK_CLASSIC): $(LOGBACK_CLASSIC).md5 22 | set dummy "$(LOGBACK_CLASSIC_BASE_URL)" "$(LOGBACK_CLASSIC)"; shift; $(FETCH_DEPENDENCY) 23 | 24 | 25 | LOGBACK_CORE_VERSION := $(LOGBACK_VERSION) 26 | LOGBACK_CORE := third_party/logback/logback-core-$(LOGBACK_CORE_VERSION).jar 27 | LOGBACK_CORE_BASE_URL := https://repo1.maven.org/maven2/ch/qos/logback/logback-core/$(LOGBACK_VERSION) 28 | 29 | $(LOGBACK_CORE): $(LOGBACK_CORE).md5 30 | set dummy "$(LOGBACK_CORE_BASE_URL)" "$(LOGBACK_CORE)"; shift; $(FETCH_DEPENDENCY) 31 | 32 | THIRD_PARTY += $(LOGBACK_CLASSIC) $(LOGBACK_CORE) 33 | -------------------------------------------------------------------------------- /src/core/RequestBuilder.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.hbase.async.AppendRequest; 16 | import org.hbase.async.HBaseRpc; 17 | import org.hbase.async.PutRequest; 18 | 19 | import net.opentsdb.utils.Config; 20 | 21 | public class RequestBuilder { 22 | 23 | public static PutRequest buildPutRequest(Config config, byte[] tableName, byte[] row, byte[] family, byte[] qualifier, byte[] value, long timestamp) { 24 | 25 | if(config.use_otsdb_timestamp()) 26 | if((timestamp & Const.SECOND_MASK) != 0) 27 | return new PutRequest(tableName, row, family, qualifier, value, timestamp); 28 | else 29 | return new PutRequest(tableName, row, family, qualifier, value, timestamp * 1000); 30 | else 31 | return new PutRequest(tableName, row, family, qualifier, value); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /test/core/TestSaltScannerHistogramSalted.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.junit.Before; 16 | import org.powermock.api.mockito.PowerMockito; 17 | 18 | public class TestSaltScannerHistogramSalted extends TestSaltScannerHistogram { 19 | 20 | @Before 21 | public void beforeLocal() throws Exception { 22 | PowerMockito.mockStatic(Const.class); 23 | PowerMockito.when(Const.SALT_WIDTH()).thenReturn(1); 24 | PowerMockito.when(Const.SALT_BUCKETS()).thenReturn(2); 25 | 26 | key_a = getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_STRING, 27 | TAGK_B_STRING, TAGV_STRING); 28 | key_b = getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_B_STRING, 29 | TAGK_B_STRING, TAGV_STRING); 30 | key_c = getRowKey(METRIC_STRING, 1359680400, TAGK_STRING, TAGV_STRING, 31 | TAGK_B_STRING, TAGV_STRING); 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /test/core/TestTsdbQueryDownsampleSalted.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.junit.Before; 16 | import org.junit.runner.RunWith; 17 | import org.powermock.api.mockito.PowerMockito; 18 | import org.powermock.modules.junit4.PowerMockRunner; 19 | 20 | /** 21 | * Integration test that runs all of the tests in {@see TestTsdbQueryDownsample} 22 | * but with salting enabled just to verify nothing goes wrong with the extra 23 | * salt bytes. 24 | */ 25 | @RunWith(PowerMockRunner.class) 26 | public class TestTsdbQueryDownsampleSalted extends TestTsdbQueryDownsample { 27 | 28 | @Before 29 | public void beforeLocal() throws Exception { 30 | PowerMockito.mockStatic(Const.class); 31 | PowerMockito.when(Const.SALT_WIDTH()).thenReturn(1); 32 | PowerMockito.when(Const.SALT_BUCKETS()).thenReturn(2); 33 | PowerMockito.when(Const.MAX_NUM_TAGS()).thenReturn((short) 8); 34 | 35 | query = new TsdbQuery(tsdb); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/tsd/WordSplitter.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import java.nio.charset.Charset; 16 | 17 | import org.jboss.netty.buffer.ChannelBuffer; 18 | import org.jboss.netty.channel.Channel; 19 | import org.jboss.netty.channel.ChannelHandlerContext; 20 | import org.jboss.netty.handler.codec.oneone.OneToOneDecoder; 21 | 22 | import net.opentsdb.core.Tags; 23 | 24 | /** 25 | * Splits a ChannelBuffer in multiple space separated words. 26 | */ 27 | final class WordSplitter extends OneToOneDecoder { 28 | 29 | private static final Charset CHARSET = Charset.forName("ISO-8859-1"); 30 | 31 | /** Constructor. */ 32 | public WordSplitter() { 33 | } 34 | 35 | @Override 36 | protected Object decode(final ChannelHandlerContext ctx, 37 | final Channel channel, 38 | final Object msg) throws Exception { 39 | return Tags.splitString(((ChannelBuffer) msg).toString(CHARSET), ' '); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /test/core/TestTsdbQueryAggregatorsSalted.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.junit.Before; 16 | import org.junit.runner.RunWith; 17 | import org.powermock.api.mockito.PowerMockito; 18 | import org.powermock.modules.junit4.PowerMockRunner; 19 | 20 | /** 21 | * Integration test that runs all of the tests in {@see TestTsdbQueryAggregators} 22 | * but with salting enabled just to verify nothing goes wrong with the extra 23 | * salt bytes. 24 | */ 25 | @RunWith(PowerMockRunner.class) 26 | public class TestTsdbQueryAggregatorsSalted extends TestTsdbQueryAggregators { 27 | 28 | @Before 29 | public void beforeLocal() throws Exception { 30 | PowerMockito.mockStatic(Const.class); 31 | PowerMockito.when(Const.SALT_WIDTH()).thenReturn(1); 32 | PowerMockito.when(Const.SALT_BUCKETS()).thenReturn(2); 33 | PowerMockito.when(Const.MAX_NUM_TAGS()).thenReturn((short) 8); 34 | 35 | query = new TsdbQuery(tsdb); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/utils/Exceptions.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.utils; 14 | 15 | import com.stumbleupon.async.DeferredGroupException; 16 | 17 | /** 18 | * A class with utility methods for dealing with Exceptions in OpenTSDB 19 | * @since 2.2 20 | */ 21 | public class Exceptions { 22 | 23 | /** 24 | * Iterates through the stack trace, looking for the actual cause of the 25 | * deferred group exception. These traces can be huge and truncated in the 26 | * logs so it's really useful to be able to spit out the source. 27 | * @param e A DeferredGroupException to parse 28 | * @return The root cause of the exception if found. 29 | */ 30 | public static Throwable getCause(final DeferredGroupException e) { 31 | Throwable ex = e; 32 | while (ex.getClass().equals(DeferredGroupException.class)) { 33 | if (ex.getCause() == null) { 34 | break; 35 | } else { 36 | ex = ex.getCause(); 37 | } 38 | } 39 | return ex; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/core/TestTSDBAddPointSalted.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.junit.Before; 16 | import org.junit.runner.RunWith; 17 | import org.powermock.api.mockito.PowerMockito; 18 | import org.powermock.modules.junit4.PowerMockRunner; 19 | 20 | /** 21 | * Integration test that runs all of the tests in {@see TestTSDBAddPoint} 22 | * but with salting enabled just to verify nothing goes wrong with the extra 23 | * salt bytes. 24 | */ 25 | @RunWith(PowerMockRunner.class) 26 | public class TestTSDBAddPointSalted extends TestTSDBAddPoint { 27 | 28 | @Before 29 | public void beforeLocal() throws Exception { 30 | PowerMockito.mockStatic(Const.class); 31 | PowerMockito.when(Const.SALT_WIDTH()).thenReturn(1); 32 | PowerMockito.when(Const.SALT_BUCKETS()).thenReturn(2); 33 | PowerMockito.when(Const.MAX_NUM_TAGS()).thenReturn((short) 8); 34 | 35 | row = getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_STRING); 36 | setDataPointStorage(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/tsd/RpcUtil.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2014 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import org.jboss.netty.handler.codec.http.HttpMethod; 16 | import org.jboss.netty.handler.codec.http.HttpResponseStatus; 17 | import org.slf4j.Logger; 18 | import org.slf4j.LoggerFactory; 19 | 20 | import java.util.List; 21 | 22 | public class RpcUtil { 23 | 24 | private static final Logger LOG = LoggerFactory.getLogger(RpcUtil.class); 25 | 26 | public static void allowedMethods(HttpMethod requestMethod, String... allowedMethods) { 27 | for(String method : allowedMethods) { 28 | LOG.debug(String.format("Trying Method: %s", method)); 29 | if (requestMethod.getName() == method) { 30 | LOG.debug(String.format("Method Allowed: %s", method)); 31 | return; 32 | } 33 | } 34 | throw new BadRequestException(HttpResponseStatus.METHOD_NOT_ALLOWED, 35 | "Method not allowed", "The HTTP method [" + requestMethod.getName() + "] is not permitted for this endpoint"); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/core/TestHistogramPojo.java: -------------------------------------------------------------------------------- 1 | package net.opentsdb.core; 2 | 3 | import static org.mockito.Mockito.when; 4 | 5 | import org.hbase.async.Bytes; 6 | import org.junit.Before; 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | import org.powermock.api.mockito.PowerMockito; 10 | import org.powermock.core.classloader.annotations.PrepareForTest; 11 | import org.powermock.modules.junit4.PowerMockRunner; 12 | 13 | import net.opentsdb.utils.Config; 14 | 15 | @RunWith(PowerMockRunner.class) 16 | @PrepareForTest({ TSDB.class }) 17 | public class TestHistogramPojo { 18 | 19 | private TSDB tsdb; 20 | private Config config; 21 | private HistogramCodecManager manager; 22 | 23 | @Before 24 | public void before() throws Exception { 25 | tsdb = PowerMockito.mock(TSDB.class); 26 | config = new Config(false); 27 | 28 | config.overrideConfig("tsd.core.histograms.config", 29 | "{\"net.opentsdb.core.SimpleHistogramDecoder\": 0}"); 30 | when(tsdb.getConfig()).thenReturn(config); 31 | 32 | manager = new HistogramCodecManager(tsdb); 33 | when(tsdb.histogramManager()).thenReturn(manager); 34 | } 35 | 36 | @Test 37 | public void foo() throws Exception { 38 | int v = 255; 39 | 40 | System.out.println("CV: " + (byte) v); 41 | 42 | // SimpleHistogram y1Hist = new SimpleHistogram(); 43 | // y1Hist.addBucket(1.0f, 2.0f, 5L); 44 | // y1Hist.addBucket(2.0f, 3.0f, 5L); 45 | // y1Hist.addBucket(3.0f, 10.0f, 0L); 46 | // 47 | // byte[] raw = y1Hist.histogram(manager); 48 | // System.out.println(HistogramPojo.bytesToBase64String(raw)); 49 | // System.out.println(HistogramPojo.bytesToHexString(raw)); 50 | // 51 | //HistogramDataPoint h = tsdb.histogramManager().getDecoder((byte) 0).decode(raw, 1356998400000L); 52 | //System.out.println(h); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/utils/JSONException.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2013 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.utils; 14 | 15 | /** 16 | * Exception class used to wrap the myriad of typed exceptions thrown by 17 | * Jackson. 18 | * @since 2.0 19 | */ 20 | public final class JSONException extends RuntimeException { 21 | 22 | /** 23 | * Constructor. 24 | * @param msg The message of the exception, potentially including a stack 25 | * trace. 26 | */ 27 | public JSONException(final String msg) { 28 | super(msg); 29 | } 30 | 31 | /** 32 | * Constructor. 33 | * @param cause The exception that caused this one to be thrown. 34 | */ 35 | public JSONException(final Throwable cause) { 36 | super(cause); 37 | } 38 | 39 | /** 40 | * Constructor. 41 | * @param msg The message of the exception, potentially including a stack 42 | * trace. 43 | * @param cause The exception that caused this one to be thrown. 44 | */ 45 | public JSONException(final String msg, final Throwable cause) { 46 | super(msg, cause); 47 | } 48 | 49 | private static final long serialVersionUID = 1365518940; 50 | } 51 | -------------------------------------------------------------------------------- /third_party/gwt/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2023 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | GWT_VERSION := 2.6.1 17 | 18 | GWT_DEV_VERSION := $(GWT_VERSION) 19 | GWT_DEV := third_party/gwt/gwt-dev-$(GWT_DEV_VERSION).jar 20 | GWT_DEV_BASE_URL := https://repo1.maven.org/maven2/com/google/gwt/gwt-dev/$(GWT_DEV_VERSION) 21 | 22 | $(GWT_DEV): $(GWT_DEV).md5 23 | set dummy "$(GWT_DEV_BASE_URL)" "$(GWT_DEV)"; shift; $(FETCH_DEPENDENCY) 24 | 25 | 26 | GWT_USER_VERSION := $(GWT_VERSION) 27 | GWT_USER := third_party/gwt/gwt-user-$(GWT_USER_VERSION).jar 28 | GWT_USER_BASE_URL := https://repo1.maven.org/maven2/com/google/gwt/gwt-user/$(GWT_USER_VERSION) 29 | 30 | $(GWT_USER): $(GWT_USER).md5 31 | set dummy "$(GWT_USER_BASE_URL)" "$(GWT_USER)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | GWT_THEME_VERSION := 1.0.0 34 | GWT_THEME := third_party/gwt/opentsdb-gwt-theme-$(GWT_THEME_VERSION).jar 35 | GWT_THEME_BASE_URL := https://repo1.maven.org/maven2/net/opentsdb/opentsdb-gwt-theme/$(GWT_THEME_VERSION) 36 | 37 | $(GWT_THEME): $(GWT_THEME).md5 38 | set dummy "$(GWT_THEME_BASE_URL)" "$(GWT_THEME)"; shift; $(FETCH_DEPENDENCY) 39 | 40 | THIRD_PARTY += $(GWT_DEV) $(GWT_USER) $(GWT_THEME) 41 | -------------------------------------------------------------------------------- /test/search/TestTimeSeriesLookupSalted.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.search; 14 | 15 | import net.opentsdb.core.Const; 16 | import net.opentsdb.core.TSDB; 17 | import net.opentsdb.uid.UniqueId; 18 | import net.opentsdb.utils.Config; 19 | 20 | import org.hbase.async.HBaseClient; 21 | import org.hbase.async.KeyValue; 22 | import org.hbase.async.Scanner; 23 | import org.junit.Before; 24 | import org.junit.runner.RunWith; 25 | import org.powermock.api.mockito.PowerMockito; 26 | import org.powermock.core.classloader.annotations.PrepareForTest; 27 | import org.powermock.modules.junit4.PowerMockRunner; 28 | 29 | @RunWith(PowerMockRunner.class) 30 | @PrepareForTest({TSDB.class, Config.class, UniqueId.class, HBaseClient.class, 31 | KeyValue.class, Scanner.class, TimeSeriesLookup.class, Const.class }) 32 | public class TestTimeSeriesLookupSalted extends TestTimeSeriesLookup { 33 | 34 | @Before 35 | public void beforeLocalSalted() throws Exception { 36 | PowerMockito.mockStatic(Const.class); 37 | PowerMockito.when(Const.SALT_WIDTH()).thenReturn(1); 38 | PowerMockito.when(Const.SALT_BUCKETS()).thenReturn(4); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /test/tsd/DummyHttpRpcPlugin.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2014 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import java.io.IOException; 16 | 17 | import com.google.common.base.Preconditions; 18 | import com.stumbleupon.async.Deferred; 19 | 20 | import net.opentsdb.core.TSDB; 21 | import net.opentsdb.stats.StatsCollector; 22 | 23 | /** 24 | * This is a dummy HTTP RPC plugin implementation for unit test purposes. 25 | * @since 2.1 26 | */ 27 | public class DummyHttpRpcPlugin extends HttpRpcPlugin { 28 | @Override 29 | public void initialize(TSDB tsdb) { 30 | Preconditions.checkNotNull(tsdb); 31 | } 32 | 33 | @Override 34 | public Deferred shutdown() { 35 | return Deferred.fromResult(null); 36 | } 37 | 38 | @Override 39 | public String version() { 40 | return "2.0.0"; 41 | } 42 | 43 | @Override 44 | public void collectStats(StatsCollector collector) { 45 | collector.record("http_rpcplugin.dummy.value", 1); 46 | } 47 | 48 | @Override 49 | public String getPath() { 50 | return "/dummy/test"; 51 | } 52 | 53 | @Override 54 | public void execute(TSDB tsdb, HttpRpcPluginQuery query) throws IOException { 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /test/core/TestRollupSpanSalted.java: -------------------------------------------------------------------------------- 1 | package net.opentsdb.core; 2 | 3 | import org.junit.Before; 4 | import org.powermock.api.mockito.PowerMockito; 5 | import org.powermock.reflect.Whitebox; 6 | 7 | import net.opentsdb.rollup.RollupConfig; 8 | import net.opentsdb.rollup.RollupInterval; 9 | 10 | public class TestRollupSpanSalted extends TestRollupSpan { 11 | 12 | @Before 13 | public void beforeLocal() throws Exception { 14 | PowerMockito.mockStatic(Const.class); 15 | PowerMockito.when(Const.SALT_WIDTH()).thenReturn(1); 16 | PowerMockito.when(Const.SALT_BUCKETS()).thenReturn(2); 17 | PowerMockito.when(Const.MAX_NUM_TAGS()).thenReturn((short) 8); 18 | 19 | hour1 = getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_STRING); 20 | hour2 = getRowKey(METRIC_STRING, 1357002000, TAGK_STRING, TAGV_STRING); 21 | hour3 = getRowKey(METRIC_STRING, 1357005600, TAGK_STRING, TAGV_STRING); 22 | 23 | rollup_config = RollupConfig.builder() 24 | .addAggregationId("sum", 0) 25 | .addAggregationId("count", 1) 26 | .addAggregationId("max", 2) 27 | .addAggregationId("min", 3) 28 | .addInterval(RollupInterval.builder() 29 | .setTable("tsdb-rollup-10m") 30 | .setPreAggregationTable("tsdb-rollup-agg-10m") 31 | .setInterval("10m") 32 | .setRowSpan("6h")) 33 | .addInterval(RollupInterval.builder() 34 | .setTable("tsdb-rollup-1h") 35 | .setPreAggregationTable("tsdb-rollup-agg-1h") 36 | .setInterval("1h") 37 | .setRowSpan("1d")) 38 | .addInterval(RollupInterval.builder() 39 | .setTable("tsdb-rollup-1d") 40 | .setPreAggregationTable("tsdb-rollup-agg-1d") 41 | .setInterval("1d") 42 | .setRowSpan("1n")) 43 | .build(); 44 | Whitebox.setInternalState(tsdb, "rollup_config", rollup_config); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/tsd/HttpRpcPluginQuery.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2014 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import org.jboss.netty.channel.Channel; 16 | import org.jboss.netty.handler.codec.http.HttpRequest; 17 | 18 | import net.opentsdb.core.TSDB; 19 | 20 | /** 21 | * Query class for {@link HttpRpcPlugin}s. Binds together a request, its 22 | * owning channel, and reponse helpers. 23 | * 24 | * @since 2.2 25 | */ 26 | public final class HttpRpcPluginQuery extends AbstractHttpQuery { 27 | public HttpRpcPluginQuery(final TSDB tsdb, final HttpRequest request, final Channel chan) { 28 | super(tsdb, request, chan); 29 | } 30 | 31 | /** 32 | * Return the base route with no plugin prefix in it. This is matched with 33 | * values returned by {@link HttpRpcPlugin#getPath()}. 34 | * @return the base route path (no query parameters, etc.) 35 | */ 36 | @Override 37 | public String getQueryBaseRoute() { 38 | final String[] parts = explodePath(); 39 | if (parts.length < 2) { // Must be at least something like: /plugin/blah 40 | throw new BadRequestException("Invalid plugin request path: " + getQueryPath()); 41 | } 42 | return parts[1]; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /test/query/pojo/TestOutput.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.query.pojo; 14 | 15 | import net.opentsdb.utils.JSON; 16 | import org.junit.Test; 17 | 18 | import static org.junit.Assert.assertEquals; 19 | 20 | public class TestOutput { 21 | @Test 22 | public void deserializeAllFields() throws Exception { 23 | String json = "{\"id\":\"m1\",\"alias\":\"CPU OK\"}"; 24 | Output output = JSON.parseToObject(json, Output.class); 25 | Output expectedOutput = Output.Builder().setId("m1").setAlias("CPU OK") 26 | .build(); 27 | assertEquals(expectedOutput, output); 28 | } 29 | 30 | @Test 31 | public void serialize() throws Exception { 32 | Output output = Output.Builder().setId("m1").setAlias("CPU OK") 33 | .build(); 34 | String actual = JSON.serializeToString(output); 35 | String expected = "{\"id\":\"m1\",\"alias\":\"CPU OK\"}"; 36 | assertEquals(expected, actual); 37 | } 38 | 39 | @Test 40 | public void unknownFieldShouldBeIgnored() throws Exception { 41 | String json = "{\"id\":\"m1\",\"unknown\":\"yo\"}"; 42 | JSON.parseToObject(json, Filter.class); 43 | // pass if no unexpected exception 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/query/expression/Expression.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.query.expression; 14 | 15 | import java.util.List; 16 | 17 | import net.opentsdb.core.DataPoints; 18 | import net.opentsdb.core.TSQuery; 19 | 20 | /** 21 | * The interface for various expressions/functions used when querying OpenTSDB. 22 | * @since 2.3 23 | */ 24 | public interface Expression { 25 | 26 | /** 27 | * Computes a set of results given the results of a {@link TSQuery} that may 28 | * include multiple metrics and/or group by result sets. 29 | * @param data_query The original query from the user 30 | * @param results The results of the query 31 | * @param params Parameters parsed from the expression endpoint related to 32 | * the implementing function 33 | * @return An array of data points resulting from the implementation 34 | */ 35 | public DataPoints[] evaluate(TSQuery data_query, 36 | List results, List params); 37 | 38 | /** 39 | * TODO - document me! 40 | * @param params 41 | * @param inner_expression 42 | * @return 43 | */ 44 | public String writeStringField(List params, String inner_expression); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /fat-jar/test-logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | %d{ISO8601} %-5level [%thread] %logger{0}: %msg%n 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/uid/NoSuchUniqueId.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.uid; 14 | 15 | import java.util.Arrays; 16 | import java.util.NoSuchElementException; 17 | 18 | /** 19 | * Exception used when a Unique ID can't be found. 20 | * 21 | * @see UniqueId 22 | */ 23 | public final class NoSuchUniqueId extends NoSuchElementException { 24 | 25 | /** The 'kind' of the table. */ 26 | private final String kind; 27 | /** The ID that couldn't be found. */ 28 | private final byte[] id; 29 | 30 | /** 31 | * Constructor. 32 | * 33 | * @param kind The kind of unique ID that triggered the exception. 34 | * @param id The ID that couldn't be found. 35 | */ 36 | public NoSuchUniqueId(final String kind, final byte[] id) { 37 | super("No such unique ID for '" + kind + "': " + Arrays.toString(id)); 38 | this.kind = kind; 39 | this.id = id; 40 | } 41 | 42 | /** Returns the kind of unique ID that couldn't be found. */ 43 | public String kind() { 44 | return kind; 45 | } 46 | 47 | /** Returns the unique ID that couldn't be found. */ 48 | public byte[] id() { 49 | return id; 50 | } 51 | 52 | static final long serialVersionUID = 1266815251; 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/uid/NoSuchUniqueName.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.uid; 14 | 15 | import java.util.NoSuchElementException; 16 | 17 | /** 18 | * Exception used when a name's Unique ID can't be found. 19 | * 20 | * @see UniqueId 21 | */ 22 | public final class NoSuchUniqueName extends NoSuchElementException { 23 | 24 | /** The 'kind' of the table. */ 25 | private final String kind; 26 | /** The name that couldn't be found. */ 27 | private final String name; 28 | 29 | /** 30 | * Constructor. 31 | * 32 | * @param kind The kind of unique ID that triggered the exception. 33 | * @param name The name that couldn't be found. 34 | */ 35 | public NoSuchUniqueName(final String kind, final String name) { 36 | super("No such name for '" + kind + "': '" + name + "'"); 37 | this.kind = kind; 38 | this.name = name; 39 | } 40 | 41 | /** Returns the kind of unique ID that couldn't be found. */ 42 | public String kind() { 43 | return kind; 44 | } 45 | 46 | /** Returns the name for which the unique ID couldn't be found. */ 47 | public String name() { 48 | return name; 49 | } 50 | 51 | static final long serialVersionUID = 1266815261; 52 | 53 | } 54 | -------------------------------------------------------------------------------- /test/tsd/DummyHttpSerializer.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2013 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import net.opentsdb.core.TSDB; 16 | 17 | import com.stumbleupon.async.Deferred; 18 | import org.junit.Ignore; 19 | 20 | /** 21 | * This is a dummy HTTP plugin seralizer implementation for unit test purposes 22 | * @since 2.0 23 | */ 24 | @Ignore 25 | public class DummyHttpSerializer extends HttpSerializer { 26 | 27 | public DummyHttpSerializer() { 28 | super(); 29 | this.request_content_type = "application/tsdbdummy"; 30 | this.response_content_type = "application/tsdbdummy; charset=UTF-8"; 31 | } 32 | 33 | public DummyHttpSerializer(final HttpQuery query) { 34 | super(query); 35 | this.request_content_type = "application/tsdbdummy"; 36 | this.response_content_type = "application/tsdbdummy; charset=UTF-8"; 37 | } 38 | 39 | @Override 40 | public void initialize(final TSDB tsdb) { 41 | // nothing to do 42 | } 43 | 44 | @Override 45 | public Deferred shutdown() { 46 | return new Deferred(); 47 | } 48 | 49 | @Override 50 | public String version() { 51 | return "1.0.0"; 52 | } 53 | 54 | @Override 55 | public String shortName() { 56 | return "dummy"; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /third_party/guava/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | GUAVA_VERSION := 18.0 27 | GUAVA := third_party/guava/guava-$(GUAVA_VERSION).jar 28 | GUAVA_BASE_URL := https://repo1.maven.org/maven2/com/google/guava/guava/$(GUAVA_VERSION) 29 | 30 | $(GUAVA): $(GUAVA).md5 31 | set dummy "$(GUAVA_BASE_URL)" "$(GUAVA)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(GUAVA) 34 | -------------------------------------------------------------------------------- /test/utils/TestFileSystem.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2013-2014 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.utils; 14 | 15 | import java.io.File; 16 | 17 | import net.opentsdb.utils.FileSystem; 18 | 19 | import org.junit.Before; 20 | import org.junit.Test; 21 | import org.junit.runner.RunWith; 22 | import org.powermock.api.mockito.PowerMockito; 23 | import org.powermock.core.classloader.annotations.PrepareForTest; 24 | import org.powermock.modules.junit4.PowerMockRunner; 25 | 26 | @RunWith(PowerMockRunner.class) 27 | @PrepareForTest({File.class, FileSystem.class}) 28 | public final class TestFileSystem { 29 | 30 | File mockFile; 31 | 32 | @Before 33 | public void setUp() throws Exception { 34 | mockFile = PowerMockito.mock(File.class); 35 | PowerMockito.whenNew(File.class).withAnyArguments().thenReturn(mockFile); 36 | PowerMockito.when(mockFile, "getParent").thenReturn("/temp/opentsdb"); 37 | PowerMockito.when(mockFile, "exists").thenReturn(true); 38 | PowerMockito.when(mockFile, "isDirectory").thenReturn(true); 39 | PowerMockito.when(mockFile, "canWrite").thenReturn(true); 40 | } 41 | 42 | @Test (expected = IllegalArgumentException.class) 43 | public void checkDirectoryEmptyString() throws Exception { 44 | FileSystem.checkDirectory("", true, false); 45 | } 46 | } -------------------------------------------------------------------------------- /third_party/apache/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2022 The OpenTSDB Authors. 2 | # 3 | # Redistribution and use in source and binary forms, with or without 4 | # modification, are permitted provided that the following conditions are met: 5 | # - Redistributions of source code must retain the above copyright notice, 6 | # this list of conditions and the following disclaimer. 7 | # - Redistributions in binary form must reproduce the above copyright notice, 8 | # this list of conditions and the following disclaimer in the documentation 9 | # and/or other materials provided with the distribution. 10 | # - Neither the name of the StumbleUpon nor the names of its contributors 11 | # may be used to endorse or promote products derived from this software 12 | # without specific prior written permission. 13 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 17 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | # POSSIBILITY OF SUCH DAMAGE. 24 | 25 | APACHE_MATH_VERSION := 3.6.1 26 | APACHE_MATH := third_party/apache/commons-math3-$(APACHE_MATH_VERSION).jar 27 | APACHE_MATH_BASE_URL := https://repo1.maven.org/maven2/org/apache/commons/commons-math3/$(APACHE_MATH_VERSION) 28 | 29 | $(APACHE_MATH): $(APACHE_MATH).md5 30 | set dummy "$(APACHE_MATH_BASE_URL)" "$(APACHE_MATH)"; shift; $(FETCH_DEPENDENCY) 31 | 32 | THIRD_PARTY += $(APACHE_MATH) 33 | -------------------------------------------------------------------------------- /third_party/netty/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | NETTY_MAJOR_VERSION = 3.10 27 | NETTY_VERSION := 3.10.6.Final 28 | NETTY := third_party/netty/netty-$(NETTY_VERSION).jar 29 | NETTY_BASE_URL := https://repo1.maven.org/maven2/io/netty/netty/$(NETTY_VERSION) 30 | 31 | $(NETTY): $(NETTY).md5 32 | set dummy "$(NETTY_BASE_URL)" "$(NETTY)"; shift; $(FETCH_DEPENDENCY) 33 | 34 | THIRD_PARTY += $(NETTY) 35 | -------------------------------------------------------------------------------- /third_party/javassist/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | JAVASSIST_VERSION := 3.21.0-GA 27 | JAVASSIST := third_party/javassist/javassist-$(JAVASSIST_VERSION).jar 28 | JAVASSIST_BASE_URL := https://repo1.maven.org/maven2/org/javassist/javassist/$(JAVASSIST_VERSION) 29 | 30 | $(JAVASSIST): $(JAVASSIST).md5 31 | set dummy "$(JAVASSIST_BASE_URL)" "$(JAVASSIST)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(JAVASSIST) 34 | -------------------------------------------------------------------------------- /src/utils/FileSystem.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.utils; 14 | 15 | import java.io.File; 16 | 17 | public class FileSystem { 18 | /** 19 | * Verifies a directory and checks to see if it's writeable or not if 20 | * configured 21 | * @param dir The path to check on 22 | * @param need_write Set to true if the path needs write access 23 | * @param create Set to true if the directory should be created if it does not 24 | * exist 25 | * @throws IllegalArgumentException if the path is empty, if it's not there 26 | * and told not to create it or if it needs write access and can't 27 | * be written to 28 | */ 29 | public static void checkDirectory(final String dir, 30 | final boolean need_write, final boolean create) { 31 | if (dir.isEmpty()) 32 | throw new IllegalArgumentException("Directory path is empty"); 33 | final File f = new File(dir); 34 | if (!f.exists() && !(create && f.mkdirs())) { 35 | throw new IllegalArgumentException("No such directory [" + dir + "]"); 36 | } else if (!f.isDirectory()) { 37 | throw new IllegalArgumentException("Not a directory [" + dir + "]"); 38 | } else if (need_write && !f.canWrite()) { 39 | throw new IllegalArgumentException("Cannot write to directory [" + dir 40 | + "]"); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /third_party/kryo/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2017 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | KRYO_VERSION := 3.0.0 17 | KRYO := third_party/kryo/kryo-$(KRYO_VERSION).jar 18 | KRYO_BASE_URL := https://repo1.maven.org/maven2/com/esotericsoftware/kryo/$(KRYO_VERSION) 19 | 20 | $(KRYO): $(KRYO).md5 21 | set dummy "$(KRYO_BASE_URL)" "$(KRYO)"; shift; $(FETCH_DEPENDENCY) 22 | 23 | REFLECTASM_VERSION := 1.10.0 24 | REFLECTASM := third_party/kryo/reflectasm-$(REFLECTASM_VERSION)-shaded.jar 25 | REFLECTASM_BASE_URL :=https://repo1.maven.org/maven2/com/esotericsoftware/reflectasm/$(REFLECTASM_VERSION) 26 | 27 | $(REFLECTASM): $(REFLECTASM).md5 28 | set dummy "$(REFLECTASM_BASE_URL)" "$(REFLECTASM)"; shift; $(FETCH_DEPENDENCY) 29 | 30 | ASM_VERSION := 4.0 31 | ASM := third_party/kryo/asm-$(ASM_VERSION).jar 32 | ASM_BASE_URL := https://repo1.maven.org/maven2/org/ow2/asm/asm/$(ASM_VERSION) 33 | 34 | $(ASM): $(ASM).md5 35 | set dummy "$(ASM_BASE_URL)" "$(ASM)"; shift; $(FETCH_DEPENDENCY) 36 | 37 | MINLOG_VERSION := 1.3 38 | MINLOG := third_party/kryo/minlog-$(MINLOG_VERSION).jar 39 | MINLOG_BASE_URL := https://repo1.maven.org/maven2/com/esotericsoftware/minlog/$(MINLOG_VERSION) 40 | 41 | $(MINLOG): $(MINLOG).md5 42 | set dummy "$(MINLOG_BASE_URL)" "$(MINLOG)"; shift; $(FETCH_DEPENDENCY) 43 | 44 | THIRD_PARTY += $(KRYO) $(REFLECTASM) $(ASM) $(MINLOG) 45 | 46 | https://repo1.maven.org/maven2/com/esotericsoftware/reflectasm/1.10.0/reflectasm-1.10.0-shaded.jar 47 | -------------------------------------------------------------------------------- /fat-jar/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | %d{ISO8601} %-5level [%thread] %logger{0}: %msg%n 8 | 9 | 10 | 11 | 12 | 1024 13 | 14 | 15 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /third_party/jackson/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2022 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | JACKSON_VERSION := 2.14.1 17 | 18 | JACKSON_ANNOTATIONS_VERSION = $(JACKSON_VERSION) 19 | JACKSON_ANNOTATIONS := third_party/jackson/jackson-annotations-$(JACKSON_ANNOTATIONS_VERSION).jar 20 | JACKSON_ANNOTATIONS_BASE_URL := https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-annotations/$(JACKSON_VERSION) 21 | 22 | $(JACKSON_ANNOTATIONS): $(JACKSON_ANNOTATIONS).md5 23 | set dummy "$(JACKSON_ANNOTATIONS_BASE_URL)" "$(JACKSON_ANNOTATIONS)"; shift; $(FETCH_DEPENDENCY) 24 | 25 | JACKSON_CORE_VERSION = $(JACKSON_VERSION) 26 | JACKSON_CORE := third_party/jackson/jackson-core-$(JACKSON_CORE_VERSION).jar 27 | JACKSON_CORE_BASE_URL := https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-core/$(JACKSON_VERSION) 28 | 29 | $(JACKSON_CORE): $(JACKSON_CORE).md5 30 | set dummy "$(JACKSON_CORE_BASE_URL)" "$(JACKSON_CORE)"; shift; $(FETCH_DEPENDENCY) 31 | 32 | JACKSON_DATABIND_VERSION = $(JACKSON_VERSION) 33 | JACKSON_DATABIND := third_party/jackson/jackson-databind-$(JACKSON_DATABIND_VERSION).jar 34 | JACKSON_DATABIND_BASE_URL := https://repo1.maven.org/maven2/com/fasterxml/jackson/core/jackson-databind/$(JACKSON_VERSION) 35 | 36 | $(JACKSON_DATABIND): $(JACKSON_DATABIND).md5 37 | set dummy "$(JACKSON_DATABIND_BASE_URL)" "$(JACKSON_DATABIND)"; shift; $(FETCH_DEPENDENCY) 38 | 39 | 40 | THIRD_PARTY += $(JACKSON_ANNOTATIONS) $(JACKSON_CORE) $(JACKSON_DATABIND) 41 | -------------------------------------------------------------------------------- /third_party/powermock/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2012 The Async HBase Authors. All rights reserved. 2 | # This file is part of Async HBase. 3 | # 4 | # Redistribution and use in source and binary forms, with or without 5 | # modification, are permitted provided that the following conditions are met: 6 | # - Redistributions of source code must retain the above copyright notice, 7 | # this list of conditions and the following disclaimer. 8 | # - Redistributions in binary form must reproduce the above copyright notice, 9 | # this list of conditions and the following disclaimer in the documentation 10 | # and/or other materials provided with the distribution. 11 | # - Neither the name of the StumbleUpon nor the names of its contributors 12 | # may be used to endorse or promote products derived from this software 13 | # without specific prior written permission. 14 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 15 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 18 | # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 19 | # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 20 | # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 22 | # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 23 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 24 | # POSSIBILITY OF SUCH DAMAGE. 25 | 26 | POWERMOCK_MOCKITO_VERSION := 1.5.4 27 | POWERMOCK_MOCKITO := third_party/powermock/powermock-mockito-release-full-$(POWERMOCK_MOCKITO_VERSION)-full.jar 28 | POWERMOCK_MOCKITO_BASE_URL := https://repo1.maven.org/maven2/org/powermock/powermock-mockito-release-full/$(POWERMOCK_MOCKITO_VERSION) 29 | 30 | $(POWERMOCK_MOCKITO): $(POWERMOCK_MOCKITO).md5 31 | set dummy "$(POWERMOCK_MOCKITO_BASE_URL)" "$(POWERMOCK_MOCKITO)"; shift; $(FETCH_DEPENDENCY) 32 | 33 | THIRD_PARTY += $(POWERMOCK_MOCKITO) 34 | -------------------------------------------------------------------------------- /src/query/filter/TagVNotKeyFilter.java: -------------------------------------------------------------------------------- 1 | package net.opentsdb.query.filter; 2 | 3 | import java.util.Map; 4 | 5 | import com.google.common.base.Objects; 6 | import com.stumbleupon.async.Deferred; 7 | 8 | public class TagVNotKeyFilter extends TagVFilter { 9 | /** Name of this filter */ 10 | final public static String FILTER_NAME = "not_key"; 11 | 12 | public TagVNotKeyFilter(final String tagk, final String filter) { 13 | super(tagk, ""); 14 | if (filter != null && filter.length() > 0) { 15 | throw new IllegalArgumentException("The filter must be empty for the " + 16 | FILTER_NAME + " filter"); 17 | } 18 | post_scan = true; 19 | } 20 | 21 | @Override 22 | public Deferred match(Map tags) { 23 | if (tags.containsKey(tagk)) { 24 | return Deferred.fromResult(false); 25 | } 26 | return Deferred.fromResult(true); 27 | } 28 | 29 | @Override 30 | public String getType() { 31 | return FILTER_NAME; 32 | } 33 | 34 | @Override 35 | public String debugInfo() { 36 | return "{}"; 37 | } 38 | 39 | @Override 40 | public boolean equals(final Object obj) { 41 | if (obj == null) { 42 | return false; 43 | } 44 | if (!(obj instanceof TagVRegexFilter)) { 45 | return false; 46 | } 47 | if (obj == this) { 48 | return true; 49 | } 50 | final TagVNotKeyFilter filter = (TagVNotKeyFilter)obj; 51 | return Objects.equal(tagk, filter.tagk); 52 | } 53 | 54 | @Override 55 | public int hashCode() { 56 | return Objects.hashCode(tagk); 57 | } 58 | 59 | /** @return a string describing the filter */ 60 | public static String description() { 61 | return "Skips any time series with the given tag key, regardless of the " 62 | + "value. This can be useful for situations where a metric has " 63 | + "inconsistent tag sets. NOTE: The filter value must be null or an " 64 | + "empty string."; 65 | } 66 | 67 | /** @return a list of examples showing how to use the filter */ 68 | public static String examples() { 69 | return "host=not_key() {\"type\":\"not_key\",\"tagk\":\"host\"," 70 | + "\"filter\":\"\",\"groupBy\":false}"; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /test/tsd/DummyRpcPlugin.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2013 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import net.opentsdb.core.TSDB; 16 | import net.opentsdb.stats.StatsCollector; 17 | 18 | import org.junit.Ignore; 19 | 20 | import com.stumbleupon.async.Deferred; 21 | 22 | /** 23 | * This is a dummy RPC plugin implementation for unit test purposes 24 | * @since 2.0 25 | */ 26 | @Ignore 27 | public class DummyRpcPlugin extends RpcPlugin { 28 | 29 | @Override 30 | public void initialize(TSDB tsdb) { 31 | if (tsdb == null) { 32 | throw new IllegalArgumentException("The TSDB object was null"); 33 | } 34 | // some dummy configs to check to throw exceptions 35 | if (!tsdb.getConfig().hasProperty("tsd.rpcplugin.DummyRPCPlugin.hosts")) { 36 | throw new IllegalArgumentException("Missing hosts config"); 37 | } 38 | if (tsdb.getConfig().getString("tsd.rpcplugin.DummyRPCPlugin.hosts") 39 | .isEmpty()) { 40 | throw new IllegalArgumentException("Empty Hosts config"); 41 | } 42 | // throw an NFE for fun 43 | tsdb.getConfig().getInt("tsd.rpcplugin.DummyRPCPlugin.port"); 44 | } 45 | 46 | @Override 47 | public Deferred shutdown() { 48 | return Deferred.fromResult(null); 49 | } 50 | 51 | @Override 52 | public String version() { 53 | return "2.0.0"; 54 | } 55 | 56 | @Override 57 | public void collectStats(StatsCollector collector) { 58 | collector.record("rpcplugin.dummy.writes", 1); 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/core/HistogramDataPointCodec.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | /** 16 | * Responsible for encoding or decoding {@code HistogramDataPoint}s to and from 17 | * byte arrays. 18 | * 19 | * NOTE: Implementation of this plugin should be thread safe. 20 | * @see HistogramCodecManager 21 | * 22 | * @since 2.4 23 | */ 24 | public abstract class HistogramDataPointCodec { 25 | 26 | /** The ID of this codec in the Histogram Manager. */ 27 | protected int id; 28 | 29 | /** 30 | * Default empty ctor, required for plugin and class instantiation. 31 | * WARNING Any overrides with arguments will be ignored. 32 | */ 33 | public HistogramDataPointCodec() { 34 | 35 | } 36 | 37 | public int getId() { 38 | return id; 39 | } 40 | 41 | public void setId(final int id) { 42 | this.id = id; 43 | } 44 | 45 | /** 46 | * Creates {@code HistogramDataPoint} from raw data and timestamp. Note that 47 | * the data point identifier is separate. 48 | * @param raw_data The encoded byte array of the histogram data 49 | * @param includes_id Whether or not to include the id prefix. 50 | * @return The decoded histogram data point instance 51 | */ 52 | public abstract Histogram decode(final byte[] raw_data, 53 | final boolean includes_id); 54 | 55 | 56 | public abstract byte[] encode(final Histogram data_point, 57 | final boolean include_id); 58 | } 59 | -------------------------------------------------------------------------------- /test/tsd/DummySEHPlugin.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import net.opentsdb.core.IllegalDataException; 16 | import net.opentsdb.core.IncomingDataPoint; 17 | import net.opentsdb.core.TSDB; 18 | import net.opentsdb.stats.StatsCollector; 19 | 20 | import com.stumbleupon.async.Deferred; 21 | 22 | public class DummySEHPlugin extends StorageExceptionHandler { 23 | 24 | @Override 25 | public void initialize(TSDB tsdb) { 26 | if (tsdb == null) { 27 | throw new IllegalArgumentException("The TSDB object was null"); 28 | } 29 | // a dummy config to check for throwing exceptions 30 | if (!tsdb.getConfig().hasProperty( 31 | "tsd.core.storage_exception_handler.DummySEHPlugin.hosts")) { 32 | throw new IllegalArgumentException("Missing hosts config"); 33 | } 34 | } 35 | 36 | @Override 37 | public Deferred shutdown() { 38 | return Deferred.fromResult(new Object()); 39 | } 40 | 41 | @Override 42 | public String version() { 43 | return "2.2.0"; 44 | } 45 | 46 | @Override 47 | public void collectStats(StatsCollector collector) { 48 | collector.record("seh.dummy.retries", 1); 49 | } 50 | 51 | @Override 52 | public void handleError(IncomingDataPoint dp, Exception exception) { 53 | if (dp == null) { 54 | throw new IllegalArgumentException("Missing Data Point"); 55 | } 56 | if (dp.getValue().equals("42")) { 57 | throw new IllegalDataException("Testing"); 58 | } 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/core/FillPolicy.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import com.fasterxml.jackson.annotation.JsonCreator; 16 | import com.fasterxml.jackson.annotation.JsonValue; 17 | 18 | /** 19 | * Specification of how to deal with missing intervals when downsampling. 20 | * @since 2.2 21 | */ 22 | public enum FillPolicy { 23 | NONE("none"), 24 | ZERO("zero"), 25 | NOT_A_NUMBER("nan"), 26 | NULL("null"), 27 | SCALAR("scalar"); 28 | 29 | // The user-friendly name of this policy. 30 | private final String name; 31 | 32 | FillPolicy(final String name) { 33 | this.name = name; 34 | } 35 | 36 | /** 37 | * Get this fill policy's user-friendly name. 38 | * @return this fill policy's user-friendly name. 39 | */ 40 | @JsonValue 41 | public String getName() { 42 | return name; 43 | } 44 | 45 | /** 46 | * Get an instance of this enumeration from a user-friendly name. 47 | * @param name The user-friendly name of a fill policy. 48 | * @return an instance of {@link FillPolicy}, or {@code null} if the name 49 | * does not match any instance. 50 | * @throws IllegalArgumentException if the name doesn't match a policy 51 | */ 52 | @JsonCreator 53 | public static FillPolicy fromString(final String name) { 54 | for (final FillPolicy policy : FillPolicy.values()) { 55 | if (policy.name.equalsIgnoreCase(name)) { 56 | return policy; 57 | } 58 | } 59 | 60 | throw new IllegalArgumentException("Unrecognized fill policy: " + name); 61 | } 62 | } 63 | 64 | -------------------------------------------------------------------------------- /test/core/TestRpcResponsder.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | 16 | import net.opentsdb.utils.Config; 17 | import org.jboss.netty.util.internal.ThreadLocalRandom; 18 | import org.junit.Assert; 19 | import org.junit.Test; 20 | 21 | import java.util.concurrent.atomic.AtomicInteger; 22 | 23 | public class TestRpcResponsder { 24 | 25 | private final AtomicInteger complete_counter = new AtomicInteger(0); 26 | 27 | @Test(timeout = 60000) 28 | public void testGracefulShutdown() throws InterruptedException { 29 | RpcResponder rpcResponder = new RpcResponder(new Config()); 30 | 31 | final int n = 100; 32 | for (int i = 0; i < n; i++) { 33 | rpcResponder.response(new MockResponseProcess()); 34 | } 35 | 36 | Thread.sleep(500); 37 | rpcResponder.close(); 38 | 39 | try { 40 | rpcResponder.response(new MockResponseProcess()); 41 | Assert.fail("Expect an IllegalStateException"); 42 | } catch (IllegalStateException ignore) { 43 | } 44 | 45 | Assert.assertEquals(n, complete_counter.get()); 46 | } 47 | 48 | private class MockResponseProcess implements Runnable { 49 | 50 | @Override 51 | public void run() { 52 | long duration = ThreadLocalRandom.current().nextInt(5000); 53 | while (duration > 0) { 54 | try { 55 | Thread.sleep(100); 56 | } catch (InterruptedException ignore) { 57 | } 58 | duration -= 100; 59 | } 60 | complete_counter.incrementAndGet(); 61 | } 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /src/tsd/client/ValidatedTextBox.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package tsd.client; 14 | 15 | import com.google.gwt.event.dom.client.BlurEvent; 16 | import com.google.gwt.event.dom.client.BlurHandler; 17 | import com.google.gwt.user.client.Command; 18 | import com.google.gwt.user.client.DeferredCommand; 19 | import com.google.gwt.user.client.ui.TextBox; 20 | 21 | class ValidatedTextBox extends TextBox implements BlurHandler { 22 | 23 | private String regexp; 24 | 25 | public ValidatedTextBox() { 26 | } 27 | 28 | public void setValidationRegexp(final String regexp) { 29 | if (this.regexp == null) { // First call to this method. 30 | super.addBlurHandler(this); 31 | } 32 | this.regexp = regexp; 33 | } 34 | 35 | public String getValidationRegexp() { 36 | return regexp; 37 | } 38 | 39 | public void onBlur(final BlurEvent event) { 40 | final String interval = getText(); 41 | if (!interval.matches(regexp)) { 42 | // Steal the dateBoxFormatError :) 43 | addStyleName("dateBoxFormatError"); 44 | event.stopPropagation(); 45 | DeferredCommand.addCommand(new Command() { 46 | public void execute() { 47 | // TODO(tsuna): Understand why this doesn't work as expected, even 48 | // though we cancel the onBlur event and we put the focus afterwards 49 | // using a deferred command. 50 | //setFocus(true); 51 | selectAll(); 52 | } 53 | }); 54 | } else { 55 | removeStyleName("dateBoxFormatError"); 56 | } 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /third_party/include.mk: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2013 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | OPENTSDB_THIRD_PARTY_BASE_URL := http://opentsdb.googlecode.com/files 17 | FETCH_DEPENDENCY := ./build-aux/fetchdep.sh "$$@" 18 | all-am: build-aux/fetchdep.sh 19 | THIRD_PARTY = 20 | 21 | include third_party/guava/include.mk 22 | include third_party/gwt/include.mk 23 | include third_party/hamcrest/include.mk 24 | include third_party/jackson/include.mk 25 | include third_party/javacc/include.mk 26 | include third_party/javassist/include.mk 27 | include third_party/jexl/include.mk 28 | include third_party/jgrapht/include.mk 29 | include third_party/junit/include.mk 30 | include third_party/kryo/include.mk 31 | include third_party/logback/include.mk 32 | include third_party/mockito/include.mk 33 | include third_party/netty/include.mk 34 | include third_party/objenesis/include.mk 35 | include third_party/powermock/include.mk 36 | include third_party/slf4j/include.mk 37 | include third_party/suasync/include.mk 38 | include third_party/validation-api/include.mk 39 | include third_party/apache/include.mk 40 | 41 | if BIGTABLE 42 | include third_party/asyncbigtable/include.mk 43 | ASYNCCASSANDRA_VERSION = 0.0 44 | ASYNCHBASE_VERSION = 0.0 45 | ZOOKEEPER_VERSION = 0.0 46 | else 47 | if CASSANDRA 48 | include third_party/asynccassandra/include.mk 49 | ASYNCBIGTABLE_VERSION = 0.0 50 | ASYNCHBASE_VERSION = 0.0 51 | ZOOKEEPER_VERSION = 0.0 52 | else 53 | include third_party/hbase/include.mk 54 | include third_party/protobuf/include.mk 55 | include third_party/zookeeper/include.mk 56 | ASYNCBIGTABLE_VERSION = 0.0 57 | ASYNCCASSANDRA_VERSION = 0.0 58 | endif 59 | endif 60 | -------------------------------------------------------------------------------- /src/core/HistogramSeekableView.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import java.util.Iterator; 16 | import java.util.NoSuchElementException; 17 | 18 | /** 19 | * A clone of the DataPoints seekable view but for histograms. 20 | * 21 | * @since 2.4 22 | */ 23 | public interface HistogramSeekableView extends Iterator { 24 | 25 | /** 26 | * Returns {@code true} if this view has more elements. 27 | */ 28 | boolean hasNext(); 29 | 30 | /** 31 | * Returns a view on the next data point. 32 | * No new object gets created, the referenced returned is always the same 33 | * and must not be stored since its internal data structure will change the 34 | * next time {@code next()} is called. 35 | * @throws NoSuchElementException if there were no more elements to iterate 36 | * on (in which case {@link #hasNext} would have returned {@code false}. 37 | */ 38 | HistogramDataPoint next(); 39 | 40 | /** 41 | * Unsupported operation. 42 | * @throws UnsupportedOperationException always. 43 | */ 44 | void remove(); 45 | 46 | /** 47 | * Advances the iterator to the given point in time. 48 | *

49 | * This allows the iterator to skip all the data points that are strictly 50 | * before the given timestamp. 51 | * @param timestamp A strictly positive 32 bit UNIX timestamp (in seconds). 52 | * @throws IllegalArgumentException if the timestamp is zero, or negative, 53 | * or doesn't fit on 32 bits (think "unsigned int" -- yay Java!). 54 | */ 55 | void seek(long timestamp); 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/query/pojo/Validatable.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.query.pojo; 14 | 15 | import java.util.Collection; 16 | import java.util.Iterator; 17 | 18 | /** 19 | * An interface for the pojos to implement to make sure all the bits of the 20 | * expression queries are there 21 | * @since 2.3 22 | */ 23 | public abstract class Validatable { 24 | abstract public void validate(); 25 | 26 | /** 27 | * Iterate through a field that is a collection of POJOs and validate each of 28 | * them. Inherit member POJO's error message. 29 | * @param collection the validatable POJO collection 30 | * @param name name of the field 31 | */ 32 | void validateCollection(final Collection collection, 33 | final String name) { 34 | Iterator iterator = collection.iterator(); 35 | int i = 0; 36 | while (iterator.hasNext()) { 37 | try { 38 | iterator.next().validate(); 39 | } catch (final IllegalArgumentException e) { 40 | throw new IllegalArgumentException("Invalid " + name + 41 | " at index " + i, e); 42 | } 43 | i++; 44 | } 45 | } 46 | 47 | /** 48 | * Validate a single POJO validate 49 | * @param pojo The POJO object to validate 50 | * @param name name of the field 51 | */ 52 | void validatePOJO(final T pojo, final String name) { 53 | try { 54 | pojo.validate(); 55 | } catch (final IllegalArgumentException e) { 56 | throw new IllegalArgumentException("Invalid " + name, e); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /test/core/TestSaltScannerSalted.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import java.util.ArrayList; 16 | import java.util.TreeMap; 17 | 18 | import net.opentsdb.query.filter.TagVFilter; 19 | import net.opentsdb.uid.UniqueId; 20 | 21 | import org.hbase.async.Scanner; 22 | import org.junit.Before; 23 | import org.junit.runner.RunWith; 24 | import org.powermock.api.mockito.PowerMockito; 25 | import org.powermock.core.classloader.annotations.PowerMockIgnore; 26 | import org.powermock.core.classloader.annotations.PrepareForTest; 27 | import org.powermock.modules.junit4.PowerMockRunner; 28 | 29 | @RunWith(PowerMockRunner.class) 30 | @PowerMockIgnore({"javax.management.*", "javax.xml.*", 31 | "ch.qos.*", "org.slf4j.*", 32 | "com.sum.*", "org.xml.*"}) 33 | @PrepareForTest({ TSDB.class, Scanner.class, SaltScanner.class, Span.class, 34 | Const.class, UniqueId.class }) 35 | public class TestSaltScannerSalted extends TestSaltScanner { 36 | 37 | @Before 38 | public void beforeLocal() throws Exception { 39 | PowerMockito.mockStatic(Const.class); 40 | PowerMockito.when(Const.SALT_WIDTH()).thenReturn(1); 41 | PowerMockito.when(Const.SALT_BUCKETS()).thenReturn(2); 42 | 43 | KEY_A = getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_STRING); 44 | KEY_B = getRowKey(METRIC_STRING, 1356998400, TAGK_STRING, TAGV_B_STRING); 45 | KEY_C = getRowKey(METRIC_STRING, 1359680400, TAGK_STRING, TAGV_STRING); 46 | 47 | filters = new ArrayList(); 48 | 49 | spans = new TreeMap(new RowKey.SaltCmp()); 50 | setupMockScanners(true); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/tsd/StaticFileRpc.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import java.io.IOException; 16 | 17 | import net.opentsdb.core.TSDB; 18 | import org.jboss.netty.handler.codec.http.HttpMethod; 19 | 20 | /** Implements the "/s" endpoint to serve static files. */ 21 | final class StaticFileRpc implements HttpRpc { 22 | 23 | /** 24 | * Constructor. 25 | */ 26 | public StaticFileRpc() { 27 | } 28 | 29 | public void execute(final TSDB tsdb, final HttpQuery query) 30 | throws BadRequestException, IOException { 31 | 32 | // only accept GET 33 | RpcUtil.allowedMethods(query.method(), HttpMethod.GET.getName()); 34 | 35 | final String uri = query.request().getUri(); 36 | if ("/favicon.ico".equals(uri)) { 37 | query.sendFile(tsdb.getConfig().getDirectoryName("tsd.http.staticroot") 38 | + "/favicon.ico", 31536000 /*=1yr*/); 39 | return; 40 | } 41 | 42 | if (uri.length() < 3) { // Must be at least 3 because of the "/s/". 43 | throw new BadRequestException("URI too short " + uri + ""); 44 | } 45 | // Cheap security check to avoid directory traversal attacks. 46 | // TODO(tsuna): This is certainly not sufficient. 47 | if (uri.indexOf("..", 3) > 0) { 48 | throw new BadRequestException("Malformed URI " + uri + ""); 49 | } 50 | 51 | final int questionmark = uri.indexOf('?', 3); 52 | final int pathend = questionmark > 0 ? questionmark : uri.length(); 53 | query.sendFile(tsdb.getConfig().getDirectoryName("tsd.http.staticroot") 54 | + uri.substring(2, pathend), // Drop the "/s" 55 | uri.contains("nocache") ? 0 : 31536000 /*=1yr*/); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/auth/Roles.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | 14 | package net.opentsdb.auth; 15 | 16 | import java.util.*; 17 | 18 | /** 19 | * Suggested standard Roles for OpenTSDB Users 20 | * 21 | * @author jonathan.creasy 22 | * @since 2.4.0 23 | */ 24 | @SuppressWarnings({"WeakerAccess", "unused"}) 25 | public class Roles { 26 | final static EnumSet ADMINISTRATOR = EnumSet.allOf(Permissions.class); 27 | final static EnumSet PUTONLY = EnumSet.of(Permissions.HTTP_PUT, Permissions.TELNET_PUT); 28 | final static EnumSet WRITER = EnumSet.of(Permissions.HTTP_PUT, Permissions.TELNET_PUT, Permissions.CREATE_TAGV); 29 | final static EnumSet READER = EnumSet.of(Permissions.HTTP_QUERY); 30 | final static EnumSet CREATOR = EnumSet.of(Permissions.CREATE_METRIC, Permissions.CREATE_TAGK, Permissions.CREATE_TAGV); 31 | final static EnumSet GUEST = EnumSet.noneOf(Permissions.class); 32 | 33 | @SuppressWarnings("Convert2Diamond") 34 | private final Set> grantedPermissions = new HashSet>(); 35 | 36 | public Roles() { 37 | this.grantedPermissions.add(GUEST); 38 | } 39 | 40 | public Roles(final EnumSet permissions) { 41 | this.grantedPermissions.add(permissions); 42 | } 43 | 44 | public void grantPermissions(final EnumSet permissions) { 45 | grantedPermissions.add(permissions); 46 | } 47 | 48 | public Boolean hasPermission(final Permissions permission) { 49 | for (EnumSet permissions : this.grantedPermissions) { 50 | if (permissions.contains(permission)) { 51 | return true; 52 | } 53 | } 54 | return false; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/core/SimpleHistogramDecoder.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import java.util.Arrays; 16 | 17 | /** 18 | *

19 | * Histogram decoder for Simple style histograms. 20 | *

21 | *

22 | * It currently checks the first byte of the encoded data and decide the type of 23 | * the histogram. Then it uses that histogram types builtin factory method to 24 | * create the instance. 25 | *

26 | *

27 | * This class is thread safe as it has no state. 28 | *

29 | * @since 2.4 30 | */ 31 | public class SimpleHistogramDecoder extends HistogramDataPointCodec { 32 | @Override 33 | public Histogram decode(final byte[] raw_data, 34 | final boolean includes_type) { 35 | if (raw_data == null) { 36 | throw new IllegalArgumentException("The data array cannot be null."); 37 | } 38 | if (includes_type && raw_data.length < 1) { 39 | throw new IllegalArgumentException("The data array cannot be empty."); 40 | } 41 | if (includes_type && (int) raw_data[0] != id) { 42 | throw new IllegalArgumentException("Data ID " + (int) raw_data[0] 43 | + " did not match the codec ID " + id); 44 | } 45 | final Histogram histogram = new SimpleHistogram(id); 46 | histogram.fromHistogram(raw_data, includes_type); 47 | return histogram; 48 | } 49 | 50 | @Override 51 | public byte[] encode(final Histogram data_point, 52 | final boolean include_id) { 53 | if (!(data_point instanceof SimpleHistogram)) { 54 | throw new IllegalArgumentException("The given histogram is not a " 55 | + "SimpleHistogram: " + data_point.getClass()); 56 | } 57 | return data_point.histogram(include_id); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/core/DataPoint.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | /** 16 | * Represents a single data point. 17 | *

18 | * Implementations of this interface aren't expected to be synchronized. 19 | */ 20 | public interface DataPoint { 21 | 22 | /** 23 | * Returns the timestamp (in milliseconds) associated with this data point. 24 | * @return A strictly positive, 32 bit integer. 25 | */ 26 | long timestamp(); 27 | 28 | /** 29 | * Tells whether or not the this data point is a value of integer type. 30 | * @return {@code true} if the {@code i}th value is of integer type, 31 | * {@code false} if it's of doubleing point type. 32 | */ 33 | boolean isInteger(); 34 | 35 | /** 36 | * Returns the value of the this data point as a {@code long}. 37 | * @throws ClassCastException if the {@code isInteger() == false}. 38 | */ 39 | long longValue(); 40 | 41 | /** 42 | * Returns the value of the this data point as a {@code double}. 43 | * @throws ClassCastException if the {@code isInteger() == true}. 44 | */ 45 | double doubleValue(); 46 | 47 | /** 48 | * Returns the value of the this data point as a {@code double}, even if 49 | * it's a {@code long}. 50 | * @return When {@code isInteger() == false}, this method returns the same 51 | * thing as {@link #doubleValue}. Otherwise, it returns the same thing as 52 | * {@link #longValue}'s return value casted to a {@code double}. 53 | */ 54 | double toDouble(); 55 | 56 | /** 57 | * Represents the number of real values behind this data point when referring 58 | * to a pre-aggregated and/or rolled up value. 59 | * @return The number of real values represented in this data point. Usually 60 | * just 1 for raw values. 61 | */ 62 | long valueCount(); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2011-2024 The OpenTSDB Authors. 2 | # 3 | # This library is free software: you can redistribute it and/or modify it 4 | # under the terms of the GNU Lesser General Public License as published 5 | # by the Free Software Foundation, either version 2.1 of the License, or 6 | # (at your option) any later version. 7 | # 8 | # This library is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU Lesser General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU Lesser General Public License 14 | # along with this library. If not, see . 15 | 16 | # Semantic Versioning (see http://semver.org/). 17 | AC_INIT([opentsdb], [2.5.0-RC1], [opentsdb@googlegroups.com]) 18 | AC_CONFIG_AUX_DIR([build-aux]) 19 | AM_INIT_AUTOMAKE([foreign]) 20 | 21 | AC_CONFIG_FILES([ 22 | Makefile 23 | ]) 24 | AC_CONFIG_FILES([opentsdb.spec]) 25 | AC_CONFIG_FILES([build-aux/fetchdep.sh], [chmod +x build-aux/fetchdep.sh]) 26 | 27 | AC_ARG_WITH([bigtable], 28 | [AS_HELP_STRING([--with-bigtable], [Enable Google's Bigtable backend])], 29 | [with_bigtable=yes], 30 | [with_bigtable=no]) 31 | 32 | AS_IF([test "x$with_bigtable" = "xyes"], 33 | [AM_CONDITIONAL(BIGTABLE, true)], 34 | [AM_CONDITIONAL(BIGTABLE, false)] 35 | ) 36 | 37 | AC_ARG_WITH([cassandra], 38 | [AS_HELP_STRING([--with-cassandra], [Enable Cassandra backend])], 39 | [with_cassandra=yes], 40 | [with_cassandra=no]) 41 | 42 | AS_IF([test "x$with_cassandra" = "xyes"], 43 | [AM_CONDITIONAL(CASSANDRA, true)], 44 | [AM_CONDITIONAL(CASSANDRA, false)] 45 | ) 46 | 47 | TSDB_FIND_PROG([md5], [md5sum md5 gmd5sum digest]) 48 | if test x`basename "$MD5"` = x'digest'; then 49 | MD5='digest -a md5' 50 | fi 51 | TSDB_FIND_PROG([java]) 52 | TSDB_FIND_PROG([javac]) 53 | TSDB_FIND_PROG([jar]) 54 | # Mac OS does not have gnuplot. Falls back to /usr/bin/true to make gnuplot 55 | # optional. 56 | TSDB_FIND_PROG([gnuplot], [true]) 57 | AC_PATH_PROG([JAVADOC], [javadoc], []) 58 | AM_MISSING_PROG([JAVADOC], [javadoc]) 59 | 60 | # Find a tool to download 3rd party dependencies. 61 | AC_PATH_PROG([WGET], [wget]) 62 | AC_PATH_PROG([CURL], [curl]) 63 | # Make sure we have at least one. 64 | if test -z "$WGET$CURL"; then 65 | AC_MSG_ERROR([cannot find a tool to download an URL]) 66 | fi 67 | 68 | AC_SUBST([staticdir], ['${pkgdatadir}/static']) 69 | 70 | AC_OUTPUT 71 | -------------------------------------------------------------------------------- /src/create_table.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Small script to setup the HBase tables used by OpenTSDB. 3 | 4 | test -n "$HBASE_HOME" || { 5 | echo >&2 'The environment variable HBASE_HOME must be set' 6 | exit 1 7 | } 8 | test -d "$HBASE_HOME" || { 9 | echo >&2 "No such directory: HBASE_HOME=$HBASE_HOME" 10 | exit 1 11 | } 12 | 13 | TSDB_TABLE=${TSDB_TABLE-'tsdb'} 14 | UID_TABLE=${UID_TABLE-'tsdb-uid'} 15 | TREE_TABLE=${TREE_TABLE-'tsdb-tree'} 16 | META_TABLE=${META_TABLE-'tsdb-meta'} 17 | BLOOMFILTER=${BLOOMFILTER-'ROW'} 18 | # LZO requires lzo2 64bit to be installed + the hadoop-gpl-compression jar. 19 | COMPRESSION=${COMPRESSION-'LZO'} 20 | # All compression codec names are upper case (NONE, LZO, SNAPPY, etc). 21 | COMPRESSION=`echo "$COMPRESSION" | tr a-z A-Z` 22 | # DIFF encoding is very useful for OpenTSDB's case that many small KVs and common prefix. 23 | # This can save a lot of storage space. 24 | DATA_BLOCK_ENCODING=${DATA_BLOCK_ENCODING-'DIFF'} 25 | DATA_BLOCK_ENCODING=`echo "$DATA_BLOCK_ENCODING" | tr a-z A-Z` 26 | TSDB_TTL=${TSDB_TTL-'FOREVER'} 27 | 28 | case $COMPRESSION in 29 | (NONE|LZO|GZIP|SNAPPY) :;; # Known good. 30 | (*) 31 | echo >&2 "warning: compression codec '$COMPRESSION' might not be supported." 32 | ;; 33 | esac 34 | 35 | case $DATA_BLOCK_ENCODING in 36 | (NONE|PREFIX|DIFF|FAST_DIFF|ROW_INDEX_V1) :;; # Know good 37 | (*) 38 | echo >&2 "warning: encoding '$DATA_BLOCK_ENCODING' might not be supported." 39 | ;; 40 | esac 41 | 42 | # HBase scripts also use a variable named `HBASE_HOME', and having this 43 | # variable in the environment with a value somewhat different from what 44 | # they expect can confuse them in some cases. So rename the variable. 45 | hbh=$HBASE_HOME 46 | unset HBASE_HOME 47 | exec "$hbh/bin/hbase" shell < 'id', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'}, 50 | {NAME => 'name', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'} 51 | 52 | create '$TSDB_TABLE', 53 | {NAME => 't', VERSIONS => 1, COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING', TTL => '$TSDB_TTL'} 54 | 55 | create '$TREE_TABLE', 56 | {NAME => 't', VERSIONS => 1, COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'} 57 | 58 | create '$META_TABLE', 59 | {NAME => 'name', COMPRESSION => '$COMPRESSION', BLOOMFILTER => '$BLOOMFILTER', DATA_BLOCK_ENCODING => '$DATA_BLOCK_ENCODING'} 60 | EOF 61 | -------------------------------------------------------------------------------- /test/utils/TestByteSet.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.utils; 14 | 15 | import static org.junit.Assert.assertArrayEquals; 16 | import static org.junit.Assert.assertEquals; 17 | import static org.junit.Assert.assertFalse; 18 | import static org.junit.Assert.assertNotNull; 19 | import static org.junit.Assert.assertTrue; 20 | 21 | import java.util.Iterator; 22 | 23 | import org.junit.Test; 24 | 25 | public class TestByteSet { 26 | 27 | private static final byte[] V1 = new byte[] { 0, 0, 1 }; 28 | private static final byte[] V2 = new byte[] { 0, 0, 2 }; 29 | private static final byte[] V3 = new byte[] { 0, 0, 3 }; 30 | private static final byte[] V4 = new byte[] { 0, 0, 4 }; 31 | 32 | @Test 33 | public void ctor() { 34 | final ByteSet set = new ByteSet(); 35 | assertNotNull(set); 36 | assertEquals(0, set.size()); 37 | assertTrue(set.isEmpty()); 38 | } 39 | 40 | @Test 41 | public void goodOperations() { 42 | final ByteSet set = new ByteSet(); 43 | set.add(V3); 44 | set.add(V2); 45 | set.add(V1); 46 | 47 | assertEquals(3, set.size()); 48 | assertFalse(set.isEmpty()); 49 | 50 | // should come out in order 51 | final Iterator it = set.iterator(); 52 | assertArrayEquals(V1, it.next()); 53 | assertArrayEquals(V2, it.next()); 54 | assertArrayEquals(V3, it.next()); 55 | assertFalse(it.hasNext()); 56 | 57 | assertEquals("[[0, 0, 1],[0, 0, 2],[0, 0, 3]]", set.toString()); 58 | 59 | assertTrue(set.contains(V1)); 60 | assertFalse(set.contains(V4)); 61 | 62 | assertTrue(set.remove(V1)); 63 | assertFalse(set.contains(V1)); 64 | assertFalse(set.remove(V4)); 65 | 66 | set.clear(); 67 | assertFalse(set.contains(V2)); 68 | assertFalse(set.contains(V3)); 69 | assertTrue(set.isEmpty()); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /test/search/TestSearchQuery.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2013 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.search; 14 | 15 | import static org.junit.Assert.assertEquals; 16 | import net.opentsdb.search.SearchQuery.SearchType; 17 | 18 | import org.junit.Test; 19 | import org.junit.runner.RunWith; 20 | import org.powermock.modules.junit4.PowerMockRunner; 21 | 22 | @RunWith(PowerMockRunner.class) 23 | public final class TestSearchQuery { 24 | 25 | @Test 26 | public void parseSearchTypeTSMeta() throws Exception { 27 | assertEquals(SearchType.TSMETA, SearchQuery.parseSearchType("tsmeta")); 28 | } 29 | 30 | @Test 31 | public void parseSearchTypeTSMetaSummary() throws Exception { 32 | assertEquals(SearchType.TSMETA_SUMMARY, 33 | SearchQuery.parseSearchType("TSMeta_Summary")); 34 | } 35 | 36 | @Test 37 | public void parseSearchTypeTSUIDs() throws Exception { 38 | assertEquals(SearchType.TSUIDS, SearchQuery.parseSearchType("tsuids")); 39 | } 40 | 41 | @Test 42 | public void parseSearchTypeUIDMeta() throws Exception { 43 | assertEquals(SearchType.UIDMETA, SearchQuery.parseSearchType("UIDMeta")); 44 | } 45 | 46 | @Test 47 | public void parseSearchTypeAnnotation() throws Exception { 48 | assertEquals(SearchType.ANNOTATION, 49 | SearchQuery.parseSearchType("Annotation")); 50 | } 51 | 52 | @Test (expected = IllegalArgumentException.class) 53 | public void parseSearchTypeNull() throws Exception { 54 | SearchQuery.parseSearchType(null); 55 | } 56 | 57 | @Test (expected = IllegalArgumentException.class) 58 | public void parseSearchTypeEmtpy() throws Exception { 59 | SearchQuery.parseSearchType(""); 60 | } 61 | 62 | @Test (expected = IllegalArgumentException.class) 63 | public void parseSearchTypeInvalid() throws Exception { 64 | SearchQuery.parseSearchType("NotAType"); 65 | } 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/core/iHistogramRowSeq.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2016-2017 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import java.util.List; 16 | 17 | /** 18 | * Clone of the {@link iRowSeq} interface but for histograms. 19 | * 20 | * @since 2.4 21 | */ 22 | public interface iHistogramRowSeq extends HistogramDataPoints { 23 | 24 | /** 25 | * Sets the initial column in the sequence. The key cannot be empty. 26 | * @param key The row key. 27 | * @param row A non-null list of histogram points. 28 | * @throws IllegalStateException if {@link #setRow(byte[], List)} or 29 | * {@link #addRow(List)} has already been called. 30 | */ 31 | public void setRow(final byte[] key, final List row); 32 | 33 | /** 34 | * Adds a column in the proper sequence in the row. Must be called after 35 | * {@link #setRow(byte[], List)} has been called. 36 | * @param row A non-null list of histogram points. 37 | * @throws IllegalStateException if {@link #setRow(byte[], List)} has not been 38 | * called first. 39 | */ 40 | public void addRow(final List row); 41 | 42 | /** 43 | * Returns the row key this sequence represents. May be null if 44 | * {@link #setRow(byte[], List)} has not been called. 45 | * @return The row key for this sequence. 46 | */ 47 | public byte[] key(); 48 | 49 | /** 50 | * Returns the base time for the row in Unix epoch seconds. 51 | * @return The base time for the row. 52 | * @throws NullPointerException if {@link #setRow(byte[], List)} has not been 53 | * called. 54 | */ 55 | public long baseTime(); 56 | 57 | /** @return an internal iterator for this row sequence. */ 58 | public Iterator internalIterator(); 59 | 60 | /** 61 | * An interface for an iterator that all row sequences must implement. 62 | */ 63 | public interface Iterator extends HistogramSeekableView, HistogramDataPoint { 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/core/iRowSeq.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.hbase.async.KeyValue; 16 | 17 | /** 18 | * An interface that defines methods implemented by row sequence implementations 19 | * that represent a row of data in storage. 20 | * @since 2.4 21 | */ 22 | public interface iRowSeq extends DataPoints { 23 | 24 | /** 25 | * Sets the initial column in the sequence. The row must be empty and this 26 | * must be called before {@link #addRow(KeyValue)}. 27 | * @param row A non-null KeyValue representing a column in the row. 28 | * @throws IllegalStateException if {@link #setRow(KeyValue)} or 29 | * {@link #addRow(KeyValue)} has already been called. 30 | */ 31 | public void setRow(final KeyValue row); 32 | 33 | /** 34 | * Adds a column in the proper sequence in the row. Must be called after 35 | * {@link #setRow(KeyValue)} has been called. 36 | * @param row A non-null KeyValue representing a column in the row. 37 | * @throws IllegalStateException if {@link #setRow(KeyValue)} has not been 38 | * called first. 39 | */ 40 | public void addRow(final KeyValue row); 41 | 42 | /** 43 | * Returns the row key this sequence represents. May be null if 44 | * {@link #setRow(KeyValue)} has not been called. 45 | * @return The row key for this sequence. 46 | */ 47 | public byte[] key(); 48 | 49 | /** 50 | * Returns the base time for the row in Unix epoch seconds. 51 | * @return The base time for the row. 52 | * @throws NullPointerException if {@link #setRow(KeyValue)} has not been 53 | * called. 54 | */ 55 | public long baseTime(); 56 | 57 | /** @return an internal iterator for this row sequence. */ 58 | public Iterator internalIterator(); 59 | 60 | /** 61 | * An interface for an iterator that all row sequences must implement. 62 | */ 63 | public interface Iterator extends SeekableView, DataPoint { 64 | 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/core/QueryException.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.jboss.netty.handler.codec.http.HttpResponseStatus; 16 | 17 | /** 18 | * An exception thrown during query execution such as a timeout or other 19 | * type of error. 20 | * @since 2.2 21 | */ 22 | public final class QueryException extends RuntimeException { 23 | 24 | /** An optional, detailed error message */ 25 | private final String details; 26 | 27 | /** The HTTP status code to return to the user */ 28 | private final HttpResponseStatus status; 29 | 30 | /** 31 | * Default ctor 32 | * @param msg Message describing the problem. 33 | */ 34 | public QueryException(final String msg) { 35 | super(msg); 36 | status = HttpResponseStatus.BAD_REQUEST; 37 | details = msg; 38 | } 39 | 40 | /** 41 | * Ctor setting the status 42 | * @param status The status code to respond with for HTTP requests 43 | * @param msg Message describing the problem. 44 | */ 45 | public QueryException(final HttpResponseStatus status, final String msg) { 46 | super(msg); 47 | this.status = status; 48 | details = msg; 49 | } 50 | 51 | /** 52 | * Ctor setting status and the messages 53 | * @param status The status code to respond with for HTTP requests 54 | * @param msg Message describing the problem. 55 | * @param details Extra details for the error 56 | */ 57 | public QueryException(final HttpResponseStatus status, final String msg, 58 | final String details) { 59 | super(msg); 60 | this.status = status; 61 | this.details = details; 62 | } 63 | 64 | /** @return the HTTP status code */ 65 | public final HttpResponseStatus getStatus() { 66 | return this.status; 67 | } 68 | 69 | /** @return the details, may be an empty string */ 70 | public final String getDetails() { 71 | return this.details; 72 | } 73 | 74 | private static final long serialVersionUID = 9040020770546069974L; 75 | } 76 | -------------------------------------------------------------------------------- /test/utils/TestExceptions.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.utils; 14 | 15 | import static org.junit.Assert.assertSame; 16 | import static org.junit.Assert.fail; 17 | 18 | import java.util.ArrayList; 19 | 20 | import org.junit.Before; 21 | import org.junit.Test; 22 | 23 | import com.stumbleupon.async.Callback; 24 | import com.stumbleupon.async.Deferred; 25 | import com.stumbleupon.async.DeferredGroupException; 26 | 27 | public class TestExceptions { 28 | private ArrayList> deferreds; 29 | 30 | @Before 31 | public void before() { 32 | deferreds = new ArrayList>(1); 33 | } 34 | 35 | @Test 36 | public void oneLevel() throws Exception { 37 | final RuntimeException ex = new RuntimeException("Boo!"); 38 | deferreds.add(Deferred.fromError(ex)); 39 | try { 40 | Deferred.group(deferreds).join(); 41 | fail("Expected a DeferredGroupException"); 42 | } catch (DeferredGroupException dge) { 43 | assertSame(ex, Exceptions.getCause(dge)); 44 | } 45 | } 46 | 47 | @Test 48 | public void nested() throws Exception { 49 | final RuntimeException ex = new RuntimeException("Boo!"); 50 | deferreds.add(Deferred.fromError(ex)); 51 | 52 | final ArrayList> deferreds2 = 53 | new ArrayList>(1); 54 | deferreds2.add(Deferred.fromResult(null)); 55 | 56 | class LOne implements 57 | Callback>, ArrayList> { 58 | @Override 59 | public Deferred> call(final ArrayList piff) 60 | throws Exception { 61 | return Deferred.group(deferreds); 62 | } 63 | } 64 | 65 | try { 66 | Deferred.group(deferreds2).addCallbackDeferring(new LOne()).join(); 67 | fail("Expected a DeferredGroupException"); 68 | } catch (DeferredGroupException dge) { 69 | assertSame(ex, Exceptions.getCause(dge)); 70 | } 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /test/tsd/DummyRTPublisher.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2013 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import java.util.Map; 16 | 17 | import net.opentsdb.core.TSDB; 18 | import net.opentsdb.meta.Annotation; 19 | import net.opentsdb.stats.StatsCollector; 20 | 21 | import com.stumbleupon.async.Deferred; 22 | 23 | public final class DummyRTPublisher extends RTPublisher { 24 | 25 | @Override 26 | public void initialize(TSDB tsdb) { 27 | if (tsdb == null) { 28 | throw new IllegalArgumentException("The TSDB object was null"); 29 | } 30 | // some dummy configs to check to throw exceptions 31 | if (!tsdb.getConfig().hasProperty("tsd.rtpublisher.DummyRTPublisher.hosts")) { 32 | throw new IllegalArgumentException("Missing hosts config"); 33 | } 34 | if (tsdb.getConfig().getString("tsd.rtpublisher.DummyRTPublisher.hosts") 35 | .isEmpty()) { 36 | throw new IllegalArgumentException("Empty Hosts config"); 37 | } 38 | // throw an NFE for fun 39 | tsdb.getConfig().getInt("tsd.rtpublisher.DummyRTPublisher.port"); 40 | } 41 | 42 | @Override 43 | public Deferred shutdown() { 44 | return Deferred.fromResult(new Object()); 45 | } 46 | 47 | @Override 48 | public String version() { 49 | return "2.0.0"; 50 | } 51 | 52 | @Override 53 | public void collectStats(StatsCollector collector) { 54 | collector.record("rtpublisher.dummy.writes", 1); 55 | } 56 | 57 | @Override 58 | public Deferred publishDataPoint(String metric, long timestamp, 59 | long value, Map tags, byte[] tsuid) { 60 | return Deferred.fromResult(new Object()); 61 | } 62 | 63 | @Override 64 | public Deferred publishDataPoint(String metric, long timestamp, 65 | double value, Map tags, byte[] tsuid) { 66 | return Deferred.fromResult(new Object()); 67 | } 68 | 69 | @Override 70 | public Deferred publishAnnotation(Annotation annotation) { 71 | return Deferred.fromResult(new Object()); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /tools/tsddrain.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # 3 | # This little script can be used to replace TSDs while performing prolonged 4 | # HBase or HDFS maintenances. It runs a simple, low-end TCP server to accept 5 | # all the data points from tcollectors and dump them to a bunch of files, one 6 | # per client IP address. These files can then later be batch-imported, once 7 | # HBase is back up. 8 | # 9 | # This file is part of OpenTSDB. 10 | # Copyright (C) 2013 The OpenTSDB Authors. 11 | # 12 | # This library is free software: you can redistribute it and/or modify it 13 | # under the terms of the GNU Lesser General Public License as published 14 | # by the Free Software Foundation; either version 2.1 of the License, or 15 | # (at your option) any later version. 16 | # 17 | # This library is distributed in the hope that it will be useful, 18 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 19 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 | # GNU Lesser General Public License for more details. 21 | # 22 | # You should have received a copy of the GNU Lesser General Public License 23 | # along with this library. If not, see . 24 | 25 | import os 26 | import socket 27 | import sys 28 | import SocketServer 29 | 30 | class ThreadedTCPServer(SocketServer.ThreadingMixIn, SocketServer.TCPServer): 31 | allow_reuse_address = True 32 | 33 | 34 | DRAINDIR = None 35 | 36 | class Handler(SocketServer.StreamRequestHandler): 37 | def handle(self): 38 | sys.stdout.write("O") 39 | sys.stdout.flush() 40 | out = open(os.path.join(DRAINDIR, self.client_address[0]), "a") 41 | n = 0 42 | while True: 43 | req = self.rfile.readline() 44 | if not req: 45 | break 46 | if req == "version\n": 47 | self.wfile.write("drain.py\n") 48 | sys.stdout.write("V") 49 | sys.stdout.flush() 50 | continue 51 | if not req.startswith("put "): 52 | sys.stdout.write("!") 53 | sys.stdout.flush() 54 | continue 55 | out.write(req[4:]) 56 | out.flush() 57 | if n % 100 == 0: 58 | sys.stdout.write(".") 59 | sys.stdout.flush() 60 | n += 1 61 | out.close() 62 | sys.stdout.write("X") 63 | sys.stdout.flush() 64 | 65 | 66 | def main(args): 67 | if len(args) != 3: 68 | sys.stderr.write("Usage: %s " % args[0]) 69 | return 1 70 | global DRAINDIR 71 | port = int(args[1]) 72 | DRAINDIR = args[2] 73 | if not os.path.isdir(DRAINDIR): 74 | os.makedirs(DRAINDIR) 75 | server = ThreadedTCPServer(("0.0.0.0", port), Handler) 76 | try: 77 | print ("Use Ctrl-C to stop me.") 78 | server.serve_forever() 79 | except KeyboardInterrupt: 80 | pass 81 | 82 | 83 | if __name__ == "__main__": 84 | sys.exit(main(sys.argv)) 85 | -------------------------------------------------------------------------------- /test/query/pojo/TestJoin.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2015 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.query.pojo; 14 | 15 | import static org.junit.Assert.assertEquals; 16 | import static org.junit.Assert.assertTrue; 17 | import net.opentsdb.query.expression.VariableIterator.SetOperator; 18 | import net.opentsdb.utils.JSON; 19 | 20 | import org.junit.Test; 21 | 22 | public class TestJoin { 23 | 24 | @Test 25 | public void deserialize() throws Exception { 26 | final String json = "{\"operator\":\"union\"}"; 27 | final Join join = Join.Builder().setOperator(SetOperator.UNION).build(); 28 | final Join deserialized = JSON.parseToObject(json, Join.class); 29 | assertEquals(join, deserialized); 30 | } 31 | 32 | @Test 33 | public void serialize() throws Exception { 34 | final Join join = Join.Builder().setOperator(SetOperator.UNION).build(); 35 | final String json = JSON.serializeToString(join); 36 | assertTrue(json.contains("\"operator\":\"union\"")); 37 | } 38 | 39 | @Test(expected = IllegalArgumentException.class) 40 | public void validationErrorWhenOperatorIsNull() throws Exception { 41 | final String json = "{\"operator\":null}"; 42 | final Join join = JSON.parseToObject(json, Join.class); 43 | join.validate(); 44 | } 45 | 46 | @Test(expected = IllegalArgumentException.class) 47 | public void validationErrorWhenOperatorIsEmpty() throws Exception { 48 | final String json = "{\"operator\":\"\"}"; 49 | final Join join = JSON.parseToObject(json, Join.class); 50 | join.validate(); 51 | } 52 | 53 | @Test(expected = IllegalArgumentException.class) 54 | public void validationErrorWhenOperatorIsInvalid() throws Exception { 55 | final String json = "{\"operator\":\"nosuchop\"}"; 56 | final Join join = JSON.parseToObject(json, Join.class); 57 | join.validate(); 58 | } 59 | 60 | @Test 61 | public void unknownShouldBeIgnored() throws Exception { 62 | String json = "{\"operator\":\"intersection\",\"unknown\":\"yo\"}"; 63 | JSON.parseToObject(json, Filter.class); 64 | // pass if no unexpected exception 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/core/AbstractQuery.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2010-2012 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.core; 14 | 15 | import org.hbase.async.HBaseException; 16 | 17 | public abstract class AbstractQuery implements Query { 18 | /** 19 | * Runs this query. 20 | * 21 | * @return The data points matched by this query. 22 | *

23 | * Each element in the non-{@code null} but possibly empty array returned 24 | * corresponds to one time series for which some data points have been 25 | * matched by the query. 26 | * @throws HBaseException if there was a problem communicating with HBase to 27 | * perform the search. 28 | */ 29 | @Override 30 | public DataPoints[] run() throws HBaseException { 31 | try { 32 | return runAsync().joinUninterruptibly(); 33 | } catch (RuntimeException e) { 34 | throw e; 35 | } catch (Exception e) { 36 | throw new RuntimeException("Should never be here", e); 37 | } 38 | } 39 | 40 | /** 41 | * Runs this query. 42 | * 43 | * @return The data points matched by this query and applied with percentile calculation 44 | *

45 | * Each element in the non-{@code null} but possibly empty array returned 46 | * corresponds to one time series for which some data points have been 47 | * matched by the query. 48 | * @throws HBaseException if there was a problem communicating with HBase to 49 | * perform the search. 50 | * @throws IllegalStateException if the query is not a histogram query 51 | */ 52 | @Override 53 | public DataPoints[] runHistogram() throws HBaseException { 54 | if (!isHistogramQuery()) { 55 | throw new RuntimeException("Should never be here"); 56 | } 57 | 58 | try { 59 | return runHistogramAsync().joinUninterruptibly(); 60 | } catch (RuntimeException e) { 61 | throw e; 62 | } catch (Exception e) { 63 | throw new RuntimeException("Should never be here", e); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/uid/FailedToAssignUniqueIdException.java: -------------------------------------------------------------------------------- 1 | package net.opentsdb.uid; 2 | 3 | /** 4 | * Thrown when we failed to assign an ID to a string such as a metric, tagk 5 | * or tag v. 6 | * @see UniqueId 7 | */ 8 | public final class FailedToAssignUniqueIdException extends RuntimeException { 9 | /** The 'kind' of the table. */ 10 | private final String kind; 11 | /** The name of the object attempting to be assigned */ 12 | private final String name; 13 | /** How many attempts were made to assign the ID */ 14 | private final int attempts; 15 | 16 | /** 17 | * CTor 18 | * @param kind The kind of object that couldn't be assigned 19 | * @param name The name of the object that couldn't be assigned 20 | * @param attempts How many attempts were made to assign 21 | */ 22 | public FailedToAssignUniqueIdException(final String kind, final String name, 23 | final int attempts) { 24 | super("Failed to assign random ID for kind='" + kind + "' name='" + 25 | name + "' after " + attempts + " attempts"); 26 | this.kind = kind; 27 | this.name = name; 28 | this.attempts = attempts; 29 | } 30 | 31 | /** 32 | * CTor 33 | * @param kind The kind of object that couldn't be assigned 34 | * @param name The name of the object that couldn't be assigned 35 | * @param attempts How many attempts were made to assign 36 | * @param msg A message to append 37 | * @since 2.3 38 | */ 39 | public FailedToAssignUniqueIdException(final String kind, final String name, 40 | final int attempts, final String msg) { 41 | super("Failed to assign ID for kind='" + kind + "' name='" + 42 | name + "' after " + attempts + " attempts due to: " + msg); 43 | this.kind = kind; 44 | this.name = name; 45 | this.attempts = attempts; 46 | } 47 | 48 | /** 49 | * CTor 50 | * @param kind The kind of object that couldn't be assigned 51 | * @param name The name of the object that couldn't be assigned 52 | * @param attempts How many attempts were made to assign 53 | * @param ex An exception that caused assignment to fail 54 | */ 55 | public FailedToAssignUniqueIdException(final String kind, final String name, 56 | final int attempts, final Throwable ex) { 57 | super("Failed to assign random ID for kind='" + kind + "' name='" + 58 | name + "' after " + attempts + " attempts", ex); 59 | this.kind = kind; 60 | this.name = name; 61 | this.attempts = attempts; 62 | } 63 | 64 | 65 | /** @return Returns the kind of unique ID that couldn't be assigned. */ 66 | public String kind() { 67 | return kind; 68 | } 69 | 70 | /** @return Returns the name of the object that couldn't be assigned */ 71 | public String name() { 72 | return name; 73 | } 74 | 75 | /** @return Returns how many attempts were made to assign a UID */ 76 | public int attempts() { 77 | return attempts; 78 | } 79 | 80 | private static final long serialVersionUID = 399163221436118367L; 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/opentsdb.conf: -------------------------------------------------------------------------------- 1 | # --------- NETWORK ---------- 2 | # The TCP port TSD should use for communications 3 | # *** REQUIRED *** 4 | tsd.network.port = 5 | 6 | # The IPv4 network address to bind to, defaults to all addresses 7 | # tsd.network.bind = 0.0.0.0 8 | 9 | # Disable Nagel's algorithm, default is True 10 | #tsd.network.tcp_no_delay = true 11 | 12 | # Determines whether or not to send keepalive packets to peers, default 13 | # is True 14 | #tsd.network.keep_alive = true 15 | 16 | # Determines if the same socket should be used for new connections, default 17 | # is True 18 | #tsd.network.reuse_address = true 19 | 20 | # Number of worker threads dedicated to Netty, defaults to # of CPUs * 2 21 | #tsd.network.worker_threads = 8 22 | 23 | # Whether or not to use NIO or tradditional blocking IO, defaults to True 24 | #tsd.network.async_io = true 25 | 26 | # ----------- HTTP ----------- 27 | # The location of static files for the HTTP GUI interface. 28 | # *** REQUIRED *** 29 | tsd.http.staticroot = 30 | 31 | # Where TSD should write it's cache files to 32 | # *** REQUIRED *** 33 | tsd.http.cachedir = 34 | 35 | # --------- CORE ---------- 36 | # Whether or not to automatically create UIDs for new metric types, default 37 | # is False 38 | #tsd.core.auto_create_metrics = false 39 | 40 | # Whether or not to enable the built-in UI Rpc Plugins, default 41 | # is True 42 | #tsd.core.enable_ui = true 43 | 44 | # Whether or not to enable the built-in API Rpc Plugins, default 45 | # is True 46 | #tsd.core.enable_api = true 47 | 48 | # --------- STORAGE ---------- 49 | # Whether or not to enable data compaction in HBase, default is True 50 | #tsd.storage.enable_compaction = true 51 | 52 | # How often, in milliseconds, to flush the data point queue to storage, 53 | # default is 1,000 54 | # tsd.storage.flush_interval = 1000 55 | 56 | # Max number of rows to be returned per Scanner round trip 57 | # tsd.storage.hbase.scanner.maxNumRows = 128 58 | 59 | # Name of the HBase table where data points are stored, default is "tsdb" 60 | #tsd.storage.hbase.data_table = tsdb 61 | 62 | # Name of the HBase table where UID information is stored, default is "tsdb-uid" 63 | #tsd.storage.hbase.uid_table = tsdb-uid 64 | 65 | # Path under which the znode for the -ROOT- region is located, default is "/hbase" 66 | #tsd.storage.hbase.zk_basedir = /hbase 67 | 68 | # A comma separated list of Zookeeper hosts to connect to, with or without 69 | # port specifiers, default is "localhost" 70 | #tsd.storage.hbase.zk_quorum = localhost 71 | 72 | # --------- COMPACTIONS --------------------------------- 73 | # Frequency at which compaction thread wakes up to flush stuff in seconds, default 10 74 | # tsd.storage.compaction.flush_interval = 10 75 | 76 | # Minimum rows attempted to compact at once, default 100 77 | # tsd.storage.compaction.min_flush_threshold = 100 78 | 79 | # Maximum number of rows, compacted concirrently, default 10000 80 | # tsd.storage.compaction.max_concurrent_flushes = 10000 81 | 82 | # Compaction flush speed multiplier, default 2 83 | # tsd.storage.compaction.flush_speed = 2 84 | -------------------------------------------------------------------------------- /test/tsd/TestHttpRpcPluginQuery.java: -------------------------------------------------------------------------------- 1 | // This file is part of OpenTSDB. 2 | // Copyright (C) 2011-2014 The OpenTSDB Authors. 3 | // 4 | // This program is free software: you can redistribute it and/or modify it 5 | // under the terms of the GNU Lesser General Public License as published by 6 | // the Free Software Foundation, either version 2.1 of the License, or (at your 7 | // option) any later version. This program is distributed in the hope that it 8 | // will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 9 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 | // General Public License for more details. You should have received a copy 11 | // of the GNU Lesser General Public License along with this program. If not, 12 | // see . 13 | package net.opentsdb.tsd; 14 | 15 | import static org.junit.Assert.assertEquals; 16 | import static org.mockito.Mockito.mock; 17 | 18 | import org.jboss.netty.channel.Channel; 19 | import org.jboss.netty.handler.codec.http.DefaultHttpRequest; 20 | import org.jboss.netty.handler.codec.http.HttpMethod; 21 | import org.jboss.netty.handler.codec.http.HttpRequest; 22 | import org.jboss.netty.handler.codec.http.HttpVersion; 23 | import org.junit.Before; 24 | import org.junit.Test; 25 | import org.junit.runner.RunWith; 26 | import org.powermock.core.classloader.annotations.PrepareForTest; 27 | import org.powermock.modules.junit4.PowerMockRunner; 28 | 29 | import net.opentsdb.core.TSDB; 30 | import net.opentsdb.utils.Config; 31 | 32 | @RunWith(PowerMockRunner.class) 33 | @PrepareForTest({TSDB.class, Config.class, HttpRpcPluginQuery.class}) 34 | public final class TestHttpRpcPluginQuery { 35 | private TSDB mockTsdb; 36 | private Channel mockChannel; 37 | 38 | @Before 39 | public void before() { 40 | mockTsdb = mock(TSDB.class); 41 | mockChannel = NettyMocks.fakeChannel(); 42 | } 43 | 44 | @Test 45 | public void getQueryBaseRoute() { 46 | assertEquals("test", makeQuery("/plugin/test/this/path").getQueryBaseRoute()); 47 | assertEquals("test", makeQuery("/plugin/test/").getQueryBaseRoute()); 48 | assertEquals("test", makeQuery("/plugin/test?some=else&this=that").getQueryBaseRoute()); 49 | } 50 | 51 | @Test(expected=BadRequestException.class) 52 | public void getQueryBaseRouteNoSlash() { 53 | makeQuery("plugin/test?some=else&this=that").getQueryBaseRoute(); 54 | } 55 | 56 | @Test(expected=BadRequestException.class) 57 | public void getQueryBaseRouteNoPluginBase() { 58 | makeQuery("/test?some=else&this=that").getQueryBaseRoute(); 59 | } 60 | 61 | @Test(expected=BadRequestException.class) 62 | public void getQueryBaseRouteNoPath() { 63 | makeQuery("/plugin?some=else&this=that").getQueryBaseRoute(); 64 | } 65 | 66 | private HttpRpcPluginQuery makeQuery(final String uriString) { 67 | HttpRequest req = new DefaultHttpRequest( 68 | HttpVersion.HTTP_1_1, 69 | HttpMethod.GET, 70 | uriString); 71 | return new HttpRpcPluginQuery(mockTsdb, req, mockChannel); 72 | } 73 | } --------------------------------------------------------------------------------