Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
15c0c607
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 搜索 >>
提交
15c0c607
编写于
12月 11, 2019
作者:
公众号-WU双
提交者:
avalon566
12月 11, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#3704 Config optimization for ShardingScaling (#3706)
* Config optimization * For checkstyle * use basic type
上级
576985bf
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
117 addition
and
32 deletion
+117
-32
sharding-distribution/sharding-scaling-distribution/src/main/resources/bin/start.sh
...ding-scaling-distribution/src/main/resources/bin/start.sh
+1
-3
sharding-distribution/sharding-scaling-distribution/src/main/resources/conf/config.json
...-scaling-distribution/src/main/resources/conf/config.json
+1
-3
sharding-distribution/sharding-scaling-distribution/src/main/resources/conf/server.yaml
...-scaling-distribution/src/main/resources/conf/server.yaml
+21
-0
sharding-scaling/sharding-scaling-bootstrap/src/main/java/org/apache/shardingsphere/shardingscaling/Bootstrap.java
.../org/apache/shardingsphere/shardingscaling/Bootstrap.java
+18
-3
sharding-scaling/sharding-scaling-bootstrap/src/main/resources/conf/config.json
...ing-scaling-bootstrap/src/main/resources/conf/config.json
+2
-4
sharding-scaling/sharding-scaling-bootstrap/src/main/resources/conf/server.yaml
...ing-scaling-bootstrap/src/main/resources/conf/server.yaml
+21
-0
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/config/JobConfiguration.java
...gsphere/shardingscaling/core/config/JobConfiguration.java
+30
-0
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/config/ScalingConfiguration.java
...ere/shardingscaling/core/config/ScalingConfiguration.java
+1
-1
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/config/ScalingContext.java
...ingsphere/shardingscaling/core/config/ScalingContext.java
+1
-5
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/config/ServerConfiguration.java
...here/shardingscaling/core/config/ServerConfiguration.java
+11
-6
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/execute/engine/ExecuteUtil.java
...here/shardingscaling/core/execute/engine/ExecuteUtil.java
+2
-1
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/execute/executor/channel/MemoryChannel.java
...gscaling/core/execute/executor/channel/MemoryChannel.java
+3
-2
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/web/util/SyncConfigurationUtil.java
.../shardingscaling/core/web/util/SyncConfigurationUtil.java
+1
-1
sharding-scaling/sharding-scaling-core/src/test/java/org/apache/shardingsphere/shardingscaling/core/synctask/history/HistoryDataSyncTaskTest.java
...caling/core/synctask/history/HistoryDataSyncTaskTest.java
+3
-0
sharding-scaling/sharding-scaling-core/src/test/resources/config.json
...ling/sharding-scaling-core/src/test/resources/config.json
+1
-3
未找到文件。
sharding-distribution/sharding-scaling-distribution/src/main/resources/bin/start.sh
浏览文件 @
15c0c607
...
...
@@ -20,10 +20,8 @@ cd `dirname $0`
cd
..
DEPLOY_DIR
=
`
pwd
`
JAVA_OPTS
=
" -Dport=8080 "
CLASS_PATH
=
.:
${
DEPLOY_DIR
}
/conf:
${
DEPLOY_DIR
}
/lib/
*
MAIN_CLASS
=
org.apache.shardingsphere.shardingscaling.Bootstrap
java
${
JAVA_OPTS
}
-classpath
${
CLASS_PATH
}
${
MAIN_CLASS
}
java
-classpath
${
CLASS_PATH
}
${
MAIN_CLASS
}
sharding-distribution/sharding-scaling-distribution/src/main/resources/conf/config.json
浏览文件 @
15c0c607
...
...
@@ -32,9 +32,7 @@
"username"
:
"root"
}
},
"serverConfiguration"
:
{
"blockQueueSize"
:
10000
,
"pushTimeout"
:
1000
,
"jobConfiguration"
:
{
"concurrency"
:
3
}
}
sharding-distribution/sharding-scaling-distribution/src/main/resources/conf/server.yaml
0 → 100644
浏览文件 @
15c0c607
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# port: 8888
# blockQueueSize: 10000
# pushTimeout: 1000
# workerThread: 30
sharding-scaling/sharding-scaling-bootstrap/src/main/java/org/apache/shardingsphere/shardingscaling/Bootstrap.java
浏览文件 @
15c0c607
...
...
@@ -17,6 +17,7 @@
package
org.apache.shardingsphere.shardingscaling
;
import
com.google.common.base.Preconditions
;
import
io.netty.bootstrap.ServerBootstrap
;
import
io.netty.channel.Channel
;
import
io.netty.channel.ChannelOption
;
...
...
@@ -28,10 +29,14 @@ import io.netty.handler.logging.LoggingHandler;
import
lombok.SneakyThrows
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.log4j.PropertyConfigurator
;
import
org.apache.shardingsphere.core.yaml.engine.YamlEngine
;
import
org.apache.shardingsphere.shardingscaling.core.config.ScalingContext
;
import
org.apache.shardingsphere.shardingscaling.core.config.ServerConfiguration
;
import
org.apache.shardingsphere.shardingscaling.core.web.HttpServerInitializer
;
import
org.apache.shardingsphere.shardingscaling.utils.RuntimeUtil
;
import
java.io.File
;
import
java.io.IOException
;
/**
* Bootstrap of ShardingScaling.
...
...
@@ -41,7 +46,7 @@ import java.io.File;
@Slf4j
public
class
Bootstrap
{
private
static
final
int
PORT
=
Integer
.
parseInt
(
System
.
getProperty
(
"port"
,
"8080"
))
;
private
static
final
String
SERVER_CONFIG_FILE
=
"/conf/server.yaml"
;
static
{
PropertyConfigurator
.
configure
(
RuntimeUtil
.
getBasePath
()
+
"conf"
+
File
.
separator
+
"log4j.properties"
);
...
...
@@ -54,6 +59,8 @@ public class Bootstrap {
*/
@SneakyThrows
public
static
void
main
(
final
String
[]
args
)
{
log
.
info
(
"Init server config"
);
initServerConfig
();
log
.
info
(
"ShardingScaling Startup"
);
EventLoopGroup
bossGroup
=
new
NioEventLoopGroup
(
1
);
EventLoopGroup
workerGroup
=
new
NioEventLoopGroup
();
...
...
@@ -65,12 +72,20 @@ public class Bootstrap {
.
channel
(
NioServerSocketChannel
.
class
)
.
handler
(
new
LoggingHandler
(
LogLevel
.
INFO
))
.
childHandler
(
new
HttpServerInitializer
());
Channel
channel
=
bootstrap
.
bind
(
PORT
).
sync
().
channel
();
log
.
info
(
"Shardingscaling is server on http://127.0.0.1:"
+
PORT
+
'/'
);
int
port
=
ScalingContext
.
getInstance
().
getServerConfiguration
().
getPort
();
Channel
channel
=
bootstrap
.
bind
(
port
).
sync
().
channel
();
log
.
info
(
"Shardingscaling is server on http://127.0.0.1:"
+
port
+
'/'
);
channel
.
closeFuture
().
sync
();
}
finally
{
bossGroup
.
shutdownGracefully
();
workerGroup
.
shutdownGracefully
();
}
}
private
static
void
initServerConfig
()
throws
IOException
{
File
yamlFile
=
new
File
(
Bootstrap
.
class
.
getResource
(
SERVER_CONFIG_FILE
).
getFile
());
ServerConfiguration
serverConfiguration
=
YamlEngine
.
unmarshal
(
yamlFile
,
ServerConfiguration
.
class
);
Preconditions
.
checkNotNull
(
serverConfiguration
,
"Server configuration file `%s` is invalid."
,
yamlFile
.
getName
());
ScalingContext
.
getInstance
().
init
(
serverConfiguration
);
}
}
sharding-scaling/sharding-scaling-bootstrap/src/main/resources/conf/config.json
浏览文件 @
15c0c607
...
...
@@ -32,9 +32,7 @@
"username"
:
"root"
}
},
"serverConfiguration"
:
{
"blockQueueSize"
:
10000
,
"pushTimeout"
:
1000
,
"jobConfiguration"
:
{
"concurrency"
:
3
}
}
\ No newline at end of file
}
sharding-scaling/sharding-scaling-bootstrap/src/main/resources/conf/server.yaml
0 → 100644
浏览文件 @
15c0c607
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# port: 8888
# blockQueueSize: 10000
# pushTimeout: 1000
# workerThread: 30
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/config/JobConfiguration.java
0 → 100644
浏览文件 @
15c0c607
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.apache.shardingsphere.shardingscaling.core.config
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@AllArgsConstructor
@NoArgsConstructor
@Data
public
class
JobConfiguration
{
private
int
concurrency
=
3
;
}
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/config/ScalingConfiguration.java
浏览文件 @
15c0c607
...
...
@@ -26,5 +26,5 @@ public class ScalingConfiguration {
private
RuleConfiguration
ruleConfiguration
;
private
ServerConfiguration
server
Configuration
;
private
JobConfiguration
job
Configuration
;
}
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/config/ScalingContext.java
浏览文件 @
15c0c607
...
...
@@ -27,8 +27,6 @@ public final class ScalingContext {
private
static
final
ScalingContext
INSTANCE
=
new
ScalingContext
();
private
RuleConfiguration
ruleConfiguration
;
private
ServerConfiguration
serverConfiguration
;
/**
...
...
@@ -43,11 +41,9 @@ public final class ScalingContext {
/**
* Initialize Scaling context.
*
* @param ruleConfiguration ruleConfiguration
* @param serverConfiguration serverConfiguration
*/
public
void
init
(
final
RuleConfiguration
ruleConfiguration
,
final
ServerConfiguration
serverConfiguration
)
{
this
.
ruleConfiguration
=
ruleConfiguration
;
public
void
init
(
final
ServerConfiguration
serverConfiguration
)
{
this
.
serverConfiguration
=
serverConfiguration
;
}
...
...
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/config/ServerConfiguration.java
浏览文件 @
15c0c607
...
...
@@ -17,19 +17,24 @@
package
org.apache.shardingsphere.shardingscaling.core.config
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
org.apache.shardingsphere.core.yaml.config.YamlConfiguration
;
@AllArgsConstructor
/**
* Global server configuration.
*
* @author ssxlulu
*/
@NoArgsConstructor
@Data
public
class
ServerConfiguration
{
public
class
ServerConfiguration
implements
YamlConfiguration
{
private
Integer
blockQueueSize
;
private
int
port
=
8080
;
private
Integer
pushTimeout
;
private
int
blockQueueSize
=
10000
;
private
Integer
concurrency
;
private
int
pushTimeout
=
1000
;
private
int
workerThread
=
30
;
}
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/execute/engine/ExecuteUtil.java
浏览文件 @
15c0c607
...
...
@@ -21,6 +21,7 @@ import com.google.common.util.concurrent.FutureCallback;
import
com.google.common.util.concurrent.Futures
;
import
com.google.common.util.concurrent.ListenableFuture
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.shardingsphere.shardingscaling.core.config.ScalingContext
;
import
org.apache.shardingsphere.shardingscaling.core.execute.executor.SyncRunner
;
import
org.apache.shardingsphere.shardingscaling.core.execute.executor.channel.Channel
;
import
org.apache.shardingsphere.shardingscaling.core.execute.executor.reader.Reader
;
...
...
@@ -37,7 +38,7 @@ import java.util.List;
@Slf4j
public
class
ExecuteUtil
{
private
static
final
SyncTaskExecuteEngine
EXECUTE_ENGINE
=
new
DefaultSyncTaskExecuteEngine
(
30
);
private
static
final
SyncTaskExecuteEngine
EXECUTE_ENGINE
=
new
DefaultSyncTaskExecuteEngine
(
ScalingContext
.
getInstance
().
getServerConfiguration
().
getWorkerThread
()
);
/**
* Execute.
...
...
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/execute/executor/channel/MemoryChannel.java
浏览文件 @
15c0c607
...
...
@@ -17,6 +17,7 @@
package
org.apache.shardingsphere.shardingscaling.core.execute.executor.channel
;
import
org.apache.shardingsphere.shardingscaling.core.config.ScalingContext
;
import
org.apache.shardingsphere.shardingscaling.core.execute.executor.record.Record
;
import
java.util.ArrayList
;
...
...
@@ -34,9 +35,9 @@ import java.util.concurrent.TimeUnit;
*/
public
class
MemoryChannel
implements
Channel
{
private
static
final
int
PUSH_TIMEOUT
=
1000
;
private
static
final
int
PUSH_TIMEOUT
=
ScalingContext
.
getInstance
().
getServerConfiguration
().
getPushTimeout
()
;
private
final
BlockingQueue
<
Record
>
queue
=
new
ArrayBlockingQueue
<>(
10000
);
private
final
BlockingQueue
<
Record
>
queue
=
new
ArrayBlockingQueue
<>(
ScalingContext
.
getInstance
().
getServerConfiguration
().
getBlockQueueSize
()
);
private
final
List
<
AckCallback
>
ackCallbacks
;
...
...
sharding-scaling/sharding-scaling-core/src/main/java/org/apache/shardingsphere/shardingscaling/core/web/util/SyncConfigurationUtil.java
浏览文件 @
15c0c607
...
...
@@ -56,7 +56,7 @@ public class SyncConfigurationUtil {
ruleConfig
.
getDestinationDataSources
().
getUsername
(),
ruleConfig
.
getDestinationDataSources
().
getPassword
());
writerConfiguration
.
setDataSourceConfiguration
(
writerDataSourceConfiguration
);
syncConfigurations
.
add
(
new
SyncConfiguration
(
scalingConfiguration
.
get
Server
Configuration
().
getConcurrency
(),
readerConfiguration
,
writerConfiguration
));
syncConfigurations
.
add
(
new
SyncConfiguration
(
scalingConfiguration
.
get
Job
Configuration
().
getConcurrency
(),
readerConfiguration
,
writerConfiguration
));
}
return
syncConfigurations
;
}
...
...
sharding-scaling/sharding-scaling-core/src/test/java/org/apache/shardingsphere/shardingscaling/core/synctask/history/HistoryDataSyncTaskTest.java
浏览文件 @
15c0c607
...
...
@@ -21,6 +21,8 @@ import lombok.SneakyThrows;
import
org.apache.shardingsphere.shardingscaling.core.config.DataSourceConfiguration
;
import
org.apache.shardingsphere.shardingscaling.core.config.JdbcDataSourceConfiguration
;
import
org.apache.shardingsphere.shardingscaling.core.config.RdbmsConfiguration
;
import
org.apache.shardingsphere.shardingscaling.core.config.ScalingContext
;
import
org.apache.shardingsphere.shardingscaling.core.config.ServerConfiguration
;
import
org.apache.shardingsphere.shardingscaling.core.config.SyncConfiguration
;
import
org.apache.shardingsphere.shardingscaling.core.controller.task.ReportCallback
;
import
org.apache.shardingsphere.shardingscaling.core.execute.Event
;
...
...
@@ -52,6 +54,7 @@ public class HistoryDataSyncTaskTest {
public
void
setUp
()
{
RdbmsConfiguration
readerConfig
=
mockReaderConfig
();
RdbmsConfiguration
writerConfig
=
mockWriterConfig
();
ScalingContext
.
getInstance
().
init
(
new
ServerConfiguration
());
syncConfiguration
=
new
SyncConfiguration
(
3
,
readerConfig
,
writerConfig
);
dataSourceFactory
=
new
DataSourceFactory
();
}
...
...
sharding-scaling/sharding-scaling-core/src/test/resources/config.json
浏览文件 @
15c0c607
...
...
@@ -32,9 +32,7 @@
"username"
:
"root"
}
},
"serverConfiguration"
:
{
"blockQueueSize"
:
10000
,
"pushTimeout"
:
1000
,
"jobConfiguration"
:
{
"concurrency"
:
3
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录