Search in sources :

Example 1 with HistogramCodecManager

use of net.opentsdb.core.HistogramCodecManager in project opentsdb by OpenTSDB.

the class TestHistogramDataPointRpc method before.

@Before
public void before() throws Exception {
    uid_map = Maps.newHashMap();
    PowerMockito.mockStatic(Threads.class);
    timer = new FakeTaskTimer();
    PowerMockito.when(Threads.newTimer(anyString())).thenReturn(timer);
    PowerMockito.when(Threads.newTimer(anyInt(), anyString())).thenReturn(timer);
    PowerMockito.whenNew(HashedWheelTimer.class).withNoArguments().thenReturn(timer);
    PowerMockito.whenNew(HBaseClient.class).withAnyArguments().thenReturn(client);
    config = new Config(false);
    config.overrideConfig("tsd.storage.enable_compaction", "false");
    config.overrideConfig("tsd.core.histograms.config", "{\"net.opentsdb.core.SimpleHistogramDecoder\": 42}");
    tsdb = new TSDB(config);
    config.setAutoMetric(true);
    Whitebox.setInternalState(tsdb, "metrics", metrics);
    Whitebox.setInternalState(tsdb, "tag_names", tag_names);
    Whitebox.setInternalState(tsdb, "tag_values", tag_values);
    setupMetricMaps();
    setupTagkMaps();
    setupTagvMaps();
    mockUID(UniqueIdType.METRIC, HISTOGRAM_METRIC_STRING, HISTOGRAM_METRIC_BYTES);
    // add metrics and tags to the UIDs list for other functions to share
    uid_map.put(METRIC_STRING, METRIC_BYTES);
    uid_map.put(METRIC_B_STRING, METRIC_B_BYTES);
    uid_map.put(NSUN_METRIC, NSUI_METRIC);
    uid_map.put(HISTOGRAM_METRIC_STRING, HISTOGRAM_METRIC_BYTES);
    uid_map.put(TAGK_STRING, TAGK_BYTES);
    uid_map.put(TAGK_B_STRING, TAGK_B_BYTES);
    uid_map.put(NSUN_TAGK, NSUI_TAGK);
    uid_map.put(TAGV_STRING, TAGV_BYTES);
    uid_map.put(TAGV_B_STRING, TAGV_B_BYTES);
    uid_map.put(NSUN_TAGV, NSUI_TAGV);
    uid_map.putAll(UIDS);
    when(metrics.width()).thenReturn((short) 3);
    when(tag_names.width()).thenReturn((short) 3);
    when(tag_values.width()).thenReturn((short) 3);
    tags = new HashMap<String, String>(1);
    tags.put(TAGK_STRING, TAGV_STRING);
    manager = new HistogramCodecManager(tsdb);
    Whitebox.setInternalState(tsdb, "histogram_manager", manager);
    storage = new MockBase(tsdb, client, true, true, true, true);
    test_histo = new SimpleHistogram(42);
    test_histo.addBucket(0F, 1F, 42L);
    test_histo.addBucket(1F, 5F, 24L);
    test_histo.setOverflow(1L);
    // counters
    raw_histograms = Whitebox.getInternalState(PutDataPointRpc.class, "raw_histograms");
    raw_histograms.set(0);
    raw_histograms_stored = Whitebox.getInternalState(PutDataPointRpc.class, "raw_histograms_stored");
    raw_histograms_stored.set(0);
}
Also used : HistogramCodecManager(net.opentsdb.core.HistogramCodecManager) Config(net.opentsdb.utils.Config) TSDB(net.opentsdb.core.TSDB) MockBase(net.opentsdb.storage.MockBase) SimpleHistogram(net.opentsdb.core.SimpleHistogram) Matchers.anyString(org.mockito.Matchers.anyString) Before(org.junit.Before)

Aggregations

HistogramCodecManager (net.opentsdb.core.HistogramCodecManager)1 SimpleHistogram (net.opentsdb.core.SimpleHistogram)1 TSDB (net.opentsdb.core.TSDB)1 MockBase (net.opentsdb.storage.MockBase)1 Config (net.opentsdb.utils.Config)1 Before (org.junit.Before)1 Matchers.anyString (org.mockito.Matchers.anyString)1