Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Iotdb
提交
8e4b05ba
I
Iotdb
项目概览
apache
/
Iotdb
12 个月 前同步成功
通知
25
Star
3344
Fork
916
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
I
Iotdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8e4b05ba
编写于
4月 01, 2019
作者:
T
Tianan Li
提交者:
XuYi
4月 01, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add check sg exists of path for cluster (#126)
上级
c7ad2afc
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
115 addition
and
0 deletion
+115
-0
iotdb/src/main/java/org/apache/iotdb/db/metadata/MGraph.java
iotdb/src/main/java/org/apache/iotdb/db/metadata/MGraph.java
+11
-0
iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java
.../src/main/java/org/apache/iotdb/db/metadata/MManager.java
+14
-0
iotdb/src/main/java/org/apache/iotdb/db/metadata/MTree.java
iotdb/src/main/java/org/apache/iotdb/db/metadata/MTree.java
+33
-0
iotdb/src/test/java/org/apache/iotdb/db/metadata/MManagerBasicTest.java
.../java/org/apache/iotdb/db/metadata/MManagerBasicTest.java
+28
-0
iotdb/src/test/java/org/apache/iotdb/db/metadata/MTreeTest.java
...src/test/java/org/apache/iotdb/db/metadata/MTreeTest.java
+29
-0
未找到文件。
iotdb/src/main/java/org/apache/iotdb/db/metadata/MGraph.java
浏览文件 @
8e4b05ba
...
...
@@ -148,11 +148,22 @@ public class MGraph implements Serializable {
* Check whether the input path is storage level for current Metadata Tree or not.
*
* @param path Format: root.node.(node)*
* @apiNote :for cluster
*/
public
boolean
checkStorageLevel
(
String
path
)
{
return
mtree
.
checkStorageGroup
(
path
);
}
/**
* Check whether the storage group of the input path exists or not
*
* @param path Format: root.node.(node)*
* @apiNote :for cluster
*/
public
boolean
checkStorageExistOfPath
(
String
path
)
{
return
mtree
.
checkStorageExistOfPath
(
path
);
}
/**
* Get all paths for given seriesPath regular expression if given seriesPath belongs to MTree, or
* get all linked seriesPath for given seriesPath if given seriesPath belongs to PTree Notice:
...
...
iotdb/src/main/java/org/apache/iotdb/db/metadata/MManager.java
浏览文件 @
8e4b05ba
...
...
@@ -343,6 +343,7 @@ public class MManager {
/**
* function for checking if the given path is storage level of mTree or not.
* @apiNote :for cluster
*/
public
boolean
checkStorageLevelOfMTree
(
String
path
)
{
lock
.
readLock
().
lock
();
...
...
@@ -353,6 +354,19 @@ public class MManager {
}
}
/**
* function for checking if the storage group of given path exists in mTree or not.
* @apiNote :for cluster
*/
public
boolean
checkStorageExistOfPath
(
String
path
)
{
lock
.
readLock
().
lock
();
try
{
return
mgraph
.
checkStorageExistOfPath
(
path
);
}
finally
{
lock
.
readLock
().
unlock
();
}
}
/**
* function for adding a pTree.
*/
...
...
iotdb/src/main/java/org/apache/iotdb/db/metadata/MTree.java
浏览文件 @
8e4b05ba
...
...
@@ -216,6 +216,7 @@ public class MTree implements Serializable {
* check whether the input path is storage group or not
* @param path input path
* @return if it is storage group, return true. Else return false
* @apiNote :for cluster
*/
public
boolean
checkStorageGroup
(
String
path
)
{
String
[]
nodeNames
=
path
.
split
(
DOUB_SEPARATOR
);
...
...
@@ -240,6 +241,38 @@ public class MTree implements Serializable {
}
}
/**
* Check whether the storage group of the path exists or not
* @param path input path
* @return If it's storage group exists, return true. Else return false
* @apiNote :for cluster
*/
public
boolean
checkStorageExistOfPath
(
String
path
)
{
String
[]
nodeNames
=
path
.
split
(
DOUB_SEPARATOR
);
MNode
cur
=
root
;
if
(
nodeNames
.
length
<=
1
||
!
nodeNames
[
0
].
equals
(
root
.
getName
()))
{
return
false
;
}
int
i
=
1
;
while
(
i
<
nodeNames
.
length
-
1
)
{
MNode
temp
=
cur
.
getChild
(
nodeNames
[
i
]);
if
(
temp
==
null
)
{
return
false
;
}
if
(
temp
.
isStorageLevel
()){
return
true
;
}
cur
=
cur
.
getChild
(
nodeNames
[
i
]);
i
++;
}
MNode
temp
=
cur
.
getChild
(
nodeNames
[
i
]);
if
(
temp
!=
null
&&
temp
.
isStorageLevel
())
{
return
true
;
}
else
{
return
false
;
}
}
/**
* Check whether set file seriesPath for this node or not. If not, throw an exception
*/
...
...
iotdb/src/test/java/org/apache/iotdb/db/metadata/MManagerBasicTest.java
浏览文件 @
8e4b05ba
...
...
@@ -287,4 +287,32 @@ public class MManagerBasicTest {
fail
(
e
.
getMessage
());
}
}
@Test
public
void
testCheckStorageExistOfPath
()
{
MManager
manager
=
MManager
.
getInstance
();
try
{
assertEquals
(
false
,
manager
.
checkStorageExistOfPath
(
"root"
));
assertEquals
(
false
,
manager
.
checkStorageExistOfPath
(
"root.vehicle"
));
assertEquals
(
false
,
manager
.
checkStorageExistOfPath
(
"root.vehicle.device"
));
assertEquals
(
false
,
manager
.
checkStorageExistOfPath
(
"root.vehicle.device.sensor"
));
manager
.
setStorageLevelToMTree
(
"root.vehicle"
);
assertEquals
(
true
,
manager
.
checkStorageExistOfPath
(
"root.vehicle"
));
assertEquals
(
true
,
manager
.
checkStorageExistOfPath
(
"root.vehicle.device"
));
assertEquals
(
true
,
manager
.
checkStorageExistOfPath
(
"root.vehicle.device.sensor"
));
assertEquals
(
false
,
manager
.
checkStorageExistOfPath
(
"root.vehicle1"
));
assertEquals
(
false
,
manager
.
checkStorageExistOfPath
(
"root.vehicle1.device"
));
manager
.
setStorageLevelToMTree
(
"root.vehicle1.device"
);
assertEquals
(
false
,
manager
.
checkStorageExistOfPath
(
"root.vehicle1.device1"
));
assertEquals
(
false
,
manager
.
checkStorageExistOfPath
(
"root.vehicle1.device2"
));
assertEquals
(
false
,
manager
.
checkStorageExistOfPath
(
"root.vehicle1.device3"
));
assertEquals
(
true
,
manager
.
checkStorageExistOfPath
(
"root.vehicle1.device"
));
}
catch
(
PathErrorException
|
IOException
e
)
{
e
.
printStackTrace
();
fail
(
e
.
getMessage
());
}
}
}
iotdb/src/test/java/org/apache/iotdb/db/metadata/MTreeTest.java
浏览文件 @
8e4b05ba
...
...
@@ -213,4 +213,33 @@ public class MTreeTest {
fail
(
e
.
getMessage
());
}
}
@Test
public
void
testCheckStorageExistOfPath
()
{
// set storage group first
MTree
root
=
new
MTree
(
"root"
);
try
{
assertEquals
(
false
,
root
.
checkStorageExistOfPath
(
"root"
));
assertEquals
(
false
,
root
.
checkStorageExistOfPath
(
"root.vehicle"
));
assertEquals
(
false
,
root
.
checkStorageExistOfPath
(
"root.vehicle.device"
));
assertEquals
(
false
,
root
.
checkStorageExistOfPath
(
"root.vehicle.device.sensor"
));
root
.
setStorageGroup
(
"root.vehicle"
);
assertEquals
(
true
,
root
.
checkStorageExistOfPath
(
"root.vehicle"
));
assertEquals
(
true
,
root
.
checkStorageExistOfPath
(
"root.vehicle.device"
));
assertEquals
(
true
,
root
.
checkStorageExistOfPath
(
"root.vehicle.device.sensor"
));
assertEquals
(
false
,
root
.
checkStorageExistOfPath
(
"root.vehicle1"
));
assertEquals
(
false
,
root
.
checkStorageExistOfPath
(
"root.vehicle1.device"
));
root
.
setStorageGroup
(
"root.vehicle1.device"
);
assertEquals
(
false
,
root
.
checkStorageExistOfPath
(
"root.vehicle1.device1"
));
assertEquals
(
false
,
root
.
checkStorageExistOfPath
(
"root.vehicle1.device2"
));
assertEquals
(
false
,
root
.
checkStorageExistOfPath
(
"root.vehicle1.device3"
));
assertEquals
(
true
,
root
.
checkStorageExistOfPath
(
"root.vehicle1.device"
));
}
catch
(
PathErrorException
e
)
{
e
.
printStackTrace
();
fail
(
e
.
getMessage
());
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录