Search in sources :

Example 41 with TSDB

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());
}
Also used : KeyValue(org.hbase.async.KeyValue) ArrayList(java.util.ArrayList) TSDB(net.opentsdb.core.TSDB) Matchers.anyString(org.mockito.Matchers.anyString) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 42 with TSDB

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());
}
Also used : KeyValue(org.hbase.async.KeyValue) ArrayList(java.util.ArrayList) TSDB(net.opentsdb.core.TSDB) Matchers.anyString(org.mockito.Matchers.anyString) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 43 with TSDB

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", ".*");
}
Also used : Config(net.opentsdb.utils.Config) TSDB(net.opentsdb.core.TSDB) Before(org.junit.Before)

Aggregations

TSDB (net.opentsdb.core.TSDB)43 Config (net.opentsdb.utils.Config)41 Before (org.junit.Before)16 Test (org.junit.Test)14 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)14 MockBase (net.opentsdb.storage.MockBase)13 KeyValue (org.hbase.async.KeyValue)12 ArrayList (java.util.ArrayList)11 Matchers.anyString (org.mockito.Matchers.anyString)11 UniqueIdType (net.opentsdb.uid.UniqueId.UniqueIdType)8 Field (java.lang.reflect.Field)6 NoSuchUniqueName (net.opentsdb.uid.NoSuchUniqueName)5 IOException (java.io.IOException)4 UnitTestException (net.opentsdb.core.BaseTsdbTest.UnitTestException)4 Deferred (com.stumbleupon.async.Deferred)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 DataPoint (net.opentsdb.core.DataPoint)2 Query (net.opentsdb.core.Query)2 HBaseException (org.hbase.async.HBaseException)2