@Test public void testIllegalStorageGroup() { MTree root = new MTree(); try { root.setStorageGroup(new PartialPath("root.\"sg.ln\"")); } catch (MetadataException e) { Assert.assertEquals("The storage group name can only be characters, numbers and underscores. root.\"sg.ln\" is not a legal path", e.getMessage()); } }
void setStorageGroup(PartialPath path) throws MetadataException { String[] nodeNames = path.getNodes(); checkStorageGroup(path.getFullPath()); MNode cur = root; if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new IllegalPathException(path.getFullPath()); } int i = 1; while (i < nodeNames.length - 1) { MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(cur, nodeNames[i])); } else if (temp instanceof StorageGroupMNode) { throw new StorageGroupAlreadySetException(temp.getFullPath()); } cur = cur.getChild(nodeNames[i]); i++; } if (cur.hasChild(nodeNames[i])) { throw new StorageGroupAlreadySetException(path.getFullPath()); } else { StorageGroupMNode storageGroupMNode = new StorageGroupMNode( cur, nodeNames[i], IoTDBDescriptor.getInstance().getConfig().getDefaultTTL()); cur.addChild(nodeNames[i], storageGroupMNode); } }
MTree implements Serializable { void setStorageGroup(PartialPath path) throws MetadataException { String[] nodeNames = path.getNodes(); checkStorageGroup(path.getFullPath()); MNode cur = root; if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new IllegalPathException(path.getFullPath()); } int i = 1; while (i < nodeNames.length - 1) { MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(cur, nodeNames[i])); } else if (temp instanceof StorageGroupMNode) { throw new StorageGroupAlreadySetException(temp.getFullPath()); } cur = cur.getChild(nodeNames[i]); i++; } if (cur.hasChild(nodeNames[i])) { throw new StorageGroupAlreadySetException(path.getFullPath()); } else { StorageGroupMNode storageGroupMNode = new StorageGroupMNode( cur, nodeNames[i], IoTDBDescriptor.getInstance().getConfig().getDefaultTTL()); cur.addChild(nodeNames[i], storageGroupMNode); } } }
MTree implements Serializable { void setStorageGroup(PartialPath path) throws MetadataException { String[] nodeNames = path.getNodes(); checkStorageGroup(path.getFullPath()); MNode cur = root; if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new IllegalPathException(path.getFullPath()); } int i = 1; while (i < nodeNames.length - 1) { MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(cur, nodeNames[i])); } else if (temp instanceof StorageGroupMNode) { throw new StorageGroupAlreadySetException(temp.getFullPath()); } cur = cur.getChild(nodeNames[i]); i++; } if (cur.hasChild(nodeNames[i])) { throw new StorageGroupAlreadySetException(path.getFullPath()); } else { StorageGroupMNode storageGroupMNode = new StorageGroupMNode( cur, nodeNames[i], IoTDBDescriptor.getInstance().getConfig().getDefaultTTL()); cur.addChild(nodeNames[i], storageGroupMNode); } } MTree(); private  MTree(MNode root); }
MTree implements Serializable { void setStorageGroup(PartialPath path) throws MetadataException { String[] nodeNames = path.getNodes(); checkStorageGroup(path.getFullPath()); MNode cur = root; if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new IllegalPathException(path.getFullPath()); } int i = 1; while (i < nodeNames.length - 1) { MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(cur, nodeNames[i])); } else if (temp instanceof StorageGroupMNode) { throw new StorageGroupAlreadySetException(temp.getFullPath()); } cur = cur.getChild(nodeNames[i]); i++; } if (cur.hasChild(nodeNames[i])) { throw new StorageGroupAlreadySetException(path.getFullPath()); } else { StorageGroupMNode storageGroupMNode = new StorageGroupMNode( cur, nodeNames[i], IoTDBDescriptor.getInstance().getConfig().getDefaultTTL()); cur.addChild(nodeNames[i], storageGroupMNode); } } MTree(); private  MTree(MNode root); void serializeTo(String snapshotPath); @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning static MTree deserializeFrom(File mtreeSnapshot); @Override String toString(); }
MTree implements Serializable { void setStorageGroup(PartialPath path) throws MetadataException { String[] nodeNames = path.getNodes(); checkStorageGroup(path.getFullPath()); MNode cur = root; if (nodeNames.length <= 1 || !nodeNames[0].equals(root.getName())) { throw new IllegalPathException(path.getFullPath()); } int i = 1; while (i < nodeNames.length - 1) { MNode temp = cur.getChild(nodeNames[i]); if (temp == null) { cur.addChild(nodeNames[i], new MNode(cur, nodeNames[i])); } else if (temp instanceof StorageGroupMNode) { throw new StorageGroupAlreadySetException(temp.getFullPath()); } cur = cur.getChild(nodeNames[i]); i++; } if (cur.hasChild(nodeNames[i])) { throw new StorageGroupAlreadySetException(path.getFullPath()); } else { StorageGroupMNode storageGroupMNode = new StorageGroupMNode( cur, nodeNames[i], IoTDBDescriptor.getInstance().getConfig().getDefaultTTL()); cur.addChild(nodeNames[i], storageGroupMNode); } } MTree(); private  MTree(MNode root); void serializeTo(String snapshotPath); @SuppressWarnings("squid:S3776") // Suppress high Cognitive Complexity warning static MTree deserializeFrom(File mtreeSnapshot); @Override String toString(); static final Gson GSON; }