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;
}
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();
}
}
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();
}
}
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();
}
}
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'"));
}
Aggregations