Search in sources :

Example 1 with TagVWildcardFilter

use of net.opentsdb.query.filter.TagVWildcardFilter in project opentsdb by OpenTSDB.

the class TestTsdbQuery method configureFromQueryWithFilter.

@Test
public void configureFromQueryWithFilter() throws Exception {
    setDataPointStorage();
    final TSQuery ts_query = getTSQuery();
    final List<TagVFilter> filters = new ArrayList<TagVFilter>(1);
    filters.add(new TagVWildcardFilter("host", "*imes"));
    ts_query.getQueries().get(0).setFilters(filters);
    ts_query.validateAndSetQuery();
    query = new TsdbQuery(tsdb);
    query.configureFromQuery(ts_query, 0).joinUninterruptibly();
    assertArrayEquals(METRIC_BYTES, ForTesting.getMetric(query));
    assertEquals(1, ForTesting.getFilters(query).size());
    assertNull(ForTesting.getGroupBys(query));
    assertEquals(1, ForTesting.getRowKeyLiterals(query).size());
    assertNull(ForTesting.getRowKeyLiterals(query).get(TAGV_BYTES));
    assertNotNull(ForTesting.getRateOptions(query));
}
Also used : TagVFilter(net.opentsdb.query.filter.TagVFilter) TagVWildcardFilter(net.opentsdb.query.filter.TagVWildcardFilter) ArrayList(java.util.ArrayList) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with TagVWildcardFilter

use of net.opentsdb.query.filter.TagVWildcardFilter in project opentsdb by OpenTSDB.

the class TestQueryRpc method parseQueryMTypeWGroupByWildcardExplicit.

@Test
public void parseQueryMTypeWGroupByWildcardExplicit() throws Exception {
    HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0{host=" + TagVWildcardFilter.FILTER_NAME + "(*quirm)}");
    TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
    TSSubQuery sub = tsq.getQueries().get(0);
    sub.validateAndSetQuery();
    assertEquals(1, sub.getFilters().size());
    assertTrue(sub.getFilters().get(0) instanceof TagVWildcardFilter);
}
Also used : TSQuery(net.opentsdb.core.TSQuery) TagVWildcardFilter(net.opentsdb.query.filter.TagVWildcardFilter) TSSubQuery(net.opentsdb.core.TSSubQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 3 with TagVWildcardFilter

use of net.opentsdb.query.filter.TagVWildcardFilter in project opentsdb by OpenTSDB.

the class TestQueryRpc method parseQueryMTypeWGroupByAndWildcardFilterSameTagK.

@Test
public void parseQueryMTypeWGroupByAndWildcardFilterSameTagK() throws Exception {
    HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0{host=quirm|tsort}" + "{host=wildcard(*quirm)}");
    TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
    TSSubQuery sub = tsq.getQueries().get(0);
    sub.validateAndSetQuery();
    assertTrue(sub.getFilters().get(0) instanceof TagVWildcardFilter);
    assertTrue(sub.getFilters().get(1) instanceof TagVLiteralOrFilter);
}
Also used : TSQuery(net.opentsdb.core.TSQuery) TagVWildcardFilter(net.opentsdb.query.filter.TagVWildcardFilter) TSSubQuery(net.opentsdb.core.TSSubQuery) TagVLiteralOrFilter(net.opentsdb.query.filter.TagVLiteralOrFilter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 4 with TagVWildcardFilter

use of net.opentsdb.query.filter.TagVWildcardFilter in project opentsdb by OpenTSDB.

the class TestQueryRpc method parseQueryMTypeWWildcardFilterImplicit.

@Test
public void parseQueryMTypeWWildcardFilterImplicit() throws Exception {
    HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0{}{host=*quirm}");
    TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
    TSSubQuery sub = tsq.getQueries().get(0);
    sub.validateAndSetQuery();
    assertEquals(1, sub.getFilters().size());
    assertTrue(sub.getFilters().get(0) instanceof TagVWildcardFilter);
}
Also used : TSQuery(net.opentsdb.core.TSQuery) TagVWildcardFilter(net.opentsdb.query.filter.TagVWildcardFilter) TSSubQuery(net.opentsdb.core.TSSubQuery) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 5 with TagVWildcardFilter

use of net.opentsdb.query.filter.TagVWildcardFilter in project opentsdb by OpenTSDB.

the class TestQueryRpc method parseQueryMTypeWGroupByAndWildcardFilterExplicit.

@Test
public void parseQueryMTypeWGroupByAndWildcardFilterExplicit() throws Exception {
    HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.0{colo=lga}{host=wildcard(*quirm)}");
    TSQuery tsq = (TSQuery) parseQuery.invoke(rpc, tsdb, query, expressions);
    TSSubQuery sub = tsq.getQueries().get(0);
    sub.validateAndSetQuery();
    assertTrue(sub.getFilters().get(0) instanceof TagVWildcardFilter);
    assertTrue(sub.getFilters().get(1) instanceof TagVLiteralOrFilter);
}
Also used : TSQuery(net.opentsdb.core.TSQuery) TagVWildcardFilter(net.opentsdb.query.filter.TagVWildcardFilter) TSSubQuery(net.opentsdb.core.TSSubQuery) TagVLiteralOrFilter(net.opentsdb.query.filter.TagVLiteralOrFilter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

TagVWildcardFilter (net.opentsdb.query.filter.TagVWildcardFilter)12 Test (org.junit.Test)12 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 TSQuery (net.opentsdb.core.TSQuery)7 TSSubQuery (net.opentsdb.core.TSSubQuery)7 ArrayList (java.util.ArrayList)5 TagVFilter (net.opentsdb.query.filter.TagVFilter)5 TagVLiteralOrFilter (net.opentsdb.query.filter.TagVLiteralOrFilter)3 HashMap (java.util.HashMap)2 TagVILiteralOrFilter (net.opentsdb.query.filter.TagVLiteralOrFilter.TagVILiteralOrFilter)1 TagVRegexFilter (net.opentsdb.query.filter.TagVRegexFilter)1 Matchers.anyString (org.mockito.Matchers.anyString)1