Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
9252aa9a
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,发现更多精彩内容 >>
提交
9252aa9a
编写于
9月 08, 2017
作者:
T
terrymanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor api 16th version
上级
4bc8853f
变更
8
显示空白变更内容
内联
并排
Showing
8 changed file
with
13 addition
and
145 deletion
+13
-145
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/main/java/com/dangdang/ddframe/rdb/sharding/config/common/api/ShardingRuleBuilder.java
...e/rdb/sharding/config/common/api/ShardingRuleBuilder.java
+2
-2
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/main/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureDatabaseShardingAlgorithm.java
.../internal/algorithm/ClosureDatabaseShardingAlgorithm.java
+0
-32
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/main/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureShardingAlgorithm.java
...g/common/internal/algorithm/ClosureShardingAlgorithm.java
+1
-1
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/main/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureTableShardingAlgorithm.java
...mon/internal/algorithm/ClosureTableShardingAlgorithm.java
+0
-32
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/test/java/com/dangdang/ddframe/rdb/sharding/config/common/AllTests.java
...dangdang/ddframe/rdb/sharding/config/common/AllTests.java
+2
-4
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/test/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureDatabaseShardingAlgorithmTest.java
...ernal/algorithm/ClosureDatabaseShardingAlgorithmTest.java
+0
-31
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/test/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureShardingAlgorithmTest.java
...mmon/internal/algorithm/ClosureShardingAlgorithmTest.java
+8
-12
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/test/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureTableShardingAlgorithmTest.java
...internal/algorithm/ClosureTableShardingAlgorithmTest.java
+0
-31
未找到文件。
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/main/java/com/dangdang/ddframe/rdb/sharding/config/common/api/ShardingRuleBuilder.java
浏览文件 @
9252aa9a
...
...
@@ -26,7 +26,7 @@ import com.dangdang.ddframe.rdb.sharding.config.common.api.config.GenerateKeyCol
import
com.dangdang.ddframe.rdb.sharding.config.common.api.config.ShardingRuleConfig
;
import
com.dangdang.ddframe.rdb.sharding.config.common.api.config.StrategyConfig
;
import
com.dangdang.ddframe.rdb.sharding.config.common.api.config.TableRuleConfig
;
import
com.dangdang.ddframe.rdb.sharding.config.common.internal.algorithm.Closure
Database
ShardingAlgorithm
;
import
com.dangdang.ddframe.rdb.sharding.config.common.internal.algorithm.ClosureShardingAlgorithm
;
import
com.dangdang.ddframe.rdb.sharding.config.common.internal.parser.InlineParser
;
import
com.dangdang.ddframe.rdb.sharding.keygen.KeyGenerator
;
import
com.dangdang.ddframe.rdb.sharding.routing.strategy.ShardingAlgorithm
;
...
...
@@ -175,7 +175,7 @@ public final class ShardingRuleBuilder {
@SuppressWarnings
(
"unchecked"
)
private
<
T
extends
ShardingStrategy
>
T
buildShardingAlgorithmExpression
(
final
List
<
String
>
shardingColumns
,
final
String
algorithmExpression
)
{
return
(
T
)
new
ComplexShardingStrategy
(
shardingColumns
,
new
Closure
Database
ShardingAlgorithm
(
algorithmExpression
,
logRoot
));
return
(
T
)
new
ComplexShardingStrategy
(
shardingColumns
,
new
ClosureShardingAlgorithm
(
algorithmExpression
,
logRoot
));
}
@SuppressWarnings
(
"unchecked"
)
...
...
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/main/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureDatabaseShardingAlgorithm.java
已删除
100644 → 0
浏览文件 @
4bc8853f
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.config.common.internal.algorithm
;
import
com.dangdang.ddframe.rdb.sharding.routing.strategy.complex.ComplexKeysShardingAlgorithm
;
/**
* Closure for database sharding algorithm.
*
* @author gaohongtao
*/
public
class
ClosureDatabaseShardingAlgorithm
extends
ClosureShardingAlgorithm
implements
ComplexKeysShardingAlgorithm
{
public
ClosureDatabaseShardingAlgorithm
(
final
String
expression
,
final
String
logRoot
)
{
super
(
expression
,
logRoot
);
}
}
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/main/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureShardingAlgorithm.java
浏览文件 @
9252aa9a
...
...
@@ -41,7 +41,7 @@ import java.util.Set;
*
* @author gaohongtao
*/
public
class
ClosureShardingAlgorithm
implements
ComplexKeysShardingAlgorithm
{
public
final
class
ClosureShardingAlgorithm
implements
ComplexKeysShardingAlgorithm
{
private
final
Closure
<?>
closureTemplate
;
...
...
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/main/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureTableShardingAlgorithm.java
已删除
100644 → 0
浏览文件 @
4bc8853f
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.config.common.internal.algorithm
;
import
com.dangdang.ddframe.rdb.sharding.routing.strategy.complex.ComplexKeysShardingAlgorithm
;
/**
* Closure for table sharding algorithm.
*
* @author gaohongtao
*/
public
class
ClosureTableShardingAlgorithm
extends
ClosureShardingAlgorithm
implements
ComplexKeysShardingAlgorithm
{
public
ClosureTableShardingAlgorithm
(
final
String
expression
,
final
String
logRoot
)
{
super
(
expression
,
logRoot
);
}
}
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/test/java/com/dangdang/ddframe/rdb/sharding/config/common/AllTests.java
浏览文件 @
9252aa9a
...
...
@@ -18,8 +18,7 @@
package
com.dangdang.ddframe.rdb.sharding.config.common
;
import
com.dangdang.ddframe.rdb.sharding.config.common.api.ShardingRuleBuilderTest
;
import
com.dangdang.ddframe.rdb.sharding.config.common.internal.algorithm.ClosureDatabaseShardingAlgorithmTest
;
import
com.dangdang.ddframe.rdb.sharding.config.common.internal.algorithm.ClosureTableShardingAlgorithmTest
;
import
com.dangdang.ddframe.rdb.sharding.config.common.internal.algorithm.ClosureShardingAlgorithmTest
;
import
com.dangdang.ddframe.rdb.sharding.config.common.internal.algorithm.ShardingValueWrapperTest
;
import
com.dangdang.ddframe.rdb.sharding.config.common.internal.parser.InlineParserTest
;
import
org.junit.runner.RunWith
;
...
...
@@ -28,8 +27,7 @@ import org.junit.runners.Suite;
@RunWith
(
Suite
.
class
)
@Suite
.
SuiteClasses
({
ShardingRuleBuilderTest
.
class
,
ClosureDatabaseShardingAlgorithmTest
.
class
,
ClosureTableShardingAlgorithmTest
.
class
,
ClosureShardingAlgorithmTest
.
class
,
ShardingValueWrapperTest
.
class
,
InlineParserTest
.
class
})
...
...
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/test/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureDatabaseShardingAlgorithmTest.java
已删除
100644 → 0
浏览文件 @
4bc8853f
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.config.common.internal.algorithm
;
public
final
class
ClosureDatabaseShardingAlgorithmTest
extends
AbstractClosureShardingAlgorithmTest
{
@Override
protected
ClosureShardingAlgorithm
createClosureShardingAlgorithm
()
{
return
new
ClosureDatabaseShardingAlgorithm
(
EXPRESSION
,
LOG_ROOT
);
}
@Override
protected
ClosureShardingAlgorithm
createErrorClosureShardingAlgorithm
()
{
return
new
ClosureDatabaseShardingAlgorithm
(
WRONG_EXPRESSION
,
LOG_ROOT
);
}
}
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/test/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/
Abstract
ClosureShardingAlgorithmTest.java
→
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/test/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureShardingAlgorithmTest.java
浏览文件 @
9252aa9a
...
...
@@ -33,21 +33,17 @@ import static org.hamcrest.core.Is.is;
import
static
org
.
hamcrest
.
core
.
IsCollectionContaining
.
hasItem
;
import
static
org
.
junit
.
Assert
.
assertThat
;
public
abstract
class
Abstract
ClosureShardingAlgorithmTest
{
public
final
class
ClosureShardingAlgorithmTest
{
pr
otected
static
final
String
EXPRESSION
=
"target_${log.info(id.toString()); id.longValue() % 2}"
;
pr
ivate
static
final
String
EXPRESSION
=
"target_${log.info(id.toString()); id.longValue() % 2}"
;
pr
otected
static
final
String
WRONG_EXPRESSION
=
"target_${log.info(id.error());}"
;
pr
ivate
static
final
String
WRONG_EXPRESSION
=
"target_${log.info(id.error());}"
;
protected
static
final
String
LOG_ROOT
=
"default"
;
protected
abstract
ClosureShardingAlgorithm
createClosureShardingAlgorithm
();
protected
abstract
ClosureShardingAlgorithm
createErrorClosureShardingAlgorithm
();
private
static
final
String
LOG_ROOT
=
"default"
;
@Test
public
void
assertEqual
()
{
Collection
<
String
>
result
=
createClosureShardingAlgorithm
(
).
doSharding
(
Collection
<
String
>
result
=
new
ClosureShardingAlgorithm
(
EXPRESSION
,
LOG_ROOT
).
doSharding
(
Collections
.
singletonList
(
"target_1"
),
Collections
.<
ShardingValue
>
singletonList
(
new
ListShardingValue
<>(
"target"
,
"id"
,
Collections
.
singletonList
(
1L
))));
assertThat
(
result
.
size
(),
is
(
1
));
assertThat
(
result
,
hasItem
(
"target_1"
));
...
...
@@ -55,7 +51,7 @@ public abstract class AbstractClosureShardingAlgorithmTest {
@Test
public
void
assertIn
()
{
Collection
<
String
>
result
=
createClosureShardingAlgorithm
(
).
doSharding
(
Arrays
.
asList
(
"target_0"
,
"target_1"
),
Collection
<
String
>
result
=
new
ClosureShardingAlgorithm
(
EXPRESSION
,
LOG_ROOT
).
doSharding
(
Arrays
.
asList
(
"target_0"
,
"target_1"
),
Collections
.<
ShardingValue
>
singletonList
(
new
ListShardingValue
<>(
"target"
,
"id"
,
Arrays
.
asList
(
1
,
2
))));
assertThat
(
result
.
size
(),
is
(
2
));
assertThat
(
result
,
hasItem
(
"target_0"
));
...
...
@@ -64,13 +60,13 @@ public abstract class AbstractClosureShardingAlgorithmTest {
@Test
(
expected
=
UnsupportedOperationException
.
class
)
public
void
assertBetween
()
{
createClosureShardingAlgorithm
(
).
doSharding
(
Arrays
.
asList
(
"target_0"
,
"target_1"
),
new
ClosureShardingAlgorithm
(
EXPRESSION
,
LOG_ROOT
).
doSharding
(
Arrays
.
asList
(
"target_0"
,
"target_1"
),
Collections
.<
ShardingValue
>
singletonList
(
new
RangeShardingValue
<>(
"target"
,
"id"
,
Range
.
range
(
1
,
BoundType
.
CLOSED
,
2
,
BoundType
.
OPEN
))));
}
@Test
(
expected
=
MissingMethodException
.
class
)
public
void
assertEvaluateInlineExpressionFailure
()
{
createErrorClosureShardingAlgorithm
(
).
doSharding
(
new
ClosureShardingAlgorithm
(
WRONG_EXPRESSION
,
LOG_ROOT
).
doSharding
(
Collections
.
singletonList
(
"target_1"
),
Collections
.<
ShardingValue
>
singletonList
(
new
ListShardingValue
<>(
"target"
,
"id"
,
Collections
.
singletonList
(
1L
))));
}
}
sharding-jdbc-config-parent/sharding-jdbc-config-common/src/test/java/com/dangdang/ddframe/rdb/sharding/config/common/internal/algorithm/ClosureTableShardingAlgorithmTest.java
已删除
100644 → 0
浏览文件 @
4bc8853f
/*
* Copyright 1999-2015 dangdang.com.
* <p>
* Licensed 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.
* </p>
*/
package
com.dangdang.ddframe.rdb.sharding.config.common.internal.algorithm
;
public
final
class
ClosureTableShardingAlgorithmTest
extends
AbstractClosureShardingAlgorithmTest
{
@Override
protected
ClosureShardingAlgorithm
createClosureShardingAlgorithm
()
{
return
new
ClosureTableShardingAlgorithm
(
EXPRESSION
,
LOG_ROOT
);
}
@Override
protected
ClosureShardingAlgorithm
createErrorClosureShardingAlgorithm
()
{
return
new
ClosureTableShardingAlgorithm
(
WRONG_EXPRESSION
,
LOG_ROOT
);
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录