Exemple #1
0
          @Override
          public Boolean call(Boolean exists) throws Exception {
            if (!exists && create) {
              final PutRequest put =
                  new PutRequest(
                      tsdb.metaTable(),
                      UniqueId.stringToUid(tsuid),
                      TSMeta.FAMILY(),
                      TSMeta.COUNTER_QUALIFIER(),
                      Bytes.fromLong(0));
              tsdb.getClient().put(put);
            }

            return exists;
          }
Exemple #2
0
  @Before
  public void before() throws Exception {
    config = mock(Config.class);
    when(config.getString("tsd.storage.hbase.data_table")).thenReturn("tsdb");
    when(config.getString("tsd.storage.hbase.uid_table")).thenReturn("tsdb-uid");
    when(config.getString("tsd.storage.hbase.meta_table")).thenReturn("tsdb-meta");
    when(config.getString("tsd.storage.hbase.tree_table")).thenReturn("tsdb-tree");
    when(config.enable_tsuid_incrementing()).thenReturn(true);
    when(config.enable_realtime_ts()).thenReturn(true);

    PowerMockito.whenNew(HBaseClient.class)
        .withArguments(anyString(), anyString())
        .thenReturn(client);
    tsdb = new TSDB(config);
    storage = new MockBase(tsdb, client, true, true, true, true, true);

    storage.addColumn(
        new byte[] {0, 0, 1},
        NAME_FAMILY,
        "metrics".getBytes(MockBase.ASCII()),
        "sys.cpu.0".getBytes(MockBase.ASCII()));
    storage.addColumn(
        new byte[] {0, 0, 1},
        NAME_FAMILY,
        "metric_meta".getBytes(MockBase.ASCII()),
        ("{\"uid\":\"000001\",\"type\":\"METRIC\",\"name\":\"sys.cpu.0\","
                + "\"description\":\"Description\",\"notes\":\"MyNotes\",\"created\":"
                + "1328140801,\"displayName\":\"System CPU\"}")
            .getBytes(MockBase.ASCII()));

    storage.addColumn(
        new byte[] {0, 0, 1},
        NAME_FAMILY,
        "tagk".getBytes(MockBase.ASCII()),
        "host".getBytes(MockBase.ASCII()));
    storage.addColumn(
        new byte[] {0, 0, 1},
        NAME_FAMILY,
        "tagk_meta".getBytes(MockBase.ASCII()),
        ("{\"uid\":\"000001\",\"type\":\"TAGK\",\"name\":\"host\","
                + "\"description\":\"Description\",\"notes\":\"MyNotes\",\"created\":"
                + "1328140801,\"displayName\":\"Host server name\"}")
            .getBytes(MockBase.ASCII()));

    storage.addColumn(
        new byte[] {0, 0, 1},
        NAME_FAMILY,
        "tagv".getBytes(MockBase.ASCII()),
        "web01".getBytes(MockBase.ASCII()));
    storage.addColumn(
        new byte[] {0, 0, 1},
        NAME_FAMILY,
        "tagv_meta".getBytes(MockBase.ASCII()),
        ("{\"uid\":\"000001\",\"type\":\"TAGV\",\"name\":\"web01\","
                + "\"description\":\"Description\",\"notes\":\"MyNotes\",\"created\":"
                + "1328140801,\"displayName\":\"Web server 1\"}")
            .getBytes(MockBase.ASCII()));

    storage.addColumn(
        new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 1},
        NAME_FAMILY,
        "ts_meta".getBytes(MockBase.ASCII()),
        ("{\"tsuid\":\"000001000001000001\",\""
                + "description\":\"Description\",\"notes\":\"Notes\",\"created\":1328140800,"
                + "\"custom\":null,\"units\":\"\",\"retention\":42,\"max\":1.0,\"min\":"
                + "\"NaN\",\"displayName\":\"Display\",\"dataType\":\"Data\"}")
            .getBytes(MockBase.ASCII()));
    storage.addColumn(
        new byte[] {0, 0, 1, 0, 0, 1, 0, 0, 1},
        NAME_FAMILY,
        "ts_ctr".getBytes(MockBase.ASCII()),
        Bytes.fromLong(1L));
  }