use of net.opentsdb.core.TSDB in project opentsdb by OpenTSDB.
the class TestUniqueId method getUsedUIDsEmptyRow.
@Test
public void getUsedUIDsEmptyRow() throws Exception {
final ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(0);
final byte[] metrics = { 'm', 'e', 't', 'r', 'i', 'c', 's' };
final byte[] tagk = { 't', 'a', 'g', 'k' };
final byte[] tagv = { 't', 'a', 'g', 'v' };
final TSDB tsdb = mock(TSDB.class);
when(tsdb.getClient()).thenReturn(client);
when(tsdb.uidTable()).thenReturn(new byte[] { 'u', 'i', 'd' });
when(client.get(anyGet())).thenReturn(Deferred.fromResult(kvs));
final byte[][] kinds = { metrics, tagk, tagv };
final Map<String, Long> uids = UniqueId.getUsedUIDs(tsdb, kinds).joinUninterruptibly();
assertNotNull(uids);
assertEquals(3, uids.size());
assertEquals(0L, uids.get("metrics").longValue());
assertEquals(0L, uids.get("tagk").longValue());
assertEquals(0L, uids.get("tagv").longValue());
}
use of net.opentsdb.core.TSDB in project opentsdb by OpenTSDB.
the class TestUniqueId method getUsedUIDs.
@Test
public void getUsedUIDs() throws Exception {
final ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(3);
final byte[] metrics = { 'm', 'e', 't', 'r', 'i', 'c', 's' };
final byte[] tagk = { 't', 'a', 'g', 'k' };
final byte[] tagv = { 't', 'a', 'g', 'v' };
kvs.add(new KeyValue(MAXID, ID, metrics, Bytes.fromLong(64L)));
kvs.add(new KeyValue(MAXID, ID, tagk, Bytes.fromLong(42L)));
kvs.add(new KeyValue(MAXID, ID, tagv, Bytes.fromLong(1024L)));
final TSDB tsdb = mock(TSDB.class);
when(tsdb.getClient()).thenReturn(client);
when(tsdb.uidTable()).thenReturn(new byte[] { 'u', 'i', 'd' });
when(client.get(anyGet())).thenReturn(Deferred.fromResult(kvs));
final byte[][] kinds = { metrics, tagk, tagv };
final Map<String, Long> uids = UniqueId.getUsedUIDs(tsdb, kinds).joinUninterruptibly();
assertNotNull(uids);
assertEquals(3, uids.size());
assertEquals(64L, uids.get("metrics").longValue());
assertEquals(42L, uids.get("tagk").longValue());
assertEquals(1024L, uids.get("tagv").longValue());
}
use of net.opentsdb.core.TSDB in project opentsdb by OpenTSDB.
the class TestUniqueIdWhitelistFilter method before.
@Before
public void before() throws Exception {
tsdb = PowerMockito.mock(TSDB.class);
config = new Config(false);
when(tsdb.getConfig()).thenReturn(config);
filter = new UniqueIdWhitelistFilter();
config.overrideConfig("tsd.uidfilter.whitelist.metric_patterns", ".*");
config.overrideConfig("tsd.uidfilter.whitelist.tagk_patterns", ".*");
config.overrideConfig("tsd.uidfilter.whitelist.tagv_patterns", ".*");
}
Aggregations