Sets up storage with or without salting and writes a few bits of data @param salted Whether or not to use salting
(final boolean salted)
| 636 | * @param salted Whether or not to use salting |
| 637 | */ |
| 638 | private void setupStorage(final boolean salted) { |
| 639 | if (salted) { |
| 640 | PowerMockito.mockStatic(Const.class); |
| 641 | PowerMockito.when(Const.SALT_WIDTH()).thenReturn(1); |
| 642 | PowerMockito.when(Const.SALT_BUCKETS()).thenReturn(2); |
| 643 | } |
| 644 | |
| 645 | global_row_key = new byte[Const.SALT_WIDTH() + TSDB.metrics_width() + |
| 646 | Const.TIMESTAMP_BYTES]; |
| 647 | System.arraycopy(Bytes.fromInt(1328140800), 0, global_row_key, |
| 648 | Const.SALT_WIDTH() + TSDB.metrics_width(), Const.TIMESTAMP_BYTES); |
| 649 | |
| 650 | global_row_key_2015_midnight = |
| 651 | new byte[Const.SALT_WIDTH() + TSDB.metrics_width() + |
| 652 | Const.TIMESTAMP_BYTES]; |
| 653 | System.arraycopy(Bytes.fromInt(1425715200), 0, global_row_key_2015_midnight, |
| 654 | Const.SALT_WIDTH() + TSDB.metrics_width(), Const.TIMESTAMP_BYTES); |
| 655 | |
| 656 | tsuid_row_key = getRowKeyTemplate(); |
| 657 | System.arraycopy(Bytes.fromInt(1388448000), 0, tsuid_row_key, |
| 658 | Const.SALT_WIDTH() + TSDB.metrics_width(), Const.TIMESTAMP_BYTES); |
| 659 | RowKey.prefixKeyWithSalt(tsuid_row_key); |
| 660 | |
| 661 | storage = new MockBase(tsdb, client, true, true, true, true); |
| 662 | |
| 663 | // add a global |
| 664 | storage.addColumn(global_row_key, |
| 665 | new byte[] { 1, 0, 0 }, |
| 666 | ("{\"startTime\":1328140800,\"endTime\":1328140801,\"description\":" + |
| 667 | "\"Description\",\"notes\":\"Notes\",\"custom\":{\"owner\":" + |
| 668 | "\"ops\"}}").getBytes(MockBase.ASCII()), 1328140799972L); |
| 669 | |
| 670 | storage.addColumn(global_row_key, |
| 671 | new byte[] { 1, 0, 1 }, |
| 672 | ("{\"startTime\":1328140801,\"endTime\":1328140803,\"description\":" + |
| 673 | "\"Global 2\",\"notes\":\"Nothing\"}").getBytes(MockBase.ASCII()), 1328140799973L); |
| 674 | |
| 675 | // add a local |
| 676 | storage.addColumn(tsuid_row_key, |
| 677 | new byte[] { 1, 0x0A, 0x02 }, |
| 678 | ("{\"tsuid\":\"000001000001000001\",\"startTime\":1388450562," + |
| 679 | "\"endTime\":1419984000,\"description\":\"Hello!\",\"notes\":" + |
| 680 | "\"My Notes\",\"custom\":{\"owner\":\"ops\"}}") |
| 681 | .getBytes(MockBase.ASCII()), 1388448000003L); |
| 682 | |
| 683 | storage.addColumn(tsuid_row_key, |
| 684 | new byte[] { 1, 0x0A, 0x03 }, |
| 685 | ("{\"tsuid\":\"000001000001000001\",\"startTime\":1388450563," + |
| 686 | "\"endTime\":1419984000,\"description\":\"Note2\",\"notes\":" + |
| 687 | "\"Nothing\"}") |
| 688 | .getBytes(MockBase.ASCII()), 1388448000004L); |
| 689 | |
| 690 | // add some data points too |
| 691 | storage.addColumn(tsuid_row_key, |
| 692 | new byte[] { 0x50, 0x10 }, new byte[] { 1 }, 1388448000005L); |
| 693 | |
| 694 | storage.addColumn(tsuid_row_key, |
| 695 | new byte[] { 0x50, 0x18 }, new byte[] { 2 }, 1388448000006L); |
no test coverage detected