Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
holden_csdn
tx-lcn
提交
a20574f8
T
tx-lcn
项目概览
holden_csdn
/
tx-lcn
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tx-lcn
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a20574f8
编写于
1月 16, 2019
作者:
U
ujued
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rollback
上级
67f62c91
变更
26
展开全部
隐藏空白更改
内联
并排
Showing
26 changed file
with
87 addition
and
49 deletion
+87
-49
LICENSE
LICENSE
+1
-1
tx-client/src/main/java/com/codingapi/txlcn/client/aspect/weave/DTXResourceWeaver.java
...odingapi/txlcn/client/aspect/weave/DTXResourceWeaver.java
+3
-3
tx-client/src/main/java/com/codingapi/txlcn/client/core/lcn/control/LcnTransactionCleanService.java
...n/client/core/lcn/control/LcnTransactionCleanService.java
+1
-1
tx-client/src/main/java/com/codingapi/txlcn/client/core/lcn/resource/LcnConnectionProxy.java
...pi/txlcn/client/core/lcn/resource/LcnConnectionProxy.java
+1
-1
tx-client/src/main/java/com/codingapi/txlcn/client/core/txc/control/TxcStartingTransaction.java
...txlcn/client/core/txc/control/TxcStartingTransaction.java
+1
-1
tx-client/src/main/java/com/codingapi/txlcn/client/initializer/TxClientInitializer.java
...dingapi/txlcn/client/initializer/TxClientInitializer.java
+2
-2
tx-client/src/main/java/com/codingapi/txlcn/client/message/TXLCNClientMessageServer.java
...ingapi/txlcn/client/message/TXLCNClientMessageServer.java
+2
-2
tx-client/src/main/java/com/codingapi/txlcn/client/message/helper/ClientRpcAnswer.java
...odingapi/txlcn/client/message/helper/ClientRpcAnswer.java
+3
-3
tx-client/src/main/java/com/codingapi/txlcn/client/message/helper/TxMangerReporter.java
...dingapi/txlcn/client/message/helper/TxMangerReporter.java
+2
-2
tx-client/src/main/java/com/codingapi/txlcn/client/support/TXLCNTransactionBeanHelper.java
...gapi/txlcn/client/support/TXLCNTransactionBeanHelper.java
+6
-6
tx-client/src/main/java/com/codingapi/txlcn/client/support/TXLCNTransactionServiceExecutor.java
...txlcn/client/support/TXLCNTransactionServiceExecutor.java
+3
-3
tx-client/src/main/java/com/codingapi/txlcn/client/support/checking/SimpleDTXChecking.java
...gapi/txlcn/client/support/checking/SimpleDTXChecking.java
+3
-3
tx-client/src/main/java/com/codingapi/txlcn/client/support/common/template/TransactionCleanTemplate.java
...ent/support/common/template/TransactionCleanTemplate.java
+5
-5
tx-client/src/main/java/com/codingapi/txlcn/client/support/common/template/TransactionControlTemplate.java
...t/support/common/template/TransactionControlTemplate.java
+1
-1
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/context/SimpleTransactionManager.java
.../txlcn/manager/core/context/SimpleTransactionManager.java
+5
-0
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/group/TransactionUnit.java
...m/codingapi/txlcn/manager/core/group/TransactionUnit.java
+8
-1
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/transaction/AskTransactionStateExecuteService.java
...r/core/transaction/AskTransactionStateExecuteService.java
+2
-1
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/transaction/JoinGroupExecuteService.java
...lcn/manager/core/transaction/JoinGroupExecuteService.java
+1
-1
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/transaction/NotifyGroupExecuteService.java
...n/manager/core/transaction/NotifyGroupExecuteService.java
+10
-3
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/transaction/WriteTxExceptionExecuteService.java
...ager/core/transaction/WriteTxExceptionExecuteService.java
+14
-2
tx-manager/src/main/java/com/codingapi/txlcn/manager/db/mapper/TxExceptionMapper.java
.../codingapi/txlcn/manager/db/mapper/TxExceptionMapper.java
+2
-2
tx-manager/src/main/java/com/codingapi/txlcn/manager/db/redis/RedisGroupRelationship.java
...ingapi/txlcn/manager/db/redis/RedisGroupRelationship.java
+2
-2
tx-manager/src/main/resources/static/admin/js/index.js
tx-manager/src/main/resources/static/admin/js/index.js
+1
-1
tx-spi-message-netty/src/main/java/com/codingapi/txlcn/spi/message/netty/impl/NettyRpcClientInitializer.java
...lcn/spi/message/netty/impl/NettyRpcClientInitializer.java
+1
-1
tx-spi-message/src/main/java/com/codingapi/txlcn/spi/message/LCNCmdType.java
...main/java/com/codingapi/txlcn/spi/message/LCNCmdType.java
+1
-1
tx-spi-message/src/main/java/com/codingapi/txlcn/spi/message/params/JoinGroupParams.java
...m/codingapi/txlcn/spi/message/params/JoinGroupParams.java
+6
-0
未找到文件。
LICENSE
浏览文件 @
a20574f8
...
...
@@ -127,7 +127,7 @@
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly
s
tate otherwise,
5. Submission of Contributions. Unless You explicitly
transactionS
tate otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/aspect/weave/DTXResourceWeaver.java
浏览文件 @
a20574f8
...
...
@@ -16,7 +16,7 @@
package
com.codingapi.txlcn.client.aspect.weave
;
import
com.codingapi.txlcn.client.bean.DTXLocal
;
import
com.codingapi.txlcn.client.support.LCNTransactionBeanHelper
;
import
com.codingapi.txlcn.client.support.
TX
LCNTransactionBeanHelper
;
import
com.codingapi.txlcn.client.support.resouce.TransactionResourceExecutor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.ProceedingJoinPoint
;
...
...
@@ -37,10 +37,10 @@ import java.util.Objects;
@Slf4j
public
class
DTXResourceWeaver
{
private
final
LCNTransactionBeanHelper
transactionBeanHelper
;
private
final
TX
LCNTransactionBeanHelper
transactionBeanHelper
;
@Autowired
public
DTXResourceWeaver
(
LCNTransactionBeanHelper
transactionBeanHelper
)
{
public
DTXResourceWeaver
(
TX
LCNTransactionBeanHelper
transactionBeanHelper
)
{
this
.
transactionBeanHelper
=
transactionBeanHelper
;
}
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/core/lcn/control/LcnTransactionCleanService.java
浏览文件 @
a20574f8
...
...
@@ -56,7 +56,7 @@ public class LcnTransactionCleanService implements TransactionCleanService {
log
.
error
(
"本地事务通知失败"
);
throw
new
TransactionClearException
(
"通知资源时出错"
);
}
log
.
error
(
"local non transaction, but notified. probably net message timeout . groupId: {},
s
tate: {}"
,
groupId
,
state
);
log
.
error
(
"local non transaction, but notified. probably net message timeout . groupId: {},
transactionS
tate: {}"
,
groupId
,
state
);
throw
new
TransactionClearException
(
"local non transaction, but notified. probably net message timeout ."
);
}
}
tx-client/src/main/java/com/codingapi/txlcn/client/core/lcn/resource/LcnConnectionProxy.java
浏览文件 @
a20574f8
...
...
@@ -38,7 +38,7 @@ public class LcnConnectionProxy implements Connection {
/**
* 通知事务
*
* @param state
s
tate
* @param state
transactionS
tate
* @return RpcResponseState RpcResponseState
*/
public
RpcResponseState
notify
(
int
state
)
{
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/core/txc/control/TxcStartingTransaction.java
浏览文件 @
a20574f8
...
...
@@ -69,7 +69,7 @@ public class TxcStartingTransaction implements TXLCNTransactionControl {
@Override
public
void
onBusinessCodeSuccess
(
TxTransactionInfo
info
,
Object
result
)
{
// set
s
tate equ 1
// set
transactionS
tate equ 1
DTXLocal
.
cur
().
setState
(
1
);
}
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/initializer/TxClientInitializer.java
浏览文件 @
a20574f8
...
...
@@ -16,7 +16,7 @@
package
com.codingapi.txlcn.client.initializer
;
import
com.codingapi.txlcn.client.aspectlog.AspectLogHelper
;
import
com.codingapi.txlcn.client.message.T
xLcn
ClientMessageServer
;
import
com.codingapi.txlcn.client.message.T
XLCN
ClientMessageServer
;
import
com.codingapi.txlcn.commons.runner.TxLcnInitializer
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -35,7 +35,7 @@ public class TxClientInitializer implements TxLcnInitializer {
private
AspectLogHelper
aspectLogHelper
;
@Autowired
private
T
xLcn
ClientMessageServer
txLcnClientMessageServer
;
private
T
XLCN
ClientMessageServer
txLcnClientMessageServer
;
@Override
public
void
init
()
throws
Exception
{
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/message/T
xLcn
ClientMessageServer.java
→
tx-client/src/main/java/com/codingapi/txlcn/client/message/T
XLCN
ClientMessageServer.java
浏览文件 @
a20574f8
...
...
@@ -29,14 +29,14 @@ import org.springframework.stereotype.Component;
* @author lorne
*/
@Component
public
class
T
xLcnClientMessageServer
{
public
class
T
XLCNClientMessageServer
{
private
final
RpcClientInitializer
rpcClientInitializer
;
private
final
TxClientConfig
txClientConfig
;
@Autowired
public
T
xLcn
ClientMessageServer
(
RpcClientInitializer
rpcClientInitializer
,
TxClientConfig
txClientConfig
)
{
public
T
XLCN
ClientMessageServer
(
RpcClientInitializer
rpcClientInitializer
,
TxClientConfig
txClientConfig
)
{
this
.
rpcClientInitializer
=
rpcClientInitializer
;
this
.
txClientConfig
=
txClientConfig
;
}
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/message/helper/ClientRpcAnswer.java
浏览文件 @
a20574f8
...
...
@@ -20,7 +20,7 @@ import com.codingapi.txlcn.spi.message.RpcClient;
import
com.codingapi.txlcn.spi.message.dto.MessageDto
;
import
com.codingapi.txlcn.spi.message.dto.RpcCmd
;
import
com.codingapi.txlcn.spi.message.exception.RpcException
;
import
com.codingapi.txlcn.client.support.LCNTransactionBeanHelper
;
import
com.codingapi.txlcn.client.support.
TX
LCNTransactionBeanHelper
;
import
com.codingapi.txlcn.commons.exception.TxClientException
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -39,12 +39,12 @@ import java.util.Objects;
@Slf4j
public
class
ClientRpcAnswer
implements
RpcAnswer
{
private
final
LCNTransactionBeanHelper
transactionBeanHelper
;
private
final
TX
LCNTransactionBeanHelper
transactionBeanHelper
;
private
final
RpcClient
rpcClient
;
@Autowired
public
ClientRpcAnswer
(
LCNTransactionBeanHelper
transactionBeanHelper
,
RpcClient
rpcClient
)
{
public
ClientRpcAnswer
(
TX
LCNTransactionBeanHelper
transactionBeanHelper
,
RpcClient
rpcClient
)
{
this
.
transactionBeanHelper
=
transactionBeanHelper
;
this
.
rpcClient
=
rpcClient
;
}
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/message/helper/TxMangerReporter.java
浏览文件 @
a20574f8
...
...
@@ -45,7 +45,7 @@ public class TxMangerReporter {
* @param groupId groupId
* @param unitId unitId
* @param registrar registrar
* @param state
s
tate
* @param state
transactionS
tate
*/
public
void
reportTransactionState
(
String
groupId
,
String
unitId
,
Short
registrar
,
int
state
)
{
TxExceptionParams
txExceptionParams
=
new
TxExceptionParams
();
...
...
@@ -78,7 +78,7 @@ public class TxMangerReporter {
break
;
}
catch
(
RpcException
e
)
{
if
(
e
.
getCode
()
==
RpcException
.
NON_TX_MANAGER
)
{
log
.
error
(
"report transaction
s
tate error. non tx-manager is alive."
);
log
.
error
(
"report transaction
transactionS
tate error. non tx-manager is alive."
);
break
;
}
}
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/support/LCNTransactionBeanHelper.java
→
tx-client/src/main/java/com/codingapi/txlcn/client/support/
TX
LCNTransactionBeanHelper.java
浏览文件 @
a20574f8
...
...
@@ -33,7 +33,7 @@ import org.springframework.stereotype.Component;
*/
@Component
@Slf4j
public
class
LCNTransactionBeanHelper
{
public
class
TX
LCNTransactionBeanHelper
{
/**
...
...
@@ -60,11 +60,11 @@ public class LCNTransactionBeanHelper {
private
static
final
String
TRANSACTION_BEAN_NAME_FORMAT
=
"transaction_%s"
;
/**
* transaction
s
tate resolver
* transaction
transactionS
tate resolver
* transaction_state_resolver_%s
* %s:transaction type. lcn, tcc, txc so on.
*/
private
static
final
String
TRANSACTION_STATE_RESOLVER_BEAN_NAME_F
ARMO
T
=
"transaction_state_resolver_%s"
;
private
static
final
String
TRANSACTION_STATE_RESOLVER_BEAN_NAME_F
ORMA
T
=
"transaction_state_resolver_%s"
;
/**
* Transaction Clean Service
...
...
@@ -76,7 +76,7 @@ public class LCNTransactionBeanHelper {
private
final
ApplicationContext
spring
;
@Autowired
public
LCNTransactionBeanHelper
(
ApplicationContext
spring
)
{
public
TX
LCNTransactionBeanHelper
(
ApplicationContext
spring
)
{
this
.
spring
=
spring
;
}
...
...
@@ -131,10 +131,10 @@ public class LCNTransactionBeanHelper {
*/
public
TXLCNTransactionSeparator
loadLCNTransactionStateResolver
(
String
transactionType
)
{
try
{
String
name
=
String
.
format
(
TRANSACTION_STATE_RESOLVER_BEAN_NAME_F
ARMO
T
,
transactionType
);
String
name
=
String
.
format
(
TRANSACTION_STATE_RESOLVER_BEAN_NAME_F
ORMA
T
,
transactionType
);
return
spring
.
getBean
(
name
,
TXLCNTransactionSeparator
.
class
);
}
catch
(
Exception
e
)
{
return
spring
.
getBean
(
String
.
format
(
TRANSACTION_STATE_RESOLVER_BEAN_NAME_F
ARMO
T
,
"default"
),
TXLCNTransactionSeparator
.
class
);
return
spring
.
getBean
(
String
.
format
(
TRANSACTION_STATE_RESOLVER_BEAN_NAME_F
ORMA
T
,
"default"
),
TXLCNTransactionSeparator
.
class
);
}
}
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/support/TXLCNTransactionServiceExecutor.java
浏览文件 @
a20574f8
...
...
@@ -36,7 +36,7 @@ public class TXLCNTransactionServiceExecutor {
@Autowired
private
LCNTransactionBeanHelper
lcn
TransactionBeanHelper
;
private
TXLCNTransactionBeanHelper
TXLCN
TransactionBeanHelper
;
@Autowired
private
TransactionAttachmentCache
transactionAttachmentCache
;
...
...
@@ -58,7 +58,7 @@ public class TXLCNTransactionServiceExecutor {
// 2. 事务状态抉择器
TXLCNTransactionSeparator
lcnTransactionSeparator
=
lcn
TransactionBeanHelper
.
loadLCNTransactionStateResolver
(
transactionType
);
TXLCN
TransactionBeanHelper
.
loadLCNTransactionStateResolver
(
transactionType
);
// 3. 获取事务状态
TXLCNTransactionState
lcnTransactionState
=
lcnTransactionSeparator
.
loadTransactionState
(
info
);
...
...
@@ -69,7 +69,7 @@ public class TXLCNTransactionServiceExecutor {
// 4. 获取bean
TXLCNTransactionControl
lcnTransactionControl
=
lcn
TransactionBeanHelper
.
loadLCNTransactionControl
(
transactionType
,
lcnTransactionState
);
TXLCN
TransactionBeanHelper
.
loadLCNTransactionControl
(
transactionType
,
lcnTransactionState
);
// 5. 织入事务操作
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/support/checking/SimpleDTXChecking.java
浏览文件 @
a20574f8
...
...
@@ -106,8 +106,8 @@ public class SimpleDTXChecking implements DTXChecking {
String
channel
=
rpcClient
.
loadRemoteKey
();
MessageDto
messageDto
=
rpcClient
.
request
(
channel
,
MessageCreator
.
askTransactionState
(
groupId
,
unitId
));
int
state
=
SerializerContext
.
getInstance
().
deSerialize
(
messageDto
.
getBytes
(),
Short
.
class
);
log
.
info
(
"support > ask transaction
s
tate:{}"
,
state
);
txLogger
.
trace
(
groupId
,
unitId
,
Transactions
.
TAG_TASK
,
"ask transaction
s
tate "
+
state
);
log
.
info
(
"support > ask transaction
transactionS
tate:{}"
,
state
);
txLogger
.
trace
(
groupId
,
unitId
,
Transactions
.
TAG_TASK
,
"ask transaction
transactionS
tate "
+
state
);
if
(
state
==
-
1
)
{
log
.
error
(
"delay clean transaction error."
);
onAskTransactionStateException
(
groupId
,
unitId
,
transactionType
);
...
...
@@ -119,7 +119,7 @@ public class SimpleDTXChecking implements DTXChecking {
}
catch
(
RpcException
e
)
{
onAskTransactionStateException
(
groupId
,
unitId
,
transactionType
);
}
catch
(
TransactionClearException
|
SerializerException
|
InterruptedException
e
)
{
log
.
error
(
"{} > [transaction
s
tate message] error or [clean transaction] error."
,
transactionType
);
log
.
error
(
"{} > [transaction
transactionS
tate message] error or [clean transaction] error."
,
transactionType
);
}
},
clientConfig
.
getDtxTime
(),
TimeUnit
.
MILLISECONDS
);
delayTasks
.
put
(
groupId
+
unitId
,
scheduledFuture
);
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/support/common/template/TransactionCleanTemplate.java
浏览文件 @
a20574f8
...
...
@@ -16,7 +16,7 @@
package
com.codingapi.txlcn.client.support.common.template
;
import
com.codingapi.txlcn.client.aspectlog.AspectLogger
;
import
com.codingapi.txlcn.client.support.LCNTransactionBeanHelper
;
import
com.codingapi.txlcn.client.support.
TX
LCNTransactionBeanHelper
;
import
com.codingapi.txlcn.client.support.checking.DTXChecking
;
import
com.codingapi.txlcn.commons.exception.TransactionClearException
;
import
com.codingapi.txlcn.commons.util.Transactions
;
...
...
@@ -35,7 +35,7 @@ import org.springframework.stereotype.Component;
@Slf4j
public
class
TransactionCleanTemplate
{
private
final
LCNTransactionBeanHelper
transactionBeanHelper
;
private
final
TX
LCNTransactionBeanHelper
transactionBeanHelper
;
private
final
DTXChecking
dtxChecking
;
...
...
@@ -44,7 +44,7 @@ public class TransactionCleanTemplate {
private
final
TxLogger
txLogger
;
@Autowired
public
TransactionCleanTemplate
(
LCNTransactionBeanHelper
transactionBeanHelper
,
public
TransactionCleanTemplate
(
TX
LCNTransactionBeanHelper
transactionBeanHelper
,
DTXChecking
dtxChecking
,
AspectLogger
aspectLogger
,
TxLogger
txLogger
)
{
...
...
@@ -60,7 +60,7 @@ public class TransactionCleanTemplate {
* @param groupId groupId
* @param unitId unitId
* @param unitType unitType
* @param state
s
tate
* @param state
transactionS
tate
* @throws TransactionClearException TransactionClearException
*/
public
void
clean
(
String
groupId
,
String
unitId
,
String
unitType
,
int
state
)
throws
TransactionClearException
{
...
...
@@ -85,7 +85,7 @@ public class TransactionCleanTemplate {
* @param groupId groupId
* @param unitId unitId
* @param unitType unitType
* @param state
s
tate
* @param state
transactionS
tate
* @throws TransactionClearException TransactionClearException
*/
public
void
compensationClean
(
String
groupId
,
String
unitId
,
String
unitType
,
int
state
)
throws
TransactionClearException
{
...
...
tx-client/src/main/java/com/codingapi/txlcn/client/support/common/template/TransactionControlTemplate.java
浏览文件 @
a20574f8
...
...
@@ -170,7 +170,7 @@ public class TransactionControlTemplate {
* @param groupId groupId
* @param unitId unitId
* @param transactionType transactionType
* @param state
s
tate
* @param state
transactionS
tate
*/
public
void
notifyGroup
(
String
groupId
,
String
unitId
,
String
transactionType
,
int
state
)
{
txLogger
.
trace
(
groupId
,
unitId
,
Transactions
.
TAG_TRANSACTION
,
"notify group "
+
state
);
...
...
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/context/SimpleTransactionManager.java
浏览文件 @
a20574f8
...
...
@@ -88,6 +88,10 @@ public class SimpleTransactionManager implements TransactionManager {
transUnit
.
setUnitId
(
transactionUnit
.
unitId
());
log
.
info
(
"unit:{} joined group:{}"
,
transactionUnit
.
unitId
(),
dtxTransaction
.
groupId
());
try
{
//手动回滚时设置状态为回滚状态 0
if
(
transactionUnit
.
getTranscationState
()==
0
){
groupRelationship
.
setTransactionState
(
dtxTransaction
.
groupId
(),
0
);
}
groupRelationship
.
joinGroup
(
dtxTransaction
.
groupId
(),
transUnit
);
}
catch
(
JoinGroupException
e
)
{
throw
new
TransactionException
(
e
);
...
...
@@ -113,6 +117,7 @@ public class SimpleTransactionManager implements TransactionManager {
@Override
public
int
transactionState
(
DTXTransaction
groupTransaction
)
{
int
state
=
exceptionService
.
transactionState
(
groupTransaction
.
groupId
());
//存在数据时返回数据状态
if
(
state
!=
-
1
)
{
return
state
;
}
...
...
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/group/TransactionUnit.java
浏览文件 @
a20574f8
...
...
@@ -29,10 +29,13 @@ public class TransactionUnit {
private
String
messageContextId
;
public
TransactionUnit
(
String
unitId
,
String
unitType
,
String
messageContextId
)
{
private
int
transcationState
;
public
TransactionUnit
(
String
unitId
,
String
unitType
,
int
transcationState
,
String
messageContextId
)
{
this
.
unitId
=
unitId
;
this
.
unitType
=
unitType
;
this
.
messageContextId
=
messageContextId
;
this
.
transcationState
=
transcationState
;
}
public
String
unitId
()
{
...
...
@@ -46,4 +49,8 @@ public class TransactionUnit {
public
String
unitType
()
{
return
unitType
;
}
public
int
getTranscationState
()
{
return
transcationState
;
}
}
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/transaction/AskTransactionStateExecuteService.java
浏览文件 @
a20574f8
...
...
@@ -45,6 +45,7 @@ public class AskTransactionStateExecuteService implements RpcExecuteService {
@Override
public
Object
execute
(
TransactionCmd
transactionCmd
)
{
return
transactionManager
.
transactionState
(
transactionContext
.
getTransaction
(
transactionCmd
.
getGroupId
()));
int
state
=
transactionManager
.
transactionState
(
transactionContext
.
getTransaction
(
transactionCmd
.
getGroupId
()));
return
state
==
-
1
?
0
:
state
;
}
}
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/transaction/JoinGroupExecuteService.java
浏览文件 @
a20574f8
...
...
@@ -65,7 +65,7 @@ public class JoinGroupExecuteService implements RpcExecuteService {
txLogger
.
trace
(
transactionCmd
.
getGroupId
(),
joinGroupParams
.
getUnitId
(),
Transactions
.
TAG_TRANSACTION
,
"start join group"
);
TransactionUnit
transactionUnit
=
new
TransactionUnit
(
joinGroupParams
.
getUnitId
(),
joinGroupParams
.
getUnitType
(),
transactionCmd
.
getRemoteKey
());
new
TransactionUnit
(
joinGroupParams
.
getUnitId
(),
joinGroupParams
.
getUnitType
(),
joinGroupParams
.
getTransactionState
(),
transactionCmd
.
getRemoteKey
());
transactionManager
.
join
(
dtxTransaction
,
transactionUnit
);
txLogger
.
trace
(
...
...
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/transaction/NotifyGroupExecuteService.java
浏览文件 @
a20574f8
...
...
@@ -61,19 +61,26 @@ public class NotifyGroupExecuteService implements RpcExecuteService {
NotifyGroupParams
notifyGroupParams
=
transactionCmd
.
getMsg
().
loadData
(
NotifyGroupParams
.
class
);
log
.
debug
(
"notify group params: {}"
,
JSON
.
toJSONString
(
notifyGroupParams
));
int
commitState
=
notifyGroupParams
.
getState
();
//获取事务状态(当手动回滚时会先设置状态)
int
transactionState
=
transactionManager
.
transactionState
(
dtxTransaction
);
if
(
transactionState
==
0
)
{
commitState
=
0
;
}
// 系统日志
txLogger
.
trace
(
transactionCmd
.
getGroupId
(),
""
,
Transactions
.
TAG_TRANSACTION
,
"notify group "
+
notifyGroupParams
.
getState
());
if
(
notifyGroupParams
.
getState
()
==
1
)
{
if
(
commitState
==
1
)
{
transactionManager
.
commit
(
dtxTransaction
);
return
null
;
}
else
if
(
notifyGroupParams
.
getState
()
==
0
)
{
}
else
if
(
commitState
==
0
)
{
transactionManager
.
rollback
(
dtxTransaction
);
return
null
;
}
log
.
error
(
"ignored transaction
s
tate:{}"
,
notifyGroupParams
.
getState
());
log
.
error
(
"ignored transaction
transactionS
tate:{}"
,
notifyGroupParams
.
getState
());
}
catch
(
SerializerException
e
)
{
throw
new
TxManagerException
(
e
.
getMessage
());
}
finally
{
...
...
tx-manager/src/main/java/com/codingapi/txlcn/manager/core/transaction/WriteTxExceptionExecuteService.java
浏览文件 @
a20574f8
...
...
@@ -17,6 +17,8 @@ package com.codingapi.txlcn.manager.core.transaction;
import
com.codingapi.txlcn.commons.exception.SerializerException
;
import
com.codingapi.txlcn.commons.exception.TxManagerException
;
import
com.codingapi.txlcn.manager.core.context.DTXTransactionContext
;
import
com.codingapi.txlcn.manager.core.context.TransactionManager
;
import
com.codingapi.txlcn.manager.support.service.TxExceptionService
;
import
com.codingapi.txlcn.manager.support.service.WriteTxExceptionDTO
;
import
com.codingapi.txlcn.manager.core.message.RpcExecuteService
;
...
...
@@ -43,10 +45,16 @@ public class WriteTxExceptionExecuteService implements RpcExecuteService {
private
final
RpcClient
rpcClient
;
private
final
TransactionManager
transactionManager
;
private
final
DTXTransactionContext
transactionContext
;
@Autowired
public
WriteTxExceptionExecuteService
(
TxExceptionService
compensationService
,
RpcClient
rpcClient
)
{
public
WriteTxExceptionExecuteService
(
TxExceptionService
compensationService
,
RpcClient
rpcClient
,
TransactionManager
transactionManager
,
DTXTransactionContext
transactionContext
)
{
this
.
compensationService
=
compensationService
;
this
.
rpcClient
=
rpcClient
;
this
.
transactionManager
=
transactionManager
;
this
.
transactionContext
=
transactionContext
;
}
@Override
...
...
@@ -55,7 +63,11 @@ public class WriteTxExceptionExecuteService implements RpcExecuteService {
TxExceptionParams
txExceptionParams
=
transactionCmd
.
getMsg
().
loadData
(
TxExceptionParams
.
class
);
WriteTxExceptionDTO
writeTxExceptionReq
=
new
WriteTxExceptionDTO
();
writeTxExceptionReq
.
setModId
(
rpcClient
.
getAppName
(
transactionCmd
.
getRemoteKey
()));
writeTxExceptionReq
.
setTransactionState
(
txExceptionParams
.
getTransactionState
());
//获取事务状态(可能存在设置了手动回滚)
int
transactionState
=
transactionManager
.
transactionState
(
transactionContext
.
getTransaction
(
txExceptionParams
.
getGroupId
()));
writeTxExceptionReq
.
setTransactionState
(
transactionState
==-
1
?
txExceptionParams
.
getTransactionState
():
transactionState
);
writeTxExceptionReq
.
setGroupId
(
txExceptionParams
.
getGroupId
());
writeTxExceptionReq
.
setUnitId
(
txExceptionParams
.
getUnitId
());
writeTxExceptionReq
.
setRegistrar
(
Objects
.
isNull
(
txExceptionParams
.
getRegistrar
())
?
-
1
:
txExceptionParams
.
getRegistrar
());
...
...
tx-manager/src/main/java/com/codingapi/txlcn/manager/db/mapper/TxExceptionMapper.java
浏览文件 @
a20574f8
...
...
@@ -39,8 +39,8 @@ public interface TxExceptionMapper {
@Select
(
"select * from t_tx_exception"
)
List
<
TxException
>
findAll
();
@Update
(
"update t_tx_exception set ex_state=#{
s
tate} where id=#{id}"
)
void
changeExState
(
@Param
(
"id"
)
Long
id
,
@Param
(
"
s
tate"
)
short
state
);
@Update
(
"update t_tx_exception set ex_state=#{
transactionS
tate} where id=#{id}"
)
void
changeExState
(
@Param
(
"id"
)
Long
id
,
@Param
(
"
transactionS
tate"
)
short
state
);
@Select
(
"select * from t_tx_exception where group_id=#{groupId}"
)
TxException
getByGroupId
(
String
groupId
);
...
...
tx-manager/src/main/java/com/codingapi/txlcn/manager/db/redis/RedisGroupRelationship.java
浏览文件 @
a20574f8
...
...
@@ -44,7 +44,7 @@ public class RedisGroupRelationship implements GroupRelationship {
private
static
final
String
REDIS_PREFIX
=
"tx.manager:group:"
;
private
static
final
String
REDIS_GROUP_STATE
=
REDIS_PREFIX
+
":
s
tate"
;
private
static
final
String
REDIS_GROUP_STATE
=
REDIS_PREFIX
+
":
transactionS
tate"
;
private
final
RedisTemplate
<
String
,
String
>
redisTemplate
;
...
...
@@ -104,7 +104,7 @@ public class RedisGroupRelationship implements GroupRelationship {
public
Short
transactionState
(
String
groupId
)
{
String
state
=
redisTemplate
.
opsForValue
().
get
(
REDIS_GROUP_STATE
+
groupId
);
if
(
Objects
.
isNull
(
state
))
{
return
0
;
return
-
1
;
}
try
{
return
Short
.
valueOf
(
state
);
...
...
tx-manager/src/main/resources/static/admin/js/index.js
浏览文件 @
a20574f8
此差异已折叠。
点击以展开。
tx-spi-message-netty/src/main/java/com/codingapi/txlcn/spi/message/netty/impl/NettyRpcClientInitializer.java
浏览文件 @
a20574f8
...
...
@@ -84,7 +84,7 @@ public class NettyRpcClientInitializer implements RpcClientInitializer, Disposab
b
.
option
(
ChannelOption
.
CONNECT_TIMEOUT_MILLIS
,
5000
);
b
.
handler
(
nettyRpcClientHandlerInitHandler
);
ChannelFuture
channelFuture
=
b
.
connect
(
socketAddress
).
syncUninterruptibly
();
log
.
info
(
"client -> {} ,
s
tate:{}"
,
socketAddress
,
channelFuture
.
isSuccess
());
log
.
info
(
"client -> {} ,
transactionS
tate:{}"
,
socketAddress
,
channelFuture
.
isSuccess
());
connected
=
true
;
break
;
...
...
tx-spi-message/src/main/java/com/codingapi/txlcn/spi/message/LCNCmdType.java
浏览文件 @
a20574f8
...
...
@@ -53,7 +53,7 @@ public enum LCNCmdType {
* 响应事务状态
* 间写 ats
*/
askTransactionState
(
"ask-transaction-
s
tate"
,
MessageConstants
.
ACTION_ASK_TRANSACTION_STATE
),
askTransactionState
(
"ask-transaction-
transactionS
tate"
,
MessageConstants
.
ACTION_ASK_TRANSACTION_STATE
),
/**
* 记录补偿
...
...
tx-spi-message/src/main/java/com/codingapi/txlcn/spi/message/params/JoinGroupParams.java
浏览文件 @
a20574f8
...
...
@@ -47,4 +47,10 @@ public class JoinGroupParams implements Serializable {
* 通讯标识
*/
private
String
remoteKey
;
/**
* 事务状态
* 0 回滚 1提交
*/
private
int
transactionState
=
1
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录