MCPcopy Index your code
hub / github.com/OpenTSDB/opentsdb / setupStorage

Method setupStorage

test/tsd/TestTreeRpc.java:1150–1315  ·  view source on GitHub ↗

Setups objects in MockBase including two trees, rule sets, root branch, child branch, leaves and some collisions and no matches. These are used for most of the tests so they're all here.

()

Source from the content-addressed store, hash-verified

1148 * most of the tests so they're all here.
1149 */
1150 private void setupStorage() throws Exception {
1151 Tree tree = TestTree.buildTestTree();
1152
1153 // store root
1154 TreeMap<Integer, String> root_path = new TreeMap<Integer, String>();
1155 Branch root = new Branch(tree.getTreeId());
1156 root.setDisplayName("ROOT");
1157 root_path.put(0, "ROOT");
1158 root.prependParentPath(root_path);
1159 storage.addColumn(TREE_TABLE, root.compileBranchId(), Tree.TREE_FAMILY(),
1160 "branch".getBytes(MockBase.ASCII()),
1161 (byte[])branchToStorageJson.invoke(root));
1162
1163 // store the first tree
1164 byte[] key = new byte[] { 0, 1 };
1165 storage.addColumn(TREE_TABLE, key, Tree.TREE_FAMILY(),
1166 "tree".getBytes(MockBase.ASCII()),
1167 (byte[])TreetoStorageJson.invoke(TestTree.buildTestTree()));
1168
1169 TreeRule rule = new TreeRule(1);
1170 rule.setField("host");
1171 rule.setDescription("Hostname rule");
1172 rule.setType(TreeRuleType.TAGK);
1173 rule.setDescription("Host Name");
1174 storage.addColumn(TREE_TABLE, key, Tree.TREE_FAMILY(),
1175 "tree_rule:0:0".getBytes(MockBase.ASCII()),
1176 JSON.serializeToBytes(rule));
1177
1178 rule = new TreeRule(1);
1179 rule.setField("");
1180 rule.setLevel(1);
1181 rule.setNotes("Metric rule");
1182 rule.setType(TreeRuleType.METRIC);
1183 storage.addColumn(TREE_TABLE, key, Tree.TREE_FAMILY(),
1184 "tree_rule:1:0".getBytes(MockBase.ASCII()),
1185 JSON.serializeToBytes(rule));
1186
1187 root = new Branch(1);
1188 root.setDisplayName("ROOT");
1189 root_path = new TreeMap<Integer, String>();
1190 root_path.put(0, "ROOT");
1191 root.prependParentPath(root_path);
1192 storage.addColumn(TREE_TABLE, key, Tree.TREE_FAMILY(),
1193 "branch".getBytes(MockBase.ASCII()),
1194 (byte[])branchToStorageJson.invoke(root));
1195
1196 // tree 2
1197 key = new byte[] { 0, 2 };
1198
1199 Tree tree2 = new Tree();
1200 tree2.setTreeId(2);
1201 tree2.setName("2nd Tree");
1202 tree2.setDescription("Other Tree");
1203 storage.addColumn(TREE_TABLE, key, Tree.TREE_FAMILY(),
1204 "tree".getBytes(MockBase.ASCII()),
1205 (byte[])TreetoStorageJson.invoke(tree2));
1206
1207 rule = new TreeRule(2);

Callers 15

handleTreeGetAllMethod · 0.95
handleTreeGetSingleMethod · 0.95
handleTreeGetNotFoundMethod · 0.95
handleTreeQSCreateMethod · 0.95
handleTreePOSTCreateMethod · 0.95
handleTreeQSModifyMethod · 0.95
handleTreePOSTModifyMethod · 0.95

Calls 15

buildTestTreeMethod · 0.95
getTreeIdMethod · 0.95
setDisplayNameMethod · 0.95
prependParentPathMethod · 0.95
compileBranchIdMethod · 0.95
TREE_FAMILYMethod · 0.95
ASCIIMethod · 0.95
setFieldMethod · 0.95
setDescriptionMethod · 0.95
setTypeMethod · 0.95
serializeToBytesMethod · 0.95
setLevelMethod · 0.95

Tested by

no test coverage detected