Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
e785816d
Shardingsphere
项目概览
apache
/
Shardingsphere
通知
56
Star
3
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Shardingsphere
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
e785816d
编写于
11月 10, 2020
作者:
L
Liang Zhang
提交者:
GitHub
11月 10, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add addressingDataSources in reg center (#8123)
上级
dccf7c66
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
17 addition
and
1 deletion
+17
-1
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/main/java/org/apache/shardingsphere/governance/core/yaml/config/schema/YamlTableMetaData.java
...governance/core/yaml/config/schema/YamlTableMetaData.java
+3
-0
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/SchemaYamlSwapper.java
...phere/governance/core/yaml/swapper/SchemaYamlSwapper.java
+4
-1
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/SchemaYamlSwapperTest.java
...e/governance/core/yaml/swapper/SchemaYamlSwapperTest.java
+7
-0
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/test/resources/yaml/schema.yaml
...overnance-core-common/src/test/resources/yaml/schema.yaml
+3
-0
未找到文件。
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/main/java/org/apache/shardingsphere/governance/core/yaml/config/schema/YamlTableMetaData.java
浏览文件 @
e785816d
...
...
@@ -21,6 +21,7 @@ import lombok.Getter;
import
lombok.Setter
;
import
org.apache.shardingsphere.infra.yaml.config.YamlConfiguration
;
import
java.util.Collection
;
import
java.util.Map
;
/**
...
...
@@ -33,4 +34,6 @@ public final class YamlTableMetaData implements YamlConfiguration {
private
Map
<
String
,
YamlColumnMetaData
>
columns
;
private
Map
<
String
,
YamlIndexMetaData
>
indexes
;
private
Collection
<
String
>
addressingDataSources
;
}
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/main/java/org/apache/shardingsphere/governance/core/yaml/swapper/SchemaYamlSwapper.java
浏览文件 @
e785816d
...
...
@@ -60,7 +60,9 @@ public final class SchemaYamlSwapper implements YamlSwapper<YamlSchema, Sharding
}
private
TableMetaData
convertTable
(
final
YamlTableMetaData
table
)
{
return
new
TableMetaData
(
convertColumns
(
table
.
getColumns
()),
convertIndexes
(
table
.
getIndexes
()));
TableMetaData
result
=
new
TableMetaData
(
convertColumns
(
table
.
getColumns
()),
convertIndexes
(
table
.
getIndexes
()));
result
.
getAddressingDataSources
().
addAll
(
table
.
getAddressingDataSources
());
return
result
;
}
private
Collection
<
IndexMetaData
>
convertIndexes
(
final
Map
<
String
,
YamlIndexMetaData
>
indexes
)
{
...
...
@@ -83,6 +85,7 @@ public final class SchemaYamlSwapper implements YamlSwapper<YamlSchema, Sharding
YamlTableMetaData
result
=
new
YamlTableMetaData
();
result
.
setColumns
(
convertYamlColumns
(
table
.
getColumns
()));
result
.
setIndexes
(
convertYamlIndexes
(
table
.
getIndexes
()));
result
.
setAddressingDataSources
(
table
.
getAddressingDataSources
());
return
result
;
}
...
...
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/test/java/org/apache/shardingsphere/governance/core/yaml/swapper/SchemaYamlSwapperTest.java
浏览文件 @
e785816d
...
...
@@ -33,6 +33,7 @@ import java.util.stream.Collectors;
import
static
org
.
hamcrest
.
CoreMatchers
.
is
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertThat
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
public
final
class
SchemaYamlSwapperTest
{
...
...
@@ -46,6 +47,9 @@ public final class SchemaYamlSwapperTest {
assertThat
(
yamlSchema
.
getTables
().
keySet
(),
is
(
Collections
.
singleton
(
"t_order"
)));
assertThat
(
yamlSchema
.
getTables
().
get
(
"t_order"
).
getIndexes
().
keySet
(),
is
(
Collections
.
singleton
(
"primary"
)));
assertThat
(
yamlSchema
.
getTables
().
get
(
"t_order"
).
getColumns
().
keySet
(),
is
(
Collections
.
singleton
(
"id"
)));
assertThat
(
yamlSchema
.
getTables
().
get
(
"t_order"
).
getAddressingDataSources
().
size
(),
is
(
2
));
assertTrue
(
yamlSchema
.
getTables
().
get
(
"t_order"
).
getAddressingDataSources
().
contains
(
"ds_0"
));
assertTrue
(
yamlSchema
.
getTables
().
get
(
"t_order"
).
getAddressingDataSources
().
contains
(
"ds_1"
));
}
@Test
...
...
@@ -56,6 +60,9 @@ public final class SchemaYamlSwapperTest {
assertThat
(
schema
.
get
(
"t_order"
).
getIndexes
().
keySet
(),
is
(
Collections
.
singleton
(
"primary"
)));
assertThat
(
schema
.
getAllColumnNames
(
"t_order"
).
size
(),
is
(
1
));
assertThat
(
schema
.
get
(
"t_order"
).
getColumns
().
keySet
(),
is
(
Collections
.
singleton
(
"id"
)));
assertThat
(
schema
.
get
(
"t_order"
).
getAddressingDataSources
().
size
(),
is
(
2
));
assertTrue
(
schema
.
get
(
"t_order"
).
getAddressingDataSources
().
contains
(
"ds_0"
));
assertTrue
(
schema
.
get
(
"t_order"
).
getAddressingDataSources
().
contains
(
"ds_1"
));
}
@SneakyThrows
({
URISyntaxException
.
class
,
IOException
.
class
})
...
...
shardingsphere-governance/shardingsphere-governance-core/shardingsphere-governance-core-common/src/test/resources/yaml/schema.yaml
浏览文件 @
e785816d
...
...
@@ -27,3 +27,6 @@ tables:
indexes
:
primary
:
name
:
PRIMARY
addressingDataSources
:
-
ds_0
-
ds_1
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录