Skip to content

Commit 1b4e31d

Browse files
committed
fix
1 parent 8888e09 commit 1b4e31d

File tree

34 files changed

+159
-88
lines changed

34 files changed

+159
-88
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 yedf
3+
Copyright (c) 2022 dtm-labs
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IDtmCommunicationClient.java dtmcli-common/src/main/java/pub/dtm/client/interfaces/stub/IDtmServerStub.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
package pub.dtm.client.interfaces.communication;
25+
package pub.dtm.client.interfaces.stub;
2626

2727
import feign.Response;
2828
import pub.dtm.client.model.param.OperatorParam;
@@ -32,11 +32,11 @@
3232
import java.util.Map;
3333

3434
/**
35-
* A feign client interface for dtm svr, we designed different implements for different client.
35+
* A stub interface for dtm svr, different client has different implements.
3636
*
3737
* @author horseLk
3838
*/
39-
public interface IDtmCommunicationClient {
39+
public interface IDtmServerStub {
4040
/**
4141
* get stubType
4242
* @return type

dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IURIParser.java dtmcli-common/src/main/java/pub/dtm/client/interfaces/stub/IURIParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -22,7 +22,7 @@
2222
* SOFTWARE.
2323
*/
2424

25-
package pub.dtm.client.interfaces.communication;
25+
package pub.dtm.client.interfaces.stub;
2626

2727
import pub.dtm.client.model.feign.ServiceMessage;
2828

dtmcli-common/src/main/java/pub/dtm/client/log/DtmFeignLogger.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/model/param/SagaOperatorParam.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/model/param/TccOperatorParam.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -27,7 +27,7 @@
2727
import pub.dtm.client.constant.Constants;
2828
import pub.dtm.client.exception.FailureException;
2929
import feign.Response;
30-
import pub.dtm.client.interfaces.communication.IURIParser;
30+
import pub.dtm.client.interfaces.stub.IURIParser;
3131
import pub.dtm.client.model.feign.ServiceMessage;
3232
import org.apache.commons.io.IOUtils;
3333
import org.apache.commons.lang3.StringUtils;

dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-common/src/main/java/pub/dtm/client/utils/JsonUtils.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal

dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -32,7 +32,7 @@
3232
import pub.dtm.client.constant.ParamFieldConstants;
3333
import pub.dtm.client.enums.TransTypeEnum;
3434
import pub.dtm.client.exception.FailureException;
35-
import pub.dtm.client.interfaces.communication.IDtmCommunicationClient;
35+
import pub.dtm.client.interfaces.stub.IDtmServerStub;
3636
import pub.dtm.client.model.dtm.TransBase;
3737
import pub.dtm.client.model.feign.ServiceMessage;
3838
import pub.dtm.client.model.param.SagaOperatorParam;
@@ -58,7 +58,7 @@ public class Saga extends TransBase {
5858

5959
private static final String CONCURRENT = "concurrent";
6060

61-
private IDtmCommunicationClient dtmCommunicationClient;
61+
private IDtmServerStub dtmServerStub;
6262

6363
private boolean concurrent;
6464

@@ -78,11 +78,11 @@ public class Saga extends TransBase {
7878

7979
private List<String> payloads = new ArrayList<>();
8080

81-
public Saga(String gid, IDtmCommunicationClient dtmCommunicationClient) {
81+
public Saga(String gid, IDtmServerStub dtmServerStub) {
8282
super(gid, TransTypeEnum.SAGA, false);
8383
this.concurrent = false;
8484
this.orders = new HashMap<>();
85-
this.dtmCommunicationClient = dtmCommunicationClient;
85+
this.dtmServerStub = dtmServerStub;
8686
}
8787

8888
public Saga add(ServiceMessage action, ServiceMessage compensate, Object postData) {
@@ -114,15 +114,15 @@ public Saga add(String action, String compensate, Object postData) {
114114

115115
public String submit() throws Exception {
116116
if (StringUtils.isEmpty(this.getGid())) {
117-
this.setGid(FeignUtils.parseGid(dtmCommunicationClient.newGid()));
117+
this.setGid(FeignUtils.parseGid(dtmServerStub.newGid()));
118118
}
119119
addConcurrentContext();
120120
SagaOperatorParam operatorParam = new SagaOperatorParam(this.getGid(), TransTypeEnum.SAGA, this.getSteps(),
121121
this.getPayloads(), this.getCustomData(), this.isWaitResult(), this.getTimeoutToFail(),
122122
this.getRetryInterval(), this.getPassthroughHeaders(), this.getBranchHeaders());
123123

124124
try {
125-
dtmCommunicationClient.submit(operatorParam);
125+
dtmServerStub.submit(operatorParam);
126126
} catch (Exception e) {
127127
log.error("saga transaction submit failed, transaction gid is {}", this.getGid());
128128
throw new FailureException(e);

dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* MIT License
33
*
4-
* Copyright (c) 2022 yedf
4+
* Copyright (c) 2022 dtm-labs
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -30,7 +30,7 @@
3030
import pub.dtm.client.constant.ParamFieldConstants;
3131
import pub.dtm.client.enums.TransTypeEnum;
3232
import pub.dtm.client.exception.FailureException;
33-
import pub.dtm.client.interfaces.communication.IDtmCommunicationClient;
33+
import pub.dtm.client.interfaces.stub.IDtmServerStub;
3434
import pub.dtm.client.interfaces.dtm.DtmConsumer;
3535
import pub.dtm.client.model.dtm.TransBase;
3636
import pub.dtm.client.model.feign.ServiceMessage;
@@ -68,16 +68,16 @@ public class Tcc extends TransBase {
6868
/**
6969
* feign client
7070
*/
71-
private IDtmCommunicationClient dtmCommunicationClient;
71+
private IDtmServerStub dtmServerStub;
7272

73-
public Tcc(String gid, IDtmCommunicationClient dtmCommunicationClient) {
73+
public Tcc(String gid, IDtmServerStub dtmServerStub) {
7474
super(gid, TransTypeEnum.TCC, false);
7575
this.branchIdGenerator = new BranchIdGenerator(Constants.EMPTY_STRING);
76-
this.dtmCommunicationClient = dtmCommunicationClient;
76+
this.dtmServerStub = dtmServerStub;
7777
}
7878

79-
public void setdtmCommunicationClient(IDtmCommunicationClient dtmCommunicationClient) {
80-
this.dtmCommunicationClient = dtmCommunicationClient;
79+
public void setDtmServerStub(IDtmServerStub dtmServerStub) {
80+
this.dtmServerStub = dtmServerStub;
8181
}
8282

8383
/**
@@ -89,23 +89,23 @@ public void setdtmCommunicationClient(IDtmCommunicationClient dtmCommunicationCl
8989
public String tccGlobalTransaction(DtmConsumer<Tcc> consumer) throws Exception {
9090
// if tcc's gid is empty, need to request a new gid from dtm svr
9191
if (StringUtils.isEmpty(this.getGid())) {
92-
this.setGid(FeignUtils.parseGid(dtmCommunicationClient.newGid()));
92+
this.setGid(FeignUtils.parseGid(dtmServerStub.newGid()));
9393
}
9494
log.info("the tcc transaction's gid is {}", this.getGid());
9595

9696
OperatorParam operatorParam = new OperatorParam(this.getGid(), TransTypeEnum.TCC);
97-
DtmResponse resp = dtmCommunicationClient.prepare(operatorParam);
97+
DtmResponse resp = dtmServerStub.prepare(operatorParam);
9898
log.info("prepare response: {}", resp);
9999
if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) {
100100
log.error("TCC transaction prepare fail. returned dtm_result is: {}, transaction gid: {}", resp.getDtmResult(), this.getGid());
101101
throw new FailureException("TCC Transaction prepare fail");
102102
}
103103
try {
104104
consumer.accept(this);
105-
dtmCommunicationClient.submit(operatorParam);
105+
dtmServerStub.submit(operatorParam);
106106
} catch (Exception e) {
107107
log.error("TCC transaction submit fail, start abort it. transaction gid: {}", this.getGid());
108-
dtmCommunicationClient.abort(operatorParam);
108+
dtmServerStub.abort(operatorParam);
109109
throw new FailureException(e);
110110
}
111111
return this.getGid();
@@ -128,7 +128,7 @@ public feign.Response callBranch(Object body, ServiceMessage tryMessage, Service
128128

129129
TccOperatorParam operatorParam = new TccOperatorParam(this.getGid(), TransTypeEnum.TCC, branchId, Constants.DEFAULT_STATUS,
130130
JsonUtils.toJson(body), FeignUtils.generatorURI(confirmMessage, false), FeignUtils.generatorURI(cancelMessage, false));
131-
DtmResponse resp = dtmCommunicationClient.registerBranch(operatorParam);
131+
DtmResponse resp = dtmServerStub.registerBranch(operatorParam);
132132
if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) {
133133
log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid());
134134
throw new FailureException("TCC Transaction register branch fail");
@@ -140,7 +140,7 @@ public feign.Response callBranch(Object body, ServiceMessage tryMessage, Service
140140
paramsMap.put(ParamFieldConstants.BRANCH_ID, branchId);
141141
paramsMap.put(ParamFieldConstants.OP, OP);
142142

143-
feign.Response response = dtmCommunicationClient.busiPost(new URI(FeignUtils.generatorURI(tryMessage, true)),
143+
feign.Response response = dtmServerStub.busiPost(new URI(FeignUtils.generatorURI(tryMessage, true)),
144144
tryMessage.getPath(), paramsMap, body);
145145
log.info("busi post is: {}", response);
146146
FeignUtils.checkResult(response);
@@ -163,7 +163,7 @@ public Response callBranch(Object body, String tryUrl, String confirmUrl, String
163163

164164
TccOperatorParam operatorParam = new TccOperatorParam(this.getGid(), TransTypeEnum.TCC, branchId, Constants.DEFAULT_STATUS,
165165
JsonUtils.toJson(body), confirmUrl, cancelUrl);
166-
DtmResponse resp = dtmCommunicationClient.registerBranch(operatorParam);
166+
DtmResponse resp = dtmServerStub.registerBranch(operatorParam);
167167
if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) {
168168
log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid());
169169
throw new FailureException("TCC Transaction register branch fail");

0 commit comments

Comments
 (0)