Esempio n. 1
0
 @Test
 public void storeNew() throws Exception {
   meta = new TSMeta(new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 1}, 1357300800000L);
   meta.setDisplayName("New DN");
   meta.storeNew(tsdb);
   assertEquals("New DN", meta.getDisplayName());
 }
Esempio n. 2
0
 @Test
 public void syncToStorageOverwrite() throws Exception {
   meta = new TSMeta(new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 1}, 1357300800000L);
   meta.setDisplayName("New DN");
   meta.syncToStorage(tsdb, true).joinUninterruptibly();
   assertEquals("New DN", meta.getDisplayName());
   assertEquals(0, meta.getRetention());
 }
Esempio n. 3
0
 @Test
 public void deserialize() throws Exception {
   String json =
       "{\"tsuid\":\"ABCD\",\""
           + "description\":\"Description\",\"notes\":\"Notes\",\"created\":1328140800,"
           + "\"custom\":null,\"units\":\"\",\"retention\":42,\"max\":1.0,\"min\":"
           + "\"NaN\",\"displayName\":\"Display\",\"dataType\":\"Data\",\"lastReceived"
           + "\":1328140801,\"unknownkey\":null}";
   TSMeta tsmeta = JSON.parseToObject(json, TSMeta.class);
   assertNotNull(tsmeta);
   assertEquals("ABCD", tsmeta.getTSUID());
   assertEquals("Notes", tsmeta.getNotes());
   assertEquals(42, tsmeta.getRetention());
 }
Esempio n. 4
0
 @Test
 public void parseFromColumn() throws Exception {
   final KeyValue column = mock(KeyValue.class);
   when(column.key()).thenReturn(new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 1});
   when(column.value())
       .thenReturn(
           storage.getColumn(
               new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 1},
               NAME_FAMILY,
               "ts_meta".getBytes(MockBase.ASCII())));
   final TSMeta meta = TSMeta.parseFromColumn(tsdb, column, false).joinUninterruptibly();
   assertNotNull(meta);
   assertEquals("000001000001000001", meta.getTSUID());
   assertNull(meta.getMetric());
 }
Esempio n. 5
0
 @Test
 public void counterExistsInStorageNot() throws Exception {
   storage.flushRow(new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 1});
   assertFalse(
       TSMeta.counterExistsInStorage(tsdb, new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 1})
           .joinUninterruptibly());
 }
Esempio n. 6
0
 @Test
 public void getTSMeta() throws Exception {
   meta = TSMeta.getTSMeta(tsdb, "000001000001000001").joinUninterruptibly();
   assertNotNull(meta);
   assertEquals("000001000001000001", meta.getTSUID());
   assertEquals("sys.cpu.0", meta.getMetric().getName());
   assertEquals(2, meta.getTags().size());
   assertEquals("host", meta.getTags().get(0).getName());
   assertEquals("web01", meta.getTags().get(1).getName());
   assertEquals(1, meta.getTotalDatapoints());
   // no support for timestamps in mockbase yet
   // assertEquals(1328140801L, meta.getLastReceived());
 }
Esempio n. 7
0
  @Test(expected = NoSuchUniqueId.class)
  public void incrementAndGetCounterNSU() throws Exception {
    final byte[] tsuid = {0, 0, 1, 0, 0, 1, 0, 0, 2};
    class ErrBack implements Callback<Object, Exception> {
      @Override
      public Object call(Exception e) throws Exception {
        Throwable ex = e;
        while (ex.getClass().equals(DeferredGroupException.class)) {
          ex = ex.getCause();
        }
        throw (Exception) ex;
      }
    }

    TSMeta.incrementAndGetCounter(tsdb, tsuid).addErrback(new ErrBack()).joinUninterruptibly();
  }
Esempio n. 8
0
 @Test(expected = NoSuchUniqueId.class)
 public void getTSMetaNSUTagv() throws Throwable {
   storage.addColumn(
       new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 2},
       NAME_FAMILY,
       "ts_meta".getBytes(MockBase.ASCII()),
       ("{\"tsuid\":\"000001000001000002\",\""
               + "description\":\"Description\",\"notes\":\"Notes\",\"created\":1328140800,"
               + "\"custom\":null,\"units\":\"\",\"retention\":42,\"max\":1.0,\"min\":"
               + "\"NaN\",\"displayName\":\"Display\",\"dataType\":\"Data\"}")
           .getBytes(MockBase.ASCII()));
   try {
     TSMeta.getTSMeta(tsdb, "000001000001000002").joinUninterruptibly();
   } catch (DeferredGroupException e) {
     throw e.getCause();
   }
 }
