Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Shardingsphere
提交
2a3667c3
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,发现更多精彩内容 >>
提交
2a3667c3
编写于
3月 22, 2018
作者:
W
WangKai
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix some checkstyle
上级
05813876
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
43 addition
and
20 deletion
+43
-20
sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingjdbc/transaction/config/AsyncSoftTransactionJobConfiguration.java
...nsaction/config/AsyncSoftTransactionJobConfiguration.java
+2
-2
sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingjdbc/transaction/job/QuartzJob.java
.../main/java/io/shardingjdbc/transaction/job/QuartzJob.java
+13
-11
sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingjdbc/transaction/job/QuartzJobConfiguration.java
.../shardingjdbc/transaction/job/QuartzJobConfiguration.java
+13
-2
sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingjdbc/transaction/job/QuartzJobFactory.java
...ava/io/shardingjdbc/transaction/job/QuartzJobFactory.java
+14
-4
sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingjdbc/transaction/job/QuartzJobMain.java
...n/java/io/shardingjdbc/transaction/job/QuartzJobMain.java
+1
-1
未找到文件。
sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingjdbc/transaction/config/AsyncSoftTransactionJobConfiguration.java
浏览文件 @
2a3667c3
...
...
@@ -5,7 +5,7 @@
* 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
* 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,
...
...
@@ -28,7 +28,7 @@ import lombok.Setter;
*/
@Getter
@Setter
public
class
AsyncSoftTransactionJobConfiguration
{
public
final
class
AsyncSoftTransactionJobConfiguration
{
/**
* Job name.
...
...
sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingjdbc/transaction/job/QuartzJob.java
浏览文件 @
2a3667c3
...
...
@@ -5,7 +5,7 @@
* 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
* 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,
...
...
@@ -34,20 +34,22 @@ import java.util.List;
* @author wangkai
*/
@Slf4j
public
class
QuartzJob
implements
Job
{
public
final
class
QuartzJob
implements
Job
{
@Override
public
void
execute
(
final
JobExecutionContext
jobExecutionContext
)
{
QuartzJobConfiguration
quartzJobConfiguration
=
(
QuartzJobConfiguration
)
jobExecutionContext
.
getJobDetail
().
getJobDataMap
().
get
(
"quartzJobConfiguration"
);
TransactionLogStorage
transactionLogStorage
=
(
TransactionLogStorage
)
jobExecutionContext
.
getJobDetail
().
getJobDataMap
().
get
(
"transactionLogStorage"
);
List
<
TransactionLog
>
T
ransactionLogList
=
transactionLogStorage
.
findEligibleTransactionLogs
(
quartzJobConfiguration
.
getJobConfig
().
getTransactionLogFetchDataCount
(),
QuartzJobConfiguration
quartzJobConfiguration
=
(
QuartzJobConfiguration
)
jobExecutionContext
.
getJobDetail
().
getJobDataMap
().
get
(
"quartzJobConfiguration"
);
TransactionLogStorage
transactionLogStorage
=
(
TransactionLogStorage
)
jobExecutionContext
.
getJobDetail
().
getJobDataMap
().
get
(
"transactionLogStorage"
);
List
<
TransactionLog
>
t
ransactionLogList
=
transactionLogStorage
.
findEligibleTransactionLogs
(
quartzJobConfiguration
.
getJobConfig
().
getTransactionLogFetchDataCount
(),
quartzJobConfiguration
.
getJobConfig
().
getMaxDeliveryTryTimes
(),
quartzJobConfiguration
.
getJobConfig
().
getMaxDeliveryTryDelayMillis
());
for
(
TransactionLog
data
:
TransactionLogList
)
{
try
(
Connection
conn
=
quartzJobConfiguration
.
getTargetDataSource
(
data
.
getDataSource
()).
getConnection
())
{
transactionLogStorage
.
processData
(
conn
,
data
,
quartzJobConfiguration
.
getJobConfig
().
getMaxDeliveryTryTimes
());
}
catch
(
final
SQLException
|
TransactionCompensationException
ex
)
{
log
.
error
(
String
.
format
(
"Async delivery times %s error, max try times is %s, exception is %s"
,
data
.
getAsyncDeliveryTryTimes
()
+
1
,
quartzJobConfiguration
.
getJobConfig
().
getMaxDeliveryTryTimes
(),
ex
.
getMessage
()));
if
(
transactionLogList
!=
null
)
{
for
(
TransactionLog
data
:
transactionLogList
)
{
try
(
Connection
conn
=
quartzJobConfiguration
.
getTargetDataSource
(
data
.
getDataSource
()).
getConnection
())
{
transactionLogStorage
.
processData
(
conn
,
data
,
quartzJobConfiguration
.
getJobConfig
().
getMaxDeliveryTryTimes
());
}
catch
(
final
SQLException
|
TransactionCompensationException
ex
)
{
log
.
error
(
String
.
format
(
"Async delivery times %s error, max try times is %s, exception is %s"
,
data
.
getAsyncDeliveryTryTimes
()
+
1
,
quartzJobConfiguration
.
getJobConfig
().
getMaxDeliveryTryTimes
(),
ex
.
getMessage
()));
}
}
}
}
...
...
sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingjdbc/transaction/job/QuartzJobConfiguration.java
浏览文件 @
2a3667c3
...
...
@@ -5,7 +5,7 @@
* 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
* 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,
...
...
@@ -31,7 +31,7 @@ import java.util.Map;
*/
@Getter
@Setter
public
class
QuartzJobConfiguration
{
public
final
class
QuartzJobConfiguration
{
/**
* Data source for transaction manager.
...
...
@@ -48,10 +48,21 @@ public class QuartzJobConfiguration {
*/
private
io
.
shardingjdbc
.
transaction
.
config
.
AsyncSoftTransactionJobConfiguration
jobConfig
;
/**
* Get one data source by name.
*
* @param dataSourceName data source name
* @return dataSourceName object
*/
public
DataSource
getTargetDataSource
(
final
String
dataSourceName
)
{
return
targetDataSource
.
get
(
dataSourceName
);
}
/**
* Get next one transaction log data sorce.
*
* @return next one transaction log data sorce
*/
public
DataSource
getDefaultTransactionLogDataSource
()
{
return
transactionLogDataSource
.
values
().
iterator
().
next
();
}
...
...
sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingjdbc/transaction/job/QuartzJobFactory.java
浏览文件 @
2a3667c3
...
...
@@ -5,7 +5,7 @@
* 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
* 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,
...
...
@@ -20,7 +20,14 @@ package io.shardingjdbc.transaction.job;
import
io.shardingjdbc.transaction.datasource.impl.RdbTransactionLogDataSource
;
import
io.shardingjdbc.transaction.storage.TransactionLogStorageFactory
;
import
lombok.RequiredArgsConstructor
;
import
org.quartz.*
;
import
org.quartz.JobDetail
;
import
org.quartz.Scheduler
;
import
org.quartz.SchedulerException
;
import
org.quartz.SchedulerFactory
;
import
org.quartz.JobBuilder
;
import
org.quartz.Trigger
;
import
org.quartz.TriggerBuilder
;
import
org.quartz.CronScheduleBuilder
;
import
org.quartz.impl.StdSchedulerFactory
;
/**
...
...
@@ -35,6 +42,8 @@ public final class QuartzJobFactory {
/**
* start job.
*
* @throws SchedulerException quartz scheduler exception
*/
public
void
start
()
throws
SchedulerException
{
SchedulerFactory
schedulerFactory
=
new
StdSchedulerFactory
();
...
...
@@ -45,8 +54,9 @@ public final class QuartzJobFactory {
private
JobDetail
buildJobDetail
()
{
JobDetail
jobDetail
=
JobBuilder
.
newJob
(
QuartzJob
.
class
).
withIdentity
(
quartzJobConfiguration
.
getJobConfig
().
getName
()
+
"-Job"
).
build
();
jobDetail
.
getJobDataMap
().
put
(
"quartzJobConfiguration"
,
quartzJobConfiguration
);
jobDetail
.
getJobDataMap
().
put
(
"transactionLogStorage"
,
TransactionLogStorageFactory
.
createTransactionLogStorage
(
new
RdbTransactionLogDataSource
(
quartzJobConfiguration
.
getDefaultTransactionLogDataSource
())));
jobDetail
.
getJobDataMap
().
put
(
"quartzJobConfiguration"
,
quartzJobConfiguration
);
jobDetail
.
getJobDataMap
().
put
(
"transactionLogStorage"
,
TransactionLogStorageFactory
.
createTransactionLogStorage
(
new
RdbTransactionLogDataSource
(
quartzJobConfiguration
.
getDefaultTransactionLogDataSource
())));
return
jobDetail
;
}
...
...
sharding-jdbc-transaction-parent/sharding-jdbc-transaction-async-job/src/main/java/io/shardingjdbc/transaction/job/QuartzJobMain.java
浏览文件 @
2a3667c3
...
...
@@ -5,7 +5,7 @@
* 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
* 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,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录