Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
a2ededd6
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,发现更多精彩内容 >>
未验证
提交
a2ededd6
编写于
3月 17, 2020
作者:
M
menghaoranss
提交者:
GitHub
3月 17, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
For issue4736 fix example errors (#4796)
上级
cb2c4942
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
68 addition
and
68 deletion
+68
-68
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/JavaConfigurationExampleMain.java
.../orchestration/raw/jdbc/JavaConfigurationExampleMain.java
+6
-6
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/RegistryCenterConfigurationUtil.java
...tion/raw/jdbc/config/RegistryCenterConfigurationUtil.java
+8
-8
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/cloud/CloudEncryptConfiguration.java
...tion/raw/jdbc/config/cloud/CloudEncryptConfiguration.java
+6
-6
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/cloud/CloudMasterSlaveConfiguration.java
.../raw/jdbc/config/cloud/CloudMasterSlaveConfiguration.java
+6
-6
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/cloud/CloudShardingDatabasesAndTablesConfiguration.java
...g/cloud/CloudShardingDatabasesAndTablesConfiguration.java
+6
-6
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalEncryptConfiguration.java
...tion/raw/jdbc/config/local/LocalEncryptConfiguration.java
+6
-6
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalMasterSlaveConfiguration.java
.../raw/jdbc/config/local/LocalMasterSlaveConfiguration.java
+6
-6
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalShardingDatabasesAndTablesConfiguration.java
...g/local/LocalShardingDatabasesAndTablesConfiguration.java
+6
-6
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalShardingDatabasesConfiguration.java
...dbc/config/local/LocalShardingDatabasesConfiguration.java
+6
-6
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalShardingMasterSlaveConfiguration.java
...c/config/local/LocalShardingMasterSlaveConfiguration.java
+6
-6
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalShardingTablesConfiguration.java
...w/jdbc/config/local/LocalShardingTablesConfiguration.java
+6
-6
未找到文件。
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/JavaConfigurationExampleMain.java
浏览文件 @
a2ededd6
...
...
@@ -30,8 +30,8 @@ import org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local.Loc
import
org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local.LocalShardingDatabasesAndTablesConfiguration
;
import
org.apache.shardingsphere.example.type.RegistryCenterType
;
import
org.apache.shardingsphere.example.type.ShardingType
;
import
org.apache.shardingsphere.orchestration.center.configuration.InstanceConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.jdbc.adapter.AbstractDataSourceAdapter
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.CenterConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
...
...
@@ -64,18 +64,18 @@ public class JavaConfigurationExampleMain {
}
private
static
DataSource
getDataSource
(
final
ShardingType
shardingType
,
final
boolean
loadConfigFromRegCenter
)
throws
SQLException
{
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
=
getRegistryCenterConfiguration
(
registryCenterType
,
shardingType
);
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
=
getRegistryCenterConfiguration
(
registryCenterType
,
shardingType
);
ExampleConfiguration
configuration
;
switch
(
shardingType
)
{
case
SHARDING_DATABASES_AND_TABLES:
configuration
=
loadConfigFromRegCenter
?
new
CloudShardingDatabasesAndTablesConfiguration
(
instanceConfigurationMap
)
:
new
LocalShardingDatabasesAndTablesConfiguration
(
instance
ConfigurationMap
);
?
new
CloudShardingDatabasesAndTablesConfiguration
(
centerConfigurationMap
)
:
new
LocalShardingDatabasesAndTablesConfiguration
(
center
ConfigurationMap
);
break
;
case
MASTER_SLAVE:
configuration
=
loadConfigFromRegCenter
?
new
CloudMasterSlaveConfiguration
(
instanceConfigurationMap
)
:
new
LocalMasterSlaveConfiguration
(
instance
ConfigurationMap
);
configuration
=
loadConfigFromRegCenter
?
new
CloudMasterSlaveConfiguration
(
centerConfigurationMap
)
:
new
LocalMasterSlaveConfiguration
(
center
ConfigurationMap
);
break
;
case
ENCRYPT:
configuration
=
loadConfigFromRegCenter
?
new
CloudEncryptConfiguration
(
instanceConfigurationMap
)
:
new
LocalEncryptConfiguration
(
instance
ConfigurationMap
);
configuration
=
loadConfigFromRegCenter
?
new
CloudEncryptConfiguration
(
centerConfigurationMap
)
:
new
LocalEncryptConfiguration
(
center
ConfigurationMap
);
break
;
default
:
throw
new
UnsupportedOperationException
(
shardingType
.
name
());
...
...
@@ -83,7 +83,7 @@ public class JavaConfigurationExampleMain {
return
configuration
.
getDataSource
();
}
private
static
Map
<
String
,
Instance
Configuration
>
getRegistryCenterConfiguration
(
final
RegistryCenterType
registryCenterType
,
ShardingType
shardingType
)
{
private
static
Map
<
String
,
Center
Configuration
>
getRegistryCenterConfiguration
(
final
RegistryCenterType
registryCenterType
,
ShardingType
shardingType
)
{
return
RegistryCenterType
.
ZOOKEEPER
==
registryCenterType
?
RegistryCenterConfigurationUtil
.
getZooKeeperConfiguration
(
String
.
valueOf
(!
loadConfigFromRegCenter
),
shardingType
)
:
RegistryCenterConfigurationUtil
.
getNacosConfiguration
(
String
.
valueOf
(!
loadConfigFromRegCenter
),
shardingType
);
}
...
...
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/RegistryCenterConfigurationUtil.java
浏览文件 @
a2ededd6
...
...
@@ -18,7 +18,7 @@
package
org.apache.shardingsphere.example.orchestration.raw.jdbc.config
;
import
org.apache.shardingsphere.example.type.ShardingType
;
import
org.apache.shardingsphere.
orchestration.center.configuration.Instance
Configuration
;
import
org.apache.shardingsphere.
underlying.common.config.orchestration.Center
Configuration
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -34,11 +34,11 @@ public class RegistryCenterConfigurationUtil {
private
static
final
String
NACOS_NAMESPACE
=
""
;
public
static
Map
<
String
,
Instance
Configuration
>
getZooKeeperConfiguration
(
String
overwrite
,
ShardingType
shardingType
)
{
Map
<
String
,
InstanceConfiguration
>
instanceConfigurationMap
=
new
HashMap
<
String
,
Instance
Configuration
>();
public
static
Map
<
String
,
Center
Configuration
>
getZooKeeperConfiguration
(
String
overwrite
,
ShardingType
shardingType
)
{
Map
<
String
,
CenterConfiguration
>
instanceConfigurationMap
=
new
HashMap
<
String
,
Center
Configuration
>();
Properties
properties
=
new
Properties
();
properties
.
setProperty
(
"overwrite"
,
overwrite
);
InstanceConfiguration
result
=
new
Instance
Configuration
(
"zookeeper"
,
properties
);
CenterConfiguration
result
=
new
Center
Configuration
(
"zookeeper"
,
properties
);
result
.
setServerLists
(
ZOOKEEPER_CONNECTION_STRING
);
result
.
setNamespace
(
NAMESPACE
);
result
.
setOrchestrationType
(
"registry_center,config_center"
);
...
...
@@ -56,19 +56,19 @@ public class RegistryCenterConfigurationUtil {
return
instanceConfigurationMap
;
}
public
static
Map
<
String
,
Instance
Configuration
>
getNacosConfiguration
(
String
overwrite
,
ShardingType
shardingType
)
{
Map
<
String
,
InstanceConfiguration
>
instanceConfigurationMap
=
new
HashMap
<
String
,
Instance
Configuration
>();
public
static
Map
<
String
,
Center
Configuration
>
getNacosConfiguration
(
String
overwrite
,
ShardingType
shardingType
)
{
Map
<
String
,
CenterConfiguration
>
instanceConfigurationMap
=
new
HashMap
<
String
,
Center
Configuration
>();
Properties
nacosProperties
=
new
Properties
();
nacosProperties
.
setProperty
(
"group"
,
"SHARDING_SPHERE_DEFAULT_GROUP"
);
nacosProperties
.
setProperty
(
"timeout"
,
"3000"
);
nacosProperties
.
setProperty
(
"overwrite"
,
overwrite
);
InstanceConfiguration
nacosResult
=
new
Instance
Configuration
(
"nacos"
,
nacosProperties
);
CenterConfiguration
nacosResult
=
new
Center
Configuration
(
"nacos"
,
nacosProperties
);
nacosResult
.
setServerLists
(
NACOS_CONNECTION_STRING
);
nacosResult
.
setNamespace
(
NACOS_NAMESPACE
);
nacosResult
.
setOrchestrationType
(
"config_center"
);
Properties
zookeeperProperties
=
new
Properties
();
zookeeperProperties
.
setProperty
(
"overwrite"
,
overwrite
);
InstanceConfiguration
zookeeperResult
=
new
Instance
Configuration
(
"zookeeper"
,
zookeeperProperties
);
CenterConfiguration
zookeeperResult
=
new
Center
Configuration
(
"zookeeper"
,
zookeeperProperties
);
zookeeperResult
.
setServerLists
(
ZOOKEEPER_CONNECTION_STRING
);
zookeeperResult
.
setNamespace
(
NAMESPACE
);
zookeeperResult
.
setOrchestrationType
(
"registry_center"
);
...
...
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/cloud/CloudEncryptConfiguration.java
浏览文件 @
a2ededd6
...
...
@@ -18,9 +18,9 @@
package
org.apache.shardingsphere.example.orchestration.raw.jdbc.config.cloud
;
import
org.apache.shardingsphere.example.config.ExampleConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.InstanceConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.api.OrchestrationEncryptDataSourceFactory
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.CenterConfiguration
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.OrchestrationConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
...
...
@@ -28,14 +28,14 @@ import java.util.Map;
public
class
CloudEncryptConfiguration
implements
ExampleConfiguration
{
private
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
;
private
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
;
public
CloudEncryptConfiguration
(
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
)
{
this
.
instanceConfigurationMap
=
instance
ConfigurationMap
;
public
CloudEncryptConfiguration
(
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
)
{
this
.
centerConfigurationMap
=
center
ConfigurationMap
;
}
@Override
public
DataSource
getDataSource
()
throws
SQLException
{
return
OrchestrationEncryptDataSourceFactory
.
createDataSource
(
new
OrchestrationConfiguration
(
instance
ConfigurationMap
));
return
OrchestrationEncryptDataSourceFactory
.
createDataSource
(
new
OrchestrationConfiguration
(
center
ConfigurationMap
));
}
}
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/cloud/CloudMasterSlaveConfiguration.java
浏览文件 @
a2ededd6
...
...
@@ -18,9 +18,9 @@
package
org.apache.shardingsphere.example.orchestration.raw.jdbc.config.cloud
;
import
org.apache.shardingsphere.example.config.ExampleConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.InstanceConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.api.OrchestrationMasterSlaveDataSourceFactory
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.CenterConfiguration
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.OrchestrationConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
...
...
@@ -28,15 +28,15 @@ import java.util.Map;
public
final
class
CloudMasterSlaveConfiguration
implements
ExampleConfiguration
{
private
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
;
private
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
;
public
CloudMasterSlaveConfiguration
(
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
)
{
this
.
instanceConfigurationMap
=
instance
ConfigurationMap
;
public
CloudMasterSlaveConfiguration
(
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
)
{
this
.
centerConfigurationMap
=
center
ConfigurationMap
;
}
@Override
public
DataSource
getDataSource
()
throws
SQLException
{
return
OrchestrationMasterSlaveDataSourceFactory
.
createDataSource
(
new
OrchestrationConfiguration
(
instance
ConfigurationMap
));
return
OrchestrationMasterSlaveDataSourceFactory
.
createDataSource
(
new
OrchestrationConfiguration
(
center
ConfigurationMap
));
}
}
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/cloud/CloudShardingDatabasesAndTablesConfiguration.java
浏览文件 @
a2ededd6
...
...
@@ -18,9 +18,9 @@
package
org.apache.shardingsphere.example.orchestration.raw.jdbc.config.cloud
;
import
org.apache.shardingsphere.example.config.ExampleConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.InstanceConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.api.OrchestrationShardingDataSourceFactory
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.CenterConfiguration
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.OrchestrationConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
...
...
@@ -28,14 +28,14 @@ import java.util.Map;
public
final
class
CloudShardingDatabasesAndTablesConfiguration
implements
ExampleConfiguration
{
private
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
;
private
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
;
public
CloudShardingDatabasesAndTablesConfiguration
(
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
)
{
this
.
instanceConfigurationMap
=
instance
ConfigurationMap
;
public
CloudShardingDatabasesAndTablesConfiguration
(
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
)
{
this
.
centerConfigurationMap
=
center
ConfigurationMap
;
}
@Override
public
DataSource
getDataSource
()
throws
SQLException
{
return
OrchestrationShardingDataSourceFactory
.
createDataSource
(
new
OrchestrationConfiguration
(
instance
ConfigurationMap
));
return
OrchestrationShardingDataSourceFactory
.
createDataSource
(
new
OrchestrationConfiguration
(
center
ConfigurationMap
));
}
}
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalEncryptConfiguration.java
浏览文件 @
a2ededd6
...
...
@@ -23,9 +23,9 @@ import org.apache.shardingsphere.encrypt.api.EncryptTableRuleConfiguration;
import
org.apache.shardingsphere.encrypt.api.EncryptorRuleConfiguration
;
import
org.apache.shardingsphere.example.config.ExampleConfiguration
;
import
org.apache.shardingsphere.example.core.api.DataSourceUtil
;
import
org.apache.shardingsphere.orchestration.center.configuration.InstanceConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.api.OrchestrationEncryptDataSourceFactory
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.CenterConfiguration
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.OrchestrationConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
...
...
@@ -35,10 +35,10 @@ import java.util.Properties;
public
class
LocalEncryptConfiguration
implements
ExampleConfiguration
{
private
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
;
private
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
;
public
LocalEncryptConfiguration
(
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
)
{
this
.
instanceConfigurationMap
=
instance
ConfigurationMap
;
public
LocalEncryptConfiguration
(
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
)
{
this
.
centerConfigurationMap
=
center
ConfigurationMap
;
}
@Override
...
...
@@ -47,7 +47,7 @@ public class LocalEncryptConfiguration implements ExampleConfiguration {
}
private
OrchestrationConfiguration
getOrchestrationConfiguration
()
{
return
new
OrchestrationConfiguration
(
instance
ConfigurationMap
);
return
new
OrchestrationConfiguration
(
center
ConfigurationMap
);
}
private
EncryptRuleConfiguration
getEncryptRuleConfiguration
()
{
...
...
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalMasterSlaveConfiguration.java
浏览文件 @
a2ededd6
...
...
@@ -20,9 +20,9 @@ package org.apache.shardingsphere.example.orchestration.raw.jdbc.config.local;
import
org.apache.shardingsphere.api.config.masterslave.MasterSlaveRuleConfiguration
;
import
org.apache.shardingsphere.example.config.ExampleConfiguration
;
import
org.apache.shardingsphere.example.core.api.DataSourceUtil
;
import
org.apache.shardingsphere.orchestration.center.configuration.InstanceConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.api.OrchestrationMasterSlaveDataSourceFactory
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.CenterConfiguration
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.OrchestrationConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
...
...
@@ -33,16 +33,16 @@ import java.util.Properties;
public
final
class
LocalMasterSlaveConfiguration
implements
ExampleConfiguration
{
private
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
;
private
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
;
public
LocalMasterSlaveConfiguration
(
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
)
{
this
.
instanceConfigurationMap
=
instance
ConfigurationMap
;
public
LocalMasterSlaveConfiguration
(
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
)
{
this
.
centerConfigurationMap
=
center
ConfigurationMap
;
}
@Override
public
DataSource
getDataSource
()
throws
SQLException
{
MasterSlaveRuleConfiguration
masterSlaveRuleConfig
=
new
MasterSlaveRuleConfiguration
(
"demo_ds_master_slave"
,
"demo_ds_master"
,
Arrays
.
asList
(
"demo_ds_slave_0"
,
"demo_ds_slave_1"
));
OrchestrationConfiguration
orchestrationConfig
=
new
OrchestrationConfiguration
(
instance
ConfigurationMap
);
OrchestrationConfiguration
orchestrationConfig
=
new
OrchestrationConfiguration
(
center
ConfigurationMap
);
return
OrchestrationMasterSlaveDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
masterSlaveRuleConfig
,
new
Properties
(),
orchestrationConfig
);
}
...
...
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalShardingDatabasesAndTablesConfiguration.java
浏览文件 @
a2ededd6
...
...
@@ -25,9 +25,9 @@ import org.apache.shardingsphere.api.config.sharding.strategy.StandardShardingSt
import
org.apache.shardingsphere.example.algorithm.PreciseModuloShardingTableAlgorithm
;
import
org.apache.shardingsphere.example.config.ExampleConfiguration
;
import
org.apache.shardingsphere.example.core.api.DataSourceUtil
;
import
org.apache.shardingsphere.orchestration.center.configuration.InstanceConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.api.OrchestrationShardingDataSourceFactory
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.CenterConfiguration
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.OrchestrationConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
...
...
@@ -37,10 +37,10 @@ import java.util.Properties;
public
final
class
LocalShardingDatabasesAndTablesConfiguration
implements
ExampleConfiguration
{
private
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
;
private
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
;
public
LocalShardingDatabasesAndTablesConfiguration
(
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
)
{
this
.
instanceConfigurationMap
=
instance
ConfigurationMap
;
public
LocalShardingDatabasesAndTablesConfiguration
(
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
)
{
this
.
centerConfigurationMap
=
center
ConfigurationMap
;
}
private
static
KeyGeneratorConfiguration
getKeyGeneratorConfiguration
()
{
...
...
@@ -58,7 +58,7 @@ public final class LocalShardingDatabasesAndTablesConfiguration implements Examp
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_address"
);
shardingRuleConfig
.
setDefaultDatabaseShardingStrategyConfig
(
new
InlineShardingStrategyConfiguration
(
"user_id"
,
"demo_ds_${user_id % 2}"
));
shardingRuleConfig
.
setDefaultTableShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"order_id"
,
new
PreciseModuloShardingTableAlgorithm
()));
OrchestrationConfiguration
orchestrationConfig
=
new
OrchestrationConfiguration
(
instance
ConfigurationMap
);
OrchestrationConfiguration
orchestrationConfig
=
new
OrchestrationConfiguration
(
center
ConfigurationMap
);
return
OrchestrationShardingDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
shardingRuleConfig
,
new
Properties
(),
orchestrationConfig
);
}
...
...
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalShardingDatabasesConfiguration.java
浏览文件 @
a2ededd6
...
...
@@ -23,9 +23,9 @@ import org.apache.shardingsphere.api.config.sharding.TableRuleConfiguration;
import
org.apache.shardingsphere.api.config.sharding.strategy.InlineShardingStrategyConfiguration
;
import
org.apache.shardingsphere.example.config.ExampleConfiguration
;
import
org.apache.shardingsphere.example.core.api.DataSourceUtil
;
import
org.apache.shardingsphere.orchestration.center.configuration.InstanceConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.api.OrchestrationShardingDataSourceFactory
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.CenterConfiguration
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.OrchestrationConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
...
...
@@ -35,10 +35,10 @@ import java.util.Properties;
public
final
class
LocalShardingDatabasesConfiguration
implements
ExampleConfiguration
{
private
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
;
private
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
;
public
LocalShardingDatabasesConfiguration
(
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
)
{
this
.
instanceConfigurationMap
=
instance
ConfigurationMap
;
public
LocalShardingDatabasesConfiguration
(
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
)
{
this
.
centerConfigurationMap
=
center
ConfigurationMap
;
}
private
static
KeyGeneratorConfiguration
getKeyGeneratorConfiguration
()
{
...
...
@@ -55,7 +55,7 @@ public final class LocalShardingDatabasesConfiguration implements ExampleConfigu
shardingRuleConfig
.
getBindingTableGroups
().
add
(
"t_order, t_order_item"
);
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_address"
);
shardingRuleConfig
.
setDefaultDatabaseShardingStrategyConfig
(
new
InlineShardingStrategyConfiguration
(
"user_id"
,
"demo_ds_${user_id % 2}"
));
OrchestrationConfiguration
orchestrationConfig
=
new
OrchestrationConfiguration
(
instance
ConfigurationMap
);
OrchestrationConfiguration
orchestrationConfig
=
new
OrchestrationConfiguration
(
center
ConfigurationMap
);
return
OrchestrationShardingDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
shardingRuleConfig
,
new
Properties
(),
orchestrationConfig
);
}
...
...
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalShardingMasterSlaveConfiguration.java
浏览文件 @
a2ededd6
...
...
@@ -27,9 +27,9 @@ import org.apache.shardingsphere.api.config.sharding.KeyGeneratorConfiguration;
import
org.apache.shardingsphere.api.config.sharding.ShardingRuleConfiguration
;
import
org.apache.shardingsphere.api.config.sharding.TableRuleConfiguration
;
import
org.apache.shardingsphere.api.config.sharding.strategy.StandardShardingStrategyConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.InstanceConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.api.OrchestrationShardingDataSourceFactory
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.CenterConfiguration
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.OrchestrationConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
...
...
@@ -41,10 +41,10 @@ import java.util.Properties;
public
final
class
LocalShardingMasterSlaveConfiguration
implements
ExampleConfiguration
{
private
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
;
private
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
;
public
LocalShardingMasterSlaveConfiguration
(
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
)
{
this
.
instanceConfigurationMap
=
instance
ConfigurationMap
;
public
LocalShardingMasterSlaveConfiguration
(
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
)
{
this
.
centerConfigurationMap
=
center
ConfigurationMap
;
}
@Override
...
...
@@ -57,7 +57,7 @@ public final class LocalShardingMasterSlaveConfiguration implements ExampleConfi
shardingRuleConfig
.
setDefaultDatabaseShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"user_id"
,
new
PreciseModuloShardingDatabaseAlgorithm
()));
shardingRuleConfig
.
setDefaultTableShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"order_id"
,
new
PreciseModuloShardingTableAlgorithm
()));
shardingRuleConfig
.
setMasterSlaveRuleConfigs
(
getMasterSlaveRuleConfigurations
());
OrchestrationConfiguration
orchestrationConfig
=
new
OrchestrationConfiguration
(
instance
ConfigurationMap
);
OrchestrationConfiguration
orchestrationConfig
=
new
OrchestrationConfiguration
(
center
ConfigurationMap
);
return
OrchestrationShardingDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
shardingRuleConfig
,
new
Properties
(),
orchestrationConfig
);
}
...
...
examples/sharding-jdbc-example/orchestration-example/orchestration-raw-jdbc-example/src/main/java/org/apache/shardingsphere/example/orchestration/raw/jdbc/config/local/LocalShardingTablesConfiguration.java
浏览文件 @
a2ededd6
...
...
@@ -24,9 +24,9 @@ import org.apache.shardingsphere.api.config.sharding.strategy.StandardShardingSt
import
org.apache.shardingsphere.example.algorithm.PreciseModuloShardingTableAlgorithm
;
import
org.apache.shardingsphere.example.config.ExampleConfiguration
;
import
org.apache.shardingsphere.example.core.api.DataSourceUtil
;
import
org.apache.shardingsphere.orchestration.center.configuration.InstanceConfiguration
;
import
org.apache.shardingsphere.orchestration.center.configuration.OrchestrationConfiguration
;
import
org.apache.shardingsphere.shardingjdbc.orchestration.api.OrchestrationShardingDataSourceFactory
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.CenterConfiguration
;
import
org.apache.shardingsphere.underlying.common.config.orchestration.OrchestrationConfiguration
;
import
javax.sql.DataSource
;
import
java.sql.SQLException
;
...
...
@@ -36,10 +36,10 @@ import java.util.Properties;
public
final
class
LocalShardingTablesConfiguration
implements
ExampleConfiguration
{
private
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
;
private
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
;
public
LocalShardingTablesConfiguration
(
final
Map
<
String
,
InstanceConfiguration
>
instance
ConfigurationMap
)
{
this
.
instanceConfigurationMap
=
instance
ConfigurationMap
;
public
LocalShardingTablesConfiguration
(
final
Map
<
String
,
CenterConfiguration
>
center
ConfigurationMap
)
{
this
.
centerConfigurationMap
=
center
ConfigurationMap
;
}
@Override
...
...
@@ -50,7 +50,7 @@ public final class LocalShardingTablesConfiguration implements ExampleConfigurat
shardingRuleConfig
.
getBindingTableGroups
().
add
(
"t_order, t_order_item"
);
shardingRuleConfig
.
getBroadcastTables
().
add
(
"t_address"
);
shardingRuleConfig
.
setDefaultTableShardingStrategyConfig
(
new
StandardShardingStrategyConfiguration
(
"order_id"
,
new
PreciseModuloShardingTableAlgorithm
()));
OrchestrationConfiguration
orchestrationConfig
=
new
OrchestrationConfiguration
(
instance
ConfigurationMap
);
OrchestrationConfiguration
orchestrationConfig
=
new
OrchestrationConfiguration
(
center
ConfigurationMap
);
return
OrchestrationShardingDataSourceFactory
.
createDataSource
(
createDataSourceMap
(),
shardingRuleConfig
,
new
Properties
(),
orchestrationConfig
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录