forked from baihui212/tsharding
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request baihui212#7 from threezhang/jiuru
Thank threezhang([email protected]) for fix the jar dependency problem.
- Loading branch information
Showing
57 changed files
with
1,493 additions
and
729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# maven ignore | ||
target/ | ||
*.jar | ||
*.war | ||
*.zip | ||
*.tar | ||
*.tar.gz | ||
|
||
# eclipse ignore | ||
.metadata/ | ||
.settings/ | ||
.project | ||
.classpath | ||
.springBeans | ||
|
||
# idea ignore | ||
.idea/ | ||
*.ipr | ||
*.iml | ||
*.iws | ||
|
||
# temp ignore | ||
logs/ | ||
*.log | ||
*.cache | ||
*.diff | ||
*.patch | ||
*.tmp | ||
*.swp | ||
|
||
# system ignore | ||
.DS_Store | ||
Thumbs.db | ||
|
||
/bin/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
交易分库分表组件TSharding | ||
|
||
1.0.0-SNAPSHOT | ||
|
||
##2015-09-08 | ||
##版本1.0.0-SNAPSHOT | ||
new features: | ||
com.mogujie.trade.tsharding.route.orm.MapperEnhancer#enhanceMapperClass //增加注解信息和注解内容,以支持mybatis mapper类的动态绑定 | ||
|
||
##2015-09-18 | ||
##版本1.0.0 | ||
已经支持交易订单分库分表完整需求,灰度完成100%发布上线。发布tsharding稳定版. | ||
#### | ||
1.测试用例入口 com.mogujie.service.tsharding.test#TShardingTest | ||
2.默认走Master库的前缀命名 com.mogujie.trade.tsharding.route.orm.base.ReadWriteSplittingContextInitializer.DEFAULT_WRITE_METHOD_NAMES | ||
3.SQL增强 com.mogujie.trade.tsharding.route.orm.MapperResourceEnhancer.enhancedShardingSQL | ||
|
||
##版本1.0.1.1 | ||
优化orm元数据增强扩展时的内存消耗 | ||
##版本1.0.2 | ||
增加XDItemOrderEx表sharding支持。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
tsharding-client/src/main/java/com/mogujie/trade/db/DataSourceConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package com.mogujie.trade.db; | ||
|
||
/** | ||
* @author by jiuru on 16/7/14. | ||
*/ | ||
public class DataSourceConfig { | ||
|
||
static final int DEFAULT_MIN_POOL_SIZE = 0; | ||
static final int DEFAULT_MAX_POOL_SIZE = 10; | ||
static final int DEFAULT_INI_POOL_SIZE = 0; | ||
|
||
private String url; | ||
|
||
private String username; | ||
|
||
private String password; | ||
|
||
private int minPoolSize; | ||
|
||
private int maxPoolSize; | ||
|
||
private int initialPoolSize; | ||
|
||
public String getUrl() { | ||
return url; | ||
} | ||
|
||
public void setUrl(String url) { | ||
this.url = url; | ||
} | ||
|
||
public String getUsername() { | ||
return username; | ||
} | ||
|
||
public void setUsername(String username) { | ||
this.username = username; | ||
} | ||
|
||
public String getPassword() { | ||
return password; | ||
} | ||
|
||
public void setPassword(String password) { | ||
this.password = password; | ||
} | ||
|
||
public int getMinPoolSize() { | ||
return minPoolSize; | ||
} | ||
|
||
public void setMinPoolSize(int minPoolSize) { | ||
this.minPoolSize = minPoolSize; | ||
} | ||
|
||
public int getMaxPoolSize() { | ||
return maxPoolSize; | ||
} | ||
|
||
public void setMaxPoolSize(int maxPoolSize) { | ||
this.maxPoolSize = maxPoolSize; | ||
} | ||
|
||
public int getInitialPoolSize() { | ||
return initialPoolSize; | ||
} | ||
|
||
public void setInitialPoolSize(int initialPoolSize) { | ||
this.initialPoolSize = initialPoolSize; | ||
} | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
tsharding-client/src/main/java/com/mogujie/trade/db/DataSourceFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.mogujie.trade.db; | ||
|
||
import javax.sql.DataSource; | ||
import java.sql.SQLException; | ||
|
||
/** | ||
* @author by jiuru on 16/7/14. | ||
*/ | ||
public interface DataSourceFactory<T extends DataSource> { | ||
|
||
T getDataSource(DataSourceConfig config) throws SQLException; | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
tsharding-client/src/main/java/com/mogujie/trade/db/DataSourceLookup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.mogujie.trade.db; | ||
|
||
import java.io.Closeable; | ||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author by jiuru on 16/7/14. | ||
*/ | ||
public class DataSourceLookup implements Closeable { | ||
|
||
private final Map<String, ReadWriteSplittingDataSource> dataSources; | ||
|
||
public DataSourceLookup(Map<String, ReadWriteSplittingDataSource> dataSources) { | ||
this.dataSources = Collections.unmodifiableMap(dataSources); | ||
} | ||
|
||
/** | ||
* @param name | ||
* @return | ||
*/ | ||
public ReadWriteSplittingDataSource get(String name) { | ||
return this.dataSources.get(name); | ||
} | ||
|
||
public Map<String, ReadWriteSplittingDataSource> getMapping() { | ||
return this.dataSources; | ||
} | ||
|
||
@Override | ||
public void close() throws IOException { | ||
for (ReadWriteSplittingDataSource dataSource : dataSources.values()) { | ||
dataSource.close(); | ||
} | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
tsharding-client/src/main/java/com/mogujie/trade/db/DataSourceRouting.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.mogujie.trade.db; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* @author by jiuru on 16/7/14. | ||
*/ | ||
@Target(ElementType.TYPE) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface DataSourceRouting { | ||
/** | ||
* 静态绑定该Mapper对应的数据源 | ||
* | ||
* @return 绑定的数据源的名称 | ||
*/ | ||
String value() default ""; | ||
|
||
/** | ||
* 指定运行时路由处理的Handler,动态指定对应的数据源。<b>注意:此方式不能支持事务!</b> | ||
* | ||
* @return | ||
*/ | ||
Class<? extends DataSourceRoutingHandler> handler() default EmptyDataSourceRoutingHandler.class; | ||
|
||
} |
Oops, something went wrong.