use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method failedCompactNoop.
@Test
public void failedCompactNoop() throws Exception {
// In this case, the row contains both the compacted form as well as the
// non-compacted form. This could happen if the TSD dies in between the
// `put' of a compaction, before getting a change to do the deletes.
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(3);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual1 = { 0x00, 0x07 };
final byte[] val1 = Bytes.fromLong(4L);
kvs.add(makekv(qual1, val1));
final byte[] qual2 = { 0x00, 0x17 };
final byte[] val2 = Bytes.fromLong(5L);
kvs.add(makekv(qual2, val2));
final byte[] qualcompact = MockBase.concatByteArrays(qual1, qual2);
final byte[] valcompact = MockBase.concatByteArrays(val1, val2, ZERO);
kvs.add(makekv(qualcompact, valcompact));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(qualcompact, kv.qualifier());
assertArrayEquals(valcompact, kv.value());
// We didn't have anything to write.
verify(tsdb, never()).put(anyBytes(), anyBytes(), anyBytes());
// We had to delete stuff in 1 row.
verify(tsdb, times(1)).delete(eq(KEY), eqAnyOrder(new byte[][] { qual1, qual2 }));
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method msSameAsSecondFix.
@Test
public void msSameAsSecondFix() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(2);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual1 = { 0x00, 0x07 };
final byte[] val1 = Bytes.fromLong(4L);
kvs.add(makekv(qual1, val1));
final byte[] qual2 = { (byte) 0xF0, 0x00, 0x00, 0x07 };
final byte[] val2 = Bytes.fromLong(5L);
kvs.add(makekv(qual2, val2));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(qual2, kv.qualifier());
assertArrayEquals(val2, kv.value());
// no compacted row
verify(tsdb, never()).put(KEY, qual2, val2);
// And we had to delete the earlier entry.
verify(tsdb, times(1)).delete(KEY, new byte[][] { qual1 });
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestCompactionQueue method appendsAndLaterPuts.
@Test
public void appendsAndLaterPuts() throws Exception {
ArrayList<KeyValue> kvs = new ArrayList<KeyValue>(1);
ArrayList<Annotation> annotations = new ArrayList<Annotation>(0);
final byte[] qual = { 0x00, 0x07 };
final byte[] val = Bytes.fromLong(42L);
final byte[] qual2 = { 0x00, 0x17 };
final byte[] val2 = Bytes.fromLong(5L);
final byte[] qual3 = { 0x00, 0x27 };
final byte[] val3 = Bytes.fromLong(3L);
final byte[] qual4 = { 0x00, 0x37 };
final byte[] val4 = Bytes.fromLong(2L);
kvs.add(makekv(AppendDataPoints.APPEND_COLUMN_QUALIFIER, MockBase.concatByteArrays(qual, val, qual2, val2)));
kvs.add(makekv(qual3, val3));
kvs.add(makekv(qual4, val4));
final KeyValue kv = compactionq.compact(kvs, annotations);
assertArrayEquals(MockBase.concatByteArrays(qual, qual2, qual3, qual4), kv.qualifier());
assertArrayEquals(MockBase.concatByteArrays(val, val2, val3, val4, ZERO), kv.value());
// We had nothing to do so...
// ... verify there were no put.
verify(tsdb, never()).put(anyBytes(), anyBytes(), anyBytes());
// ... verify there were no delete.
verify(tsdb, never()).delete(anyBytes(), any(byte[][].class));
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestDumpSeries method writeData.
/**
* Store some data in MockBase for use in the unit tests. We'll put in a mix
* of all possible types so that we know they'll come out properly in the end.
* For that reason we'll use the standard OpenTSDB methods for writing data.
*/
private void writeData() throws Exception {
HashMap<String, String> tags = new HashMap<String, String>(1);
tags.put("host", "web01");
long timestamp = 1356998400;
Annotation annotation = new Annotation();
annotation.setStartTime(timestamp);
annotation.setTSUID("000001000001000001");
annotation.setDescription("Annotation on seconds");
annotation.syncToStorage(tsdb, false).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp++, 42, tags).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp++, 257, tags).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp++, 65537, tags).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp++, 4294967296L, tags).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp++, 42.5F, tags).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp++, 42.5123459999F, tags).joinUninterruptibly();
timestamp = 1357002000000L;
annotation = new Annotation();
annotation.setStartTime(timestamp);
annotation.setTSUID("000001000001000001");
annotation.setDescription("Annotation on milliseconds");
annotation.syncToStorage(tsdb, false).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp, 42, tags).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp += 1000, 257, tags).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp += 1000, 65537, tags).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp += 1000, 4294967296L, tags).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp += 1000, 42.5F, tags).joinUninterruptibly();
tsdb.addPoint("sys.cpu.user", timestamp += 1000, 42.5123459999F, tags).joinUninterruptibly();
}
use of net.opentsdb.meta.Annotation in project opentsdb by OpenTSDB.
the class TestPostAggregatedDataPoints method before.
@Before
public void before() throws Exception {
base_data_points = PowerMockito.mock(DataPoints.class);
points = new MutableDataPoint[NUM_POINTS];
long ts = BASE_TIME;
for (int i = 0; i < NUM_POINTS; i++) {
MutableDataPoint mdp = new MutableDataPoint();
mdp.reset(ts, i);
points[i] = mdp;
ts += TIME_INTERVAL;
}
tags = new HashMap<String, String>(1);
tags.put("colo", "lga");
agg_tags = new ArrayList<String>(1);
agg_tags.add("host");
tsuids = new ArrayList<String>(1);
// just 1 byte UIDs for kicks
tsuids.add("0101010202");
annotations = new ArrayList<Annotation>(1);
annotations.add(PowerMockito.mock(Annotation.class));
tag_uids = new ByteMap<byte[]>();
tag_uids.put(new byte[] { 1 }, new byte[] { 1 });
when(base_data_points.metricName()).thenReturn(METRIC_NAME);
when(base_data_points.metricNameAsync()).thenReturn(Deferred.fromResult(METRIC_NAME));
when(base_data_points.getTags()).thenReturn(tags);
when(base_data_points.getTagsAsync()).thenReturn(Deferred.fromResult(tags));
when(base_data_points.getAggregatedTags()).thenReturn(agg_tags);
when(base_data_points.getAggregatedTagsAsync()).thenReturn(Deferred.fromResult(agg_tags));
when(base_data_points.getTSUIDs()).thenReturn(tsuids);
when(base_data_points.getAnnotations()).thenReturn(annotations);
when(base_data_points.getTagUids()).thenReturn(tag_uids);
when(base_data_points.getQueryIndex()).thenReturn(42);
}
Aggregations