Search in sources :

Example 6 with DeferredGroupException

use of com.stumbleupon.async.DeferredGroupException in project opentsdb by OpenTSDB.

the class TsdbQuery method setTimeSeries.

@Override
public void setTimeSeries(final String metric, final Map<String, String> tags, final Aggregator function, final boolean rate, final RateOptions rate_options) throws NoSuchUniqueName {
    if (filters == null) {
        filters = new ArrayList<TagVFilter>(tags.size());
    }
    TagVFilter.tagsToFilters(tags, filters);
    try {
        for (final TagVFilter filter : this.filters) {
            filter.resolveTagkName(tsdb).join();
        }
    } catch (final InterruptedException e) {
        LOG.warn("Interrupted", e);
        Thread.currentThread().interrupt();
    } catch (final NoSuchUniqueName e) {
        throw e;
    } catch (final Exception e) {
        if (e instanceof DeferredGroupException) {
            // rollback to the actual case. The DGE missdirects
            Throwable ex = e.getCause();
            while (ex != null && ex instanceof DeferredGroupException) {
                ex = ex.getCause();
            }
            if (ex != null) {
                throw (RuntimeException) ex;
            }
        }
        LOG.error("Unexpected exception processing group bys", e);
        throw new RuntimeException(e);
    }
    findGroupBys();
    this.metric = tsdb.metrics.getId(metric);
    aggregator = function;
    this.rate = rate;
    this.rate_options = rate_options;
}
Also used : TagVFilter(net.opentsdb.query.filter.TagVFilter) DeferredGroupException(com.stumbleupon.async.DeferredGroupException) DeferredGroupException(com.stumbleupon.async.DeferredGroupException) HBaseException(org.hbase.async.HBaseException) NoSuchUniqueName(net.opentsdb.uid.NoSuchUniqueName)

Example 7 with DeferredGroupException

use of com.stumbleupon.async.DeferredGroupException in project opentsdb by OpenTSDB.

the class TestLeaf method parseFromStorageNSUTagV.

@Test(expected = NoSuchUniqueId.class)
public void parseFromStorageNSUTagV() throws Throwable {
    final KeyValue column = mock(KeyValue.class);
    when(column.qualifier()).thenReturn(new Leaf("0", "000001000001000002").columnQualifier());
    when(column.value()).thenReturn(("{\"displayName\":\"0\",\"tsuid\":\"000001000001000002\"}").getBytes(MockBase.ASCII()));
    try {
        Leaf.parseFromStorage(tsdb, column, true).joinUninterruptibly();
    } catch (DeferredGroupException e) {
        throw e.getCause();
    }
}
Also used : KeyValue(org.hbase.async.KeyValue) DeferredGroupException(com.stumbleupon.async.DeferredGroupException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 8 with DeferredGroupException

use of com.stumbleupon.async.DeferredGroupException in project opentsdb by OpenTSDB.

the class TestLeaf method parseFromStorageNSUMetric.

@Test(expected = NoSuchUniqueId.class)
public void parseFromStorageNSUMetric() throws Throwable {
    final KeyValue column = mock(KeyValue.class);
    when(column.qualifier()).thenReturn(new Leaf("0", "000002000001000001").columnQualifier());
    when(column.value()).thenReturn(("{\"displayName\":\"0\",\"tsuid\":\"000002000001000001\"}").getBytes(MockBase.ASCII()));
    try {
        Leaf.parseFromStorage(tsdb, column, true).joinUninterruptibly();
    } catch (DeferredGroupException e) {
        throw e.getCause();
    }
}
Also used : KeyValue(org.hbase.async.KeyValue) DeferredGroupException(com.stumbleupon.async.DeferredGroupException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 9 with DeferredGroupException

use of com.stumbleupon.async.DeferredGroupException in project opentsdb by OpenTSDB.

the class TestLeaf method parseFromStorageNSUTagk.

@Test(expected = NoSuchUniqueId.class)
public void parseFromStorageNSUTagk() throws Throwable {
    final KeyValue column = mock(KeyValue.class);
    when(column.qualifier()).thenReturn(new Leaf("0", "000001000002000001").columnQualifier());
    when(column.value()).thenReturn(("{\"displayName\":\"0\",\"tsuid\":\"000001000002000001\"}").getBytes(MockBase.ASCII()));
    try {
        Leaf.parseFromStorage(tsdb, column, true).joinUninterruptibly();
    } catch (DeferredGroupException e) {
        throw e.getCause();
    }
}
Also used : KeyValue(org.hbase.async.KeyValue) DeferredGroupException(com.stumbleupon.async.DeferredGroupException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 10 with DeferredGroupException

use of com.stumbleupon.async.DeferredGroupException in project opentsdb by OpenTSDB.

the class TestQueryRpc method executeNSU.

@Test
public void executeNSU() throws Exception {
    final DeferredGroupException dge = mock(DeferredGroupException.class);
    when(dge.getCause()).thenReturn(new NoSuchUniqueName("foo", "metrics"));
    when(query_result.configureFromQuery((TSQuery) any(), anyInt())).thenReturn(Deferred.fromError(dge));
    final HttpQuery query = NettyMocks.getQuery(tsdb, "/api/query?start=1h-ago&m=sum:sys.cpu.user");
    rpc.execute(tsdb, query);
    assertEquals(HttpResponseStatus.BAD_REQUEST, query.response().getStatus());
    final String json = query.response().getContent().toString(Charset.forName("UTF-8"));
    assertTrue(json.contains("No such name for 'foo': 'metrics'"));
}
Also used : DeferredGroupException(com.stumbleupon.async.DeferredGroupException) NoSuchUniqueName(net.opentsdb.uid.NoSuchUniqueName) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

DeferredGroupException (com.stumbleupon.async.DeferredGroupException)10 NoSuchUniqueName (net.opentsdb.uid.NoSuchUniqueName)5 Test (org.junit.Test)5 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 ArrayList (java.util.ArrayList)4 Callback (com.stumbleupon.async.Callback)3 Deferred (com.stumbleupon.async.Deferred)3 IOException (java.io.IOException)3 List (java.util.List)3 HBaseException (org.hbase.async.HBaseException)3 KeyValue (org.hbase.async.KeyValue)3 HashMap (java.util.HashMap)2 NoSuchUniqueId (net.opentsdb.uid.NoSuchUniqueId)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 PatternSyntaxException (java.util.regex.PatternSyntaxException)1 DataPoints (net.opentsdb.core.DataPoints)1 IncomingDataPoint (net.opentsdb.core.IncomingDataPoint)1 Query (net.opentsdb.core.Query)1