Esempio n. 9
0
  @Test(expected = NoSuchUniqueId.class)
  public void parseFromColumnWithUIDMetaNSU() throws Exception {
    class ErrBack implements Callback<Object, Exception> {
      @Override
      public Object call(Exception e) throws Exception {
        Throwable ex = e;
        while (ex.getClass().equals(DeferredGroupException.class)) {
          ex = ex.getCause();
        }
        throw (Exception) ex;
      }
    }

    final KeyValue column = mock(KeyValue.class);
    when(column.key()).thenReturn(new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 2});
    when(column.value())
        .thenReturn(
            ("{\"tsuid\":\"000001000001000002\",\""
                    + "description\":\"Description\",\"notes\":\"Notes\",\"created\":1328140800,"
                    + "\"custom\":null,\"units\":\"\",\"retention\":42,\"max\":1.0,\"min\":"
                    + "\"NaN\",\"displayName\":\"Display\",\"dataType\":\"Data\"}")
                .getBytes(MockBase.ASCII()));
    TSMeta.parseFromColumn(tsdb, column, true).addErrback(new ErrBack()).joinUninterruptibly();
  }
Esempio n. 10
0
 @Test
 public void getTSMetaDoesNotExist() throws Exception {
   meta = TSMeta.getTSMeta(tsdb, "000002000001000001").joinUninterruptibly();
   assertNull(meta);
 }
Esempio n. 11
0
 @Test
 public void createConstructor() {
   meta = new TSMeta(new byte[] {0, 0, 1, 0, 0, 2, 0, 0, 3}, 1357300800000L);
   assertEquals(1357300800000L / 1000, meta.getCreated());
 }
Esempio n. 12
0
 @Test
 public void META_QUALIFIER() throws Exception {
   assertArrayEquals("ts_meta".getBytes(MockBase.ASCII()), TSMeta.META_QUALIFIER());
 }
Esempio n. 13
0
 @Test
 public void COUNTER_QUALIFIER() throws Exception {
   assertArrayEquals("ts_ctr".getBytes(MockBase.ASCII()), TSMeta.COUNTER_QUALIFIER());
 }
Esempio n. 14
0
 @Test
 public void incrementAndGetCounter() throws Exception {
   final byte[] tsuid = {0, 0, 1, 0, 0, 1, 0, 0, 1};
   TSMeta.incrementAndGetCounter(tsdb, tsuid).joinUninterruptibly();
   verify(client).bufferAtomicIncrement((AtomicIncrementRequest) any());
 }
Esempio n. 15
0
 @Test
 public void delete() throws Exception {
   meta = TSMeta.getTSMeta(tsdb, "000001000001000001").joinUninterruptibly();
   meta.delete(tsdb);
 }
Esempio n. 16
0
 @Test
 public void counterExistsInStorage() throws Exception {
   assertTrue(
       TSMeta.counterExistsInStorage(tsdb, new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 1})
           .joinUninterruptibly());
 }
Esempio n. 17
0
 @Test(expected = IllegalArgumentException.class)
 public void deleteNull() throws Exception {
   meta = new TSMeta();
   meta.delete(tsdb);
 }
Esempio n. 18
0
 @Test
 public void metaExistsInStorage() throws Exception {
   assertTrue(TSMeta.metaExistsInStorage(tsdb, "000001000001000001").joinUninterruptibly());
 }
Esempio n. 19
0
 @Test(expected = IllegalArgumentException.class)
 public void storeNewEmpty() throws Exception {
   meta = new TSMeta("");
   meta.storeNew(tsdb);
 }
Esempio n. 20
0
 @Test(expected = IllegalStateException.class)
 public void syncToStorageNoChanges() throws Exception {
   meta = new TSMeta("ABCD");
   meta.syncToStorage(tsdb, true).joinUninterruptibly();
 }
Esempio n. 21
0
 @Test(expected = IllegalArgumentException.class)
 public void syncToStorageDoesNotExist() throws Exception {
   storage.flushRow(new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 1});
   meta = new TSMeta(new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 1}, 1357300800000L);
   meta.syncToStorage(tsdb, false).joinUninterruptibly();
 }
Esempio n. 22
0
 @Test(expected = IllegalArgumentException.class)
 public void syncToStorageNullTSUID() throws Exception {
   meta = new TSMeta();
   meta.syncToStorage(tsdb, true).joinUninterruptibly();
 }