Skip to content

Commit

Permalink
Merge branch 'next' into next_lastdp
Browse files Browse the repository at this point in the history
  • Loading branch information
manolama committed Oct 30, 2013
2 parents e44859a + 04ad242 commit 4e873c3
Show file tree
Hide file tree
Showing 10 changed files with 449 additions and 218 deletions.
5 changes: 3 additions & 2 deletions src/core/IncomingDataPoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

/**
* Bridging class that stores a normalized data point parsed from the "put"
Expand All @@ -30,7 +31,7 @@
* overload with their own fields or parsing methods.
* @since 2.0
*/
@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL)
@JsonInclude(Include.NON_NULL)
public class IncomingDataPoint {
/** The incoming metric name */
private String metric;
Expand Down
4 changes: 2 additions & 2 deletions src/tools/DumpSeries.java
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static void appendRawCell(final StringBuilder buf, final Cell cell,
.append("\t")
.append(cell.isInteger() ? "l" : "f")
.append("\t")
.append(cell.parseValue())
.append(Arrays.toString(cell.value()))
.append("\t")
.append(cell.absoluteTimestamp(base_time))
.append("\t")
Expand All @@ -244,7 +244,7 @@ static void appendImportCell(final StringBuilder buf, final Cell cell,
final long base_time, final String tags) {
buf.append(cell.absoluteTimestamp(base_time))
.append(" ")
.append(Arrays.toString(cell.value()))
.append(cell.parseValue())
.append(tags);
}

Expand Down
16 changes: 15 additions & 1 deletion test/meta/TestTSMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
GetRequest.class, PutRequest.class, DeleteRequest.class, KeyValue.class,
Scanner.class, UIDMeta.class, TSMeta.class, AtomicIncrementRequest.class})
public final class TestTSMeta {
private static byte[] NAME_FAMILY = "name".getBytes(MockBase.ASCII());
private TSDB tsdb;
private Config config;
private HBaseClient client = mock(HBaseClient.class);
Expand All @@ -79,44 +80,52 @@ public void before() throws Exception {
tsdb = new TSDB(config);
storage = new MockBase(tsdb, client, true, true, true, true);

storage.addColumn(new byte[] { 0, 0, 1 },
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));
}
Expand Down Expand Up @@ -176,6 +185,7 @@ public void getTSMetaDoesNotExist() throws Exception {
@Test (expected = NoSuchUniqueId.class)
public void getTSMetaNSUMetric() throws Throwable {
storage.addColumn(new byte[] { 0, 0, 2, 0, 0, 1, 0, 0, 1 },
NAME_FAMILY,
"ts_meta".getBytes(MockBase.ASCII()),
("{\"tsuid\":\"000002000001000001\",\"" +
"description\":\"Description\",\"notes\":\"Notes\",\"created\":1328140800," +
Expand All @@ -192,6 +202,7 @@ public void getTSMetaNSUMetric() throws Throwable {
@Test (expected = NoSuchUniqueId.class)
public void getTSMetaNSUTagk() throws Throwable {
storage.addColumn(new byte[] { 0, 0, 1, 0, 0, 2, 0, 0, 1 },
NAME_FAMILY,
"ts_meta".getBytes(MockBase.ASCII()),
("{\"tsuid\":\"000001000002000001\",\"" +
"description\":\"Description\",\"notes\":\"Notes\",\"created\":1328140800," +
Expand All @@ -208,6 +219,7 @@ public void getTSMetaNSUTagk() throws Throwable {
@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," +
Expand Down Expand Up @@ -359,6 +371,7 @@ public void parseFromColumn() throws Exception {
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();
Expand All @@ -373,6 +386,7 @@ public void parseFromColumnWithUIDMeta() throws Exception {
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, true)
.joinUninterruptibly();
Expand Down
5 changes: 5 additions & 0 deletions test/meta/TestUIDMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
GetRequest.class, PutRequest.class, DeleteRequest.class, KeyValue.class,
Scanner.class, UIDMeta.class})
public final class TestUIDMeta {
private static byte[] NAME_FAMILY = "name".getBytes(MockBase.ASCII());
private TSDB tsdb;
private HBaseClient client = mock(HBaseClient.class);
private MockBase storage;
Expand All @@ -64,14 +65,17 @@ public void before() throws Exception {
storage = new MockBase(tsdb, client, 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, 3 },
NAME_FAMILY,
"metrics".getBytes(MockBase.ASCII()),
"sys.cpu.2".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\":" +
Expand Down Expand Up @@ -249,6 +253,7 @@ public void storeNew() throws Exception {
meta = new UIDMeta(UniqueIdType.METRIC, new byte[] { 0, 0, 1 }, "sys.cpu.1");
meta.storeNew(tsdb).joinUninterruptibly();
meta = JSON.parseToObject(storage.getColumn(new byte[] { 0, 0, 1 },
NAME_FAMILY,
"metric_meta".getBytes(MockBase.ASCII())), UIDMeta.class);
assertEquals("", meta.getDisplayName());
assertEquals("sys.cpu.1", meta.getName());
Expand Down
Loading

0 comments on commit 4e873c3

Please sign in to comment.