From 8180ee16957421ac69eb5dea4426f983061aa9a1 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Tue, 26 Apr 2022 16:12:21 +0800 Subject: [PATCH 01/24] dtmcli-java v2 --- dtmcli-common/pom.xml | 64 +++++++ .../src/main/java/constant/Constants.java | 37 ++++ .../java/constant/ParamFieldConstants.java | 27 +++ .../src/main/java/enums/TransTypeEnum.java | 29 ++++ .../src/main/java/exception/DtmException.java | 11 ++ .../main/java/interfaces/dtm/DtmConsumer.java | 8 + .../main/java/interfaces/dtm/IDtmService.java | 4 + .../interfaces/feign/IDtmFeignClient.java | 26 +++ .../java/interfaces/feign/IURIParser.java | 7 + .../src/main/java/model/dtm/TransBase.java | 23 +++ .../main/java/model/feign/ServiceMessage.java | 73 ++++++++ .../main/java/model/param/OperatorParam.java | 58 +++++++ .../java/model/response/ResponseBase.java | 20 +++ .../src/main/java/utils/FeignUtils.java | 66 +++++++ .../src/main/java/utils/HttpUtils.java | 63 +++++++ .../target/maven-archiver/pom.properties | 5 + .../compile/default-compile/createdFiles.lst | 14 ++ .../compile/default-compile/inputFiles.lst | 0 .../default-testCompile/inputFiles.lst | 0 dtmcli-core/pom.xml | 36 ++++ .../java/barrier/BranchBarrierService.java | 69 ++++++++ .../main/java/barrier/model/BarrierParam.java | 30 ++++ .../java/barrier/model/BranchBarrier.java | 46 +++++ .../src/main/java/base/BranchIdGenerator.java | 32 ++++ dtmcli-core/src/main/java/tcc/TccService.java | 117 +++++++++++++ dtmcli-core/src/main/java/tcc/model/Tcc.java | 19 +++ .../target/maven-archiver/pom.properties | 5 + .../compile/default-compile/createdFiles.lst | 6 + .../compile/default-compile/inputFiles.lst | 6 + .../default-testCompile/inputFiles.lst | 0 dtmcli-java/pom.xml | 47 +++++ .../src/main/java/client/DtmClient.java | 87 ++++++++++ .../src/main/java/feign/DtmFeignClient.java | 44 +++++ .../src/main/java/feign/URIParser.java | 25 +++ .../main/java/properties/DtmProperties.java | 37 ++++ .../src/main/java/utils/NacosUtils.java | 23 +++ .../target/maven-archiver/pom.properties | 5 + .../compile/default-compile/createdFiles.lst | 5 + .../compile/default-compile/inputFiles.lst | 5 + .../default-testCompile/inputFiles.lst | 0 dtmcli-spring/pom.xml | 93 ++++++++++ .../src/main/java/client/DtmClient.java | 25 +++ .../java/configuration/DtmConfiguration.java | 44 +++++ .../src/main/java/feign/DtmFeignClient.java | 51 ++++++ .../src/main/java/feign/URIParser.java | 26 +++ .../main/java/properties/DtmProperties.java | 15 ++ .../main/resources/META-INF/spring.factories | 1 + .../spring-configuration-metadata.json | 22 +++ .../target/classes/META-INF/spring.factories | 1 + .../target/maven-archiver/pom.properties | 5 + .../compile/default-compile/createdFiles.lst | 6 + .../compile/default-compile/inputFiles.lst | 5 + .../default-testCompile/inputFiles.lst | 0 pom.xml | 161 +++++++++++++----- 54 files changed, 1587 insertions(+), 47 deletions(-) create mode 100644 dtmcli-common/pom.xml create mode 100644 dtmcli-common/src/main/java/constant/Constants.java create mode 100644 dtmcli-common/src/main/java/constant/ParamFieldConstants.java create mode 100644 dtmcli-common/src/main/java/enums/TransTypeEnum.java create mode 100644 dtmcli-common/src/main/java/exception/DtmException.java create mode 100644 dtmcli-common/src/main/java/interfaces/dtm/DtmConsumer.java create mode 100644 dtmcli-common/src/main/java/interfaces/dtm/IDtmService.java create mode 100644 dtmcli-common/src/main/java/interfaces/feign/IDtmFeignClient.java create mode 100644 dtmcli-common/src/main/java/interfaces/feign/IURIParser.java create mode 100644 dtmcli-common/src/main/java/model/dtm/TransBase.java create mode 100644 dtmcli-common/src/main/java/model/feign/ServiceMessage.java create mode 100644 dtmcli-common/src/main/java/model/param/OperatorParam.java create mode 100644 dtmcli-common/src/main/java/model/response/ResponseBase.java create mode 100644 dtmcli-common/src/main/java/utils/FeignUtils.java create mode 100644 dtmcli-common/src/main/java/utils/HttpUtils.java create mode 100644 dtmcli-common/target/maven-archiver/pom.properties create mode 100644 dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 dtmcli-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst create mode 100644 dtmcli-core/pom.xml create mode 100644 dtmcli-core/src/main/java/barrier/BranchBarrierService.java create mode 100644 dtmcli-core/src/main/java/barrier/model/BarrierParam.java create mode 100644 dtmcli-core/src/main/java/barrier/model/BranchBarrier.java create mode 100644 dtmcli-core/src/main/java/base/BranchIdGenerator.java create mode 100644 dtmcli-core/src/main/java/tcc/TccService.java create mode 100644 dtmcli-core/src/main/java/tcc/model/Tcc.java create mode 100644 dtmcli-core/target/maven-archiver/pom.properties create mode 100644 dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 dtmcli-core/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst create mode 100644 dtmcli-java/pom.xml create mode 100644 dtmcli-java/src/main/java/client/DtmClient.java create mode 100644 dtmcli-java/src/main/java/feign/DtmFeignClient.java create mode 100644 dtmcli-java/src/main/java/feign/URIParser.java create mode 100644 dtmcli-java/src/main/java/properties/DtmProperties.java create mode 100644 dtmcli-java/src/main/java/utils/NacosUtils.java create mode 100644 dtmcli-java/target/maven-archiver/pom.properties create mode 100644 dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 dtmcli-java/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst create mode 100644 dtmcli-spring/pom.xml create mode 100644 dtmcli-spring/src/main/java/client/DtmClient.java create mode 100644 dtmcli-spring/src/main/java/configuration/DtmConfiguration.java create mode 100644 dtmcli-spring/src/main/java/feign/DtmFeignClient.java create mode 100644 dtmcli-spring/src/main/java/feign/URIParser.java create mode 100644 dtmcli-spring/src/main/java/properties/DtmProperties.java create mode 100644 dtmcli-spring/src/main/resources/META-INF/spring.factories create mode 100644 dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json create mode 100644 dtmcli-spring/target/classes/META-INF/spring.factories create mode 100644 dtmcli-spring/target/maven-archiver/pom.properties create mode 100644 dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst create mode 100644 dtmcli-spring/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst diff --git a/dtmcli-common/pom.xml b/dtmcli-common/pom.xml new file mode 100644 index 0000000..17984f8 --- /dev/null +++ b/dtmcli-common/pom.xml @@ -0,0 +1,64 @@ + + + + dtmcli-java-parent + pub.dtm + 1.0.0 + + 4.0.0 + + dtmcli-common + 1.0.0 + jar + dtmcli-common + + + UTF-8 + 1.8 + 1.8 + + + + + com.google.code.gson + gson + + + + com.fasterxml.jackson.core + jackson-annotations + + + + org.projectlombok + lombok + + + + io.github.openfeign + feign-core + + + + org.apache.commons + commons-lang3 + + + + com.squareup.okhttp3 + okhttp + + + + com.alibaba.nacos + nacos-client + + + + org.slf4j + slf4j-api + + + \ No newline at end of file diff --git a/dtmcli-common/src/main/java/constant/Constants.java b/dtmcli-common/src/main/java/constant/Constants.java new file mode 100644 index 0000000..15d2fbd --- /dev/null +++ b/dtmcli-common/src/main/java/constant/Constants.java @@ -0,0 +1,37 @@ +package constant; + +public class Constants { + public static final String MICRO_SERVICE_NAME_KEY = "dtm.service.name"; + + public static final String GET_METHOD = "GET "; + + public static final String POST_METHOD = "POST "; + + public static final String HTTP_PREFIX = "http://"; + + public static final String HTTPS_PREFIX = "https://"; + + public static final String PING_URL = "/api/ping"; + + private static final String BASE_URL = "/api/dtmsvr"; + + public static final String NEW_GID_URL = BASE_URL + "/newGid"; + + public static final String PREPARE_URL = BASE_URL + "/prepare"; + + public static final String SUBMIT_URL = BASE_URL + "/submit"; + + public static final String ABORT_URL = BASE_URL + "/abort"; + + public static final String REGISTER_BRANCH_URL = BASE_URL + "/registerBranch"; + + public static final String DEFAULT_STATUS = "prepared"; + + public static final String EMPTY_STRING = ""; + + public static final String SUCCESS_RESULT = "SUCCESS"; + + public static final String FAILURE_RESULT = "FAILURE"; + + public static final int RESP_ERR_CODE = 400; +} diff --git a/dtmcli-common/src/main/java/constant/ParamFieldConstants.java b/dtmcli-common/src/main/java/constant/ParamFieldConstants.java new file mode 100644 index 0000000..0adf4fb --- /dev/null +++ b/dtmcli-common/src/main/java/constant/ParamFieldConstants.java @@ -0,0 +1,27 @@ +package constant; + +public class ParamFieldConstants { + public static final String GID = "gid"; + + public static final String TRANS_TYPE = "trans_type"; + + public static final String BRANCH_ID = "branch_id"; + + public static final String STATUS = "status"; + + public static final String DATA = "data"; + + public static final String TRY = "try"; + + public static final String CONFIRM = "confirm"; + + public static final String CANCEL = "cancel"; + + public static final String OP = "op"; + + public static final String CODE = "code"; + + public static final String MESSAGE = "message"; + + public static final String DTM_RESULT = "dtm_result"; +} diff --git a/dtmcli-common/src/main/java/enums/TransTypeEnum.java b/dtmcli-common/src/main/java/enums/TransTypeEnum.java new file mode 100644 index 0000000..eb79010 --- /dev/null +++ b/dtmcli-common/src/main/java/enums/TransTypeEnum.java @@ -0,0 +1,29 @@ +package enums; + +public enum TransTypeEnum { + TCC("tcc"), + XA("xa"), + MSG("msg"), + SAGA("saga") + ; + + TransTypeEnum(String value) { + this.value = value; + } + + private String value; + + @Override + public String toString() { + return this.value; + } + + public static TransTypeEnum parseString(String value) { + for (TransTypeEnum transType : TransTypeEnum.values()) { + if (transType.value.equals(value)) { + return transType; + } + } + return null; + } +} diff --git a/dtmcli-common/src/main/java/exception/DtmException.java b/dtmcli-common/src/main/java/exception/DtmException.java new file mode 100644 index 0000000..5461824 --- /dev/null +++ b/dtmcli-common/src/main/java/exception/DtmException.java @@ -0,0 +1,11 @@ +package exception; + +public class DtmException extends Exception { + public DtmException(String msg) { + super(msg); + } + + public DtmException(Throwable e) { + super(e); + } +} diff --git a/dtmcli-common/src/main/java/interfaces/dtm/DtmConsumer.java b/dtmcli-common/src/main/java/interfaces/dtm/DtmConsumer.java new file mode 100644 index 0000000..ef81b9c --- /dev/null +++ b/dtmcli-common/src/main/java/interfaces/dtm/DtmConsumer.java @@ -0,0 +1,8 @@ +package interfaces.dtm; + +import model.dtm.TransBase; + +@FunctionalInterface +public interface DtmConsumer { + void accept(S s, T t) throws Exception; +} diff --git a/dtmcli-common/src/main/java/interfaces/dtm/IDtmService.java b/dtmcli-common/src/main/java/interfaces/dtm/IDtmService.java new file mode 100644 index 0000000..0b82617 --- /dev/null +++ b/dtmcli-common/src/main/java/interfaces/dtm/IDtmService.java @@ -0,0 +1,4 @@ +package interfaces.dtm; + +public interface IDtmService { +} diff --git a/dtmcli-common/src/main/java/interfaces/feign/IDtmFeignClient.java b/dtmcli-common/src/main/java/interfaces/feign/IDtmFeignClient.java new file mode 100644 index 0000000..3c78c28 --- /dev/null +++ b/dtmcli-common/src/main/java/interfaces/feign/IDtmFeignClient.java @@ -0,0 +1,26 @@ +package interfaces.feign; + +import feign.Response; +import model.param.OperatorParam; +import model.response.ResponseBase; + +import java.net.URI; +import java.util.Map; + +public interface IDtmFeignClient { + ResponseBase newGid(); + + ResponseBase ping(); + + ResponseBase prepare(OperatorParam body); + + ResponseBase submit(OperatorParam body); + + ResponseBase abort(OperatorParam body); + + ResponseBase registerBranch(OperatorParam body); + + Response busiGet(URI host, String path, Map queryMap); + + Response busiPost(URI host, String path, Map queryMap, Object body); +} diff --git a/dtmcli-common/src/main/java/interfaces/feign/IURIParser.java b/dtmcli-common/src/main/java/interfaces/feign/IURIParser.java new file mode 100644 index 0000000..1ac99c4 --- /dev/null +++ b/dtmcli-common/src/main/java/interfaces/feign/IURIParser.java @@ -0,0 +1,7 @@ +package interfaces.feign; + +import model.feign.ServiceMessage; + +public interface IURIParser { + String generatorURI(ServiceMessage serviceMessage, boolean httpType) throws Exception; +} diff --git a/dtmcli-common/src/main/java/model/dtm/TransBase.java b/dtmcli-common/src/main/java/model/dtm/TransBase.java new file mode 100644 index 0000000..d2b4102 --- /dev/null +++ b/dtmcli-common/src/main/java/model/dtm/TransBase.java @@ -0,0 +1,23 @@ +package model.dtm; + +import enums.TransTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TransBase { + /** + * global transaction id + */ + private String gid; + + /** + * 事务类型 + */ + private TransTypeEnum transTypeEnum; + + private boolean waitResult; +} diff --git a/dtmcli-common/src/main/java/model/feign/ServiceMessage.java b/dtmcli-common/src/main/java/model/feign/ServiceMessage.java new file mode 100644 index 0000000..8d336fc --- /dev/null +++ b/dtmcli-common/src/main/java/model/feign/ServiceMessage.java @@ -0,0 +1,73 @@ +package model.feign; + + +import org.apache.commons.lang3.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +public class ServiceMessage { + private String serviceName; + + private String groupName = "DEFAULT_GROUP"; + + private List cluster = new ArrayList<>(); + + private String path; + + public ServiceMessage(String serviceName, String path){ + this.serviceName = serviceName; + this.path = path; + } + + public ServiceMessage(String serviceName, String groupName, List cluster, String path) { + this.serviceName = serviceName; + this.groupName = groupName; + this.cluster.addAll(cluster); + this.path = path; + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public String getGroupName() { + return groupName; + } + + public void setGroupName(String groupName) { + this.groupName = groupName; + } + + public List getCluster() { + return cluster; + } + + public void setCluster(List cluster) { + this.cluster = cluster; + } + + public String getPath() { + if (StringUtils.startsWith(path, "/")) { + return path; + } + return "/" + path; + } + + public void setPath(String path) { + this.path = path; + } + + @Override + public String toString() { + String _path = path; + if (!StringUtils.startsWith(path, "/")) { + _path = "/" + path; + } + return serviceName + _path + "?groupName=" + groupName; + } +} diff --git a/dtmcli-common/src/main/java/model/param/OperatorParam.java b/dtmcli-common/src/main/java/model/param/OperatorParam.java new file mode 100644 index 0000000..206322d --- /dev/null +++ b/dtmcli-common/src/main/java/model/param/OperatorParam.java @@ -0,0 +1,58 @@ +package model.param; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.annotations.SerializedName; +import constant.ParamFieldConstants; +import enums.TransTypeEnum; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OperatorParam { + @SerializedName(ParamFieldConstants.GID) + @JsonProperty(ParamFieldConstants.GID) + private String gid; + + @SerializedName(ParamFieldConstants.TRANS_TYPE) + @JsonProperty(ParamFieldConstants.TRANS_TYPE) + private String transType; + + @SerializedName(ParamFieldConstants.BRANCH_ID) + @JsonProperty(ParamFieldConstants.BRANCH_ID) + private String branchId; + + @SerializedName(ParamFieldConstants.STATUS) + @JsonProperty(ParamFieldConstants.STATUS) + private String status; + + @SerializedName(ParamFieldConstants.DATA) + @JsonProperty(ParamFieldConstants.DATA) + private String data; + + @SerializedName(ParamFieldConstants.CONFIRM) + @JsonProperty(ParamFieldConstants.CONFIRM) + private String confirm; + + @SerializedName(ParamFieldConstants.CANCEL) + @JsonProperty(ParamFieldConstants.CANCEL) + private String cancel; + + public OperatorParam(String gid, TransTypeEnum transType, String branchId, + String status, String data, String confirmUrl, String cancelUrl) { + this.gid = gid; + this.transType = transType.toString(); + this.branchId = branchId; + this.status = status; + this.data = data; + this.confirm = confirmUrl; + this.cancel = cancelUrl; + } + + public OperatorParam(String gid, TransTypeEnum transType) { + this.gid = gid; + this.transType = transType.toString(); + } +} diff --git a/dtmcli-common/src/main/java/model/response/ResponseBase.java b/dtmcli-common/src/main/java/model/response/ResponseBase.java new file mode 100644 index 0000000..ed963ef --- /dev/null +++ b/dtmcli-common/src/main/java/model/response/ResponseBase.java @@ -0,0 +1,20 @@ +package model.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.google.gson.annotations.SerializedName; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ResponseBase { + @SerializedName("dtm_result") + @JsonProperty("dtm_result") + private String dtmResult; + + @SerializedName("gid") + @JsonProperty("gid") + private String gid; +} diff --git a/dtmcli-common/src/main/java/utils/FeignUtils.java b/dtmcli-common/src/main/java/utils/FeignUtils.java new file mode 100644 index 0000000..6be5c93 --- /dev/null +++ b/dtmcli-common/src/main/java/utils/FeignUtils.java @@ -0,0 +1,66 @@ +package utils; + +import constant.Constants; +import exception.DtmException; +import feign.Response; +import interfaces.feign.IURIParser; +import model.response.ResponseBase; +import model.feign.ServiceMessage; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +public class FeignUtils { + private static final Logger log = LoggerFactory.getLogger(FeignUtils.class); + + private static IURIParser uriParser; + + public static void setUriParser(IURIParser uriParser) { + FeignUtils.uriParser = uriParser; + } + + public static String parseGid(ResponseBase base) throws Exception { + if (base == null || !Constants.SUCCESS_RESULT.equals(base.getDtmResult())) { + throw new Exception("get new gid from dtm server fail."); + } + return base.getGid(); + } + + public static String generatorURI(ServiceMessage serviceMessage, boolean httpType) throws Exception { + return uriParser.generatorURI(serviceMessage, httpType); + } + + public static void checkResult(Response response) throws DtmException { + if (response.status() >= Constants.RESP_ERR_CODE){ + if (response.reason() != null) { + throw new DtmException(response.reason()); + } + try { + log.error("response code is {}, but unknown reason, response body is {}", response.status(), + IOUtils.toString(response.body().asReader(StandardCharsets.UTF_8))); + } finally { + throw new DtmException("response code is " + response.status()); + } + } + String result = ""; + try { + InputStream inputStream = response.body().asInputStream(); + if (inputStream != null) { + result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); + } + } catch (IOException e) { + throw new DtmException("response is null"); + } + if (StringUtils.isBlank(result)) { + throw new DtmException("response is null"); + } + if (result.contains(Constants.FAILURE_RESULT)){ + throw new DtmException("Service returned failed"); + } + } +} diff --git a/dtmcli-common/src/main/java/utils/HttpUtils.java b/dtmcli-common/src/main/java/utils/HttpUtils.java new file mode 100644 index 0000000..0772674 --- /dev/null +++ b/dtmcli-common/src/main/java/utils/HttpUtils.java @@ -0,0 +1,63 @@ +package utils; + +import constant.Constants; +import exception.DtmException; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; +import org.apache.commons.lang3.StringUtils; + +import java.io.IOException; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +public class HttpUtils { + private static final OkHttpClient CLIENT = new OkHttpClient.Builder().connectTimeout(15, TimeUnit.SECONDS) + .readTimeout(5, TimeUnit.SECONDS).writeTimeout(5, TimeUnit.SECONDS).build(); + + public static final MediaType MEDIA_TYPE = MediaType.get("application/json; charset=utf-8"); + + public static Response get(String url) throws IOException { + Request request = new Request.Builder().url(url).get().build(); + return CLIENT.newCall(request).execute(); + } + + public static Response post(String url, String json) throws IOException { + RequestBody body = RequestBody.create(MEDIA_TYPE, json); + Request request = new Request.Builder().url(url).post(body).build(); + return CLIENT.newCall(request).execute(); + } + + public static String splicingUrl(String url, Map params) { + if (params == null || params.isEmpty()) { + return url; + } + StringBuilder builder = new StringBuilder(url).append("?"); + for (Map.Entry entry : params.entrySet()) { + builder.append(entry.getKey()).append("=").append(entry.getValue()).append("&"); + } + return builder.deleteCharAt(builder.length() - 1).toString(); + } + + + public static String splicingUrl(String ip, int port, String path) { + return Constants.HTTP_PREFIX + ip + ":" + String.valueOf(port) + path; + } + + public static void checkResult(Response response) throws Exception { + if (response.code() >= Constants.RESP_ERR_CODE){ + throw new DtmException(response.message()); + } + ResponseBody body = response.body(); + String result; + if (body == null || StringUtils.isBlank(result = body.string())) { + throw new DtmException("response is null"); + } + if (result.contains(Constants.FAILURE_RESULT)){ + throw new DtmException("Service returned failed"); + } + } +} diff --git a/dtmcli-common/target/maven-archiver/pom.properties b/dtmcli-common/target/maven-archiver/pom.properties new file mode 100644 index 0000000..48cb916 --- /dev/null +++ b/dtmcli-common/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Tue Apr 26 15:54:57 CST 2022 +version=1.0.0 +groupId=pub.dtm +artifactId=dtmcli-common diff --git a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..465ce62 --- /dev/null +++ b/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,14 @@ +interfaces/dtm/IDtmService.class +constant/ParamFieldConstants.class +model/feign/ServiceMessage.class +interfaces/feign/IURIParser.class +interfaces/dtm/DtmConsumer.class +constant/Constants.class +model/param/OperatorParam.class +interfaces/feign/IDtmFeignClient.class +utils/FeignUtils.class +model/dtm/TransBase.class +utils/HttpUtils.class +model/response/ResponseBase.class +enums/TransTypeEnum.class +exception/DtmException.class diff --git a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/dtmcli-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/dtmcli-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/dtmcli-core/pom.xml b/dtmcli-core/pom.xml new file mode 100644 index 0000000..e425578 --- /dev/null +++ b/dtmcli-core/pom.xml @@ -0,0 +1,36 @@ + + + + dtmcli-java-parent + pub.dtm + 1.0.0 + + 4.0.0 + + dtmcli-core + 1.0.0 + jar + dtmcli-core + + + + pub.dtm + dtmcli-common + 1.0.0 + + + + org.apache.commons + commons-lang3 + + + + org.slf4j + slf4j-api + + + + + \ No newline at end of file diff --git a/dtmcli-core/src/main/java/barrier/BranchBarrierService.java b/dtmcli-core/src/main/java/barrier/BranchBarrierService.java new file mode 100644 index 0000000..7f05d51 --- /dev/null +++ b/dtmcli-core/src/main/java/barrier/BranchBarrierService.java @@ -0,0 +1,69 @@ +package barrier; + +import barrier.model.BranchBarrier; +import constant.ParamFieldConstants; +import interfaces.dtm.DtmConsumer; +import interfaces.dtm.IDtmService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.Objects; + +public class BranchBarrierService implements IDtmService { + private static final Logger log = LoggerFactory.getLogger(BranchBarrierService.class); + + public void call(BranchBarrier barrier, Connection connection, DtmConsumer consumer) throws Exception { + barrier.addBarrierId(); + connection.setAutoCommit(false); + try { + boolean result = insertBarrier(connection, barrier); + if (result) { + consumer.accept(this, barrier); + connection.commit(); + } + } catch (Exception exception) { + log.warn("barrier call error", exception); + connection.rollback(); + throw exception; + } finally { + connection.setAutoCommit(true); + } + } + + private boolean insertBarrier(Connection connection, BranchBarrier barrier) throws SQLException { + log.info("insert barrier {}", barrier); + if (Objects.isNull(connection)) { + return false; + } + PreparedStatement preparedStatement = null; + try { + String sql = "insert ignore into barrier(trans_type, gid, branch_id, op, barrier_id, reason) values(?,?,?,?,?,?)"; + preparedStatement = connection.prepareStatement(sql); + preparedStatement.setString(1, barrier.getTransTypeEnum().toString()); + preparedStatement.setString(2, barrier.getGid()); + preparedStatement.setString(3, barrier.getBranchId()); + preparedStatement.setString(4, barrier.getOp()); + preparedStatement.setString(5, String.format("%02d", barrier.getBarrierId())); + preparedStatement.setString(6, barrier.getOp()); + + if (preparedStatement.executeUpdate() == 0) { + return false; + } + if (ParamFieldConstants.CANCEL.equals(barrier.getOp())) { + int opIndex = 4; + preparedStatement.setString(opIndex, ParamFieldConstants.TRY); + if (preparedStatement.executeUpdate() > 0) { + return false; + } + } + } finally { + if (Objects.nonNull(preparedStatement)) { + preparedStatement.close(); + } + } + return true; + } +} diff --git a/dtmcli-core/src/main/java/barrier/model/BarrierParam.java b/dtmcli-core/src/main/java/barrier/model/BarrierParam.java new file mode 100644 index 0000000..c32bffc --- /dev/null +++ b/dtmcli-core/src/main/java/barrier/model/BarrierParam.java @@ -0,0 +1,30 @@ +package barrier.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class BarrierParam { + /** + * 事务类型 + */ + private String trans_type[]; + + /** + * 全局事务id + */ + private String gid[]; + + /** + * 分支id + */ + private String branch_id[]; + + /** + * 操作 + */ + private String op[]; +} diff --git a/dtmcli-core/src/main/java/barrier/model/BranchBarrier.java b/dtmcli-core/src/main/java/barrier/model/BranchBarrier.java new file mode 100644 index 0000000..9ba2ca1 --- /dev/null +++ b/dtmcli-core/src/main/java/barrier/model/BranchBarrier.java @@ -0,0 +1,46 @@ +package barrier.model; + +import com.google.gson.Gson; +import enums.TransTypeEnum; +import exception.DtmException; +import lombok.Data; +import model.dtm.TransBase; +import org.apache.commons.lang3.ArrayUtils; + +import java.util.Map; + +@Data +public class BranchBarrier extends TransBase { + private String branchId; + + private String op; + + private int barrierId; + + public void addBarrierId() { + this.barrierId += 1; + } + + public static BranchBarrier buildBranchBarrier(Map paramsMap) throws Exception { + if (paramsMap == null || paramsMap.isEmpty()) { + throw new DtmException("build BranchBarrier error, paramsMap can not be empty."); + } + Gson gson = new Gson(); + BarrierParam barrierParam = gson.fromJson(gson.toJson(paramsMap), BarrierParam.class); + BranchBarrier branchBarrier = new BranchBarrier(); + if (ArrayUtils.isNotEmpty(barrierParam.getTrans_type())) { + branchBarrier.setTransTypeEnum(TransTypeEnum.parseString(barrierParam.getTrans_type()[0])); + } + if (ArrayUtils.isNotEmpty(barrierParam.getGid())) { + branchBarrier.setGid(barrierParam.getGid()[0]); + } + if (ArrayUtils.isNotEmpty(barrierParam.getBranch_id())) { + branchBarrier.branchId = barrierParam.getBranch_id()[0]; + } + if (ArrayUtils.isNotEmpty(barrierParam.getOp())) { + branchBarrier.op = barrierParam.getOp()[0]; + } + return branchBarrier; + } + +} diff --git a/dtmcli-core/src/main/java/base/BranchIdGenerator.java b/dtmcli-core/src/main/java/base/BranchIdGenerator.java new file mode 100644 index 0000000..915b42c --- /dev/null +++ b/dtmcli-core/src/main/java/base/BranchIdGenerator.java @@ -0,0 +1,32 @@ +package base; + +public class BranchIdGenerator { + private static final int MAX_BRANCH_ID = 99; + + private static final int LENGTH = 20; + + private final String branchId; + + private int subBranchId; + + public BranchIdGenerator(String branchId) { + this.branchId = branchId; + } + + /** + * 生成注册分支id + * + * @return + * @throws Exception + */ + public String genBranchId() throws Exception { + if (this.subBranchId >= MAX_BRANCH_ID) { + throw new Exception("branch id is larger than 99"); + } + if (this.branchId.length() >= LENGTH) { + throw new Exception("total branch id is longer than 20"); + } + this.subBranchId++; + return this.branchId + String.format("%02d", this.subBranchId); + } +} diff --git a/dtmcli-core/src/main/java/tcc/TccService.java b/dtmcli-core/src/main/java/tcc/TccService.java new file mode 100644 index 0000000..0cdf89b --- /dev/null +++ b/dtmcli-core/src/main/java/tcc/TccService.java @@ -0,0 +1,117 @@ +package tcc; + +import com.google.gson.Gson; +import constant.Constants; +import constant.ParamFieldConstants; +import enums.TransTypeEnum; +import exception.DtmException; +import interfaces.dtm.DtmConsumer; +import interfaces.dtm.IDtmService; +import interfaces.feign.IDtmFeignClient; +import model.feign.ServiceMessage; +import model.param.OperatorParam; +import model.response.ResponseBase; +import okhttp3.Response; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import tcc.model.Tcc; +import utils.FeignUtils; +import utils.HttpUtils; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; + +public class TccService implements IDtmService { + private static final Logger log = LoggerFactory.getLogger(TccService.class); + + private static final String OP = "try"; + + private IDtmFeignClient feignClient; + + public TccService(IDtmFeignClient feignClient) { + this.feignClient = feignClient; + } + + public void setFeignClient(IDtmFeignClient feignClient) { + this.feignClient = feignClient; + } + + public String tccGlobalTransaction(String gid, DtmConsumer consumer) throws Exception { + if (StringUtils.isEmpty(gid)) { + gid = FeignUtils.parseGid(feignClient.newGid()); + } + log.info("the tcc transaction's gid is {}", gid); + Tcc tcc = new Tcc(gid); + + + OperatorParam operatorParam = new OperatorParam(gid, TransTypeEnum.TCC); + ResponseBase resp = feignClient.prepare(operatorParam); + log.info("prepare response: {}", resp); + if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { + log.error("TCC transaction prepare fail. returned dtm_result is: {}, transaction gid: {}", resp.getDtmResult(), gid); + throw new DtmException("TCC Transaction prepare fail"); + } + try { + consumer.accept(this, tcc); + feignClient.submit(operatorParam); + } catch (Exception e) { + log.error("TCC transaction submit fail, start abort it. transaction gid: {}", gid); + feignClient.abort(operatorParam); + throw new DtmException(e); + } + return gid; + } + + public feign.Response callBranch(Tcc tcc, Object body, ServiceMessage tryMessage, ServiceMessage confirmMessage, ServiceMessage cancelMessage) throws Exception { + Gson gson = new Gson(); + log.info("call method Tcc.callBranch, tryMessage: {}, confirmMessage: {}, cancelMessage: {}", + gson.toJson(tryMessage), gson.toJson(confirmMessage), gson.toJson(cancelMessage)); + String branchId = tcc.getBranchIdGenerator().genBranchId(); + + OperatorParam operatorParam = new OperatorParam(tcc.getGid(), TransTypeEnum.TCC, Constants.DEFAULT_STATUS, branchId, + gson.toJson(body), FeignUtils.generatorURI(confirmMessage, false), FeignUtils.generatorURI(cancelMessage, false)); + ResponseBase resp = feignClient.registerBranch(operatorParam); + if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { + log.error("TCC transaction register branch fail. transaction gid: {}", tcc.getGid()); + throw new DtmException("TCC Transaction register branch fail"); + } + + Map paramsMap = new HashMap<>(); + paramsMap.put(ParamFieldConstants.GID, tcc.getGid()); + paramsMap.put(ParamFieldConstants.TRANS_TYPE, TransTypeEnum.TCC.toString()); + paramsMap.put(ParamFieldConstants.BRANCH_ID, branchId); + paramsMap.put(ParamFieldConstants.OP, OP); + + feign.Response response = feignClient.busiPost(new URI(FeignUtils.generatorURI(tryMessage, true)), + tryMessage.getPath(), paramsMap, body); + log.info("busi post is: {}", response); + FeignUtils.checkResult(response); + return response; + } + + public Response callBranch(Tcc tcc, Object body, String tryUrl, String confirmUrl, String cancelUrl) throws Exception { + log.info("call method Tcc.callBranch, tryUrl: {}, confirmUrl: {}, cancelUrl: {}", tryUrl, confirmUrl, cancelUrl); + String branchId = tcc.getBranchIdGenerator().genBranchId(); + Gson gson = new Gson(); + + OperatorParam operatorParam = new OperatorParam(tcc.getGid(), TransTypeEnum.TCC, Constants.DEFAULT_STATUS, + branchId, gson.toJson(body), confirmUrl, cancelUrl); + ResponseBase resp = feignClient.registerBranch(operatorParam); + if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { + log.error("TCC transaction register branch fail. transaction gid: {}", tcc.getGid()); + throw new DtmException("TCC Transaction register branch fail"); + } + + Map paramsMap = new HashMap<>(); + paramsMap.put(ParamFieldConstants.GID, tcc.getGid()); + paramsMap.put(ParamFieldConstants.TRANS_TYPE, TransTypeEnum.TCC.toString()); + paramsMap.put(ParamFieldConstants.BRANCH_ID, branchId); + paramsMap.put(ParamFieldConstants.OP, OP); + Response tryResponse = HttpUtils.post(HttpUtils.splicingUrl(tryUrl, paramsMap), gson.toJson(body)); + log.info("try response is: {}", tryResponse); + HttpUtils.checkResult(tryResponse); + return tryResponse; + } +} diff --git a/dtmcli-core/src/main/java/tcc/model/Tcc.java b/dtmcli-core/src/main/java/tcc/model/Tcc.java new file mode 100644 index 0000000..73d04b3 --- /dev/null +++ b/dtmcli-core/src/main/java/tcc/model/Tcc.java @@ -0,0 +1,19 @@ +package tcc.model; + +import base.BranchIdGenerator; +import constant.Constants; +import enums.TransTypeEnum; +import model.dtm.TransBase; + +public class Tcc extends TransBase { + private final BranchIdGenerator branchIdGenerator; + + public Tcc(String gid) { + super(gid, TransTypeEnum.TCC, false); + this.branchIdGenerator = new BranchIdGenerator(Constants.EMPTY_STRING); + } + + public BranchIdGenerator getBranchIdGenerator() { + return branchIdGenerator; + } +} diff --git a/dtmcli-core/target/maven-archiver/pom.properties b/dtmcli-core/target/maven-archiver/pom.properties new file mode 100644 index 0000000..15bc8dd --- /dev/null +++ b/dtmcli-core/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Tue Apr 26 15:54:58 CST 2022 +version=1.0.0 +groupId=pub.dtm +artifactId=dtmcli-core diff --git a/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..16f5943 --- /dev/null +++ b/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,6 @@ +barrier/model/BarrierParam.class +barrier/BranchBarrierService.class +tcc/model/Tcc.class +barrier/model/BranchBarrier.class +tcc/TccService.class +base/BranchIdGenerator.class diff --git a/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..56f854a --- /dev/null +++ b/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,6 @@ +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/barrier/model/BarrierParam.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/tcc/model/Tcc.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/base/BranchIdGenerator.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/barrier/BranchBarrierService.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/tcc/TccService.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/barrier/model/BranchBarrier.java diff --git a/dtmcli-core/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/dtmcli-core/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/dtmcli-java/pom.xml b/dtmcli-java/pom.xml new file mode 100644 index 0000000..a8f9be0 --- /dev/null +++ b/dtmcli-java/pom.xml @@ -0,0 +1,47 @@ + + + + dtmcli-java-parent + pub.dtm + 1.0.0 + + 4.0.0 + + dtmcli-java + 1.0.0 + jar + dtmcli-java + + + + pub.dtm + dtmcli-common + 1.0.0 + + + + pub.dtm + dtmcli-core + 1.0.0 + + + + com.alibaba.nacos + nacos-client + + + + com.google.code.gson + gson + + + + io.github.openfeign + feign-gson + + + + + \ No newline at end of file diff --git a/dtmcli-java/src/main/java/client/DtmClient.java b/dtmcli-java/src/main/java/client/DtmClient.java new file mode 100644 index 0000000..dca0d61 --- /dev/null +++ b/dtmcli-java/src/main/java/client/DtmClient.java @@ -0,0 +1,87 @@ +package client; + +import com.alibaba.nacos.api.naming.pojo.Instance; +import constant.Constants; +import feign.DtmFeignClient; +import feign.Feign; +import feign.URIParser; +import feign.gson.GsonDecoder; +import feign.gson.GsonEncoder; +import interfaces.dtm.DtmConsumer; +import interfaces.feign.IDtmFeignClient; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import properties.DtmProperties; +import tcc.TccService; +import tcc.model.Tcc; +import utils.NacosUtils; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import static com.alibaba.nacos.api.common.Constants.DEFAULT_CLUSTER_NAME; +import static com.alibaba.nacos.api.common.Constants.DEFAULT_GROUP; +import static com.alibaba.nacos.api.naming.CommonParams.CLUSTER_NAME; +import static com.alibaba.nacos.api.naming.CommonParams.GROUP_NAME; + +public class DtmClient { + private static final Logger log = LoggerFactory.getLogger(DtmClient.class); + + + private TccService tccService; + + public DtmClient() { + // init URIParser + new URIParser(); + + String endpoint = null; + try { + // redirect connect to dtm + endpoint = DtmProperties.get("dtm.server.endpoint"); + // connect to dtm by nacos + if (StringUtils.isEmpty(endpoint)) { + Instance instance = NacosUtils.selectOneHealthyInstance(DtmProperties.get(Constants.MICRO_SERVICE_NAME_KEY), + DtmProperties.getOrDefault(GROUP_NAME, DEFAULT_GROUP), genClusters(DtmProperties.get(CLUSTER_NAME))); + endpoint = instance.toInetAddr(); + } + } catch (Exception e) { + log.error("initial dtm client for java error.", e); + System.exit(-1); + } + if (StringUtils.isEmpty(endpoint)) { + log.error("can not resolve dtm server message from config file, you can use nacos or redirect configure to config it."); + System.exit(-1); + } + IDtmFeignClient feignClient = Feign + .builder() + .decoder(new GsonDecoder()) + .encoder(new GsonEncoder()) + .target(DtmFeignClient.class, Constants.HTTP_PREFIX + endpoint); + if (feignClient == null) { + log.error("initial dtm client for java error, feign client can't be null."); + System.exit(-1); + } + + this.tccService = new TccService(feignClient); + } + + private List genClusters(String clusterStr) { + if (StringUtils.isEmpty(clusterStr)) { + List clusters = new ArrayList<>(); + clusters.add(DEFAULT_CLUSTER_NAME); + return clusters; + } + String[] split = StringUtils.split(clusterStr, ","); + return Arrays.asList(split); + } + + public String tccGlobalTransaction(DtmConsumer function) throws Exception { + return tccService.tccGlobalTransaction(null, function); + } + + public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { + return tccService.tccGlobalTransaction(gid, function); + } +} diff --git a/dtmcli-java/src/main/java/feign/DtmFeignClient.java b/dtmcli-java/src/main/java/feign/DtmFeignClient.java new file mode 100644 index 0000000..7e34f7f --- /dev/null +++ b/dtmcli-java/src/main/java/feign/DtmFeignClient.java @@ -0,0 +1,44 @@ +package feign; + +import constant.Constants; +import interfaces.feign.IDtmFeignClient; +import model.param.OperatorParam; +import model.response.ResponseBase; + +import java.net.URI; +import java.util.Map; + +@Headers("Content-Type: application/json") +public interface DtmFeignClient extends IDtmFeignClient { + @Override + @RequestLine(Constants.GET_METHOD + Constants.NEW_GID_URL) + ResponseBase newGid(); + + @Override + @RequestLine(Constants.GET_METHOD + Constants.PING_URL) + ResponseBase ping(); + + @Override + @RequestLine(Constants.POST_METHOD + Constants.PREPARE_URL) + ResponseBase prepare(OperatorParam body); + + @Override + @RequestLine(Constants.POST_METHOD + Constants.SUBMIT_URL) + ResponseBase submit(OperatorParam body); + + @Override + @RequestLine(Constants.POST_METHOD + Constants.ABORT_URL) + ResponseBase abort(OperatorParam body); + + @Override + @RequestLine(Constants.POST_METHOD + Constants.REGISTER_BRANCH_URL) + ResponseBase registerBranch(OperatorParam body); + + @Override + @RequestLine(Constants.GET_METHOD + "{path}") + Response busiGet(URI host, @Param("path") String path, @QueryMap Map queryMap); + + @Override + @RequestLine(Constants.POST_METHOD + "{path}") + Response busiPost(URI host, @Param("path") String path, @QueryMap Map queryMap, Object body); +} diff --git a/dtmcli-java/src/main/java/feign/URIParser.java b/dtmcli-java/src/main/java/feign/URIParser.java new file mode 100644 index 0000000..250f907 --- /dev/null +++ b/dtmcli-java/src/main/java/feign/URIParser.java @@ -0,0 +1,25 @@ +package feign; + +import com.alibaba.nacos.api.naming.pojo.Instance; +import constant.Constants; +import interfaces.feign.IURIParser; +import model.feign.ServiceMessage; +import properties.DtmProperties; +import utils.FeignUtils; +import utils.NacosUtils; + +public class URIParser implements IURIParser { + static { + FeignUtils.setUriParser(new URIParser()); + } + + @Override + public String generatorURI(ServiceMessage serviceMessage, boolean httpType) throws Exception { + Instance instance = NacosUtils.selectOneHealthyInstance(serviceMessage.getServiceName(), + serviceMessage.getGroupName(), serviceMessage.getCluster()); + if (httpType) { + return Constants.HTTP_PREFIX + instance.toInetAddr(); + } + return DtmProperties.get("dtm.service.registryType") + "://" + serviceMessage.toString(); + } +} diff --git a/dtmcli-java/src/main/java/properties/DtmProperties.java b/dtmcli-java/src/main/java/properties/DtmProperties.java new file mode 100644 index 0000000..bf4ecec --- /dev/null +++ b/dtmcli-java/src/main/java/properties/DtmProperties.java @@ -0,0 +1,37 @@ +package properties; + +import java.io.FileInputStream; +import java.io.IOException; +import java.util.Properties; + +public class DtmProperties { + private static Properties dtmProperties; + + private static void loadNacosProperties() throws IOException { + Properties properties = new Properties(); + FileInputStream in = new FileInputStream(DtmProperties.class.getResource("/dtm-conf.properties").getPath()); + properties.load(in); + dtmProperties = properties; + } + + public static String get(String key) throws IOException { + if (dtmProperties == null) { + loadNacosProperties(); + } + return dtmProperties.getProperty(key); + } + + public static String getOrDefault(String key, String defaultValue) throws IOException { + if (dtmProperties == null) { + loadNacosProperties(); + } + return dtmProperties.getProperty(key, defaultValue); + } + + public static Properties getNacosProperties() throws IOException { + if (dtmProperties == null) { + loadNacosProperties(); + } + return dtmProperties; + } +} diff --git a/dtmcli-java/src/main/java/utils/NacosUtils.java b/dtmcli-java/src/main/java/utils/NacosUtils.java new file mode 100644 index 0000000..4ee631c --- /dev/null +++ b/dtmcli-java/src/main/java/utils/NacosUtils.java @@ -0,0 +1,23 @@ +package utils; + +import com.alibaba.nacos.api.naming.NamingFactory; +import com.alibaba.nacos.api.naming.NamingService; +import com.alibaba.nacos.api.naming.pojo.Instance; +import properties.DtmProperties; + +import java.util.List; + +public class NacosUtils { + private static NamingService namingService; + + public static void buildNamingService() throws Exception { + NacosUtils.namingService = NamingFactory.createNamingService(DtmProperties.getNacosProperties()); + } + + public static Instance selectOneHealthyInstance(String serviceName, String groupName, List cluster) throws Exception { + if (namingService == null) { + buildNamingService(); + } + return namingService.selectOneHealthyInstance(serviceName, groupName, cluster); + } +} diff --git a/dtmcli-java/target/maven-archiver/pom.properties b/dtmcli-java/target/maven-archiver/pom.properties new file mode 100644 index 0000000..a464007 --- /dev/null +++ b/dtmcli-java/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Tue Apr 26 15:55:30 CST 2022 +version=1.0.0 +groupId=pub.dtm +artifactId=dtmcli-java diff --git a/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..28be81a --- /dev/null +++ b/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,5 @@ +feign/DtmFeignClient.class +feign/URIParser.class +utils/NacosUtils.class +properties/DtmProperties.class +client/DtmClient.class diff --git a/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..a9d548a --- /dev/null +++ b/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,5 @@ +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/feign/DtmFeignClient.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/properties/DtmProperties.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/client/DtmClient.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/feign/URIParser.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/utils/NacosUtils.java diff --git a/dtmcli-java/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/dtmcli-java/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/dtmcli-spring/pom.xml b/dtmcli-spring/pom.xml new file mode 100644 index 0000000..e47f7c7 --- /dev/null +++ b/dtmcli-spring/pom.xml @@ -0,0 +1,93 @@ + + + + dtmcli-java-parent + pub.dtm + 1.0.0 + + 4.0.0 + + dtmcli-spring + 1.0.0 + jar + dtmcli-spring + + + 3.1.1 + 2021.0.1.0 + 2.1.2.RELEASE + 2021.0.1 + 2.6.3 + + + + + pub.dtm + dtmcli-common + 1.0.0 + + + + pub.dtm + dtmcli-core + 1.0.0 + + + + org.springframework.boot + spring-boot-starter + ${springboot.version} + + + + org.springframework.boot + spring-boot-configuration-processor + ${springboot.version} + true + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + ${cloud.nacos.version} + + + + org.springframework.cloud + spring-cloud-starter-netflix-ribbon + + + com.netflix.ribbon + ribbon + + + + + + org.springframework.cloud + spring-cloud-starter-openfeign + ${cloud.feign.version} + + + org.springframework.cloud + spring-cloud-loadbalancer + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + \ No newline at end of file diff --git a/dtmcli-spring/src/main/java/client/DtmClient.java b/dtmcli-spring/src/main/java/client/DtmClient.java new file mode 100644 index 0000000..72a90d9 --- /dev/null +++ b/dtmcli-spring/src/main/java/client/DtmClient.java @@ -0,0 +1,25 @@ +package client; + +import interfaces.dtm.DtmConsumer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import tcc.TccService; +import tcc.model.Tcc; + +@Component +public class DtmClient { + @Autowired + private TccService tccService; + + public DtmClient(TccService tccService) { + this.tccService = tccService; + } + + public String tccGlobalTransaction(DtmConsumer function) throws Exception { + return tccService.tccGlobalTransaction(null, function); + } + + public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { + return tccService.tccGlobalTransaction(gid, function); + } +} diff --git a/dtmcli-spring/src/main/java/configuration/DtmConfiguration.java b/dtmcli-spring/src/main/java/configuration/DtmConfiguration.java new file mode 100644 index 0000000..dbdb0e2 --- /dev/null +++ b/dtmcli-spring/src/main/java/configuration/DtmConfiguration.java @@ -0,0 +1,44 @@ +package configuration; + +import barrier.BranchBarrierService; +import feign.DtmFeignClient; +import feign.URIParser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; +import properties.DtmProperties; +import tcc.TccService; + +@Component +@ComponentScan({"feign", "client"}) +@Configuration +@EnableFeignClients("feign") +@EnableConfigurationProperties(DtmProperties.class) +public class DtmConfiguration { + @Autowired + private DtmProperties dtmProperties; + + @Bean + @ConditionalOnMissingBean(TccService.class) + public TccService tccService(DtmFeignClient feignClient) { + return new TccService(feignClient); + } + + @Bean + @ConditionalOnMissingBean(BranchBarrierService.class) + public BranchBarrierService branchBarrierService() { + return new BranchBarrierService(); + } + + @Bean + @ConditionalOnMissingBean(URIParser.class) + public URIParser uriParser() { + URIParser.setRegistryType(dtmProperties.getRegistryType()); + return new URIParser(); + } +} diff --git a/dtmcli-spring/src/main/java/feign/DtmFeignClient.java b/dtmcli-spring/src/main/java/feign/DtmFeignClient.java new file mode 100644 index 0000000..e7e285b --- /dev/null +++ b/dtmcli-spring/src/main/java/feign/DtmFeignClient.java @@ -0,0 +1,51 @@ +package feign; + +import constant.Constants; +import interfaces.feign.IDtmFeignClient; +import model.param.OperatorParam; +import model.response.ResponseBase; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.cloud.openfeign.SpringQueryMap; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.net.URI; +import java.util.Map; + +@FeignClient(value = "${dtm.service.name}") +public interface DtmFeignClient extends IDtmFeignClient { + @Override + @GetMapping(Constants.NEW_GID_URL) + ResponseBase newGid(); + + @Override + @GetMapping(Constants.PING_URL) + ResponseBase ping(); + + @Override + @PostMapping(Constants.PREPARE_URL) + ResponseBase prepare(@RequestBody OperatorParam body); + + @Override + @PostMapping(Constants.SUBMIT_URL) + ResponseBase submit(@RequestBody OperatorParam body); + + @Override + @PostMapping(Constants.ABORT_URL) + ResponseBase abort(@RequestBody OperatorParam body); + + @Override + @PostMapping(Constants.REGISTER_BRANCH_URL) + ResponseBase registerBranch(@RequestBody OperatorParam body); + + @Override + @GetMapping(value = "{path}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + Response busiGet(URI host, @PathVariable("path") String path, @SpringQueryMap Map queryMap); + + @Override + @PostMapping(value = "{path}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) + Response busiPost(URI host, @PathVariable("path") String path, @SpringQueryMap Map queryMap, @RequestBody Object body); +} diff --git a/dtmcli-spring/src/main/java/feign/URIParser.java b/dtmcli-spring/src/main/java/feign/URIParser.java new file mode 100644 index 0000000..07bda35 --- /dev/null +++ b/dtmcli-spring/src/main/java/feign/URIParser.java @@ -0,0 +1,26 @@ +package feign; + +import constant.Constants; +import interfaces.feign.IURIParser; +import model.feign.ServiceMessage; +import utils.FeignUtils; + +public class URIParser implements IURIParser { + static { + FeignUtils.setUriParser(new URIParser()); + } + + private static String registryType; + + public static void setRegistryType(String registryType) { + URIParser.registryType = registryType; + } + + @Override + public String generatorURI(ServiceMessage serviceMessage, boolean httpType) throws Exception { + if (httpType) { + return Constants.HTTP_PREFIX + serviceMessage.getServiceName(); + } + return registryType + "://" + serviceMessage.toString(); + } +} diff --git a/dtmcli-spring/src/main/java/properties/DtmProperties.java b/dtmcli-spring/src/main/java/properties/DtmProperties.java new file mode 100644 index 0000000..e2f3815 --- /dev/null +++ b/dtmcli-spring/src/main/java/properties/DtmProperties.java @@ -0,0 +1,15 @@ +package properties; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = DtmProperties.PREFIX) +@Data +public class DtmProperties { + public static final String PREFIX = "dtm.service"; + + private String registryType; + + private String name; + +} diff --git a/dtmcli-spring/src/main/resources/META-INF/spring.factories b/dtmcli-spring/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..09746d6 --- /dev/null +++ b/dtmcli-spring/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=configuration.DtmConfiguration \ No newline at end of file diff --git a/dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json b/dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json new file mode 100644 index 0000000..5625e72 --- /dev/null +++ b/dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json @@ -0,0 +1,22 @@ +{ + "groups": [ + { + "name": "dtm.service", + "type": "properties.DtmProperties", + "sourceType": "properties.DtmProperties" + } + ], + "properties": [ + { + "name": "dtm.service.name", + "type": "java.lang.String", + "sourceType": "properties.DtmProperties" + }, + { + "name": "dtm.service.registry-type", + "type": "java.lang.String", + "sourceType": "properties.DtmProperties" + } + ], + "hints": [] +} \ No newline at end of file diff --git a/dtmcli-spring/target/classes/META-INF/spring.factories b/dtmcli-spring/target/classes/META-INF/spring.factories new file mode 100644 index 0000000..09746d6 --- /dev/null +++ b/dtmcli-spring/target/classes/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=configuration.DtmConfiguration \ No newline at end of file diff --git a/dtmcli-spring/target/maven-archiver/pom.properties b/dtmcli-spring/target/maven-archiver/pom.properties new file mode 100644 index 0000000..cc6c559 --- /dev/null +++ b/dtmcli-spring/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Tue Apr 26 15:55:29 CST 2022 +version=1.0.0 +groupId=pub.dtm +artifactId=dtmcli-spring diff --git a/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..b5d894c --- /dev/null +++ b/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,6 @@ +feign/URIParser.class +META-INF/spring-configuration-metadata.json +properties/DtmProperties.class +client/DtmClient.class +feign/DtmFeignClient.class +configuration/DtmConfiguration.class diff --git a/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..4282d2a --- /dev/null +++ b/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,5 @@ +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/feign/URIParser.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/client/DtmClient.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/configuration/DtmConfiguration.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/feign/DtmFeignClient.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/properties/DtmProperties.java diff --git a/dtmcli-spring/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/dtmcli-spring/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/pom.xml b/pom.xml index 158117d..7556db6 100644 --- a/pom.xml +++ b/pom.xml @@ -1,56 +1,123 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - + pub.dtm - dtmcli-java - 1.5.5-SNAPSHOT - + dtmcli-java-parent + 1.0.0 + pom + + dtmcli-java-parent + + + dtmcli-common + dtmcli-core + dtmcli-spring + dtmcli-java + + - 8 - 8 - 1.18.12 - 1.2.78 - 4.9.1 - 3.12.0 - 1.7.30 - 8.0.27 + 1.8 + 1.8 + 1.8 UTF-8 + 4.12 + 2.8.6 + 2.13.2 + 1.18.0 + 11.8 + 3.12.0 + 3.14.9 + 1.4.2 + 1.7.30 - - - - com.alibaba - fastjson - ${fastjson.version} - - - org.projectlombok - lombok - ${lombok.version} - - - com.squareup.okhttp3 - okhttp - ${okhttp.version} - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - org.slf4j - slf4j-api - ${slf4j-api.version} - - - mysql - mysql-connector-java - ${mysql-connector-java.version} - - + + + + + junit + junit + ${junit.version} + test + + + + com.google.code.gson + gson + ${gson.version} + + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + + org.projectlombok + lombok + ${lombok.version} + + + + io.github.openfeign + feign-core + ${feign.version} + + + + io.github.openfeign + feign-gson + ${feign.version} + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + + com.squareup.okhttp3 + okhttp + ${okhttp.version} + + + + com.alibaba.nacos + nacos-client + ${nacos.version} + + + + org.slf4j + slf4j-api + ${slf4j.version} + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + ${project.build.sourceEncoding} + + + + org.apache.maven.plugins + maven-resources-plugin + + ${project.build.sourceEncoding} + + + + \ No newline at end of file From b603d194910262e4243d081a260c747bd5b99745 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Tue, 26 Apr 2022 22:37:08 +0800 Subject: [PATCH 02/24] update package --- .../main/java/interfaces/dtm/DtmConsumer.java | 8 - .../main/java/interfaces/dtm/IDtmService.java | 4 - .../interfaces/feign/IDtmFeignClient.java | 26 --- .../dtm/client}/constant/Constants.java | 2 +- .../client}/constant/ParamFieldConstants.java | 2 +- .../dtm/client}/enums/TransTypeEnum.java | 2 +- .../dtm/client}/exception/DtmException.java | 2 +- .../client/interfaces/dtm/DtmConsumer.java | 8 + .../interfaces/feign/IDtmFeignClient.java | 26 +++ .../client}/interfaces/feign/IURIParser.java | 4 +- .../dtm/client}/model/dtm/TransBase.java | 4 +- .../client}/model/feign/ServiceMessage.java | 2 +- .../client}/model/param/OperatorParam.java | 6 +- .../client/model/responses/DtmResponse.java} | 8 +- .../dtm/client}/utils/FeignUtils.java | 14 +- .../{ => pub/dtm/client}/utils/HttpUtils.java | 6 +- .../target/maven-archiver/pom.properties | 2 +- .../compile/default-compile/createdFiles.lst | 27 ++-- .../compile/default-compile/inputFiles.lst | 13 ++ .../java/barrier/BranchBarrierService.java | 69 -------- .../java/barrier/model/BranchBarrier.java | 46 ------ .../dtm/client/barrier}/BarrierParam.java | 2 +- .../pub/dtm/client/barrier/BranchBarrier.java | 104 ++++++++++++ .../dtm/client}/base/BranchIdGenerator.java | 2 +- .../dtm/client/tcc/Tcc.java} | 84 +++++----- dtmcli-core/src/main/java/tcc/model/Tcc.java | 19 --- .../target/maven-archiver/pom.properties | 2 +- .../compile/default-compile/createdFiles.lst | 10 +- .../compile/default-compile/inputFiles.lst | 10 +- .../java/{ => pub/dtm}/client/DtmClient.java | 56 +++++-- .../dtm/client}/feign/DtmFeignClient.java | 23 +-- .../{ => pub/dtm/client}/feign/URIParser.java | 14 +- .../dtm/client}/properties/DtmProperties.java | 2 +- .../dtm/client}/utils/NacosUtils.java | 4 +- .../target/maven-archiver/pom.properties | 2 +- .../compile/default-compile/createdFiles.lst | 10 +- .../compile/default-compile/inputFiles.lst | 10 +- .../src/main/java/client/DtmClient.java | 25 --- .../main/java/pub/dtm/client/DtmClient.java | 27 ++++ .../configuration/DtmConfiguration.java | 25 +-- .../dtm/client}/feign/DtmFeignClient.java | 23 +-- .../{ => pub/dtm/client}/feign/URIParser.java | 10 +- .../dtm/client}/properties/DtmProperties.java | 2 +- .../main/resources/META-INF/spring.factories | 2 +- .../spring-configuration-metadata.json | 8 +- .../target/classes/META-INF/spring.factories | 2 +- .../target/maven-archiver/pom.properties | 2 +- .../compile/default-compile/createdFiles.lst | 10 +- .../compile/default-compile/inputFiles.lst | 10 +- src/main/java/barrier/BarrierParam.java | 57 ------- src/main/java/barrier/BranchBarrier.java | 151 ------------------ src/main/java/client/DtmClient.java | 98 ------------ src/main/java/common/constant/Constant.java | 38 ----- .../common/constant/ParamFieldConstant.java | 76 --------- src/main/java/common/enums/TransTypeEnum.java | 41 ----- src/main/java/common/model/DtmConsumer.java | 34 ---- src/main/java/common/model/DtmServerInfo.java | 106 ------------ src/main/java/common/model/TransBase.java | 70 -------- src/main/java/common/model/TransResponse.java | 44 ----- .../common/utils/BranchIdGeneratorUtil.java | 63 -------- src/main/java/common/utils/HttpUtil.java | 71 -------- src/main/java/common/utils/StreamUtil.java | 63 -------- src/main/java/exception/FailureException.java | 32 ---- src/main/java/saga/Saga.java | 129 --------------- src/main/java/tcc/Tcc.java | 146 ----------------- src/main/java/xa/Xa.java | 29 ---- 66 files changed, 386 insertions(+), 1643 deletions(-) delete mode 100644 dtmcli-common/src/main/java/interfaces/dtm/DtmConsumer.java delete mode 100644 dtmcli-common/src/main/java/interfaces/dtm/IDtmService.java delete mode 100644 dtmcli-common/src/main/java/interfaces/feign/IDtmFeignClient.java rename dtmcli-common/src/main/java/{ => pub/dtm/client}/constant/Constants.java (97%) rename dtmcli-common/src/main/java/{ => pub/dtm/client}/constant/ParamFieldConstants.java (95%) rename dtmcli-common/src/main/java/{ => pub/dtm/client}/enums/TransTypeEnum.java (94%) rename dtmcli-common/src/main/java/{ => pub/dtm/client}/exception/DtmException.java (83%) create mode 100644 dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java create mode 100644 dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java rename dtmcli-common/src/main/java/{ => pub/dtm/client}/interfaces/feign/IURIParser.java (57%) rename dtmcli-common/src/main/java/{ => pub/dtm/client}/model/dtm/TransBase.java (81%) rename dtmcli-common/src/main/java/{ => pub/dtm/client}/model/feign/ServiceMessage.java (97%) rename dtmcli-common/src/main/java/{ => pub/dtm/client}/model/param/OperatorParam.java (92%) rename dtmcli-common/src/main/java/{model/response/ResponseBase.java => pub/dtm/client/model/responses/DtmResponse.java} (69%) rename dtmcli-common/src/main/java/{ => pub/dtm/client}/utils/FeignUtils.java (86%) rename dtmcli-common/src/main/java/{ => pub/dtm/client}/utils/HttpUtils.java (95%) delete mode 100644 dtmcli-core/src/main/java/barrier/BranchBarrierService.java delete mode 100644 dtmcli-core/src/main/java/barrier/model/BranchBarrier.java rename dtmcli-core/src/main/java/{barrier/model => pub/dtm/client/barrier}/BarrierParam.java (92%) create mode 100644 dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java rename dtmcli-core/src/main/java/{ => pub/dtm/client}/base/BranchIdGenerator.java (96%) rename dtmcli-core/src/main/java/{tcc/TccService.java => pub/dtm/client/tcc/Tcc.java} (55%) delete mode 100644 dtmcli-core/src/main/java/tcc/model/Tcc.java rename dtmcli-java/src/main/java/{ => pub/dtm}/client/DtmClient.java (64%) rename dtmcli-java/src/main/java/{ => pub/dtm/client}/feign/DtmFeignClient.java (66%) rename dtmcli-java/src/main/java/{ => pub/dtm/client}/feign/URIParser.java (68%) rename dtmcli-java/src/main/java/{ => pub/dtm/client}/properties/DtmProperties.java (96%) rename dtmcli-java/src/main/java/{ => pub/dtm/client}/utils/NacosUtils.java (90%) delete mode 100644 dtmcli-spring/src/main/java/client/DtmClient.java create mode 100644 dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java rename dtmcli-spring/src/main/java/{ => pub/dtm/client}/configuration/DtmConfiguration.java (60%) rename dtmcli-spring/src/main/java/{ => pub/dtm/client}/feign/DtmFeignClient.java (72%) rename dtmcli-spring/src/main/java/{ => pub/dtm/client}/feign/URIParser.java (72%) rename dtmcli-spring/src/main/java/{ => pub/dtm/client}/properties/DtmProperties.java (89%) delete mode 100644 src/main/java/barrier/BarrierParam.java delete mode 100644 src/main/java/barrier/BranchBarrier.java delete mode 100644 src/main/java/client/DtmClient.java delete mode 100644 src/main/java/common/constant/Constant.java delete mode 100644 src/main/java/common/constant/ParamFieldConstant.java delete mode 100644 src/main/java/common/enums/TransTypeEnum.java delete mode 100644 src/main/java/common/model/DtmConsumer.java delete mode 100644 src/main/java/common/model/DtmServerInfo.java delete mode 100644 src/main/java/common/model/TransBase.java delete mode 100644 src/main/java/common/model/TransResponse.java delete mode 100644 src/main/java/common/utils/BranchIdGeneratorUtil.java delete mode 100644 src/main/java/common/utils/HttpUtil.java delete mode 100644 src/main/java/common/utils/StreamUtil.java delete mode 100644 src/main/java/exception/FailureException.java delete mode 100644 src/main/java/saga/Saga.java delete mode 100644 src/main/java/tcc/Tcc.java delete mode 100644 src/main/java/xa/Xa.java diff --git a/dtmcli-common/src/main/java/interfaces/dtm/DtmConsumer.java b/dtmcli-common/src/main/java/interfaces/dtm/DtmConsumer.java deleted file mode 100644 index ef81b9c..0000000 --- a/dtmcli-common/src/main/java/interfaces/dtm/DtmConsumer.java +++ /dev/null @@ -1,8 +0,0 @@ -package interfaces.dtm; - -import model.dtm.TransBase; - -@FunctionalInterface -public interface DtmConsumer { - void accept(S s, T t) throws Exception; -} diff --git a/dtmcli-common/src/main/java/interfaces/dtm/IDtmService.java b/dtmcli-common/src/main/java/interfaces/dtm/IDtmService.java deleted file mode 100644 index 0b82617..0000000 --- a/dtmcli-common/src/main/java/interfaces/dtm/IDtmService.java +++ /dev/null @@ -1,4 +0,0 @@ -package interfaces.dtm; - -public interface IDtmService { -} diff --git a/dtmcli-common/src/main/java/interfaces/feign/IDtmFeignClient.java b/dtmcli-common/src/main/java/interfaces/feign/IDtmFeignClient.java deleted file mode 100644 index 3c78c28..0000000 --- a/dtmcli-common/src/main/java/interfaces/feign/IDtmFeignClient.java +++ /dev/null @@ -1,26 +0,0 @@ -package interfaces.feign; - -import feign.Response; -import model.param.OperatorParam; -import model.response.ResponseBase; - -import java.net.URI; -import java.util.Map; - -public interface IDtmFeignClient { - ResponseBase newGid(); - - ResponseBase ping(); - - ResponseBase prepare(OperatorParam body); - - ResponseBase submit(OperatorParam body); - - ResponseBase abort(OperatorParam body); - - ResponseBase registerBranch(OperatorParam body); - - Response busiGet(URI host, String path, Map queryMap); - - Response busiPost(URI host, String path, Map queryMap, Object body); -} diff --git a/dtmcli-common/src/main/java/constant/Constants.java b/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java similarity index 97% rename from dtmcli-common/src/main/java/constant/Constants.java rename to dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java index 15d2fbd..84e71bb 100644 --- a/dtmcli-common/src/main/java/constant/Constants.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java @@ -1,4 +1,4 @@ -package constant; +package pub.dtm.client.constant; public class Constants { public static final String MICRO_SERVICE_NAME_KEY = "dtm.service.name"; diff --git a/dtmcli-common/src/main/java/constant/ParamFieldConstants.java b/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java similarity index 95% rename from dtmcli-common/src/main/java/constant/ParamFieldConstants.java rename to dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java index 0adf4fb..0b0c747 100644 --- a/dtmcli-common/src/main/java/constant/ParamFieldConstants.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java @@ -1,4 +1,4 @@ -package constant; +package pub.dtm.client.constant; public class ParamFieldConstants { public static final String GID = "gid"; diff --git a/dtmcli-common/src/main/java/enums/TransTypeEnum.java b/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java similarity index 94% rename from dtmcli-common/src/main/java/enums/TransTypeEnum.java rename to dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java index eb79010..0f06343 100644 --- a/dtmcli-common/src/main/java/enums/TransTypeEnum.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java @@ -1,4 +1,4 @@ -package enums; +package pub.dtm.client.enums; public enum TransTypeEnum { TCC("tcc"), diff --git a/dtmcli-common/src/main/java/exception/DtmException.java b/dtmcli-common/src/main/java/pub/dtm/client/exception/DtmException.java similarity index 83% rename from dtmcli-common/src/main/java/exception/DtmException.java rename to dtmcli-common/src/main/java/pub/dtm/client/exception/DtmException.java index 5461824..a5a4998 100644 --- a/dtmcli-common/src/main/java/exception/DtmException.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/exception/DtmException.java @@ -1,4 +1,4 @@ -package exception; +package pub.dtm.client.exception; public class DtmException extends Exception { public DtmException(String msg) { diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java new file mode 100644 index 0000000..8f3cda1 --- /dev/null +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java @@ -0,0 +1,8 @@ +package pub.dtm.client.interfaces.dtm; + +import pub.dtm.client.model.dtm.TransBase; + +@FunctionalInterface +public interface DtmConsumer { + void accept(T t) throws Exception; +} diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java new file mode 100644 index 0000000..b2d8122 --- /dev/null +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java @@ -0,0 +1,26 @@ +package pub.dtm.client.interfaces.feign; + +import feign.Response; +import pub.dtm.client.model.param.OperatorParam; +import pub.dtm.client.model.responses.DtmResponse; + +import java.net.URI; +import java.util.Map; + +public interface IDtmFeignClient { + DtmResponse newGid(); + + DtmResponse ping(); + + DtmResponse prepare(OperatorParam body); + + DtmResponse submit(OperatorParam body); + + DtmResponse abort(OperatorParam body); + + DtmResponse registerBranch(OperatorParam body); + + Response busiGet(URI host, String path, Map queryMap); + + Response busiPost(URI host, String path, Map queryMap, Object body); +} diff --git a/dtmcli-common/src/main/java/interfaces/feign/IURIParser.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java similarity index 57% rename from dtmcli-common/src/main/java/interfaces/feign/IURIParser.java rename to dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java index 1ac99c4..c742355 100644 --- a/dtmcli-common/src/main/java/interfaces/feign/IURIParser.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java @@ -1,6 +1,6 @@ -package interfaces.feign; +package pub.dtm.client.interfaces.feign; -import model.feign.ServiceMessage; +import pub.dtm.client.model.feign.ServiceMessage; public interface IURIParser { String generatorURI(ServiceMessage serviceMessage, boolean httpType) throws Exception; diff --git a/dtmcli-common/src/main/java/model/dtm/TransBase.java b/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java similarity index 81% rename from dtmcli-common/src/main/java/model/dtm/TransBase.java rename to dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java index d2b4102..0fd84f2 100644 --- a/dtmcli-common/src/main/java/model/dtm/TransBase.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java @@ -1,6 +1,6 @@ -package model.dtm; +package pub.dtm.client.model.dtm; -import enums.TransTypeEnum; +import pub.dtm.client.enums.TransTypeEnum; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; diff --git a/dtmcli-common/src/main/java/model/feign/ServiceMessage.java b/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java similarity index 97% rename from dtmcli-common/src/main/java/model/feign/ServiceMessage.java rename to dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java index 8d336fc..ed5c685 100644 --- a/dtmcli-common/src/main/java/model/feign/ServiceMessage.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java @@ -1,4 +1,4 @@ -package model.feign; +package pub.dtm.client.model.feign; import org.apache.commons.lang3.StringUtils; diff --git a/dtmcli-common/src/main/java/model/param/OperatorParam.java b/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java similarity index 92% rename from dtmcli-common/src/main/java/model/param/OperatorParam.java rename to dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java index 206322d..d6e0834 100644 --- a/dtmcli-common/src/main/java/model/param/OperatorParam.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java @@ -1,9 +1,9 @@ -package model.param; +package pub.dtm.client.model.param; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.annotations.SerializedName; -import constant.ParamFieldConstants; -import enums.TransTypeEnum; +import pub.dtm.client.constant.ParamFieldConstants; +import pub.dtm.client.enums.TransTypeEnum; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; diff --git a/dtmcli-common/src/main/java/model/response/ResponseBase.java b/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java similarity index 69% rename from dtmcli-common/src/main/java/model/response/ResponseBase.java rename to dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java index ed963ef..8d2c659 100644 --- a/dtmcli-common/src/main/java/model/response/ResponseBase.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java @@ -1,4 +1,4 @@ -package model.response; +package pub.dtm.client.model.responses; import com.fasterxml.jackson.annotation.JsonProperty; import com.google.gson.annotations.SerializedName; @@ -9,7 +9,7 @@ @Data @AllArgsConstructor @NoArgsConstructor -public class ResponseBase { +public class DtmResponse { @SerializedName("dtm_result") @JsonProperty("dtm_result") private String dtmResult; @@ -17,4 +17,8 @@ public class ResponseBase { @SerializedName("gid") @JsonProperty("gid") private String gid; + + public static DtmResponse buildDtmResponse(String result) { + return new DtmResponse(result, null); + } } diff --git a/dtmcli-common/src/main/java/utils/FeignUtils.java b/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java similarity index 86% rename from dtmcli-common/src/main/java/utils/FeignUtils.java rename to dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java index 6be5c93..e8294c4 100644 --- a/dtmcli-common/src/main/java/utils/FeignUtils.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java @@ -1,15 +1,15 @@ -package utils; +package pub.dtm.client.utils; -import constant.Constants; -import exception.DtmException; +import pub.dtm.client.constant.Constants; +import pub.dtm.client.exception.DtmException; import feign.Response; -import interfaces.feign.IURIParser; -import model.response.ResponseBase; -import model.feign.ServiceMessage; +import pub.dtm.client.interfaces.feign.IURIParser; +import pub.dtm.client.model.feign.ServiceMessage; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import pub.dtm.client.model.responses.DtmResponse; import java.io.IOException; import java.io.InputStream; @@ -24,7 +24,7 @@ public static void setUriParser(IURIParser uriParser) { FeignUtils.uriParser = uriParser; } - public static String parseGid(ResponseBase base) throws Exception { + public static String parseGid(DtmResponse base) throws Exception { if (base == null || !Constants.SUCCESS_RESULT.equals(base.getDtmResult())) { throw new Exception("get new gid from dtm server fail."); } diff --git a/dtmcli-common/src/main/java/utils/HttpUtils.java b/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java similarity index 95% rename from dtmcli-common/src/main/java/utils/HttpUtils.java rename to dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java index 0772674..1b5bec7 100644 --- a/dtmcli-common/src/main/java/utils/HttpUtils.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java @@ -1,7 +1,7 @@ -package utils; +package pub.dtm.client.utils; -import constant.Constants; -import exception.DtmException; +import pub.dtm.client.constant.Constants; +import pub.dtm.client.exception.DtmException; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; diff --git a/dtmcli-common/target/maven-archiver/pom.properties b/dtmcli-common/target/maven-archiver/pom.properties index 48cb916..a97deb0 100644 --- a/dtmcli-common/target/maven-archiver/pom.properties +++ b/dtmcli-common/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Tue Apr 26 15:54:57 CST 2022 +#Tue Apr 26 17:58:45 CST 2022 version=1.0.0 groupId=pub.dtm artifactId=dtmcli-common diff --git a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index 465ce62..cb90b51 100644 --- a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -1,14 +1,13 @@ -interfaces/dtm/IDtmService.class -constant/ParamFieldConstants.class -model/feign/ServiceMessage.class -interfaces/feign/IURIParser.class -interfaces/dtm/DtmConsumer.class -constant/Constants.class -model/param/OperatorParam.class -interfaces/feign/IDtmFeignClient.class -utils/FeignUtils.class -model/dtm/TransBase.class -utils/HttpUtils.class -model/response/ResponseBase.class -enums/TransTypeEnum.class -exception/DtmException.class +pub/dtm/client/model/responses/DtmResponse.class +pub/dtm/client/constant/ParamFieldConstants.class +pub/dtm/client/utils/HttpUtils.class +pub/dtm/client/utils/FeignUtils.class +pub/dtm/client/model/param/OperatorParam.class +pub/dtm/client/enums/TransTypeEnum.class +pub/dtm/client/model/dtm/TransBase.class +pub/dtm/client/model/feign/ServiceMessage.class +pub/dtm/client/interfaces/dtm/DtmConsumer.class +pub/dtm/client/constant/Constants.class +pub/dtm/client/interfaces/feign/IDtmFeignClient.class +pub/dtm/client/exception/DtmException.class +pub/dtm/client/interfaces/feign/IURIParser.class diff --git a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index e69de29..8a337b3 100644 --- a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,13 @@ +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/exception/DtmException.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java diff --git a/dtmcli-core/src/main/java/barrier/BranchBarrierService.java b/dtmcli-core/src/main/java/barrier/BranchBarrierService.java deleted file mode 100644 index 7f05d51..0000000 --- a/dtmcli-core/src/main/java/barrier/BranchBarrierService.java +++ /dev/null @@ -1,69 +0,0 @@ -package barrier; - -import barrier.model.BranchBarrier; -import constant.ParamFieldConstants; -import interfaces.dtm.DtmConsumer; -import interfaces.dtm.IDtmService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.Objects; - -public class BranchBarrierService implements IDtmService { - private static final Logger log = LoggerFactory.getLogger(BranchBarrierService.class); - - public void call(BranchBarrier barrier, Connection connection, DtmConsumer consumer) throws Exception { - barrier.addBarrierId(); - connection.setAutoCommit(false); - try { - boolean result = insertBarrier(connection, barrier); - if (result) { - consumer.accept(this, barrier); - connection.commit(); - } - } catch (Exception exception) { - log.warn("barrier call error", exception); - connection.rollback(); - throw exception; - } finally { - connection.setAutoCommit(true); - } - } - - private boolean insertBarrier(Connection connection, BranchBarrier barrier) throws SQLException { - log.info("insert barrier {}", barrier); - if (Objects.isNull(connection)) { - return false; - } - PreparedStatement preparedStatement = null; - try { - String sql = "insert ignore into barrier(trans_type, gid, branch_id, op, barrier_id, reason) values(?,?,?,?,?,?)"; - preparedStatement = connection.prepareStatement(sql); - preparedStatement.setString(1, barrier.getTransTypeEnum().toString()); - preparedStatement.setString(2, barrier.getGid()); - preparedStatement.setString(3, barrier.getBranchId()); - preparedStatement.setString(4, barrier.getOp()); - preparedStatement.setString(5, String.format("%02d", barrier.getBarrierId())); - preparedStatement.setString(6, barrier.getOp()); - - if (preparedStatement.executeUpdate() == 0) { - return false; - } - if (ParamFieldConstants.CANCEL.equals(barrier.getOp())) { - int opIndex = 4; - preparedStatement.setString(opIndex, ParamFieldConstants.TRY); - if (preparedStatement.executeUpdate() > 0) { - return false; - } - } - } finally { - if (Objects.nonNull(preparedStatement)) { - preparedStatement.close(); - } - } - return true; - } -} diff --git a/dtmcli-core/src/main/java/barrier/model/BranchBarrier.java b/dtmcli-core/src/main/java/barrier/model/BranchBarrier.java deleted file mode 100644 index 9ba2ca1..0000000 --- a/dtmcli-core/src/main/java/barrier/model/BranchBarrier.java +++ /dev/null @@ -1,46 +0,0 @@ -package barrier.model; - -import com.google.gson.Gson; -import enums.TransTypeEnum; -import exception.DtmException; -import lombok.Data; -import model.dtm.TransBase; -import org.apache.commons.lang3.ArrayUtils; - -import java.util.Map; - -@Data -public class BranchBarrier extends TransBase { - private String branchId; - - private String op; - - private int barrierId; - - public void addBarrierId() { - this.barrierId += 1; - } - - public static BranchBarrier buildBranchBarrier(Map paramsMap) throws Exception { - if (paramsMap == null || paramsMap.isEmpty()) { - throw new DtmException("build BranchBarrier error, paramsMap can not be empty."); - } - Gson gson = new Gson(); - BarrierParam barrierParam = gson.fromJson(gson.toJson(paramsMap), BarrierParam.class); - BranchBarrier branchBarrier = new BranchBarrier(); - if (ArrayUtils.isNotEmpty(barrierParam.getTrans_type())) { - branchBarrier.setTransTypeEnum(TransTypeEnum.parseString(barrierParam.getTrans_type()[0])); - } - if (ArrayUtils.isNotEmpty(barrierParam.getGid())) { - branchBarrier.setGid(barrierParam.getGid()[0]); - } - if (ArrayUtils.isNotEmpty(barrierParam.getBranch_id())) { - branchBarrier.branchId = barrierParam.getBranch_id()[0]; - } - if (ArrayUtils.isNotEmpty(barrierParam.getOp())) { - branchBarrier.op = barrierParam.getOp()[0]; - } - return branchBarrier; - } - -} diff --git a/dtmcli-core/src/main/java/barrier/model/BarrierParam.java b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java similarity index 92% rename from dtmcli-core/src/main/java/barrier/model/BarrierParam.java rename to dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java index c32bffc..a8f9e54 100644 --- a/dtmcli-core/src/main/java/barrier/model/BarrierParam.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java @@ -1,4 +1,4 @@ -package barrier.model; +package pub.dtm.client.barrier; import lombok.AllArgsConstructor; import lombok.Data; diff --git a/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java new file mode 100644 index 0000000..a87093e --- /dev/null +++ b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java @@ -0,0 +1,104 @@ +package pub.dtm.client.barrier; + +import com.google.gson.Gson; +import pub.dtm.client.constant.ParamFieldConstants; +import pub.dtm.client.enums.TransTypeEnum; +import pub.dtm.client.exception.DtmException; +import pub.dtm.client.interfaces.dtm.DtmConsumer; +import lombok.Data; +import lombok.NoArgsConstructor; +import pub.dtm.client.model.dtm.TransBase; +import org.apache.commons.lang3.ArrayUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.sql.Connection; +import java.sql.PreparedStatement; +import java.sql.SQLException; +import java.util.Map; +import java.util.Objects; + +@Data +@NoArgsConstructor +public class BranchBarrier extends TransBase { + private static final Logger log = LoggerFactory.getLogger(BranchBarrier.class); + + private String branchId; + + private String op; + + private int barrierId; + + public BranchBarrier(Map paramsMap) throws Exception { + if (paramsMap == null || paramsMap.isEmpty()) { + throw new DtmException("build BranchBarrier error, paramsMap can not be empty."); + } + Gson gson = new Gson(); + BarrierParam barrierParam = gson.fromJson(gson.toJson(paramsMap), BarrierParam.class); + if (ArrayUtils.isNotEmpty(barrierParam.getTrans_type())) { + this.setTransTypeEnum(TransTypeEnum.parseString(barrierParam.getTrans_type()[0])); + } + if (ArrayUtils.isNotEmpty(barrierParam.getGid())) { + this.setGid(barrierParam.getGid()[0]); + } + if (ArrayUtils.isNotEmpty(barrierParam.getBranch_id())) { + this.branchId = barrierParam.getBranch_id()[0]; + } + if (ArrayUtils.isNotEmpty(barrierParam.getOp())) { + this.op = barrierParam.getOp()[0]; + } + } + + public void call(Connection connection, DtmConsumer consumer) throws Exception { + ++this.barrierId; + connection.setAutoCommit(false); + try { + boolean result = insertBarrier(connection); + if (result) { + consumer.accept(this); + connection.commit(); + } + } catch (Exception exception) { + log.warn("barrier call error", exception); + connection.rollback(); + throw exception; + } finally { + connection.setAutoCommit(true); + } + } + + private boolean insertBarrier(Connection connection) throws SQLException { + log.info("insert barrier {}", this); + if (Objects.isNull(connection)) { + return false; + } + PreparedStatement preparedStatement = null; + try { + String sql = "insert ignore into barrier(trans_type, gid, branch_id, op, barrier_id, reason) values(?,?,?,?,?,?)"; + preparedStatement = connection.prepareStatement(sql); + preparedStatement.setString(1, this.getTransTypeEnum().toString()); + preparedStatement.setString(2, this.getGid()); + preparedStatement.setString(3, branchId); + preparedStatement.setString(4, op); + preparedStatement.setString(5, String.format("%02d", barrierId)); + preparedStatement.setString(6, op); + + if (preparedStatement.executeUpdate() == 0) { + return false; + } + if (ParamFieldConstants.CANCEL.equals(op)) { + int opIndex = 4; + preparedStatement.setString(opIndex, ParamFieldConstants.TRY); + if (preparedStatement.executeUpdate() > 0) { + return false; + } + } + } finally { + if (Objects.nonNull(preparedStatement)) { + preparedStatement.close(); + } + } + return true; + } + +} diff --git a/dtmcli-core/src/main/java/base/BranchIdGenerator.java b/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java similarity index 96% rename from dtmcli-core/src/main/java/base/BranchIdGenerator.java rename to dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java index 915b42c..dd6d599 100644 --- a/dtmcli-core/src/main/java/base/BranchIdGenerator.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java @@ -1,4 +1,4 @@ -package base; +package pub.dtm.client.base; public class BranchIdGenerator { private static final int MAX_BRANCH_ID = 99; diff --git a/dtmcli-core/src/main/java/tcc/TccService.java b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java similarity index 55% rename from dtmcli-core/src/main/java/tcc/TccService.java rename to dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java index 0cdf89b..4d3fe3d 100644 --- a/dtmcli-core/src/main/java/tcc/TccService.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java @@ -1,36 +1,40 @@ -package tcc; +package pub.dtm.client.tcc; +import pub.dtm.client.base.BranchIdGenerator; import com.google.gson.Gson; -import constant.Constants; -import constant.ParamFieldConstants; -import enums.TransTypeEnum; -import exception.DtmException; -import interfaces.dtm.DtmConsumer; -import interfaces.dtm.IDtmService; -import interfaces.feign.IDtmFeignClient; -import model.feign.ServiceMessage; -import model.param.OperatorParam; -import model.response.ResponseBase; +import pub.dtm.client.constant.Constants; +import pub.dtm.client.constant.ParamFieldConstants; +import pub.dtm.client.enums.TransTypeEnum; +import pub.dtm.client.exception.DtmException; +import pub.dtm.client.interfaces.dtm.DtmConsumer; +import pub.dtm.client.interfaces.feign.IDtmFeignClient; +import pub.dtm.client.model.dtm.TransBase; +import pub.dtm.client.model.feign.ServiceMessage; +import pub.dtm.client.model.param.OperatorParam; import okhttp3.Response; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import tcc.model.Tcc; -import utils.FeignUtils; -import utils.HttpUtils; +import pub.dtm.client.model.responses.DtmResponse; +import pub.dtm.client.utils.FeignUtils; +import pub.dtm.client.utils.HttpUtils; import java.net.URI; import java.util.HashMap; import java.util.Map; -public class TccService implements IDtmService { - private static final Logger log = LoggerFactory.getLogger(TccService.class); +public class Tcc extends TransBase { + private static final Logger log = LoggerFactory.getLogger(Tcc.class); private static final String OP = "try"; + private final BranchIdGenerator branchIdGenerator; + private IDtmFeignClient feignClient; - public TccService(IDtmFeignClient feignClient) { + public Tcc(String gid, IDtmFeignClient feignClient) { + super(gid, TransTypeEnum.TCC, false); + this.branchIdGenerator = new BranchIdGenerator(Constants.EMPTY_STRING); this.feignClient = feignClient; } @@ -38,48 +42,46 @@ public void setFeignClient(IDtmFeignClient feignClient) { this.feignClient = feignClient; } - public String tccGlobalTransaction(String gid, DtmConsumer consumer) throws Exception { - if (StringUtils.isEmpty(gid)) { - gid = FeignUtils.parseGid(feignClient.newGid()); + public String tccGlobalTransaction(DtmConsumer consumer) throws Exception { + if (StringUtils.isEmpty(this.getGid())) { + this.setGid(FeignUtils.parseGid(feignClient.newGid())); } - log.info("the tcc transaction's gid is {}", gid); - Tcc tcc = new Tcc(gid); - + log.info("the tcc transaction's gid is {}", this.getGid()); - OperatorParam operatorParam = new OperatorParam(gid, TransTypeEnum.TCC); - ResponseBase resp = feignClient.prepare(operatorParam); + OperatorParam operatorParam = new OperatorParam(this.getGid(), TransTypeEnum.TCC); + DtmResponse resp = feignClient.prepare(operatorParam); log.info("prepare response: {}", resp); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { - log.error("TCC transaction prepare fail. returned dtm_result is: {}, transaction gid: {}", resp.getDtmResult(), gid); + log.error("TCC transaction prepare fail. returned dtm_result is: {}, transaction gid: {}", resp.getDtmResult(), this.getGid()); throw new DtmException("TCC Transaction prepare fail"); } try { - consumer.accept(this, tcc); + consumer.accept(this); feignClient.submit(operatorParam); } catch (Exception e) { - log.error("TCC transaction submit fail, start abort it. transaction gid: {}", gid); + log.error("TCC transaction submit fail, start abort it. transaction gid: {}", this.getGid()); feignClient.abort(operatorParam); throw new DtmException(e); } - return gid; + return this.getGid(); } - public feign.Response callBranch(Tcc tcc, Object body, ServiceMessage tryMessage, ServiceMessage confirmMessage, ServiceMessage cancelMessage) throws Exception { + public feign.Response callBranch(Object body, ServiceMessage tryMessage, ServiceMessage confirmMessage, ServiceMessage cancelMessage) throws Exception { Gson gson = new Gson(); log.info("call method Tcc.callBranch, tryMessage: {}, confirmMessage: {}, cancelMessage: {}", gson.toJson(tryMessage), gson.toJson(confirmMessage), gson.toJson(cancelMessage)); - String branchId = tcc.getBranchIdGenerator().genBranchId(); + String branchId = this.branchIdGenerator.genBranchId(); - OperatorParam operatorParam = new OperatorParam(tcc.getGid(), TransTypeEnum.TCC, Constants.DEFAULT_STATUS, branchId, + OperatorParam operatorParam = new OperatorParam(this.getGid(), TransTypeEnum.TCC, Constants.DEFAULT_STATUS, branchId, gson.toJson(body), FeignUtils.generatorURI(confirmMessage, false), FeignUtils.generatorURI(cancelMessage, false)); - ResponseBase resp = feignClient.registerBranch(operatorParam); + DtmResponse resp = feignClient.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { - log.error("TCC transaction register branch fail. transaction gid: {}", tcc.getGid()); + log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); throw new DtmException("TCC Transaction register branch fail"); } Map paramsMap = new HashMap<>(); - paramsMap.put(ParamFieldConstants.GID, tcc.getGid()); + paramsMap.put(ParamFieldConstants.GID, this.getGid()); paramsMap.put(ParamFieldConstants.TRANS_TYPE, TransTypeEnum.TCC.toString()); paramsMap.put(ParamFieldConstants.BRANCH_ID, branchId); paramsMap.put(ParamFieldConstants.OP, OP); @@ -91,21 +93,21 @@ public feign.Response callBranch(Tcc tcc, Object body, ServiceMessage tryMessage return response; } - public Response callBranch(Tcc tcc, Object body, String tryUrl, String confirmUrl, String cancelUrl) throws Exception { + public Response callBranch(Object body, String tryUrl, String confirmUrl, String cancelUrl) throws Exception { log.info("call method Tcc.callBranch, tryUrl: {}, confirmUrl: {}, cancelUrl: {}", tryUrl, confirmUrl, cancelUrl); - String branchId = tcc.getBranchIdGenerator().genBranchId(); + String branchId = branchIdGenerator.genBranchId(); Gson gson = new Gson(); - OperatorParam operatorParam = new OperatorParam(tcc.getGid(), TransTypeEnum.TCC, Constants.DEFAULT_STATUS, + OperatorParam operatorParam = new OperatorParam(this.getGid(), TransTypeEnum.TCC, Constants.DEFAULT_STATUS, branchId, gson.toJson(body), confirmUrl, cancelUrl); - ResponseBase resp = feignClient.registerBranch(operatorParam); + DtmResponse resp = feignClient.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { - log.error("TCC transaction register branch fail. transaction gid: {}", tcc.getGid()); + log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); throw new DtmException("TCC Transaction register branch fail"); } Map paramsMap = new HashMap<>(); - paramsMap.put(ParamFieldConstants.GID, tcc.getGid()); + paramsMap.put(ParamFieldConstants.GID, this.getGid()); paramsMap.put(ParamFieldConstants.TRANS_TYPE, TransTypeEnum.TCC.toString()); paramsMap.put(ParamFieldConstants.BRANCH_ID, branchId); paramsMap.put(ParamFieldConstants.OP, OP); diff --git a/dtmcli-core/src/main/java/tcc/model/Tcc.java b/dtmcli-core/src/main/java/tcc/model/Tcc.java deleted file mode 100644 index 73d04b3..0000000 --- a/dtmcli-core/src/main/java/tcc/model/Tcc.java +++ /dev/null @@ -1,19 +0,0 @@ -package tcc.model; - -import base.BranchIdGenerator; -import constant.Constants; -import enums.TransTypeEnum; -import model.dtm.TransBase; - -public class Tcc extends TransBase { - private final BranchIdGenerator branchIdGenerator; - - public Tcc(String gid) { - super(gid, TransTypeEnum.TCC, false); - this.branchIdGenerator = new BranchIdGenerator(Constants.EMPTY_STRING); - } - - public BranchIdGenerator getBranchIdGenerator() { - return branchIdGenerator; - } -} diff --git a/dtmcli-core/target/maven-archiver/pom.properties b/dtmcli-core/target/maven-archiver/pom.properties index 15bc8dd..9a7e43f 100644 --- a/dtmcli-core/target/maven-archiver/pom.properties +++ b/dtmcli-core/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Tue Apr 26 15:54:58 CST 2022 +#Tue Apr 26 17:58:45 CST 2022 version=1.0.0 groupId=pub.dtm artifactId=dtmcli-core diff --git a/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index 16f5943..d26f489 100644 --- a/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -1,6 +1,4 @@ -barrier/model/BarrierParam.class -barrier/BranchBarrierService.class -tcc/model/Tcc.class -barrier/model/BranchBarrier.class -tcc/TccService.class -base/BranchIdGenerator.class +pub/dtm/client/tcc/Tcc.class +pub/dtm/client/barrier/BranchBarrier.class +pub/dtm/client/barrier/BarrierParam.class +pub/dtm/client/base/BranchIdGenerator.class diff --git a/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index 56f854a..85e740c 100644 --- a/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,6 +1,4 @@ -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/barrier/model/BarrierParam.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/tcc/model/Tcc.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/base/BranchIdGenerator.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/barrier/BranchBarrierService.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/tcc/TccService.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/barrier/model/BranchBarrier.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java diff --git a/dtmcli-java/src/main/java/client/DtmClient.java b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java similarity index 64% rename from dtmcli-java/src/main/java/client/DtmClient.java rename to dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java index dca0d61..cac9fad 100644 --- a/dtmcli-java/src/main/java/client/DtmClient.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java @@ -1,21 +1,20 @@ -package client; +package pub.dtm.client; import com.alibaba.nacos.api.naming.pojo.Instance; -import constant.Constants; -import feign.DtmFeignClient; +import pub.dtm.client.constant.Constants; +import pub.dtm.client.feign.DtmFeignClient; import feign.Feign; -import feign.URIParser; +import pub.dtm.client.feign.URIParser; import feign.gson.GsonDecoder; import feign.gson.GsonEncoder; -import interfaces.dtm.DtmConsumer; -import interfaces.feign.IDtmFeignClient; +import pub.dtm.client.interfaces.dtm.DtmConsumer; +import pub.dtm.client.interfaces.feign.IDtmFeignClient; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import properties.DtmProperties; -import tcc.TccService; -import tcc.model.Tcc; -import utils.NacosUtils; +import pub.dtm.client.properties.DtmProperties; +import pub.dtm.client.tcc.Tcc; +import pub.dtm.client.utils.NacosUtils; import java.util.ArrayList; import java.util.Arrays; @@ -29,8 +28,7 @@ public class DtmClient { private static final Logger log = LoggerFactory.getLogger(DtmClient.class); - - private TccService tccService; + private IDtmFeignClient feignClient; public DtmClient() { // init URIParser @@ -64,7 +62,29 @@ public DtmClient() { System.exit(-1); } - this.tccService = new TccService(feignClient); + this.feignClient = feignClient; + } + + public DtmClient(String endpoint) { + // init URIParser + new URIParser(); + + if (StringUtils.isEmpty(endpoint)) { + log.error("dtm server endpoint can not be empty."); + System.exit(-1); + } + IDtmFeignClient feignClient = Feign + .builder() + .decoder(new GsonDecoder()) + .encoder(new GsonEncoder()) + .target(DtmFeignClient.class, Constants.HTTP_PREFIX + endpoint); + + if (feignClient == null) { + log.error("initial dtm client for java error, feign client can't be null."); + System.exit(-1); + } + + this.feignClient = feignClient; } private List genClusters(String clusterStr) { @@ -77,11 +97,13 @@ private List genClusters(String clusterStr) { return Arrays.asList(split); } - public String tccGlobalTransaction(DtmConsumer function) throws Exception { - return tccService.tccGlobalTransaction(null, function); + public String tccGlobalTransaction(DtmConsumer function) throws Exception { + Tcc tcc = new Tcc(null, feignClient); + return tcc.tccGlobalTransaction(function); } - public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { - return tccService.tccGlobalTransaction(gid, function); + public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { + Tcc tcc = new Tcc(gid, feignClient); + return tcc.tccGlobalTransaction(function); } } diff --git a/dtmcli-java/src/main/java/feign/DtmFeignClient.java b/dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java similarity index 66% rename from dtmcli-java/src/main/java/feign/DtmFeignClient.java rename to dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java index 7e34f7f..d4fe99d 100644 --- a/dtmcli-java/src/main/java/feign/DtmFeignClient.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java @@ -1,9 +1,10 @@ -package feign; +package pub.dtm.client.feign; -import constant.Constants; -import interfaces.feign.IDtmFeignClient; -import model.param.OperatorParam; -import model.response.ResponseBase; +import feign.*; +import pub.dtm.client.constant.Constants; +import pub.dtm.client.interfaces.feign.IDtmFeignClient; +import pub.dtm.client.model.param.OperatorParam; +import pub.dtm.client.model.responses.DtmResponse; import java.net.URI; import java.util.Map; @@ -12,27 +13,27 @@ public interface DtmFeignClient extends IDtmFeignClient { @Override @RequestLine(Constants.GET_METHOD + Constants.NEW_GID_URL) - ResponseBase newGid(); + DtmResponse newGid(); @Override @RequestLine(Constants.GET_METHOD + Constants.PING_URL) - ResponseBase ping(); + DtmResponse ping(); @Override @RequestLine(Constants.POST_METHOD + Constants.PREPARE_URL) - ResponseBase prepare(OperatorParam body); + DtmResponse prepare(OperatorParam body); @Override @RequestLine(Constants.POST_METHOD + Constants.SUBMIT_URL) - ResponseBase submit(OperatorParam body); + DtmResponse submit(OperatorParam body); @Override @RequestLine(Constants.POST_METHOD + Constants.ABORT_URL) - ResponseBase abort(OperatorParam body); + DtmResponse abort(OperatorParam body); @Override @RequestLine(Constants.POST_METHOD + Constants.REGISTER_BRANCH_URL) - ResponseBase registerBranch(OperatorParam body); + DtmResponse registerBranch(OperatorParam body); @Override @RequestLine(Constants.GET_METHOD + "{path}") diff --git a/dtmcli-java/src/main/java/feign/URIParser.java b/dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java similarity index 68% rename from dtmcli-java/src/main/java/feign/URIParser.java rename to dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java index 250f907..ccc73b3 100644 --- a/dtmcli-java/src/main/java/feign/URIParser.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java @@ -1,12 +1,12 @@ -package feign; +package pub.dtm.client.feign; import com.alibaba.nacos.api.naming.pojo.Instance; -import constant.Constants; -import interfaces.feign.IURIParser; -import model.feign.ServiceMessage; -import properties.DtmProperties; -import utils.FeignUtils; -import utils.NacosUtils; +import pub.dtm.client.constant.Constants; +import pub.dtm.client.interfaces.feign.IURIParser; +import pub.dtm.client.model.feign.ServiceMessage; +import pub.dtm.client.properties.DtmProperties; +import pub.dtm.client.utils.FeignUtils; +import pub.dtm.client.utils.NacosUtils; public class URIParser implements IURIParser { static { diff --git a/dtmcli-java/src/main/java/properties/DtmProperties.java b/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java similarity index 96% rename from dtmcli-java/src/main/java/properties/DtmProperties.java rename to dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java index bf4ecec..8c23607 100644 --- a/dtmcli-java/src/main/java/properties/DtmProperties.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java @@ -1,4 +1,4 @@ -package properties; +package pub.dtm.client.properties; import java.io.FileInputStream; import java.io.IOException; diff --git a/dtmcli-java/src/main/java/utils/NacosUtils.java b/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java similarity index 90% rename from dtmcli-java/src/main/java/utils/NacosUtils.java rename to dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java index 4ee631c..53c73a9 100644 --- a/dtmcli-java/src/main/java/utils/NacosUtils.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java @@ -1,9 +1,9 @@ -package utils; +package pub.dtm.client.utils; import com.alibaba.nacos.api.naming.NamingFactory; import com.alibaba.nacos.api.naming.NamingService; import com.alibaba.nacos.api.naming.pojo.Instance; -import properties.DtmProperties; +import pub.dtm.client.properties.DtmProperties; import java.util.List; diff --git a/dtmcli-java/target/maven-archiver/pom.properties b/dtmcli-java/target/maven-archiver/pom.properties index a464007..7b70382 100644 --- a/dtmcli-java/target/maven-archiver/pom.properties +++ b/dtmcli-java/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Tue Apr 26 15:55:30 CST 2022 +#Tue Apr 26 17:58:47 CST 2022 version=1.0.0 groupId=pub.dtm artifactId=dtmcli-java diff --git a/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index 28be81a..2e58121 100644 --- a/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -1,5 +1,5 @@ -feign/DtmFeignClient.class -feign/URIParser.class -utils/NacosUtils.class -properties/DtmProperties.class -client/DtmClient.class +pub/dtm/client/utils/NacosUtils.class +pub/dtm/client/feign/DtmFeignClient.class +pub/dtm/client/feign/URIParser.class +pub/dtm/client/DtmClient.class +pub/dtm/client/properties/DtmProperties.class diff --git a/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index a9d548a..6386389 100644 --- a/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,5 +1,5 @@ -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/feign/DtmFeignClient.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/properties/DtmProperties.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/client/DtmClient.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/feign/URIParser.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/utils/NacosUtils.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java diff --git a/dtmcli-spring/src/main/java/client/DtmClient.java b/dtmcli-spring/src/main/java/client/DtmClient.java deleted file mode 100644 index 72a90d9..0000000 --- a/dtmcli-spring/src/main/java/client/DtmClient.java +++ /dev/null @@ -1,25 +0,0 @@ -package client; - -import interfaces.dtm.DtmConsumer; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import tcc.TccService; -import tcc.model.Tcc; - -@Component -public class DtmClient { - @Autowired - private TccService tccService; - - public DtmClient(TccService tccService) { - this.tccService = tccService; - } - - public String tccGlobalTransaction(DtmConsumer function) throws Exception { - return tccService.tccGlobalTransaction(null, function); - } - - public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { - return tccService.tccGlobalTransaction(gid, function); - } -} diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java b/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java new file mode 100644 index 0000000..3c79d06 --- /dev/null +++ b/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java @@ -0,0 +1,27 @@ +package pub.dtm.client; + +import pub.dtm.client.interfaces.dtm.DtmConsumer; +import pub.dtm.client.interfaces.feign.IDtmFeignClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import pub.dtm.client.tcc.Tcc; + +@Component +public class DtmClient { + @Autowired + private IDtmFeignClient feignClient; + + public DtmClient(IDtmFeignClient feignClient) { + this.feignClient = feignClient; + } + + public String tccGlobalTransaction(DtmConsumer function) throws Exception { + Tcc tcc = new Tcc(null, feignClient); + return tcc.tccGlobalTransaction(function); + } + + public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { + Tcc tcc = new Tcc(gid, feignClient); + return tcc.tccGlobalTransaction(function); + } +} diff --git a/dtmcli-spring/src/main/java/configuration/DtmConfiguration.java b/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java similarity index 60% rename from dtmcli-spring/src/main/java/configuration/DtmConfiguration.java rename to dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java index dbdb0e2..6f11268 100644 --- a/dtmcli-spring/src/main/java/configuration/DtmConfiguration.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java @@ -1,8 +1,6 @@ -package configuration; +package pub.dtm.client.configuration; -import barrier.BranchBarrierService; -import feign.DtmFeignClient; -import feign.URIParser; +import pub.dtm.client.feign.URIParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -11,30 +9,17 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; -import properties.DtmProperties; -import tcc.TccService; +import pub.dtm.client.properties.DtmProperties; @Component -@ComponentScan({"feign", "client"}) +@ComponentScan({"pub.dtm.client.feign", "pub.dtm.client"}) @Configuration -@EnableFeignClients("feign") +@EnableFeignClients("pub.dtm.client.feign") @EnableConfigurationProperties(DtmProperties.class) public class DtmConfiguration { @Autowired private DtmProperties dtmProperties; - @Bean - @ConditionalOnMissingBean(TccService.class) - public TccService tccService(DtmFeignClient feignClient) { - return new TccService(feignClient); - } - - @Bean - @ConditionalOnMissingBean(BranchBarrierService.class) - public BranchBarrierService branchBarrierService() { - return new BranchBarrierService(); - } - @Bean @ConditionalOnMissingBean(URIParser.class) public URIParser uriParser() { diff --git a/dtmcli-spring/src/main/java/feign/DtmFeignClient.java b/dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java similarity index 72% rename from dtmcli-spring/src/main/java/feign/DtmFeignClient.java rename to dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java index e7e285b..5d81022 100644 --- a/dtmcli-spring/src/main/java/feign/DtmFeignClient.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java @@ -1,9 +1,9 @@ -package feign; +package pub.dtm.client.feign; -import constant.Constants; -import interfaces.feign.IDtmFeignClient; -import model.param.OperatorParam; -import model.response.ResponseBase; +import pub.dtm.client.constant.Constants; +import feign.Response; +import pub.dtm.client.interfaces.feign.IDtmFeignClient; +import pub.dtm.client.model.param.OperatorParam; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.SpringQueryMap; import org.springframework.http.MediaType; @@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import pub.dtm.client.model.responses.DtmResponse; import java.net.URI; import java.util.Map; @@ -19,27 +20,27 @@ public interface DtmFeignClient extends IDtmFeignClient { @Override @GetMapping(Constants.NEW_GID_URL) - ResponseBase newGid(); + DtmResponse newGid(); @Override @GetMapping(Constants.PING_URL) - ResponseBase ping(); + DtmResponse ping(); @Override @PostMapping(Constants.PREPARE_URL) - ResponseBase prepare(@RequestBody OperatorParam body); + DtmResponse prepare(@RequestBody OperatorParam body); @Override @PostMapping(Constants.SUBMIT_URL) - ResponseBase submit(@RequestBody OperatorParam body); + DtmResponse submit(@RequestBody OperatorParam body); @Override @PostMapping(Constants.ABORT_URL) - ResponseBase abort(@RequestBody OperatorParam body); + DtmResponse abort(@RequestBody OperatorParam body); @Override @PostMapping(Constants.REGISTER_BRANCH_URL) - ResponseBase registerBranch(@RequestBody OperatorParam body); + DtmResponse registerBranch(@RequestBody OperatorParam body); @Override @GetMapping(value = "{path}", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) diff --git a/dtmcli-spring/src/main/java/feign/URIParser.java b/dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java similarity index 72% rename from dtmcli-spring/src/main/java/feign/URIParser.java rename to dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java index 07bda35..160c604 100644 --- a/dtmcli-spring/src/main/java/feign/URIParser.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java @@ -1,9 +1,9 @@ -package feign; +package pub.dtm.client.feign; -import constant.Constants; -import interfaces.feign.IURIParser; -import model.feign.ServiceMessage; -import utils.FeignUtils; +import pub.dtm.client.constant.Constants; +import pub.dtm.client.interfaces.feign.IURIParser; +import pub.dtm.client.model.feign.ServiceMessage; +import pub.dtm.client.utils.FeignUtils; public class URIParser implements IURIParser { static { diff --git a/dtmcli-spring/src/main/java/properties/DtmProperties.java b/dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java similarity index 89% rename from dtmcli-spring/src/main/java/properties/DtmProperties.java rename to dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java index e2f3815..f3be4ef 100644 --- a/dtmcli-spring/src/main/java/properties/DtmProperties.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java @@ -1,4 +1,4 @@ -package properties; +package pub.dtm.client.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/dtmcli-spring/src/main/resources/META-INF/spring.factories b/dtmcli-spring/src/main/resources/META-INF/spring.factories index 09746d6..f780708 100644 --- a/dtmcli-spring/src/main/resources/META-INF/spring.factories +++ b/dtmcli-spring/src/main/resources/META-INF/spring.factories @@ -1 +1 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=configuration.DtmConfiguration \ No newline at end of file +org.springframework.boot.autoconfigure.EnableAutoConfiguration=pub.dtm.client.configuration.DtmConfiguration \ No newline at end of file diff --git a/dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json b/dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json index 5625e72..a141efd 100644 --- a/dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json +++ b/dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json @@ -2,20 +2,20 @@ "groups": [ { "name": "dtm.service", - "type": "properties.DtmProperties", - "sourceType": "properties.DtmProperties" + "type": "pub.dtm.client.properties.DtmProperties", + "sourceType": "pub.dtm.client.properties.DtmProperties" } ], "properties": [ { "name": "dtm.service.name", "type": "java.lang.String", - "sourceType": "properties.DtmProperties" + "sourceType": "pub.dtm.client.properties.DtmProperties" }, { "name": "dtm.service.registry-type", "type": "java.lang.String", - "sourceType": "properties.DtmProperties" + "sourceType": "pub.dtm.client.properties.DtmProperties" } ], "hints": [] diff --git a/dtmcli-spring/target/classes/META-INF/spring.factories b/dtmcli-spring/target/classes/META-INF/spring.factories index 09746d6..f780708 100644 --- a/dtmcli-spring/target/classes/META-INF/spring.factories +++ b/dtmcli-spring/target/classes/META-INF/spring.factories @@ -1 +1 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=configuration.DtmConfiguration \ No newline at end of file +org.springframework.boot.autoconfigure.EnableAutoConfiguration=pub.dtm.client.configuration.DtmConfiguration \ No newline at end of file diff --git a/dtmcli-spring/target/maven-archiver/pom.properties b/dtmcli-spring/target/maven-archiver/pom.properties index cc6c559..79c9b9e 100644 --- a/dtmcli-spring/target/maven-archiver/pom.properties +++ b/dtmcli-spring/target/maven-archiver/pom.properties @@ -1,5 +1,5 @@ #Generated by Maven -#Tue Apr 26 15:55:29 CST 2022 +#Tue Apr 26 17:58:46 CST 2022 version=1.0.0 groupId=pub.dtm artifactId=dtmcli-spring diff --git a/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index b5d894c..e23c293 100644 --- a/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -1,6 +1,6 @@ -feign/URIParser.class META-INF/spring-configuration-metadata.json -properties/DtmProperties.class -client/DtmClient.class -feign/DtmFeignClient.class -configuration/DtmConfiguration.class +pub/dtm/client/feign/URIParser.class +pub/dtm/client/feign/DtmFeignClient.class +pub/dtm/client/configuration/DtmConfiguration.class +pub/dtm/client/DtmClient.class +pub/dtm/client/properties/DtmProperties.class diff --git a/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst index 4282d2a..25eb68e 100644 --- a/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ b/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -1,5 +1,5 @@ -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/feign/URIParser.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/client/DtmClient.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/configuration/DtmConfiguration.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/feign/DtmFeignClient.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/properties/DtmProperties.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java +/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java diff --git a/src/main/java/barrier/BarrierParam.java b/src/main/java/barrier/BarrierParam.java deleted file mode 100644 index 35c1de4..0000000 --- a/src/main/java/barrier/BarrierParam.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package barrier; - -import lombok.Data; - -/** - * dtm 服务端传过来的字段格式为下划线分隔,为了减少sdk对json包依赖也采用下划线格式 - * - * @author lixiaoshuang - */ -@Data -public class BarrierParam { - - /** - * 事务类型 - */ - private String trans_type[]; - - /** - * 全局事务id - */ - private String gid[]; - - /** - * 分支id - */ - private String branch_id[]; - - /** - * 操作 - */ - private String op[]; - -} diff --git a/src/main/java/barrier/BranchBarrier.java b/src/main/java/barrier/BranchBarrier.java deleted file mode 100644 index 7604306..0000000 --- a/src/main/java/barrier/BranchBarrier.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package barrier; - -import com.alibaba.fastjson.JSONObject; -import common.constant.ParamFieldConstant; -import common.model.DtmConsumer; -import lombok.Data; -import lombok.NoArgsConstructor; -import lombok.extern.slf4j.Slf4j; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.SQLException; -import java.util.Map; -import java.util.Objects; - -/** - * @author lixiaoshuang - */ -@Data -@NoArgsConstructor -@Slf4j -public class BranchBarrier { - - /** - * 事务类型 - */ - private String transType; - - /** - * 全局事务id - */ - private String gid; - - /** - * 分支id - */ - private String branchId; - - /** - * 操作 - */ - private String op; - - /** - * 屏障id - */ - private int barrierId; - - - public BranchBarrier(Map parameterMap) throws Exception { - if (null == parameterMap) { - throw new Exception("BranchBarrier parameterMap null!"); - } - BarrierParam barrierParam = JSONObject.parseObject(JSONObject.toJSONString(parameterMap), BarrierParam.class); - if (barrierParam.getTrans_type().length > 0) { - this.transType = barrierParam.getTrans_type()[0]; - } - if (barrierParam.getGid().length > 0) { - this.gid = barrierParam.getGid()[0]; - } - if (barrierParam.getBranch_id().length > 0) { - this.branchId = barrierParam.getBranch_id()[0]; - } - if (barrierParam.getOp().length > 0) { - this.op = barrierParam.getOp()[0]; - } - } - - /** - * connection 由使用方自行管理,创建、回收。 - * - * @param connection - * @param consumer - * @return - * @throws SQLException - */ - public void call(Connection connection, DtmConsumer consumer) throws Exception { - this.barrierId++; - connection.setAutoCommit(false); - try { - boolean result = insertBarrier(connection); - if (result) { - consumer.accept(this); - connection.commit(); - } - } catch (Exception exception) { - log.warn("barrier call error", exception); - connection.rollback(); - throw exception; - } finally { - connection.setAutoCommit(true); - } - } - - private boolean insertBarrier(Connection connection) throws SQLException { - if (Objects.isNull(connection)) { - return false; - } - PreparedStatement preparedStatement = null; - try { - String sql = "insert ignore into barrier(trans_type, gid, branch_id, op, barrier_id, reason) values(?,?,?,?,?,?)"; - preparedStatement = connection.prepareStatement(sql); - preparedStatement.setString(1, transType); - preparedStatement.setString(2, gid); - preparedStatement.setString(3, branchId); - preparedStatement.setString(4, op); - preparedStatement.setString(5, String.format("%02d", barrierId)); - preparedStatement.setString(6, op); - - if (preparedStatement.executeUpdate() == 0) { - return false; - } - if (op.equals(ParamFieldConstant.CANCEL)) { - int opIndex = 4; - preparedStatement.setString(opIndex, ParamFieldConstant.TRY); - if (preparedStatement.executeUpdate() > 0) { - return false; - } - } - } finally { - if (Objects.nonNull(preparedStatement)) { - preparedStatement.close(); - } - } - return true; - } -} diff --git a/src/main/java/client/DtmClient.java b/src/main/java/client/DtmClient.java deleted file mode 100644 index a57e553..0000000 --- a/src/main/java/client/DtmClient.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package client; - - -import com.alibaba.fastjson.JSONObject; -import common.model.DtmConsumer; -import common.model.DtmServerInfo; -import common.utils.HttpUtil; -import okhttp3.Response; -import saga.Saga; -import tcc.Tcc; - -import java.util.Objects; - -/** - * @author lixiaoshuang - */ -public class DtmClient { - - private String ipPort; - - public DtmClient(String ipPort) { - this.ipPort = ipPort; - } - - /** - * 生成全局事务id - * - * @return - * @throws Exception - */ - public String genGid() throws Exception { - DtmServerInfo dtmServerInfo = new DtmServerInfo(ipPort); - JSONObject jsonObject = null; - try { - Response response = HttpUtil.get(dtmServerInfo.newGid()); - if (Objects.nonNull(response.body())) { - String result = response.body().string(); - jsonObject = JSONObject.parseObject(result); - } - } catch (Exception e) { - throw new Exception("Can’t get gid, please check the dtm server."); - } - if (Objects.isNull(jsonObject)) { - throw new Exception("Can’t get gid, please check the dtm server."); - } - Object code = jsonObject.get("code"); - if (null != code && (int) code > 0) { - Object message = jsonObject.get("message"); - throw new Exception(message.toString()); - } - return jsonObject.get("gid").toString(); - } - - /** - * tcc事务 - * - * @param gid - * @param function - * @return - * @throws Exception - */ - public void tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(ipPort, gid); - tcc.tccGlobalTransaction(function); - } - - /** - * create a new saga - * @param gid - */ - public Saga newSaga(String gid) { - return new Saga(ipPort, gid); - } -} diff --git a/src/main/java/common/constant/Constant.java b/src/main/java/common/constant/Constant.java deleted file mode 100644 index c90a7de..0000000 --- a/src/main/java/common/constant/Constant.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package common.constant; - -/** - * @author lixiaoshuang - */ -public class Constant { - - public static final int DEFAULT_INITIAL_CAPACITY = 16; - - public static final String SUCCESS_RESULT = "SUCCESS"; - - public static final String FAILURE_RESULT = "FAILURE"; - -} diff --git a/src/main/java/common/constant/ParamFieldConstant.java b/src/main/java/common/constant/ParamFieldConstant.java deleted file mode 100644 index 3da26d0..0000000 --- a/src/main/java/common/constant/ParamFieldConstant.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package common.constant; - -/** - * @author lixiaoshuang - */ -public class ParamFieldConstant { - - public static final String GID = "gid"; - - public static final String TRANS_TYPE = "trans_type"; - - public static final String BRANCH_ID = "branch_id"; - - public static final String STATUS = "status"; - - public static final String DATA = "data"; - - public static final String TRY = "try"; - - public static final String CONFIRM = "confirm"; - - public static final String CANCEL = "cancel"; - - public static final String OP = "op"; - - public static final String CODE = "code"; - - public static final String MESSAGE = "message"; - - public static final String DTM_RESULT = "dtm_result"; - - public static final String ACTION = "action"; - - public static final String COMPENSATE = "compensate"; - - public static final String STEPS = "steps"; - - public static final String PAYLOADS = "payloads"; - - public static final String CUSTOM_DATA = "custom_data"; - - public static final String WAIT_RESULT = "wait_result"; - - public static final String TIMEOUT_TO_FAIL = "timeout_to_fail"; - - public static final String RETRY_INTERVAL = "retry_interval"; - - public static final String PASSTHROGH_HEADERS = "passthrough_headers"; - - public static final String BRANCH_HEADERS = "branch_headers"; - -} diff --git a/src/main/java/common/enums/TransTypeEnum.java b/src/main/java/common/enums/TransTypeEnum.java deleted file mode 100644 index 7336c41..0000000 --- a/src/main/java/common/enums/TransTypeEnum.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package common.enums; - -public enum TransTypeEnum { - // 事务类型 - TCC("tcc"), SAGA("saga"); - - TransTypeEnum(String value) { - this.value = value; - } - - private String value; - - public String getValue() { - return this.value; - } - -} \ No newline at end of file diff --git a/src/main/java/common/model/DtmConsumer.java b/src/main/java/common/model/DtmConsumer.java deleted file mode 100644 index 2b5ffdb..0000000 --- a/src/main/java/common/model/DtmConsumer.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package common.model; - -/** - * @author lixiaoshuang - */ -@FunctionalInterface -public interface DtmConsumer { - - void accept(T t) throws Exception; -} diff --git a/src/main/java/common/model/DtmServerInfo.java b/src/main/java/common/model/DtmServerInfo.java deleted file mode 100644 index c2fc8b2..0000000 --- a/src/main/java/common/model/DtmServerInfo.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package common.model; - -import lombok.Data; -import lombok.NoArgsConstructor; - -/** - * @author lixiaoshuang - */ -@Data -@NoArgsConstructor -public class DtmServerInfo { - - /** - * ip+port - */ - private String ipPort; - - - public static final String PREFIX = "http://"; - - public static final String BASE = "/api/dtmsvr"; - - public static final String NEW_GID = BASE + "/newGid"; - - public static final String PREPARE = BASE + "/prepare"; - - public static final String SUBMIT = BASE + "/submit"; - - public static final String ABORT = BASE + "/abort"; - - public static final String REGISTER_TCC_BRANCH = BASE + "/registerTccBranch"; - - public DtmServerInfo(String ipPort) { - this.ipPort = ipPort; - } - - /** - * 生成gid url - * - * @return - */ - public String newGid() { - return PREFIX + ipPort + NEW_GID; - } - - /** - * 生成gid url - * - * @return - */ - public String prepare() { - return PREFIX + ipPort + PREPARE; - } - - /** - * submit 阶段 url - * - * @return - */ - public String submit() { - return PREFIX + ipPort + SUBMIT; - } - - /** - * abort 阶段 url - * - * @return - */ - public String abort() { - return PREFIX + ipPort + ABORT; - } - - /** - * 注册tcc 事务分支 - * - * @return - */ - public String registerTccBranch() { - return PREFIX + ipPort + REGISTER_TCC_BRANCH; - } - -} diff --git a/src/main/java/common/model/TransBase.java b/src/main/java/common/model/TransBase.java deleted file mode 100644 index 9d3ecdf..0000000 --- a/src/main/java/common/model/TransBase.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package common.model; - -import common.enums.TransTypeEnum; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -@Data -@NoArgsConstructor -public class TransBase { - - /** - * 全局事务id - */ - private String gid; - - /** - * 事务类型 - */ - private TransTypeEnum transTypeEnum; - - private boolean waitResult; - - private long timeoutToFail; - - private long retryInterval; - - private Map branchHeaders = new HashMap<>(); - - private ArrayList passthroughHeaders = new ArrayList<>(); - - private String customData; - - private ArrayList> steps = new ArrayList<>(); - - private ArrayList payloads = new ArrayList<>(); - - public TransBase(TransTypeEnum transTypeEnum, String gid, boolean waitResult) { - this.gid = gid; - this.transTypeEnum = transTypeEnum; - this.waitResult = waitResult; - } -} \ No newline at end of file diff --git a/src/main/java/common/model/TransResponse.java b/src/main/java/common/model/TransResponse.java deleted file mode 100644 index b9a6631..0000000 --- a/src/main/java/common/model/TransResponse.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package common.model; - -import lombok.Data; - -/** - * @author lixiaoshuang - */ -@Data -public class TransResponse { - - private String dtmResult; - - public TransResponse(String dtmResult) { - this.dtmResult = dtmResult; - } - - public static TransResponse buildTransResponse(String result) { - return new TransResponse(result); - } -} diff --git a/src/main/java/common/utils/BranchIdGeneratorUtil.java b/src/main/java/common/utils/BranchIdGeneratorUtil.java deleted file mode 100644 index a7fad79..0000000 --- a/src/main/java/common/utils/BranchIdGeneratorUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package common.utils; - -import lombok.Data; - -/** - * @author lixiaoshuang - */ -@Data -public class BranchIdGeneratorUtil { - - private static final int MAX_BRANCH_ID = 99; - - private static final int LENGTH = 20; - - private String branchId; - - private int subBranchId; - - public BranchIdGeneratorUtil(String branchId) { - this.branchId = branchId; - } - - /** - * 生成注册分支id - * - * @return - * @throws Exception - */ - public String genBranchId() throws Exception { - if (this.subBranchId >= MAX_BRANCH_ID) { - throw new Exception("branch id is larger than 99"); - } - if (this.branchId.length() >= LENGTH) { - throw new Exception("total branch id is longer than 20"); - } - this.subBranchId++; - return this.branchId + String.format("%02d", this.subBranchId); - } -} \ No newline at end of file diff --git a/src/main/java/common/utils/HttpUtil.java b/src/main/java/common/utils/HttpUtil.java deleted file mode 100644 index b608199..0000000 --- a/src/main/java/common/utils/HttpUtil.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package common.utils; - -import okhttp3.MediaType; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.RequestBody; -import okhttp3.Response; - -import java.io.IOException; -import java.util.concurrent.TimeUnit; - -/** - * @author lixiaoshuang - */ -public class HttpUtil { - - private static final OkHttpClient CLIENT = new OkHttpClient.Builder().connectTimeout(15, TimeUnit.SECONDS) - .readTimeout(5, TimeUnit.SECONDS).writeTimeout(5, TimeUnit.SECONDS).build(); - - public static final MediaType MEDIA_TYPE = MediaType.get("application/json; charset=utf-8"); - - /** - * get 请求 - * - * @param url - * @return - * @throws IOException - */ - public static Response get(String url) throws IOException { - Request request = new Request.Builder().url(url).get().build(); - return CLIENT.newCall(request).execute(); - } - - /** - * post 请求 - * - * @param url - * @param json - * @return - * @throws IOException - */ - public static Response post(String url, String json) throws IOException { - RequestBody body = RequestBody.create(MEDIA_TYPE, json); - Request request = new Request.Builder().url(url).post(body).build(); - return CLIENT.newCall(request).execute(); - } -} diff --git a/src/main/java/common/utils/StreamUtil.java b/src/main/java/common/utils/StreamUtil.java deleted file mode 100644 index 0d1af20..0000000 --- a/src/main/java/common/utils/StreamUtil.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package common.utils; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -/** - * @author lixiaoshuang - */ -public class StreamUtil { - - public static byte[] copyToByteArray(InputStream in) throws IOException { - if (in == null) { - return new byte[0]; - } else { - ByteArrayOutputStream out = new ByteArrayOutputStream(4096); - copy(in, out); - return out.toByteArray(); - } - } - - private static int copy(InputStream in, OutputStream out) throws IOException { - int byteCount = 0; - if (null == in) { - return byteCount; - } - if (null == out) { - return byteCount; - } - int bytesRead; - for (byte[] buffer = new byte[4096]; (bytesRead = in.read(buffer)) != -1; byteCount += bytesRead) { - out.write(buffer, 0, bytesRead); - } - out.flush(); - return byteCount; - } - -} diff --git a/src/main/java/exception/FailureException.java b/src/main/java/exception/FailureException.java deleted file mode 100644 index 768dc9d..0000000 --- a/src/main/java/exception/FailureException.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package exception; - -public class FailureException extends Exception { - - public FailureException(String message) { - super(message); - } -} diff --git a/src/main/java/saga/Saga.java b/src/main/java/saga/Saga.java deleted file mode 100644 index 9a24e57..0000000 --- a/src/main/java/saga/Saga.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package saga; - -import com.alibaba.fastjson.JSONObject; -import common.constant.Constant; -import common.constant.ParamFieldConstant; -import common.model.DtmServerInfo; -import common.utils.HttpUtil; -import common.enums.TransTypeEnum; -import common.model.TransBase; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; - -public class Saga { - - private static final String ORDERS = "orders"; - - private static final String CONCURRENT = "concurrent"; - - private TransBase transBase; - - private DtmServerInfo dtmServerInfo; - - private boolean concurrent; - - private Map> orders; - - public Saga(String ipPort, String gid) { - this.dtmServerInfo = new DtmServerInfo(ipPort); - this.transBase = new TransBase(TransTypeEnum.SAGA, gid, false); - this.concurrent = false; - this.orders = new HashMap<>(); - } - - public Saga add(String action, String compensate, Object postData) { - HashMap step = new HashMap<>(); - step.put(ParamFieldConstant.ACTION, action); - step.put(ParamFieldConstant.COMPENSATE, compensate); - transBase.getSteps().add(step); - transBase.getPayloads().add(JSONObject.toJSONString(postData)); - return this; - } - - public Saga addBranchOrder(Integer branch, ArrayList preBranches) { - orders.put(branch.toString(), preBranches); - return this; - } - - public Saga enableConcurrent() { - concurrent = true; - return this; - } - - public void submit() throws Exception { - addConcurrentContext(); - HashMap mapParam = new HashMap<>(Constant.DEFAULT_INITIAL_CAPACITY); - mapParam.put(ParamFieldConstant.GID, transBase.getGid()); - mapParam.put(ParamFieldConstant.TRANS_TYPE, TransTypeEnum.SAGA.getValue()); - mapParam.put(ParamFieldConstant.STEPS, transBase.getSteps()); - mapParam.put(ParamFieldConstant.PAYLOADS, transBase.getPayloads()); - mapParam.put(ParamFieldConstant.CUSTOM_DATA, transBase.getCustomData()); - mapParam.put(ParamFieldConstant.WAIT_RESULT, transBase.isWaitResult()); - mapParam.put(ParamFieldConstant.TIMEOUT_TO_FAIL, transBase.getTimeoutToFail()); - mapParam.put(ParamFieldConstant.RETRY_INTERVAL, transBase.getRetryInterval()); - mapParam.put(ParamFieldConstant.PASSTHROGH_HEADERS, transBase.getPassthroughHeaders()); - mapParam.put(ParamFieldConstant.BRANCH_HEADERS, transBase.getBranchHeaders()); - - HttpUtil.post(dtmServerInfo.submit(), JSONObject.toJSONString(mapParam)); - } - - public Saga enableWaitResult() { - transBase.setWaitResult(true); - return this; - } - - public Saga setTimeoutToFail(long timeoutToFail) { - transBase.setTimeoutToFail(timeoutToFail); - return this; - } - - public Saga setRetryInterval(long retryInterval) { - transBase.setRetryInterval(retryInterval); - return this; - } - - public Saga setBranchHeaders(Map headers) { - transBase.setBranchHeaders(headers); - return this; - } - - public Saga setPassthroughHeaders(ArrayList passthroughHeaders) { - transBase.setPassthroughHeaders(passthroughHeaders); - return this; - } - - private void addConcurrentContext() { - if (concurrent) { - HashMap data = new HashMap<>(); - data.put(ORDERS, orders); - data.put(CONCURRENT, true); - transBase.setCustomData(JSONObject.toJSONString(data)); - } - } -} diff --git a/src/main/java/tcc/Tcc.java b/src/main/java/tcc/Tcc.java deleted file mode 100644 index b0e3ca9..0000000 --- a/src/main/java/tcc/Tcc.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package tcc; - -import com.alibaba.fastjson.JSONObject; -import common.constant.Constant; -import common.model.DtmConsumer; -import common.model.DtmServerInfo; -import common.utils.HttpUtil; -import common.utils.BranchIdGeneratorUtil; -import common.constant.ParamFieldConstant; -import common.enums.TransTypeEnum; -import common.model.TransBase; -import exception.FailureException; -import okhttp3.Response; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.HashMap; - -/** - * @author lixiaoshuang - */ -public class Tcc { - - private static final String DEFAULT_STATUS = "prepared"; - - private static final String OP = "try"; - - private static final String FAIL_RESULT = "FAILURE"; - - Logger log = LoggerFactory.getLogger(Tcc.class); - - - /** - * 事务信息 - */ - private TransBase transBase; - - /** - * server 信息 - */ - private DtmServerInfo dtmServerInfo; - - /** - * id 生成器 - */ - private BranchIdGeneratorUtil branchIdGeneratorUtil; - - public Tcc(String ipPort, String gid) { - this.dtmServerInfo = new DtmServerInfo(ipPort); - this.branchIdGeneratorUtil = new BranchIdGeneratorUtil(""); - this.transBase = new TransBase(TransTypeEnum.TCC, gid, false); - } - - public void tccGlobalTransaction(DtmConsumer consumer) throws Exception { - HashMap paramMap = new HashMap<>(Constant.DEFAULT_INITIAL_CAPACITY); - paramMap.put(ParamFieldConstant.GID, transBase.getGid()); - paramMap.put(ParamFieldConstant.TRANS_TYPE, TransTypeEnum.TCC.getValue()); - - try { - Response response = HttpUtil.post(dtmServerInfo.prepare(), JSONObject.toJSONString(paramMap)); - this.checkResult(response); - } catch (FailureException failureException) { - log.info("tccGlobalTransaction fail message:{}" + failureException.getLocalizedMessage()); - throw failureException; - } - - try { - consumer.accept(this); - HttpUtil.post(dtmServerInfo.submit(), JSONObject.toJSONString(paramMap)); - } catch (Exception e) { - HttpUtil.post(dtmServerInfo.abort(), JSONObject.toJSONString(paramMap)); - throw e; - } - } - - public Response callBranch(Object body, String tryUrl, String confirmUrl, String cancelUrl) throws Exception { - String branchId = branchIdGeneratorUtil.genBranchId(); - HashMap registerParam = new HashMap<>(Constant.DEFAULT_INITIAL_CAPACITY); - registerParam.put(ParamFieldConstant.GID, transBase.getGid()); - registerParam.put(ParamFieldConstant.BRANCH_ID, branchId); - registerParam.put(ParamFieldConstant.TRANS_TYPE, TransTypeEnum.TCC.getValue()); - registerParam.put(ParamFieldConstant.STATUS, DEFAULT_STATUS); - registerParam.put(ParamFieldConstant.DATA, JSONObject.toJSONString(body)); - registerParam.put(ParamFieldConstant.TRY, tryUrl); - registerParam.put(ParamFieldConstant.CONFIRM, confirmUrl); - registerParam.put(ParamFieldConstant.CANCEL, cancelUrl); - - Response registerResponse = HttpUtil - .post(dtmServerInfo.registerTccBranch(), JSONObject.toJSONString(registerParam)); - this.checkResult(registerResponse); - - Response tryResponse = HttpUtil - .post(splicingTryUrl(tryUrl, transBase.getGid(), TransTypeEnum.TCC.getValue(), branchId, OP), - JSONObject.toJSONString(body)); - this.checkResult(tryResponse); - - return tryResponse; - } - - /** - * 和go 保持同样的发送方式 参数拼在url后边 - */ - private String splicingTryUrl(String tryUrl, String gid, String transType, String branchId, String op) { - return tryUrl + "?gid=" + gid + "&trans_type=" + transType + "&branch_id=" + branchId + "&op=" + op; - } - - - public void checkResult(Response response)throws Exception { - int errorCode = 400; - if (response.code() >= errorCode){ - throw new FailureException(response.message()); - } - String result = response.body().string(); - if (StringUtils.isBlank(result)) { - throw new FailureException("response is null"); - } - if (result.contains(FAIL_RESULT)){ - throw new FailureException("Service returned failed"); - } - } -} \ No newline at end of file diff --git a/src/main/java/xa/Xa.java b/src/main/java/xa/Xa.java deleted file mode 100644 index 3d394f9..0000000 --- a/src/main/java/xa/Xa.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2021 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package xa; - -public class Xa { - -} From c02dc1bc86abaa370eb3e43cd84884ca853f26fe Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Wed, 27 Apr 2022 13:23:55 +0800 Subject: [PATCH 03/24] change exception class name --- .../pub/dtm/client/exception/DtmException.java | 11 ----------- .../pub/dtm/client/exception/FailureException.java | 11 +++++++++++ .../main/java/pub/dtm/client/utils/FeignUtils.java | 14 +++++++------- .../main/java/pub/dtm/client/utils/HttpUtils.java | 8 ++++---- .../compile/default-compile/createdFiles.lst | 2 +- .../java/pub/dtm/client/barrier/BranchBarrier.java | 4 ++-- .../src/main/java/pub/dtm/client/tcc/Tcc.java | 10 +++++----- 7 files changed, 30 insertions(+), 30 deletions(-) delete mode 100644 dtmcli-common/src/main/java/pub/dtm/client/exception/DtmException.java create mode 100644 dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java diff --git a/dtmcli-common/src/main/java/pub/dtm/client/exception/DtmException.java b/dtmcli-common/src/main/java/pub/dtm/client/exception/DtmException.java deleted file mode 100644 index a5a4998..0000000 --- a/dtmcli-common/src/main/java/pub/dtm/client/exception/DtmException.java +++ /dev/null @@ -1,11 +0,0 @@ -package pub.dtm.client.exception; - -public class DtmException extends Exception { - public DtmException(String msg) { - super(msg); - } - - public DtmException(Throwable e) { - super(e); - } -} diff --git a/dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java b/dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java new file mode 100644 index 0000000..d09487f --- /dev/null +++ b/dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java @@ -0,0 +1,11 @@ +package pub.dtm.client.exception; + +public class FailureException extends Exception { + public FailureException(String msg) { + super(msg); + } + + public FailureException(Throwable e) { + super(e); + } +} diff --git a/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java b/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java index e8294c4..348ec03 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java @@ -1,7 +1,7 @@ package pub.dtm.client.utils; import pub.dtm.client.constant.Constants; -import pub.dtm.client.exception.DtmException; +import pub.dtm.client.exception.FailureException; import feign.Response; import pub.dtm.client.interfaces.feign.IURIParser; import pub.dtm.client.model.feign.ServiceMessage; @@ -35,16 +35,16 @@ public static String generatorURI(ServiceMessage serviceMessage, boolean httpTyp return uriParser.generatorURI(serviceMessage, httpType); } - public static void checkResult(Response response) throws DtmException { + public static void checkResult(Response response) throws FailureException { if (response.status() >= Constants.RESP_ERR_CODE){ if (response.reason() != null) { - throw new DtmException(response.reason()); + throw new FailureException(response.reason()); } try { log.error("response code is {}, but unknown reason, response body is {}", response.status(), IOUtils.toString(response.body().asReader(StandardCharsets.UTF_8))); } finally { - throw new DtmException("response code is " + response.status()); + throw new FailureException("response code is " + response.status()); } } String result = ""; @@ -54,13 +54,13 @@ public static void checkResult(Response response) throws DtmException { result = IOUtils.toString(inputStream, StandardCharsets.UTF_8); } } catch (IOException e) { - throw new DtmException("response is null"); + throw new FailureException("response is null"); } if (StringUtils.isBlank(result)) { - throw new DtmException("response is null"); + throw new FailureException("response is null"); } if (result.contains(Constants.FAILURE_RESULT)){ - throw new DtmException("Service returned failed"); + throw new FailureException("Service returned failed"); } } } diff --git a/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java b/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java index 1b5bec7..2cde2eb 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java @@ -1,7 +1,7 @@ package pub.dtm.client.utils; import pub.dtm.client.constant.Constants; -import pub.dtm.client.exception.DtmException; +import pub.dtm.client.exception.FailureException; import okhttp3.MediaType; import okhttp3.OkHttpClient; import okhttp3.Request; @@ -49,15 +49,15 @@ public static String splicingUrl(String ip, int port, String path) { public static void checkResult(Response response) throws Exception { if (response.code() >= Constants.RESP_ERR_CODE){ - throw new DtmException(response.message()); + throw new FailureException(response.message()); } ResponseBody body = response.body(); String result; if (body == null || StringUtils.isBlank(result = body.string())) { - throw new DtmException("response is null"); + throw new FailureException("response is null"); } if (result.contains(Constants.FAILURE_RESULT)){ - throw new DtmException("Service returned failed"); + throw new FailureException("Service returned failed"); } } } diff --git a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst index cb90b51..69be70b 100644 --- a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ b/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -5,9 +5,9 @@ pub/dtm/client/utils/FeignUtils.class pub/dtm/client/model/param/OperatorParam.class pub/dtm/client/enums/TransTypeEnum.class pub/dtm/client/model/dtm/TransBase.class +pub/dtm/client/exception/FailureException.class pub/dtm/client/model/feign/ServiceMessage.class pub/dtm/client/interfaces/dtm/DtmConsumer.class pub/dtm/client/constant/Constants.class pub/dtm/client/interfaces/feign/IDtmFeignClient.class -pub/dtm/client/exception/DtmException.class pub/dtm/client/interfaces/feign/IURIParser.class diff --git a/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java index a87093e..78913df 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java @@ -3,7 +3,7 @@ import com.google.gson.Gson; import pub.dtm.client.constant.ParamFieldConstants; import pub.dtm.client.enums.TransTypeEnum; -import pub.dtm.client.exception.DtmException; +import pub.dtm.client.exception.FailureException; import pub.dtm.client.interfaces.dtm.DtmConsumer; import lombok.Data; import lombok.NoArgsConstructor; @@ -31,7 +31,7 @@ public class BranchBarrier extends TransBase { public BranchBarrier(Map paramsMap) throws Exception { if (paramsMap == null || paramsMap.isEmpty()) { - throw new DtmException("build BranchBarrier error, paramsMap can not be empty."); + throw new FailureException("build BranchBarrier error, paramsMap can not be empty."); } Gson gson = new Gson(); BarrierParam barrierParam = gson.fromJson(gson.toJson(paramsMap), BarrierParam.class); diff --git a/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java index 4d3fe3d..860a185 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java @@ -5,7 +5,7 @@ import pub.dtm.client.constant.Constants; import pub.dtm.client.constant.ParamFieldConstants; import pub.dtm.client.enums.TransTypeEnum; -import pub.dtm.client.exception.DtmException; +import pub.dtm.client.exception.FailureException; import pub.dtm.client.interfaces.dtm.DtmConsumer; import pub.dtm.client.interfaces.feign.IDtmFeignClient; import pub.dtm.client.model.dtm.TransBase; @@ -53,7 +53,7 @@ public String tccGlobalTransaction(DtmConsumer consumer) throws Exception { log.info("prepare response: {}", resp); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction prepare fail. returned dtm_result is: {}, transaction gid: {}", resp.getDtmResult(), this.getGid()); - throw new DtmException("TCC Transaction prepare fail"); + throw new FailureException("TCC Transaction prepare fail"); } try { consumer.accept(this); @@ -61,7 +61,7 @@ public String tccGlobalTransaction(DtmConsumer consumer) throws Exception { } catch (Exception e) { log.error("TCC transaction submit fail, start abort it. transaction gid: {}", this.getGid()); feignClient.abort(operatorParam); - throw new DtmException(e); + throw new FailureException(e); } return this.getGid(); } @@ -77,7 +77,7 @@ public feign.Response callBranch(Object body, ServiceMessage tryMessage, Service DtmResponse resp = feignClient.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); - throw new DtmException("TCC Transaction register branch fail"); + throw new FailureException("TCC Transaction register branch fail"); } Map paramsMap = new HashMap<>(); @@ -103,7 +103,7 @@ public Response callBranch(Object body, String tryUrl, String confirmUrl, String DtmResponse resp = feignClient.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); - throw new DtmException("TCC Transaction register branch fail"); + throw new FailureException("TCC Transaction register branch fail"); } Map paramsMap = new HashMap<>(); From 80821ac864dcd7c59f7886017ea7b689f67aebdd Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Wed, 4 May 2022 20:38:07 +0800 Subject: [PATCH 04/24] the desc of update --- NewVersion.md | 17 +++++++++++++++++ pic_ref/newversion.png | Bin 0 -> 34833 bytes pic_ref/oldversion.png | Bin 0 -> 18873 bytes 3 files changed, 17 insertions(+) create mode 100644 NewVersion.md create mode 100644 pic_ref/newversion.png create mode 100644 pic_ref/oldversion.png diff --git a/NewVersion.md b/NewVersion.md new file mode 100644 index 0000000..883524d --- /dev/null +++ b/NewVersion.md @@ -0,0 +1,17 @@ +# new version +新版本相比于旧版本Java client的的改造 +## 旧版本客户端 +![avatar](pic_ref/oldversion.png) +### 旧版本在设计上可以改进的一些地方 +1.引入的类从引入路径看不出来自哪个jar包,比如exception.FailureException。在大型项目中可能会出现多个相同的类名,如果不明确包名可能会导致意义混乱,甚至引入冲突。 +2.tcc等类直接依赖了dtmsvr信息,这样的依赖方式对后期的维护不友好,如果修改了DtmServerInfo的属性,那么后期需要修改所有支持的方式。应该做一个客户端这样的东西专门用来发送请求。 +3.向dtmsvr传递参数时使用了map来传递,虽然这对用户是无感知的,但是客户在debug的时候使用map比较麻烦,感觉使用一个param对象比较好 +## 新版本客户端 +![avatar](pic_ref/newversion.png) +### 新版本中改进的地方 +1.由于新版本需要同时支持http和feign两种交互方式,因此将请求dtmsvr相关的部分以及整个client的公共部分抽取出来形成了dtmcli-common模块,这样后续如果需要支持更多的交互方式只需要改动dtmcli-common中的代码,并在core新增代码 +2.springcloud版本的client不在乎需要传入ipport这样的配置参数,一切通过feign+nacos/euraka集成起来处理。因此将java-client和spring-client分开处理了 +3.对于一些非springcloud的项目我们也提供了java-client来处理,java-client支持像以前那样直接配置endpoint的方式,同时为了适配frontend服务,也支持通过配置nacos服务中心地址这样的方式来动态查找dtmsvr具体的地址。 +4.优化了整个项目的包结构,让引入dtmcli-java的时候能够快速找到来自哪个包 + + diff --git a/pic_ref/newversion.png b/pic_ref/newversion.png new file mode 100644 index 0000000000000000000000000000000000000000..57828ec866e7f8244b6d3806066227892d2a352a GIT binary patch literal 34833 zcmb5W1z41S*DX9WC`e05mvpB?4GaxK45@T?#}E=K2ud4RfC!QT2BJtwqaYw6D3a2s zv>+g!J^1{e_c`x5?{}T=x)kAd?)t^vYp=C7DJI4`RL5A4ArJ^EJzXs`1cDHQKoBU9 zlfsdw_QekH4?&2T4hm8A?$iF(w0hTxac{QDihw4`T1NGQLI7QeK# zQ(&ODtCy2Uu#;bixW8K{9D@J%3vl&v_i}Un`x$9TX=yP@IWb9DtdumrjE0OPe36zB zS5Q>2{rh<*4>$jRT~JP35-xDs$jQaaKQti3lV1h}KkNC2y7|Jta2UQ~%;AeQ{FRb) zkdkvy5Q1+t0t0>BtlXRpyxLnb=(xG~1mI86 z^b8L0gCp8fl9J+*;@UjK0&{7booI(htkA&g`&8ili!4${_e zu(a`&4pLIG`THW_Zowg50senKCZ!-QD=zoPt(9>-%eCJt9N>y?rn!Y!tsVO2Nf8#7|q&T*k-A zNz24d$3?*+ToEIuq~t1NuAwg*u7H)(_feEFGP8)1i!ckfLcX=ZE| zWNHCNw1Xo2+_a=ZrEPoyEHom#O}%s_!xTd-!;Q^#yaQ4CSUAbsP~R_HMm9>(#nmrL z4-<}Z^|F@pH!|}IGq=_Zj4)F4u`mb-3AU2;mqLZf8c56eni#=pCZReogD5OY-$KFK z&=Va36M&LIX*+w#h6jfk2H@{*>hCHW0!vTZMpMxuMAB8(#?m#!UCK$x8Kt9#wla$h zH488`HC7DQkBBmJa48;$ntT)Rc?}lQxOa3Dd;MhQUc_OK)d)TTdk$J!iBuHp(f;0Ed&eaq(Bw3bNAj zl*MXVo9lW8dueEUMz{uA>$&@QYijsNY1jtJpe(#mQJMxAEsUX&shdrphNg{ma8Qs1 zPRB*x$v4bQCcw(qGSEXqOIyj>Q^wZY!^+Sm%0$V^*ucfa)-c%DDagz{L>6tXWEo`Y z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e8}H)4S;lvyfUKXEhWZ^1~tP?x4N2e_rD5jM?llP>iE^~nLWh~TR8+fkhz zkcSGuB8c;C>H!nJ>qJeV(O|*1%Tn2=oC|aSy?-8GM9BmC+Bw35YXf3O4U4=8yQ&77 z;FJG;_(NuYxI~r==$Y*&2cJ0606y*k!(>(*0~Se98((q|NKVuPFPN!FA$R}2gTNnF z!EqC?|1%z-KN-UWntL0b)fSCClPfvwQ@W=LK0ad8qn9c{!G`2-zpl_I{#7Lu@gg4h zYye7d%CHEJ!Q0BA=XVlKX&&K${$CHvxCapCzn?G>JvTn^Ri6VFp%n=@p^|_^@l|#= ztW*v)*-g7c{SXB0FXPD^?2+xzzn@8AQ$`p#k0Q`OLrF;E@kqN8@V<%OxHL67#Qp6R j%Z Date: Wed, 4 May 2022 20:43:27 +0800 Subject: [PATCH 05/24] remove target --- .../target/maven-archiver/pom.properties | 5 ----- .../compile/default-compile/createdFiles.lst | 13 ----------- .../compile/default-compile/inputFiles.lst | 13 ----------- .../default-testCompile/inputFiles.lst | 0 .../target/maven-archiver/pom.properties | 5 ----- .../compile/default-compile/createdFiles.lst | 4 ---- .../compile/default-compile/inputFiles.lst | 4 ---- .../default-testCompile/inputFiles.lst | 0 .../target/maven-archiver/pom.properties | 5 ----- .../compile/default-compile/createdFiles.lst | 5 ----- .../compile/default-compile/inputFiles.lst | 5 ----- .../default-testCompile/inputFiles.lst | 0 .../spring-configuration-metadata.json | 22 ------------------- .../target/classes/META-INF/spring.factories | 1 - .../target/maven-archiver/pom.properties | 5 ----- .../compile/default-compile/createdFiles.lst | 6 ----- .../compile/default-compile/inputFiles.lst | 5 ----- .../default-testCompile/inputFiles.lst | 0 18 files changed, 98 deletions(-) delete mode 100644 dtmcli-common/target/maven-archiver/pom.properties delete mode 100644 dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst delete mode 100644 dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst delete mode 100644 dtmcli-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst delete mode 100644 dtmcli-core/target/maven-archiver/pom.properties delete mode 100644 dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst delete mode 100644 dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst delete mode 100644 dtmcli-core/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst delete mode 100644 dtmcli-java/target/maven-archiver/pom.properties delete mode 100644 dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst delete mode 100644 dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst delete mode 100644 dtmcli-java/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst delete mode 100644 dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json delete mode 100644 dtmcli-spring/target/classes/META-INF/spring.factories delete mode 100644 dtmcli-spring/target/maven-archiver/pom.properties delete mode 100644 dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst delete mode 100644 dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst delete mode 100644 dtmcli-spring/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst diff --git a/dtmcli-common/target/maven-archiver/pom.properties b/dtmcli-common/target/maven-archiver/pom.properties deleted file mode 100644 index a97deb0..0000000 --- a/dtmcli-common/target/maven-archiver/pom.properties +++ /dev/null @@ -1,5 +0,0 @@ -#Generated by Maven -#Tue Apr 26 17:58:45 CST 2022 -version=1.0.0 -groupId=pub.dtm -artifactId=dtmcli-common diff --git a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index 69be70b..0000000 --- a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ /dev/null @@ -1,13 +0,0 @@ -pub/dtm/client/model/responses/DtmResponse.class -pub/dtm/client/constant/ParamFieldConstants.class -pub/dtm/client/utils/HttpUtils.class -pub/dtm/client/utils/FeignUtils.class -pub/dtm/client/model/param/OperatorParam.class -pub/dtm/client/enums/TransTypeEnum.class -pub/dtm/client/model/dtm/TransBase.class -pub/dtm/client/exception/FailureException.class -pub/dtm/client/model/feign/ServiceMessage.class -pub/dtm/client/interfaces/dtm/DtmConsumer.class -pub/dtm/client/constant/Constants.class -pub/dtm/client/interfaces/feign/IDtmFeignClient.class -pub/dtm/client/interfaces/feign/IURIParser.class diff --git a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 8a337b3..0000000 --- a/dtmcli-common/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,13 +0,0 @@ -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/exception/DtmException.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java diff --git a/dtmcli-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/dtmcli-common/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst deleted file mode 100644 index e69de29..0000000 diff --git a/dtmcli-core/target/maven-archiver/pom.properties b/dtmcli-core/target/maven-archiver/pom.properties deleted file mode 100644 index 9a7e43f..0000000 --- a/dtmcli-core/target/maven-archiver/pom.properties +++ /dev/null @@ -1,5 +0,0 @@ -#Generated by Maven -#Tue Apr 26 17:58:45 CST 2022 -version=1.0.0 -groupId=pub.dtm -artifactId=dtmcli-core diff --git a/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index d26f489..0000000 --- a/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ /dev/null @@ -1,4 +0,0 @@ -pub/dtm/client/tcc/Tcc.class -pub/dtm/client/barrier/BranchBarrier.class -pub/dtm/client/barrier/BarrierParam.class -pub/dtm/client/base/BranchIdGenerator.class diff --git a/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 85e740c..0000000 --- a/dtmcli-core/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,4 +0,0 @@ -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java diff --git a/dtmcli-core/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/dtmcli-core/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst deleted file mode 100644 index e69de29..0000000 diff --git a/dtmcli-java/target/maven-archiver/pom.properties b/dtmcli-java/target/maven-archiver/pom.properties deleted file mode 100644 index 7b70382..0000000 --- a/dtmcli-java/target/maven-archiver/pom.properties +++ /dev/null @@ -1,5 +0,0 @@ -#Generated by Maven -#Tue Apr 26 17:58:47 CST 2022 -version=1.0.0 -groupId=pub.dtm -artifactId=dtmcli-java diff --git a/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index 2e58121..0000000 --- a/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ /dev/null @@ -1,5 +0,0 @@ -pub/dtm/client/utils/NacosUtils.class -pub/dtm/client/feign/DtmFeignClient.class -pub/dtm/client/feign/URIParser.class -pub/dtm/client/DtmClient.class -pub/dtm/client/properties/DtmProperties.class diff --git a/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 6386389..0000000 --- a/dtmcli-java/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,5 +0,0 @@ -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java diff --git a/dtmcli-java/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/dtmcli-java/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst deleted file mode 100644 index e69de29..0000000 diff --git a/dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json b/dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json deleted file mode 100644 index a141efd..0000000 --- a/dtmcli-spring/target/classes/META-INF/spring-configuration-metadata.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "groups": [ - { - "name": "dtm.service", - "type": "pub.dtm.client.properties.DtmProperties", - "sourceType": "pub.dtm.client.properties.DtmProperties" - } - ], - "properties": [ - { - "name": "dtm.service.name", - "type": "java.lang.String", - "sourceType": "pub.dtm.client.properties.DtmProperties" - }, - { - "name": "dtm.service.registry-type", - "type": "java.lang.String", - "sourceType": "pub.dtm.client.properties.DtmProperties" - } - ], - "hints": [] -} \ No newline at end of file diff --git a/dtmcli-spring/target/classes/META-INF/spring.factories b/dtmcli-spring/target/classes/META-INF/spring.factories deleted file mode 100644 index f780708..0000000 --- a/dtmcli-spring/target/classes/META-INF/spring.factories +++ /dev/null @@ -1 +0,0 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=pub.dtm.client.configuration.DtmConfiguration \ No newline at end of file diff --git a/dtmcli-spring/target/maven-archiver/pom.properties b/dtmcli-spring/target/maven-archiver/pom.properties deleted file mode 100644 index 79c9b9e..0000000 --- a/dtmcli-spring/target/maven-archiver/pom.properties +++ /dev/null @@ -1,5 +0,0 @@ -#Generated by Maven -#Tue Apr 26 17:58:46 CST 2022 -version=1.0.0 -groupId=pub.dtm -artifactId=dtmcli-spring diff --git a/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst deleted file mode 100644 index e23c293..0000000 --- a/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst +++ /dev/null @@ -1,6 +0,0 @@ -META-INF/spring-configuration-metadata.json -pub/dtm/client/feign/URIParser.class -pub/dtm/client/feign/DtmFeignClient.class -pub/dtm/client/configuration/DtmConfiguration.class -pub/dtm/client/DtmClient.class -pub/dtm/client/properties/DtmProperties.class diff --git a/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 25eb68e..0000000 --- a/dtmcli-spring/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,5 +0,0 @@ -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java -/Users/horse/ideaProjects/dtmcli-java-parent/dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java diff --git a/dtmcli-spring/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/dtmcli-spring/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst deleted file mode 100644 index e69de29..0000000 From fe3405d59fc60a72505dbb04ae71a46f7688bf9d Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Wed, 4 May 2022 20:44:36 +0800 Subject: [PATCH 06/24] remove target --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index e7ad09b..d4dd614 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,4 @@ hs_err_pid* .idea *.iml -/target \ No newline at end of file +/*/target/ \ No newline at end of file From 46aac732af3a037ca27bd0e6fc8b97bbf174ad73 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Sun, 8 May 2022 21:01:33 +0800 Subject: [PATCH 07/24] support saga & code fix --- LICENSE | 2 +- dtmcli-common/pom.xml | 6 +- .../pub/dtm/client/constant/Constants.java | 29 +++ .../client/constant/ParamFieldConstants.java | 49 +++++ .../pub/dtm/client/enums/TransTypeEnum.java | 62 +++++- .../client/exception/FailureException.java | 29 +++ .../client/interfaces/dtm/DtmConsumer.java | 30 +++ .../interfaces/feign/IDtmFeignClient.java | 40 ++++ .../client/interfaces/feign/IURIParser.java | 36 ++++ .../pub/dtm/client/log/DtmFeignLogger.java | 63 ++++++ .../pub/dtm/client/model/dtm/TransBase.java | 34 +++- .../client/model/feign/ServiceMessage.java | 74 ++++--- .../dtm/client/model/param/OperatorParam.java | 82 ++++---- .../client/model/param/SagaOperatorParam.java | 82 ++++++++ .../client/model/param/TccOperatorParam.java | 81 ++++++++ .../client/model/responses/DtmResponse.java | 38 +++- .../java/pub/dtm/client/utils/FeignUtils.java | 53 ++++++ .../java/pub/dtm/client/utils/HttpUtils.java | 60 ++++++ .../java/pub/dtm/client/utils/JsonUtils.java | 51 +++++ .../pub/dtm/client/barrier/BarrierParam.java | 37 +++- .../pub/dtm/client/barrier/BranchBarrier.java | 51 ++++- .../dtm/client/base/BranchIdGenerator.java | 41 +++- .../main/java/pub/dtm/client/saga/Saga.java | 180 ++++++++++++++++++ .../src/main/java/pub/dtm/client/tcc/Tcc.java | 91 +++++++-- dtmcli-java/pom.xml | 7 +- .../main/java/pub/dtm/client/DtmClient.java | 76 +++++++- .../pub/dtm/client/feign/DtmFeignClient.java | 30 ++- .../java/pub/dtm/client/feign/URIParser.java | 28 ++- .../dtm/client/properties/DtmProperties.java | 24 +++ .../java/pub/dtm/client/utils/NacosUtils.java | 24 +++ .../main/java/pub/dtm/client/DtmClient.java | 51 +++++ .../configuration/DtmConfiguration.java | 40 ++++ .../pub/dtm/client/feign/DtmFeignClient.java | 24 +++ .../java/pub/dtm/client/feign/URIParser.java | 24 +++ .../dtm/client/properties/DtmProperties.java | 24 +++ pom.xml | 13 +- 36 files changed, 1535 insertions(+), 131 deletions(-) create mode 100644 dtmcli-common/src/main/java/pub/dtm/client/log/DtmFeignLogger.java create mode 100644 dtmcli-common/src/main/java/pub/dtm/client/model/param/SagaOperatorParam.java create mode 100644 dtmcli-common/src/main/java/pub/dtm/client/model/param/TccOperatorParam.java create mode 100644 dtmcli-common/src/main/java/pub/dtm/client/utils/JsonUtils.java create mode 100644 dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java diff --git a/LICENSE b/LICENSE index d9b58da..5dabd2b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 yedf +Copyright (c) 2022 yedf Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/pom.xml b/dtmcli-common/pom.xml index 17984f8..7d8cf22 100644 --- a/dtmcli-common/pom.xml +++ b/dtmcli-common/pom.xml @@ -21,14 +21,10 @@ - - com.google.code.gson - gson - com.fasterxml.jackson.core - jackson-annotations + jackson-databind diff --git a/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java b/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java index 84e71bb..1beb3f5 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java @@ -1,5 +1,34 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.constant; +/** + * Constants + * + * @author horseLk + */ public class Constants { public static final String MICRO_SERVICE_NAME_KEY = "dtm.service.name"; diff --git a/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java b/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java index 0b0c747..eea3fb4 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java @@ -1,5 +1,34 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.constant; +/** + * Constants for dtm server parameter key + * + * @author horseLk + */ public class ParamFieldConstants { public static final String GID = "gid"; @@ -24,4 +53,24 @@ public class ParamFieldConstants { public static final String MESSAGE = "message"; public static final String DTM_RESULT = "dtm_result"; + + public static final String ACTION = "action"; + + public static final String COMPENSATE = "compensate"; + + public static final String STEPS = "steps"; + + public static final String PAYLOADS = "payloads"; + + public static final String CUSTOM_DATA = "custom_data"; + + public static final String WAIT_RESULT = "wait_result"; + + public static final String TIMEOUT_TO_FAIL = "timeout_to_fail"; + + public static final String RETRY_INTERVAL = "retry_interval"; + + public static final String PASSTHROGH_HEADERS = "passthrough_headers"; + + public static final String BRANCH_HEADERS = "branch_headers"; } diff --git a/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java b/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java index 0f06343..c136495 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java @@ -1,9 +1,53 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.enums; +import java.util.HashMap; +import java.util.Map; + +/** + * Transtype enum + * + * @author horseLk + */ public enum TransTypeEnum { + /** + * tcc + */ TCC("tcc"), + /** + * xa + */ XA("xa"), + /** + * msg + */ MSG("msg"), + /** + * saga + */ SAGA("saga") ; @@ -11,19 +55,23 @@ public enum TransTypeEnum { this.value = value; } - private String value; + /** + * Trans type string + */ + private final String value; - @Override - public String toString() { + public String getValue() { return this.value; } + private static Map exist = new HashMap<>(); + public static TransTypeEnum parseString(String value) { - for (TransTypeEnum transType : TransTypeEnum.values()) { - if (transType.value.equals(value)) { - return transType; + if (exist.isEmpty()) { + for (TransTypeEnum transType : TransTypeEnum.values()) { + exist.put(transType.value, transType); } } - return null; + return exist.get(value); } } diff --git a/dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java b/dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java index d09487f..de02747 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java @@ -1,5 +1,34 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.exception; +/** + * dtm common exception + * + * @author horseLk + */ public class FailureException extends Exception { public FailureException(String msg) { super(msg); diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java index 8f3cda1..35dd954 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java @@ -1,7 +1,37 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.interfaces.dtm; import pub.dtm.client.model.dtm.TransBase; +/** + * Functional Interface for Transtype to process busi request + * + * @param + * @author horseLk + */ @FunctionalInterface public interface DtmConsumer { void accept(T t) throws Exception; diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java index b2d8122..f3fde98 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java @@ -7,20 +7,60 @@ import java.net.URI; import java.util.Map; +/** + * A feign client interface for dtm svr, we designed different implements for different client. + * + * @author horseLk + */ public interface IDtmFeignClient { + /** + * get a new gid + */ DtmResponse newGid(); + /** + * test connection + */ DtmResponse ping(); + /** + * prepare + * @param body prepare body + */ DtmResponse prepare(OperatorParam body); + /** + * submit + * @param body submit bosy + */ DtmResponse submit(OperatorParam body); + /** + * abort + * @param body abort body + */ DtmResponse abort(OperatorParam body); + /** + * registerBranch + * @param body registerBranch body + */ DtmResponse registerBranch(OperatorParam body); + /** + * use feign send busi get request + * @param host busi host + * @param path busi path + * @param queryMap querymao + */ Response busiGet(URI host, String path, Map queryMap); + /** + * use feign send busi post request + * @param host busi host + * @param path busi path + * @param queryMap query map + * @param body request body + */ Response busiPost(URI host, String path, Map queryMap, Object body); } diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java index c742355..2c1c162 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java @@ -1,7 +1,43 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.interfaces.feign; import pub.dtm.client.model.feign.ServiceMessage; +/** + * URI Parser interface + * + * @author horseLk + */ public interface IURIParser { + /** + * according to serviceMessage and connection driver generate uri + * @param serviceMessage service message + * @param httpType true means http, false means microservice + * @return uri + * @throws Exception exception + */ String generatorURI(ServiceMessage serviceMessage, boolean httpType) throws Exception; } diff --git a/dtmcli-common/src/main/java/pub/dtm/client/log/DtmFeignLogger.java b/dtmcli-common/src/main/java/pub/dtm/client/log/DtmFeignLogger.java new file mode 100644 index 0000000..fb1a27b --- /dev/null +++ b/dtmcli-common/src/main/java/pub/dtm/client/log/DtmFeignLogger.java @@ -0,0 +1,63 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package pub.dtm.client.log; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Custom feign logger for print detail feign log + * + * @author horseLk + */ +public class DtmFeignLogger extends feign.Logger { + private final Logger logger; + + public DtmFeignLogger() { + this(feign.Logger.class); + } + + public DtmFeignLogger(Class clazz) { + this(LoggerFactory.getLogger(clazz)); + } + + public DtmFeignLogger(String name) { + this(LoggerFactory.getLogger(name)); + } + + DtmFeignLogger(Logger logger) { + this.logger = logger; + } + + @Override + protected void log(String configKey, String format, Object... args) { + // Not using SLF4J's support for parameterized messages (even though it + // would be more efficient) because it would + // require the incoming message formats to be SLF4J-specific. + if (logger.isInfoEnabled()) { + logger.info(String.format(methodTag(configKey) + format, args)); + } + } +} diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java b/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java index 0fd84f2..9a3070a 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java @@ -1,3 +1,27 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.model.dtm; import pub.dtm.client.enums.TransTypeEnum; @@ -5,6 +29,11 @@ import lombok.Data; import lombok.NoArgsConstructor; +/** + * base Class for different Trans type + * + * @author horseLk + */ @Data @NoArgsConstructor @AllArgsConstructor @@ -15,9 +44,12 @@ public class TransBase { private String gid; /** - * 事务类型 + * trans type */ private TransTypeEnum transTypeEnum; + /** + * is wait for result + */ private boolean waitResult; } diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java b/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java index ed5c685..34a824c 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java @@ -1,18 +1,62 @@ -package pub.dtm.client.model.feign; +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package pub.dtm.client.model.feign; +import lombok.Data; +import lombok.NoArgsConstructor; import org.apache.commons.lang3.StringUtils; import java.util.ArrayList; import java.util.List; +/** + * Service message for micro service + * + * @author horseLk + */ +@Data +@NoArgsConstructor public class ServiceMessage { + /** + * service name + */ private String serviceName; + /** + * group name + */ private String groupName = "DEFAULT_GROUP"; + /** + * clusters + */ private List cluster = new ArrayList<>(); + /** + * request path + */ private String path; public ServiceMessage(String serviceName, String path){ @@ -27,30 +71,6 @@ public ServiceMessage(String serviceName, String groupName, List cluster this.path = path; } - public String getServiceName() { - return serviceName; - } - - public void setServiceName(String serviceName) { - this.serviceName = serviceName; - } - - public String getGroupName() { - return groupName; - } - - public void setGroupName(String groupName) { - this.groupName = groupName; - } - - public List getCluster() { - return cluster; - } - - public void setCluster(List cluster) { - this.cluster = cluster; - } - public String getPath() { if (StringUtils.startsWith(path, "/")) { return path; @@ -58,10 +78,6 @@ public String getPath() { return "/" + path; } - public void setPath(String path) { - this.path = path; - } - @Override public String toString() { String _path = path; diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java b/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java index d6e0834..f523278 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java @@ -1,58 +1,72 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.model.param; import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.gson.annotations.SerializedName; +import com.fasterxml.jackson.annotation.JsonSubTypes; +import com.fasterxml.jackson.annotation.JsonTypeInfo; import pub.dtm.client.constant.ParamFieldConstants; import pub.dtm.client.enums.TransTypeEnum; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +/** + * Request Param for dtm svr + * + * @author horseLk + */ @Data @NoArgsConstructor @AllArgsConstructor +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "subType") +@JsonSubTypes({ + @JsonSubTypes.Type(value = TccOperatorParam.class, name = "tcc"), + @JsonSubTypes.Type(value = SagaOperatorParam.class, name = "saga") +}) public class OperatorParam { - @SerializedName(ParamFieldConstants.GID) + /** + * gid + */ @JsonProperty(ParamFieldConstants.GID) private String gid; - @SerializedName(ParamFieldConstants.TRANS_TYPE) + /** + * trans type string value + */ @JsonProperty(ParamFieldConstants.TRANS_TYPE) private String transType; - @SerializedName(ParamFieldConstants.BRANCH_ID) - @JsonProperty(ParamFieldConstants.BRANCH_ID) - private String branchId; - - @SerializedName(ParamFieldConstants.STATUS) - @JsonProperty(ParamFieldConstants.STATUS) - private String status; - - @SerializedName(ParamFieldConstants.DATA) - @JsonProperty(ParamFieldConstants.DATA) - private String data; - - @SerializedName(ParamFieldConstants.CONFIRM) - @JsonProperty(ParamFieldConstants.CONFIRM) - private String confirm; - - @SerializedName(ParamFieldConstants.CANCEL) - @JsonProperty(ParamFieldConstants.CANCEL) - private String cancel; - - public OperatorParam(String gid, TransTypeEnum transType, String branchId, - String status, String data, String confirmUrl, String cancelUrl) { - this.gid = gid; - this.transType = transType.toString(); - this.branchId = branchId; - this.status = status; - this.data = data; - this.confirm = confirmUrl; - this.cancel = cancelUrl; - } + /** + * this attribute just for mark different sub class for encode/decode. + */ + @JsonProperty("subType") + private String subType; public OperatorParam(String gid, TransTypeEnum transType) { this.gid = gid; - this.transType = transType.toString(); + this.transType = transType.getValue(); } } diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/param/SagaOperatorParam.java b/dtmcli-common/src/main/java/pub/dtm/client/model/param/SagaOperatorParam.java new file mode 100644 index 0000000..6a25dad --- /dev/null +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/param/SagaOperatorParam.java @@ -0,0 +1,82 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package pub.dtm.client.model.param; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import pub.dtm.client.constant.ParamFieldConstants; +import pub.dtm.client.enums.TransTypeEnum; + +import java.util.List; +import java.util.Map; + +/** + * Saga Operator Param + * + * @author horseLk + */ +@Data +@NoArgsConstructor +public class SagaOperatorParam extends OperatorParam { + @JsonProperty(ParamFieldConstants.STEPS) + private List> steps; + + @JsonProperty(ParamFieldConstants.PAYLOADS) + private List payloads; + + @JsonProperty(ParamFieldConstants.CUSTOM_DATA) + private String customData; + + @JsonProperty(ParamFieldConstants.WAIT_RESULT) + private boolean waitResult; + + @JsonProperty(ParamFieldConstants.TIMEOUT_TO_FAIL) + private long timeoutToFail; + + @JsonProperty(ParamFieldConstants.RETRY_INTERVAL) + private long retryInterval; + + @JsonProperty(ParamFieldConstants.PASSTHROGH_HEADERS) + private List passthroughHeaders; + + @JsonProperty(ParamFieldConstants.BRANCH_HEADERS) + private Map branchHeaders; + + public SagaOperatorParam(String gid, TransTypeEnum transType, List> steps, + List payloads, String customData, boolean waitResult, long timeoutToFail, + long retryInterval, List passthroughHeaders, Map branchHeaders) { + super(gid, transType); + setSubType(transType.getValue()); + this.steps = steps; + this.payloads = payloads; + this.customData = customData; + this.waitResult = waitResult; + this.timeoutToFail = timeoutToFail; + this.retryInterval = retryInterval; + this.passthroughHeaders = passthroughHeaders; + this.branchHeaders = branchHeaders; + } +} diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/param/TccOperatorParam.java b/dtmcli-common/src/main/java/pub/dtm/client/model/param/TccOperatorParam.java new file mode 100644 index 0000000..1bb4175 --- /dev/null +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/param/TccOperatorParam.java @@ -0,0 +1,81 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package pub.dtm.client.model.param; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.NoArgsConstructor; +import pub.dtm.client.constant.ParamFieldConstants; +import pub.dtm.client.enums.TransTypeEnum; + +/** + * Tcc Operator Param + * @author horseLk + */ +@Data +@NoArgsConstructor +public class TccOperatorParam extends OperatorParam { + /** + * branch id + */ + @JsonProperty(ParamFieldConstants.BRANCH_ID) + private String branchId; + + /** + * status + */ + @JsonProperty(ParamFieldConstants.STATUS) + private String status; + + /** + * data + */ + @JsonProperty(ParamFieldConstants.DATA) + private String data; + + /** + * branch confirm uri + */ + @JsonProperty(ParamFieldConstants.CONFIRM) + private String confirm; + + /** + * branch cancel uri + */ + @JsonProperty(ParamFieldConstants.CANCEL) + private String cancel; + + + public TccOperatorParam(String gid, TransTypeEnum transTypeEnum, String branchId, String status, String data, + String confirm, String cancel) { + super(gid, transTypeEnum); + setSubType(transTypeEnum.getValue()); + this.branchId = branchId; + this.status = status; + this.data = data; + this.confirm = confirm; + this.cancel = cancel; + } +} diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java b/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java index 8d2c659..8ad9a68 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java @@ -1,20 +1,52 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.model.responses; import com.fasterxml.jackson.annotation.JsonProperty; -import com.google.gson.annotations.SerializedName; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +/** + * Response from dtm svr + * + * @author horseLk + */ @Data @AllArgsConstructor @NoArgsConstructor public class DtmResponse { - @SerializedName("dtm_result") + /** + * dtm_result + */ @JsonProperty("dtm_result") private String dtmResult; - @SerializedName("gid") + /** + * gid + */ @JsonProperty("gid") private String gid; diff --git a/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java b/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java index 348ec03..4f9d38e 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java @@ -1,3 +1,27 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.utils; import pub.dtm.client.constant.Constants; @@ -15,15 +39,32 @@ import java.io.InputStream; import java.nio.charset.StandardCharsets; +/** + * Feign Utils + * + * @author horseLk + */ public class FeignUtils { + /** + * log + */ private static final Logger log = LoggerFactory.getLogger(FeignUtils.class); + /** + * URIParser + */ private static IURIParser uriParser; public static void setUriParser(IURIParser uriParser) { FeignUtils.uriParser = uriParser; } + /** + * Get gid from DtmResponse + * @param base dtmResponse + * @return gid + * @throws Exception exception + */ public static String parseGid(DtmResponse base) throws Exception { if (base == null || !Constants.SUCCESS_RESULT.equals(base.getDtmResult())) { throw new Exception("get new gid from dtm server fail."); @@ -31,10 +72,22 @@ public static String parseGid(DtmResponse base) throws Exception { return base.getGid(); } + /** + * generate uri + * @param serviceMessage service message + * @param httpType true means http, false means micro service + * @return uri + * @throws Exception exception + */ public static String generatorURI(ServiceMessage serviceMessage, boolean httpType) throws Exception { return uriParser.generatorURI(serviceMessage, httpType); } + /** + * check response + * @param response feign response + * @throws FailureException exception + */ public static void checkResult(Response response) throws FailureException { if (response.status() >= Constants.RESP_ERR_CODE){ if (response.reason() != null) { diff --git a/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java b/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java index 2cde2eb..f04d24e 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java @@ -1,3 +1,27 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.utils; import pub.dtm.client.constant.Constants; @@ -14,23 +38,47 @@ import java.util.Map; import java.util.concurrent.TimeUnit; +/** + * Http utils + * + * @author horseLk + */ public class HttpUtils { private static final OkHttpClient CLIENT = new OkHttpClient.Builder().connectTimeout(15, TimeUnit.SECONDS) .readTimeout(5, TimeUnit.SECONDS).writeTimeout(5, TimeUnit.SECONDS).build(); public static final MediaType MEDIA_TYPE = MediaType.get("application/json; charset=utf-8"); + /** + * send get request + * @param url url + * @return http response + * @throws IOException exception + */ public static Response get(String url) throws IOException { Request request = new Request.Builder().url(url).get().build(); return CLIENT.newCall(request).execute(); } + /** + * send post request + * @param url url + * @param json body json + * @return http response + * @throws IOException exception + */ public static Response post(String url, String json) throws IOException { RequestBody body = RequestBody.create(MEDIA_TYPE, json); Request request = new Request.Builder().url(url).post(body).build(); return CLIENT.newCall(request).execute(); } + /** + * splice url with query map + * @param url main url + * @param params query map + * @return string + */ public static String splicingUrl(String url, Map params) { if (params == null || params.isEmpty()) { return url; @@ -43,10 +91,22 @@ public static String splicingUrl(String url, Map params) { } + /** + * splice url without query map + * @param ip ip + * @param port port + * @param path path + * @return string + */ public static String splicingUrl(String ip, int port, String path) { return Constants.HTTP_PREFIX + ip + ":" + String.valueOf(port) + path; } + /** + * check response + * @param response http response + * @throws Exception exception + */ public static void checkResult(Response response) throws Exception { if (response.code() >= Constants.RESP_ERR_CODE){ throw new FailureException(response.message()); diff --git a/dtmcli-common/src/main/java/pub/dtm/client/utils/JsonUtils.java b/dtmcli-common/src/main/java/pub/dtm/client/utils/JsonUtils.java new file mode 100644 index 0000000..ca381c2 --- /dev/null +++ b/dtmcli-common/src/main/java/pub/dtm/client/utils/JsonUtils.java @@ -0,0 +1,51 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package pub.dtm.client.utils; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.IOException; + +/** + * Json Utils + * + * @author horseLk + */ +public class JsonUtils { + private static final ObjectMapper objectMapper = new ObjectMapper(); + + public static T parseJson(String json, Class clzz) throws JsonProcessingException { + return objectMapper.readValue(json, clzz); + } + + public static T parseJson(byte[] bytes, Class clzz) throws IOException { + return objectMapper.readValue(bytes, clzz); + } + + public static String toJson(Object object) throws JsonProcessingException { + return objectMapper.writeValueAsString(object); + } +} diff --git a/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java index a8f9e54..e2d65c8 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java @@ -1,30 +1,59 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.barrier; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +/** + * Branch barrier parameter + * + * @author horseLk + */ @Data @NoArgsConstructor @AllArgsConstructor public class BarrierParam { /** - * 事务类型 + * trans type */ private String trans_type[]; /** - * 全局事务id + * gid */ private String gid[]; /** - * 分支id + * branch id */ private String branch_id[]; /** - * 操作 + * operator */ private String op[]; } diff --git a/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java index 78913df..ac976b8 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java @@ -1,6 +1,29 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.barrier; -import com.google.gson.Gson; import pub.dtm.client.constant.ParamFieldConstants; import pub.dtm.client.enums.TransTypeEnum; import pub.dtm.client.exception.FailureException; @@ -11,6 +34,7 @@ import org.apache.commons.lang3.ArrayUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import pub.dtm.client.utils.JsonUtils; import java.sql.Connection; import java.sql.PreparedStatement; @@ -18,23 +42,36 @@ import java.util.Map; import java.util.Objects; +/** + * Branch barrier service + * + * @author horseLk + */ @Data @NoArgsConstructor public class BranchBarrier extends TransBase { private static final Logger log = LoggerFactory.getLogger(BranchBarrier.class); + /** + * branch id + */ private String branchId; + /** + * operator + */ private String op; + /** + * barrier id + */ private int barrierId; public BranchBarrier(Map paramsMap) throws Exception { if (paramsMap == null || paramsMap.isEmpty()) { throw new FailureException("build BranchBarrier error, paramsMap can not be empty."); } - Gson gson = new Gson(); - BarrierParam barrierParam = gson.fromJson(gson.toJson(paramsMap), BarrierParam.class); + BarrierParam barrierParam = JsonUtils.parseJson(JsonUtils.toJson(paramsMap), BarrierParam.class); if (ArrayUtils.isNotEmpty(barrierParam.getTrans_type())) { this.setTransTypeEnum(TransTypeEnum.parseString(barrierParam.getTrans_type()[0])); } @@ -49,6 +86,12 @@ public BranchBarrier(Map paramsMap) throws Exception { } } + /** + * Busi can call method call() to open branch barrier + * @param connection data source connection + * @param consumer consumer + * @throws Exception exception + */ public void call(Connection connection, DtmConsumer consumer) throws Exception { ++this.barrierId; connection.setAutoCommit(false); @@ -76,7 +119,7 @@ private boolean insertBarrier(Connection connection) throws SQLException { try { String sql = "insert ignore into barrier(trans_type, gid, branch_id, op, barrier_id, reason) values(?,?,?,?,?,?)"; preparedStatement = connection.prepareStatement(sql); - preparedStatement.setString(1, this.getTransTypeEnum().toString()); + preparedStatement.setString(1, this.getTransTypeEnum().getValue()); preparedStatement.setString(2, this.getGid()); preparedStatement.setString(3, branchId); preparedStatement.setString(4, op); diff --git a/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java b/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java index dd6d599..c76fee2 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java @@ -1,12 +1,47 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.base; +/** + * BranchIdGenerator for generate branch id + * + * @author horseLk + */ public class BranchIdGenerator { private static final int MAX_BRANCH_ID = 99; private static final int LENGTH = 20; + /** + * branch id prefix + */ private final String branchId; + /** + * last branch id + */ private int subBranchId; public BranchIdGenerator(String branchId) { @@ -14,10 +49,10 @@ public BranchIdGenerator(String branchId) { } /** - * 生成注册分支id + * generate branch id * - * @return - * @throws Exception + * @return branch id + * @throws Exception exception */ public String genBranchId() throws Exception { if (this.subBranchId >= MAX_BRANCH_ID) { diff --git a/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java b/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java new file mode 100644 index 0000000..d99e8b3 --- /dev/null +++ b/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java @@ -0,0 +1,180 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package pub.dtm.client.saga; + +import lombok.Data; +import lombok.NoArgsConstructor; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import pub.dtm.client.constant.ParamFieldConstants; +import pub.dtm.client.enums.TransTypeEnum; +import pub.dtm.client.exception.FailureException; +import pub.dtm.client.interfaces.feign.IDtmFeignClient; +import pub.dtm.client.model.dtm.TransBase; +import pub.dtm.client.model.feign.ServiceMessage; +import pub.dtm.client.model.param.SagaOperatorParam; +import pub.dtm.client.utils.FeignUtils; +import pub.dtm.client.utils.JsonUtils; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * Saga trans type service + * + * @author horseLk + */ +@Data +@NoArgsConstructor +public class Saga extends TransBase { + private static final Logger log = LoggerFactory.getLogger(Saga.class); + + private static final String ORDERS = "orders"; + + private static final String CONCURRENT = "concurrent"; + + private IDtmFeignClient feignClient; + + private boolean concurrent; + + private Map> orders; + + private long timeoutToFail; + + private long retryInterval; + + private Map branchHeaders = new HashMap<>(); + + private List passthroughHeaders = new ArrayList<>(); + + private String customData; + + private List> steps = new ArrayList<>(); + + private List payloads = new ArrayList<>(); + + public Saga(String gid, IDtmFeignClient feignClient) { + super(gid, TransTypeEnum.SAGA, false); + this.concurrent = false; + this.orders = new HashMap<>(); + this.feignClient = feignClient; + } + + public Saga add(ServiceMessage action, ServiceMessage compensate, Object postData) { + Map step = new HashMap<>(); + try { + step.put(ParamFieldConstants.ACTION, FeignUtils.generatorURI(action, false)); + step.put(ParamFieldConstants.COMPENSATE, FeignUtils.generatorURI(compensate, false)); + this.payloads.add(JsonUtils.toJson(postData)); + } catch (Exception e) { + log.error("saga add branch error."); + } + this.steps.add(step); + + return this; + } + + public Saga add(String action, String compensate, Object postData) { + Map step = new HashMap<>(); + step.put(ParamFieldConstants.ACTION, action); + step.put(ParamFieldConstants.COMPENSATE, compensate); + this.steps.add(step); + try { + this.payloads.add(JsonUtils.toJson(postData)); + } catch (Exception e) { + log.error("encode json error."); + } + return this; + } + + public String submit() throws Exception { + if (StringUtils.isEmpty(this.getGid())) { + this.setGid(FeignUtils.parseGid(feignClient.newGid())); + } + addConcurrentContext(); + SagaOperatorParam operatorParam = new SagaOperatorParam(this.getGid(), TransTypeEnum.SAGA, this.getSteps(), + this.getPayloads(), this.getCustomData(), this.isWaitResult(), this.getTimeoutToFail(), + this.getRetryInterval(), this.getPassthroughHeaders(), this.getBranchHeaders()); + + try { + feignClient.submit(operatorParam); + } catch (Exception e) { + log.error("saga transaction submit failed, transaction gid is {}", this.getGid()); + throw new FailureException(e); + } + return this.getGid(); + } + + public Saga addBranchOrder(Integer branch, List preBranches) { + orders.put(branch.toString(), preBranches); + return this; + } + + public Saga enableConcurrent() { + concurrent = true; + return this; + } + + public Saga enableWaitResult() { + this.setWaitResult(true); + return this; + } + + public Saga setTimeoutToFail(long timeoutToFail) { + this.setTimeoutToFail(timeoutToFail); + return this; + } + + public Saga setRetryInterval(long retryInterval) { + this.setRetryInterval(retryInterval); + return this; + } + + public Saga setBranchHeaders(Map headers) { + this.setBranchHeaders(headers); + return this; + } + + public Saga setPassthroughHeaders(ArrayList passthroughHeaders) { + this.setPassthroughHeaders(passthroughHeaders); + return this; + } + + private void addConcurrentContext() { + if (concurrent) { + HashMap data = new HashMap<>(); + data.put(ORDERS, orders); + data.put(CONCURRENT, true); + try { + this.setCustomData(JsonUtils.toJson(data)); + } catch (Exception e) { + log.error("encode json error."); + } + } + } +} diff --git a/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java index 860a185..0e59655 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java @@ -1,7 +1,31 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.tcc; +import lombok.NoArgsConstructor; import pub.dtm.client.base.BranchIdGenerator; -import com.google.gson.Gson; import pub.dtm.client.constant.Constants; import pub.dtm.client.constant.ParamFieldConstants; import pub.dtm.client.enums.TransTypeEnum; @@ -10,26 +34,40 @@ import pub.dtm.client.interfaces.feign.IDtmFeignClient; import pub.dtm.client.model.dtm.TransBase; import pub.dtm.client.model.feign.ServiceMessage; -import pub.dtm.client.model.param.OperatorParam; import okhttp3.Response; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import pub.dtm.client.model.param.OperatorParam; +import pub.dtm.client.model.param.TccOperatorParam; import pub.dtm.client.model.responses.DtmResponse; import pub.dtm.client.utils.FeignUtils; import pub.dtm.client.utils.HttpUtils; +import pub.dtm.client.utils.JsonUtils; import java.net.URI; import java.util.HashMap; import java.util.Map; +/** + * Tcc trans type service + * + * @author horseLk + */ +@NoArgsConstructor public class Tcc extends TransBase { private static final Logger log = LoggerFactory.getLogger(Tcc.class); private static final String OP = "try"; - private final BranchIdGenerator branchIdGenerator; + /** + * branch id generator + */ + private BranchIdGenerator branchIdGenerator; + /** + * feign client + */ private IDtmFeignClient feignClient; public Tcc(String gid, IDtmFeignClient feignClient) { @@ -42,7 +80,14 @@ public void setFeignClient(IDtmFeignClient feignClient) { this.feignClient = feignClient; } + /** + * start a tcc distribute transaction + * @param consumer consumer + * @return gid + * @throws Exception exception + */ public String tccGlobalTransaction(DtmConsumer consumer) throws Exception { + // if tcc's gid is empty, need to request a new gid from dtm svr if (StringUtils.isEmpty(this.getGid())) { this.setGid(FeignUtils.parseGid(feignClient.newGid())); } @@ -66,14 +111,23 @@ public String tccGlobalTransaction(DtmConsumer consumer) throws Exception { return this.getGid(); } + /** + * busi can call method callBranch() to set tcc transaction's branch. + * the callBranch for micro service driver + * @param body busi body + * @param tryMessage service message of try operator + * @param confirmMessage service message of confirm operator + * @param cancelMessage service message of cancel operator + * @return feign response + * @throws Exception exception + */ public feign.Response callBranch(Object body, ServiceMessage tryMessage, ServiceMessage confirmMessage, ServiceMessage cancelMessage) throws Exception { - Gson gson = new Gson(); log.info("call method Tcc.callBranch, tryMessage: {}, confirmMessage: {}, cancelMessage: {}", - gson.toJson(tryMessage), gson.toJson(confirmMessage), gson.toJson(cancelMessage)); + JsonUtils.toJson(tryMessage), JsonUtils.toJson(confirmMessage), JsonUtils.toJson(cancelMessage)); String branchId = this.branchIdGenerator.genBranchId(); - OperatorParam operatorParam = new OperatorParam(this.getGid(), TransTypeEnum.TCC, Constants.DEFAULT_STATUS, branchId, - gson.toJson(body), FeignUtils.generatorURI(confirmMessage, false), FeignUtils.generatorURI(cancelMessage, false)); + TccOperatorParam operatorParam = new TccOperatorParam(this.getGid(), TransTypeEnum.TCC, branchId, Constants.DEFAULT_STATUS, + JsonUtils.toJson(body), FeignUtils.generatorURI(confirmMessage, false), FeignUtils.generatorURI(cancelMessage, false)); DtmResponse resp = feignClient.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); @@ -82,7 +136,7 @@ public feign.Response callBranch(Object body, ServiceMessage tryMessage, Service Map paramsMap = new HashMap<>(); paramsMap.put(ParamFieldConstants.GID, this.getGid()); - paramsMap.put(ParamFieldConstants.TRANS_TYPE, TransTypeEnum.TCC.toString()); + paramsMap.put(ParamFieldConstants.TRANS_TYPE, TransTypeEnum.TCC.getValue()); paramsMap.put(ParamFieldConstants.BRANCH_ID, branchId); paramsMap.put(ParamFieldConstants.OP, OP); @@ -93,13 +147,22 @@ public feign.Response callBranch(Object body, ServiceMessage tryMessage, Service return response; } + /** + * busi can call method callBranch() to set tcc transaction's branch. + * the callBranch for http driver + * @param body busi body + * @param tryUrl http url of try operator + * @param confirmUrl http url of confirm operator + * @param cancelUrl http url of cancel operator + * @return http response + * @throws Exception exception + */ public Response callBranch(Object body, String tryUrl, String confirmUrl, String cancelUrl) throws Exception { log.info("call method Tcc.callBranch, tryUrl: {}, confirmUrl: {}, cancelUrl: {}", tryUrl, confirmUrl, cancelUrl); - String branchId = branchIdGenerator.genBranchId(); - Gson gson = new Gson(); + String branchId = this.branchIdGenerator.genBranchId(); - OperatorParam operatorParam = new OperatorParam(this.getGid(), TransTypeEnum.TCC, Constants.DEFAULT_STATUS, - branchId, gson.toJson(body), confirmUrl, cancelUrl); + TccOperatorParam operatorParam = new TccOperatorParam(this.getGid(), TransTypeEnum.TCC, branchId, Constants.DEFAULT_STATUS, + JsonUtils.toJson(body), confirmUrl, cancelUrl); DtmResponse resp = feignClient.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); @@ -108,10 +171,10 @@ public Response callBranch(Object body, String tryUrl, String confirmUrl, String Map paramsMap = new HashMap<>(); paramsMap.put(ParamFieldConstants.GID, this.getGid()); - paramsMap.put(ParamFieldConstants.TRANS_TYPE, TransTypeEnum.TCC.toString()); + paramsMap.put(ParamFieldConstants.TRANS_TYPE, TransTypeEnum.TCC.getValue()); paramsMap.put(ParamFieldConstants.BRANCH_ID, branchId); paramsMap.put(ParamFieldConstants.OP, OP); - Response tryResponse = HttpUtils.post(HttpUtils.splicingUrl(tryUrl, paramsMap), gson.toJson(body)); + Response tryResponse = HttpUtils.post(HttpUtils.splicingUrl(tryUrl, paramsMap), JsonUtils.toJson(body)); log.info("try response is: {}", tryResponse); HttpUtils.checkResult(tryResponse); return tryResponse; diff --git a/dtmcli-java/pom.xml b/dtmcli-java/pom.xml index a8f9be0..091b766 100644 --- a/dtmcli-java/pom.xml +++ b/dtmcli-java/pom.xml @@ -32,14 +32,9 @@ nacos-client - - com.google.code.gson - gson - - io.github.openfeign - feign-gson + feign-jackson diff --git a/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java index cac9fad..e4f3fda 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java @@ -1,18 +1,44 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client; import com.alibaba.nacos.api.naming.pojo.Instance; +import feign.jackson.JacksonDecoder; +import feign.jackson.JacksonEncoder; import pub.dtm.client.constant.Constants; import pub.dtm.client.feign.DtmFeignClient; import feign.Feign; import pub.dtm.client.feign.URIParser; -import feign.gson.GsonDecoder; -import feign.gson.GsonEncoder; import pub.dtm.client.interfaces.dtm.DtmConsumer; import pub.dtm.client.interfaces.feign.IDtmFeignClient; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import pub.dtm.client.log.DtmFeignLogger; import pub.dtm.client.properties.DtmProperties; +import pub.dtm.client.saga.Saga; import pub.dtm.client.tcc.Tcc; import pub.dtm.client.utils.NacosUtils; @@ -37,7 +63,7 @@ public DtmClient() { String endpoint = null; try { // redirect connect to dtm - endpoint = DtmProperties.get("dtm.server.endpoint"); + endpoint = DtmProperties.get("dtm.ipport"); // connect to dtm by nacos if (StringUtils.isEmpty(endpoint)) { Instance instance = NacosUtils.selectOneHealthyInstance(DtmProperties.get(Constants.MICRO_SERVICE_NAME_KEY), @@ -54,8 +80,11 @@ public DtmClient() { } IDtmFeignClient feignClient = Feign .builder() - .decoder(new GsonDecoder()) - .encoder(new GsonEncoder()) + .decoder(new JacksonDecoder()) + .encoder(new JacksonEncoder()) +// if you need read detail log of feign, please cancel the note. +// .logLevel(feign.Logger.Level.FULL) +// .logger(new DtmFeignLogger()) .target(DtmFeignClient.class, Constants.HTTP_PREFIX + endpoint); if (feignClient == null) { log.error("initial dtm client for java error, feign client can't be null."); @@ -75,8 +104,11 @@ public DtmClient(String endpoint) { } IDtmFeignClient feignClient = Feign .builder() - .decoder(new GsonDecoder()) - .encoder(new GsonEncoder()) + .decoder(new JacksonDecoder()) + .encoder(new JacksonEncoder()) +// if you need read detail log of feign, please cancel the note. +// .logLevel(feign.Logger.Level.FULL) +// .logger(new DtmFeignLogger()) .target(DtmFeignClient.class, Constants.HTTP_PREFIX + endpoint); if (feignClient == null) { @@ -97,13 +129,43 @@ private List genClusters(String clusterStr) { return Arrays.asList(split); } + /** + * start a tcc transaction without gid, client send a request to dtm svr for obtain a new gid. + * @param function consumer + * @return gid + * @throws Exception exception + */ public String tccGlobalTransaction(DtmConsumer function) throws Exception { Tcc tcc = new Tcc(null, feignClient); return tcc.tccGlobalTransaction(function); } + /** + * start a tcc transaction with a custom gid. + * @param gid gid + * @param function consumer + * @return gid + * @throws Exception exception + */ public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { Tcc tcc = new Tcc(gid, feignClient); return tcc.tccGlobalTransaction(function); } + + /** + * start a saga transaction with custom gid + * @param gid gid + * @return Saga + */ + public Saga newSaga(String gid) { + return new Saga(gid, feignClient); + } + + /** + * start a saga transaction without gid, client send a request to dtm svr for obtain a new gid. + * @return Saga + */ + public Saga newSaga() { + return new Saga(null, feignClient); + } } diff --git a/dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java b/dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java index d4fe99d..3ef1a28 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java @@ -1,6 +1,34 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.feign; -import feign.*; +import feign.Headers; +import feign.Param; +import feign.QueryMap; +import feign.RequestLine; +import feign.Response; import pub.dtm.client.constant.Constants; import pub.dtm.client.interfaces.feign.IDtmFeignClient; import pub.dtm.client.model.param.OperatorParam; diff --git a/dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java b/dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java index ccc73b3..697c7dd 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java @@ -1,3 +1,27 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.feign; import com.alibaba.nacos.api.naming.pojo.Instance; @@ -15,9 +39,9 @@ public class URIParser implements IURIParser { @Override public String generatorURI(ServiceMessage serviceMessage, boolean httpType) throws Exception { - Instance instance = NacosUtils.selectOneHealthyInstance(serviceMessage.getServiceName(), - serviceMessage.getGroupName(), serviceMessage.getCluster()); if (httpType) { + Instance instance = NacosUtils.selectOneHealthyInstance(serviceMessage.getServiceName(), + serviceMessage.getGroupName(), serviceMessage.getCluster()); return Constants.HTTP_PREFIX + instance.toInetAddr(); } return DtmProperties.get("dtm.service.registryType") + "://" + serviceMessage.toString(); diff --git a/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java b/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java index 8c23607..06bb7b9 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java @@ -1,3 +1,27 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.properties; import java.io.FileInputStream; diff --git a/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java b/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java index 53c73a9..4529176 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java @@ -1,3 +1,27 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.utils; import com.alibaba.nacos.api.naming.NamingFactory; diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java b/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java index 3c79d06..bf9b409 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java @@ -1,9 +1,34 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client; import pub.dtm.client.interfaces.dtm.DtmConsumer; import pub.dtm.client.interfaces.feign.IDtmFeignClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import pub.dtm.client.saga.Saga; import pub.dtm.client.tcc.Tcc; @Component @@ -15,13 +40,39 @@ public DtmClient(IDtmFeignClient feignClient) { this.feignClient = feignClient; } + /** + * start a tcc transaction without gid, client send a request to dtm svr for obtain a new gid. + * @return gid + */ public String tccGlobalTransaction(DtmConsumer function) throws Exception { Tcc tcc = new Tcc(null, feignClient); return tcc.tccGlobalTransaction(function); } + /** + * start a tcc transaction with custom gid + * @param gid gid + * @return gid + */ public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { Tcc tcc = new Tcc(gid, feignClient); return tcc.tccGlobalTransaction(function); } + + /** + * start a saga transaction with custom gid + * @param gid gid + * @return Saga + */ + public Saga newSaga(String gid) { + return new Saga(gid, feignClient); + } + + /** + * start a saga transaction without gid, client send a request to dtm svr for obtain a new gid. + * @return Saga + */ + public Saga newSaga() { + return new Saga(null, feignClient); + } } diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java b/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java index 6f11268..5e7d9d7 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java @@ -1,5 +1,30 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.configuration; +import feign.Logger; import pub.dtm.client.feign.URIParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -9,6 +34,7 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; +import pub.dtm.client.log.DtmFeignLogger; import pub.dtm.client.properties.DtmProperties; @Component @@ -26,4 +52,18 @@ public URIParser uriParser() { URIParser.setRegistryType(dtmProperties.getRegistryType()); return new URIParser(); } + + /** + * if you need read detail log, please cancel note. + */ +// @Bean +// Logger.Level feignLoggerLevel() { +// return Logger.Level.FULL; +// } +// +// @Bean +// Logger feignLogger() { +// return new DtmFeignLogger(); +// } + } diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java b/dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java index 5d81022..7c6d7d8 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java @@ -1,3 +1,27 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.feign; import pub.dtm.client.constant.Constants; diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java b/dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java index 160c604..389a648 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java @@ -1,3 +1,27 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.feign; import pub.dtm.client.constant.Constants; diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java b/dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java index f3be4ef..3f7e5d9 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java @@ -1,3 +1,27 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.properties; import lombok.Data; diff --git a/pom.xml b/pom.xml index 7556db6..ba38075 100644 --- a/pom.xml +++ b/pom.xml @@ -24,8 +24,7 @@ 1.8 UTF-8 4.12 - 2.8.6 - 2.13.2 + 2.12.2 1.18.0 11.8 3.12.0 @@ -43,15 +42,9 @@ test - - com.google.code.gson - gson - ${gson.version} - - com.fasterxml.jackson.core - jackson-annotations + jackson-databind ${jackson.version} @@ -69,7 +62,7 @@ io.github.openfeign - feign-gson + feign-jackson ${feign.version} From 1dfd22a3c8431a2e326eac29e4ade8de49a6f070 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Wed, 11 May 2022 21:59:51 +0800 Subject: [PATCH 08/24] fix --- .../pub/dtm/client/enums/TransTypeEnum.java | 15 +-- .../client/interfaces/ICommunicationStub.java | 96 +++++++++++++++++++ .../interfaces/feign/IDtmFeignClient.java | 87 ++++++----------- .../main/java/pub/dtm/client/saga/Saga.java | 12 +-- .../src/main/java/pub/dtm/client/tcc/Tcc.java | 26 ++--- .../main/java/pub/dtm/client/DtmClient.java | 15 +-- .../main/java/pub/dtm/client/DtmClient.java | 16 ++-- .../configuration/DtmConfiguration.java | 1 + 8 files changed, 170 insertions(+), 98 deletions(-) create mode 100644 dtmcli-common/src/main/java/pub/dtm/client/interfaces/ICommunicationStub.java diff --git a/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java b/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java index c136495..77c64d3 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java @@ -64,14 +64,15 @@ public String getValue() { return this.value; } - private static Map exist = new HashMap<>(); + private static final Map EXIST = new HashMap<>(); - public static TransTypeEnum parseString(String value) { - if (exist.isEmpty()) { - for (TransTypeEnum transType : TransTypeEnum.values()) { - exist.put(transType.value, transType); - } + static { + for (TransTypeEnum transType : TransTypeEnum.values()) { + EXIST.put(transType.value, transType); } - return exist.get(value); + } + + public static TransTypeEnum parseString(String value) { + return EXIST.get(value); } } diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/ICommunicationStub.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/ICommunicationStub.java new file mode 100644 index 0000000..4aa7c26 --- /dev/null +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/ICommunicationStub.java @@ -0,0 +1,96 @@ +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package pub.dtm.client.interfaces; + +import feign.Response; +import pub.dtm.client.model.param.OperatorParam; +import pub.dtm.client.model.responses.DtmResponse; + +import java.net.URI; +import java.util.Map; + +/** + * Base stub to communication with server. + * + * @author horseLk + */ +public interface ICommunicationStub { + /** + * get stubType + * @return type + */ + String stubType(); + + /** + * get a new gid + */ + DtmResponse newGid(); + + /** + * test connection + */ + DtmResponse ping(); + + /** + * prepare + * @param body prepare body + */ + DtmResponse prepare(OperatorParam body); + + /** + * submit + * @param body submit bosy + */ + DtmResponse submit(OperatorParam body); + + /** + * abort + * @param body abort body + */ + DtmResponse abort(OperatorParam body); + + /** + * registerBranch + * @param body registerBranch body + */ + DtmResponse registerBranch(OperatorParam body); + + /** + * use feign send busi get request + * @param host busi host + * @param path busi path + * @param queryMap querymao + */ + Response busiGet(URI host, String path, Map queryMap); + + /** + * use feign send busi post request + * @param host busi host + * @param path busi path + * @param queryMap query map + * @param body request body + */ + Response busiPost(URI host, String path, Map queryMap, Object body); +} diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java index f3fde98..b8c87f4 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java @@ -1,66 +1,39 @@ -package pub.dtm.client.interfaces.feign; +/* + * MIT License + * + * Copyright (c) 2022 yedf + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ -import feign.Response; -import pub.dtm.client.model.param.OperatorParam; -import pub.dtm.client.model.responses.DtmResponse; +package pub.dtm.client.interfaces.feign; -import java.net.URI; -import java.util.Map; +import pub.dtm.client.interfaces.ICommunicationStub; /** * A feign client interface for dtm svr, we designed different implements for different client. * * @author horseLk */ -public interface IDtmFeignClient { - /** - * get a new gid - */ - DtmResponse newGid(); - - /** - * test connection - */ - DtmResponse ping(); - - /** - * prepare - * @param body prepare body - */ - DtmResponse prepare(OperatorParam body); - - /** - * submit - * @param body submit bosy - */ - DtmResponse submit(OperatorParam body); - - /** - * abort - * @param body abort body - */ - DtmResponse abort(OperatorParam body); - - /** - * registerBranch - * @param body registerBranch body - */ - DtmResponse registerBranch(OperatorParam body); - - /** - * use feign send busi get request - * @param host busi host - * @param path busi path - * @param queryMap querymao - */ - Response busiGet(URI host, String path, Map queryMap); - - /** - * use feign send busi post request - * @param host busi host - * @param path busi path - * @param queryMap query map - * @param body request body - */ - Response busiPost(URI host, String path, Map queryMap, Object body); +public interface IDtmFeignClient extends ICommunicationStub { + @Override + default String stubType() { + return "feign"; + } } diff --git a/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java b/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java index d99e8b3..ea60a60 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java @@ -32,7 +32,7 @@ import pub.dtm.client.constant.ParamFieldConstants; import pub.dtm.client.enums.TransTypeEnum; import pub.dtm.client.exception.FailureException; -import pub.dtm.client.interfaces.feign.IDtmFeignClient; +import pub.dtm.client.interfaces.ICommunicationStub; import pub.dtm.client.model.dtm.TransBase; import pub.dtm.client.model.feign.ServiceMessage; import pub.dtm.client.model.param.SagaOperatorParam; @@ -58,7 +58,7 @@ public class Saga extends TransBase { private static final String CONCURRENT = "concurrent"; - private IDtmFeignClient feignClient; + private ICommunicationStub communicationStub; private boolean concurrent; @@ -78,11 +78,11 @@ public class Saga extends TransBase { private List payloads = new ArrayList<>(); - public Saga(String gid, IDtmFeignClient feignClient) { + public Saga(String gid, ICommunicationStub communicationStub) { super(gid, TransTypeEnum.SAGA, false); this.concurrent = false; this.orders = new HashMap<>(); - this.feignClient = feignClient; + this.communicationStub = communicationStub; } public Saga add(ServiceMessage action, ServiceMessage compensate, Object postData) { @@ -114,7 +114,7 @@ public Saga add(String action, String compensate, Object postData) { public String submit() throws Exception { if (StringUtils.isEmpty(this.getGid())) { - this.setGid(FeignUtils.parseGid(feignClient.newGid())); + this.setGid(FeignUtils.parseGid(communicationStub.newGid())); } addConcurrentContext(); SagaOperatorParam operatorParam = new SagaOperatorParam(this.getGid(), TransTypeEnum.SAGA, this.getSteps(), @@ -122,7 +122,7 @@ public String submit() throws Exception { this.getRetryInterval(), this.getPassthroughHeaders(), this.getBranchHeaders()); try { - feignClient.submit(operatorParam); + communicationStub.submit(operatorParam); } catch (Exception e) { log.error("saga transaction submit failed, transaction gid is {}", this.getGid()); throw new FailureException(e); diff --git a/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java index 0e59655..9a5535a 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java @@ -30,8 +30,8 @@ import pub.dtm.client.constant.ParamFieldConstants; import pub.dtm.client.enums.TransTypeEnum; import pub.dtm.client.exception.FailureException; +import pub.dtm.client.interfaces.ICommunicationStub; import pub.dtm.client.interfaces.dtm.DtmConsumer; -import pub.dtm.client.interfaces.feign.IDtmFeignClient; import pub.dtm.client.model.dtm.TransBase; import pub.dtm.client.model.feign.ServiceMessage; import okhttp3.Response; @@ -68,16 +68,16 @@ public class Tcc extends TransBase { /** * feign client */ - private IDtmFeignClient feignClient; + private ICommunicationStub communicationStub; - public Tcc(String gid, IDtmFeignClient feignClient) { + public Tcc(String gid, ICommunicationStub communicationStub) { super(gid, TransTypeEnum.TCC, false); this.branchIdGenerator = new BranchIdGenerator(Constants.EMPTY_STRING); - this.feignClient = feignClient; + this.communicationStub = communicationStub; } - public void setFeignClient(IDtmFeignClient feignClient) { - this.feignClient = feignClient; + public void setCommunicationStub(ICommunicationStub communicationStub) { + this.communicationStub = communicationStub; } /** @@ -89,12 +89,12 @@ public void setFeignClient(IDtmFeignClient feignClient) { public String tccGlobalTransaction(DtmConsumer consumer) throws Exception { // if tcc's gid is empty, need to request a new gid from dtm svr if (StringUtils.isEmpty(this.getGid())) { - this.setGid(FeignUtils.parseGid(feignClient.newGid())); + this.setGid(FeignUtils.parseGid(communicationStub.newGid())); } log.info("the tcc transaction's gid is {}", this.getGid()); OperatorParam operatorParam = new OperatorParam(this.getGid(), TransTypeEnum.TCC); - DtmResponse resp = feignClient.prepare(operatorParam); + DtmResponse resp = communicationStub.prepare(operatorParam); log.info("prepare response: {}", resp); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction prepare fail. returned dtm_result is: {}, transaction gid: {}", resp.getDtmResult(), this.getGid()); @@ -102,10 +102,10 @@ public String tccGlobalTransaction(DtmConsumer consumer) throws Exception { } try { consumer.accept(this); - feignClient.submit(operatorParam); + communicationStub.submit(operatorParam); } catch (Exception e) { log.error("TCC transaction submit fail, start abort it. transaction gid: {}", this.getGid()); - feignClient.abort(operatorParam); + communicationStub.abort(operatorParam); throw new FailureException(e); } return this.getGid(); @@ -128,7 +128,7 @@ public feign.Response callBranch(Object body, ServiceMessage tryMessage, Service TccOperatorParam operatorParam = new TccOperatorParam(this.getGid(), TransTypeEnum.TCC, branchId, Constants.DEFAULT_STATUS, JsonUtils.toJson(body), FeignUtils.generatorURI(confirmMessage, false), FeignUtils.generatorURI(cancelMessage, false)); - DtmResponse resp = feignClient.registerBranch(operatorParam); + DtmResponse resp = communicationStub.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); throw new FailureException("TCC Transaction register branch fail"); @@ -140,7 +140,7 @@ public feign.Response callBranch(Object body, ServiceMessage tryMessage, Service paramsMap.put(ParamFieldConstants.BRANCH_ID, branchId); paramsMap.put(ParamFieldConstants.OP, OP); - feign.Response response = feignClient.busiPost(new URI(FeignUtils.generatorURI(tryMessage, true)), + feign.Response response = communicationStub.busiPost(new URI(FeignUtils.generatorURI(tryMessage, true)), tryMessage.getPath(), paramsMap, body); log.info("busi post is: {}", response); FeignUtils.checkResult(response); @@ -163,7 +163,7 @@ public Response callBranch(Object body, String tryUrl, String confirmUrl, String TccOperatorParam operatorParam = new TccOperatorParam(this.getGid(), TransTypeEnum.TCC, branchId, Constants.DEFAULT_STATUS, JsonUtils.toJson(body), confirmUrl, cancelUrl); - DtmResponse resp = feignClient.registerBranch(operatorParam); + DtmResponse resp = communicationStub.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); throw new FailureException("TCC Transaction register branch fail"); diff --git a/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java index e4f3fda..4b2ccdb 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java @@ -31,6 +31,7 @@ import pub.dtm.client.feign.DtmFeignClient; import feign.Feign; import pub.dtm.client.feign.URIParser; +import pub.dtm.client.interfaces.ICommunicationStub; import pub.dtm.client.interfaces.dtm.DtmConsumer; import pub.dtm.client.interfaces.feign.IDtmFeignClient; import org.apache.commons.lang3.StringUtils; @@ -54,7 +55,7 @@ public class DtmClient { private static final Logger log = LoggerFactory.getLogger(DtmClient.class); - private IDtmFeignClient feignClient; + private ICommunicationStub communicationStub; public DtmClient() { // init URIParser @@ -91,7 +92,7 @@ public DtmClient() { System.exit(-1); } - this.feignClient = feignClient; + this.communicationStub = feignClient; } public DtmClient(String endpoint) { @@ -116,7 +117,7 @@ public DtmClient(String endpoint) { System.exit(-1); } - this.feignClient = feignClient; + this.communicationStub = feignClient; } private List genClusters(String clusterStr) { @@ -136,7 +137,7 @@ private List genClusters(String clusterStr) { * @throws Exception exception */ public String tccGlobalTransaction(DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(null, feignClient); + Tcc tcc = new Tcc(null, communicationStub); return tcc.tccGlobalTransaction(function); } @@ -148,7 +149,7 @@ public String tccGlobalTransaction(DtmConsumer function) throws Exception { * @throws Exception exception */ public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(gid, feignClient); + Tcc tcc = new Tcc(gid, communicationStub); return tcc.tccGlobalTransaction(function); } @@ -158,7 +159,7 @@ public String tccGlobalTransaction(String gid, DtmConsumer function) throws * @return Saga */ public Saga newSaga(String gid) { - return new Saga(gid, feignClient); + return new Saga(gid, communicationStub); } /** @@ -166,6 +167,6 @@ public Saga newSaga(String gid) { * @return Saga */ public Saga newSaga() { - return new Saga(null, feignClient); + return new Saga(null, communicationStub); } } diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java b/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java index bf9b409..041f080 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java @@ -24,8 +24,8 @@ package pub.dtm.client; +import pub.dtm.client.interfaces.ICommunicationStub; import pub.dtm.client.interfaces.dtm.DtmConsumer; -import pub.dtm.client.interfaces.feign.IDtmFeignClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import pub.dtm.client.saga.Saga; @@ -34,10 +34,10 @@ @Component public class DtmClient { @Autowired - private IDtmFeignClient feignClient; + private ICommunicationStub communicationStub; - public DtmClient(IDtmFeignClient feignClient) { - this.feignClient = feignClient; + public DtmClient(ICommunicationStub communicationStub) { + this.communicationStub = communicationStub; } /** @@ -45,7 +45,7 @@ public DtmClient(IDtmFeignClient feignClient) { * @return gid */ public String tccGlobalTransaction(DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(null, feignClient); + Tcc tcc = new Tcc(null, communicationStub); return tcc.tccGlobalTransaction(function); } @@ -55,7 +55,7 @@ public String tccGlobalTransaction(DtmConsumer function) throws Exception { * @return gid */ public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(gid, feignClient); + Tcc tcc = new Tcc(gid, communicationStub); return tcc.tccGlobalTransaction(function); } @@ -65,7 +65,7 @@ public String tccGlobalTransaction(String gid, DtmConsumer function) throws * @return Saga */ public Saga newSaga(String gid) { - return new Saga(gid, feignClient); + return new Saga(gid, communicationStub); } /** @@ -73,6 +73,6 @@ public Saga newSaga(String gid) { * @return Saga */ public Saga newSaga() { - return new Saga(null, feignClient); + return new Saga(null, communicationStub); } } diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java b/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java index 5e7d9d7..22e8eb8 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java @@ -25,6 +25,7 @@ package pub.dtm.client.configuration; import feign.Logger; +import pub.dtm.client.DtmClient; import pub.dtm.client.feign.URIParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; From d958ea34b4598284dac8e89631f0a11282479398 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Thu, 12 May 2022 01:32:36 +0800 Subject: [PATCH 09/24] fix --- dtmcli-common/pom.xml | 6 +- .../IDtmCommunicationClient.java} | 6 +- .../{feign => communication}/IURIParser.java | 2 +- .../interfaces/feign/IDtmFeignClient.java | 39 ---- .../java/pub/dtm/client/utils/FeignUtils.java | 2 +- dtmcli-core/pom.xml | 16 +- .../main/java/pub/dtm/client/saga/Saga.java | 12 +- .../src/main/java/pub/dtm/client/tcc/Tcc.java | 26 +-- dtmcli-java/pom.xml | 20 +- .../main/java/pub/dtm/client/DtmClient.java | 26 ++- .../DtmFeignClient.java | 11 +- .../{feign => communication}/URIParser.java | 4 +- dtmcli-spring/pom.xml | 17 +- .../main/java/pub/dtm/client/DtmClient.java | 16 +- .../DtmFeignClient.java | 11 +- .../{feign => communication}/URIParser.java | 4 +- .../configuration/DtmConfiguration.java | 9 +- pom.xml | 202 ++++++++++++++++-- 18 files changed, 284 insertions(+), 145 deletions(-) rename dtmcli-common/src/main/java/pub/dtm/client/interfaces/{ICommunicationStub.java => communication/IDtmCommunicationClient.java} (92%) rename dtmcli-common/src/main/java/pub/dtm/client/interfaces/{feign => communication}/IURIParser.java (97%) delete mode 100644 dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java rename dtmcli-java/src/main/java/pub/dtm/client/{feign => communication}/DtmFeignClient.java (90%) rename dtmcli-java/src/main/java/pub/dtm/client/{feign => communication}/URIParser.java (95%) rename dtmcli-spring/src/main/java/pub/dtm/client/{feign => communication}/DtmFeignClient.java (91%) rename dtmcli-spring/src/main/java/pub/dtm/client/{feign => communication}/URIParser.java (94%) diff --git a/dtmcli-common/pom.xml b/dtmcli-common/pom.xml index 7d8cf22..19ce8ea 100644 --- a/dtmcli-common/pom.xml +++ b/dtmcli-common/pom.xml @@ -4,13 +4,13 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> dtmcli-java-parent - pub.dtm - 1.0.0 + io.github.dtm-labs + 2.0.3-Release 4.0.0 dtmcli-common - 1.0.0 + 2.0.3-Release jar dtmcli-common diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/ICommunicationStub.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IDtmCommunicationClient.java similarity index 92% rename from dtmcli-common/src/main/java/pub/dtm/client/interfaces/ICommunicationStub.java rename to dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IDtmCommunicationClient.java index 4aa7c26..9e61358 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/ICommunicationStub.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IDtmCommunicationClient.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.interfaces; +package pub.dtm.client.interfaces.communication; import feign.Response; import pub.dtm.client.model.param.OperatorParam; @@ -32,11 +32,11 @@ import java.util.Map; /** - * Base stub to communication with server. + * A feign client interface for dtm svr, we designed different implements for different client. * * @author horseLk */ -public interface ICommunicationStub { +public interface IDtmCommunicationClient { /** * get stubType * @return type diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IURIParser.java similarity index 97% rename from dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java rename to dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IURIParser.java index 2c1c162..d994fca 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IURIParser.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IURIParser.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.interfaces.feign; +package pub.dtm.client.interfaces.communication; import pub.dtm.client.model.feign.ServiceMessage; diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java deleted file mode 100644 index b8c87f4..0000000 --- a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/feign/IDtmFeignClient.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * MIT License - * - * Copyright (c) 2022 yedf - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -package pub.dtm.client.interfaces.feign; - -import pub.dtm.client.interfaces.ICommunicationStub; - -/** - * A feign client interface for dtm svr, we designed different implements for different client. - * - * @author horseLk - */ -public interface IDtmFeignClient extends ICommunicationStub { - @Override - default String stubType() { - return "feign"; - } -} diff --git a/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java b/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java index 4f9d38e..9bf5aa3 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java @@ -27,7 +27,7 @@ import pub.dtm.client.constant.Constants; import pub.dtm.client.exception.FailureException; import feign.Response; -import pub.dtm.client.interfaces.feign.IURIParser; +import pub.dtm.client.interfaces.communication.IURIParser; import pub.dtm.client.model.feign.ServiceMessage; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; diff --git a/dtmcli-core/pom.xml b/dtmcli-core/pom.xml index e425578..d0a4432 100644 --- a/dtmcli-core/pom.xml +++ b/dtmcli-core/pom.xml @@ -4,21 +4,27 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> dtmcli-java-parent - pub.dtm - 1.0.0 + io.github.dtm-labs + 2.0.3-Release 4.0.0 dtmcli-core - 1.0.0 + 2.0.3-Release jar dtmcli-core + + UTF-8 + 1.8 + 1.8 + + - pub.dtm + io.github.dtm-labs dtmcli-common - 1.0.0 + 2.0.3-Release diff --git a/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java b/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java index ea60a60..723843e 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java @@ -32,7 +32,7 @@ import pub.dtm.client.constant.ParamFieldConstants; import pub.dtm.client.enums.TransTypeEnum; import pub.dtm.client.exception.FailureException; -import pub.dtm.client.interfaces.ICommunicationStub; +import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; import pub.dtm.client.model.dtm.TransBase; import pub.dtm.client.model.feign.ServiceMessage; import pub.dtm.client.model.param.SagaOperatorParam; @@ -58,7 +58,7 @@ public class Saga extends TransBase { private static final String CONCURRENT = "concurrent"; - private ICommunicationStub communicationStub; + private IDtmCommunicationClient dtmCommunicationClient; private boolean concurrent; @@ -78,11 +78,11 @@ public class Saga extends TransBase { private List payloads = new ArrayList<>(); - public Saga(String gid, ICommunicationStub communicationStub) { + public Saga(String gid, IDtmCommunicationClient dtmCommunicationClient) { super(gid, TransTypeEnum.SAGA, false); this.concurrent = false; this.orders = new HashMap<>(); - this.communicationStub = communicationStub; + this.dtmCommunicationClient = dtmCommunicationClient; } public Saga add(ServiceMessage action, ServiceMessage compensate, Object postData) { @@ -114,7 +114,7 @@ public Saga add(String action, String compensate, Object postData) { public String submit() throws Exception { if (StringUtils.isEmpty(this.getGid())) { - this.setGid(FeignUtils.parseGid(communicationStub.newGid())); + this.setGid(FeignUtils.parseGid(dtmCommunicationClient.newGid())); } addConcurrentContext(); SagaOperatorParam operatorParam = new SagaOperatorParam(this.getGid(), TransTypeEnum.SAGA, this.getSteps(), @@ -122,7 +122,7 @@ public String submit() throws Exception { this.getRetryInterval(), this.getPassthroughHeaders(), this.getBranchHeaders()); try { - communicationStub.submit(operatorParam); + dtmCommunicationClient.submit(operatorParam); } catch (Exception e) { log.error("saga transaction submit failed, transaction gid is {}", this.getGid()); throw new FailureException(e); diff --git a/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java index 9a5535a..5a30c4a 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java @@ -30,7 +30,7 @@ import pub.dtm.client.constant.ParamFieldConstants; import pub.dtm.client.enums.TransTypeEnum; import pub.dtm.client.exception.FailureException; -import pub.dtm.client.interfaces.ICommunicationStub; +import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; import pub.dtm.client.interfaces.dtm.DtmConsumer; import pub.dtm.client.model.dtm.TransBase; import pub.dtm.client.model.feign.ServiceMessage; @@ -68,16 +68,16 @@ public class Tcc extends TransBase { /** * feign client */ - private ICommunicationStub communicationStub; + private IDtmCommunicationClient dtmCommunicationClient; - public Tcc(String gid, ICommunicationStub communicationStub) { + public Tcc(String gid, IDtmCommunicationClient dtmCommunicationClient) { super(gid, TransTypeEnum.TCC, false); this.branchIdGenerator = new BranchIdGenerator(Constants.EMPTY_STRING); - this.communicationStub = communicationStub; + this.dtmCommunicationClient = dtmCommunicationClient; } - public void setCommunicationStub(ICommunicationStub communicationStub) { - this.communicationStub = communicationStub; + public void setdtmCommunicationClient(IDtmCommunicationClient dtmCommunicationClient) { + this.dtmCommunicationClient = dtmCommunicationClient; } /** @@ -89,12 +89,12 @@ public void setCommunicationStub(ICommunicationStub communicationStub) { public String tccGlobalTransaction(DtmConsumer consumer) throws Exception { // if tcc's gid is empty, need to request a new gid from dtm svr if (StringUtils.isEmpty(this.getGid())) { - this.setGid(FeignUtils.parseGid(communicationStub.newGid())); + this.setGid(FeignUtils.parseGid(dtmCommunicationClient.newGid())); } log.info("the tcc transaction's gid is {}", this.getGid()); OperatorParam operatorParam = new OperatorParam(this.getGid(), TransTypeEnum.TCC); - DtmResponse resp = communicationStub.prepare(operatorParam); + DtmResponse resp = dtmCommunicationClient.prepare(operatorParam); log.info("prepare response: {}", resp); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction prepare fail. returned dtm_result is: {}, transaction gid: {}", resp.getDtmResult(), this.getGid()); @@ -102,10 +102,10 @@ public String tccGlobalTransaction(DtmConsumer consumer) throws Exception { } try { consumer.accept(this); - communicationStub.submit(operatorParam); + dtmCommunicationClient.submit(operatorParam); } catch (Exception e) { log.error("TCC transaction submit fail, start abort it. transaction gid: {}", this.getGid()); - communicationStub.abort(operatorParam); + dtmCommunicationClient.abort(operatorParam); throw new FailureException(e); } return this.getGid(); @@ -128,7 +128,7 @@ public feign.Response callBranch(Object body, ServiceMessage tryMessage, Service TccOperatorParam operatorParam = new TccOperatorParam(this.getGid(), TransTypeEnum.TCC, branchId, Constants.DEFAULT_STATUS, JsonUtils.toJson(body), FeignUtils.generatorURI(confirmMessage, false), FeignUtils.generatorURI(cancelMessage, false)); - DtmResponse resp = communicationStub.registerBranch(operatorParam); + DtmResponse resp = dtmCommunicationClient.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); throw new FailureException("TCC Transaction register branch fail"); @@ -140,7 +140,7 @@ public feign.Response callBranch(Object body, ServiceMessage tryMessage, Service paramsMap.put(ParamFieldConstants.BRANCH_ID, branchId); paramsMap.put(ParamFieldConstants.OP, OP); - feign.Response response = communicationStub.busiPost(new URI(FeignUtils.generatorURI(tryMessage, true)), + feign.Response response = dtmCommunicationClient.busiPost(new URI(FeignUtils.generatorURI(tryMessage, true)), tryMessage.getPath(), paramsMap, body); log.info("busi post is: {}", response); FeignUtils.checkResult(response); @@ -163,7 +163,7 @@ public Response callBranch(Object body, String tryUrl, String confirmUrl, String TccOperatorParam operatorParam = new TccOperatorParam(this.getGid(), TransTypeEnum.TCC, branchId, Constants.DEFAULT_STATUS, JsonUtils.toJson(body), confirmUrl, cancelUrl); - DtmResponse resp = communicationStub.registerBranch(operatorParam); + DtmResponse resp = dtmCommunicationClient.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); throw new FailureException("TCC Transaction register branch fail"); diff --git a/dtmcli-java/pom.xml b/dtmcli-java/pom.xml index 091b766..d8182df 100644 --- a/dtmcli-java/pom.xml +++ b/dtmcli-java/pom.xml @@ -4,27 +4,33 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> dtmcli-java-parent - pub.dtm - 1.0.0 + io.github.dtm-labs + 2.0.3-Release 4.0.0 dtmcli-java - 1.0.0 + 2.0.3-Release jar dtmcli-java + + UTF-8 + 1.8 + 1.8 + + - pub.dtm + io.github.dtm-labs dtmcli-common - 1.0.0 + 2.0.3-Release - pub.dtm + io.github.dtm-labs dtmcli-core - 1.0.0 + 2.0.3-Release diff --git a/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java index 4b2ccdb..d23da09 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java @@ -28,16 +28,14 @@ import feign.jackson.JacksonDecoder; import feign.jackson.JacksonEncoder; import pub.dtm.client.constant.Constants; -import pub.dtm.client.feign.DtmFeignClient; +import pub.dtm.client.communication.DtmFeignClient; import feign.Feign; -import pub.dtm.client.feign.URIParser; -import pub.dtm.client.interfaces.ICommunicationStub; +import pub.dtm.client.communication.URIParser; import pub.dtm.client.interfaces.dtm.DtmConsumer; -import pub.dtm.client.interfaces.feign.IDtmFeignClient; +import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import pub.dtm.client.log.DtmFeignLogger; import pub.dtm.client.properties.DtmProperties; import pub.dtm.client.saga.Saga; import pub.dtm.client.tcc.Tcc; @@ -55,7 +53,7 @@ public class DtmClient { private static final Logger log = LoggerFactory.getLogger(DtmClient.class); - private ICommunicationStub communicationStub; + private IDtmCommunicationClient dtmCommunicationClient; public DtmClient() { // init URIParser @@ -79,7 +77,7 @@ public DtmClient() { log.error("can not resolve dtm server message from config file, you can use nacos or redirect configure to config it."); System.exit(-1); } - IDtmFeignClient feignClient = Feign + IDtmCommunicationClient feignClient = Feign .builder() .decoder(new JacksonDecoder()) .encoder(new JacksonEncoder()) @@ -92,7 +90,7 @@ public DtmClient() { System.exit(-1); } - this.communicationStub = feignClient; + this.dtmCommunicationClient = feignClient; } public DtmClient(String endpoint) { @@ -103,7 +101,7 @@ public DtmClient(String endpoint) { log.error("dtm server endpoint can not be empty."); System.exit(-1); } - IDtmFeignClient feignClient = Feign + IDtmCommunicationClient feignClient = Feign .builder() .decoder(new JacksonDecoder()) .encoder(new JacksonEncoder()) @@ -117,7 +115,7 @@ public DtmClient(String endpoint) { System.exit(-1); } - this.communicationStub = feignClient; + this.dtmCommunicationClient = feignClient; } private List genClusters(String clusterStr) { @@ -137,7 +135,7 @@ private List genClusters(String clusterStr) { * @throws Exception exception */ public String tccGlobalTransaction(DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(null, communicationStub); + Tcc tcc = new Tcc(null, dtmCommunicationClient); return tcc.tccGlobalTransaction(function); } @@ -149,7 +147,7 @@ public String tccGlobalTransaction(DtmConsumer function) throws Exception { * @throws Exception exception */ public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(gid, communicationStub); + Tcc tcc = new Tcc(gid, dtmCommunicationClient); return tcc.tccGlobalTransaction(function); } @@ -159,7 +157,7 @@ public String tccGlobalTransaction(String gid, DtmConsumer function) throws * @return Saga */ public Saga newSaga(String gid) { - return new Saga(gid, communicationStub); + return new Saga(gid, dtmCommunicationClient); } /** @@ -167,6 +165,6 @@ public Saga newSaga(String gid) { * @return Saga */ public Saga newSaga() { - return new Saga(null, communicationStub); + return new Saga(null, dtmCommunicationClient); } } diff --git a/dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java b/dtmcli-java/src/main/java/pub/dtm/client/communication/DtmFeignClient.java similarity index 90% rename from dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java rename to dtmcli-java/src/main/java/pub/dtm/client/communication/DtmFeignClient.java index 3ef1a28..c9e6b5c 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/feign/DtmFeignClient.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/communication/DtmFeignClient.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.feign; +package pub.dtm.client.communication; import feign.Headers; import feign.Param; @@ -30,7 +30,7 @@ import feign.RequestLine; import feign.Response; import pub.dtm.client.constant.Constants; -import pub.dtm.client.interfaces.feign.IDtmFeignClient; +import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; import pub.dtm.client.model.param.OperatorParam; import pub.dtm.client.model.responses.DtmResponse; @@ -38,7 +38,12 @@ import java.util.Map; @Headers("Content-Type: application/json") -public interface DtmFeignClient extends IDtmFeignClient { +public interface DtmFeignClient extends IDtmCommunicationClient { + @Override + default String stubType() { + return "open-feign"; + } + @Override @RequestLine(Constants.GET_METHOD + Constants.NEW_GID_URL) DtmResponse newGid(); diff --git a/dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java b/dtmcli-java/src/main/java/pub/dtm/client/communication/URIParser.java similarity index 95% rename from dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java rename to dtmcli-java/src/main/java/pub/dtm/client/communication/URIParser.java index 697c7dd..912dda8 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/feign/URIParser.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/communication/URIParser.java @@ -22,11 +22,11 @@ * SOFTWARE. */ -package pub.dtm.client.feign; +package pub.dtm.client.communication; import com.alibaba.nacos.api.naming.pojo.Instance; import pub.dtm.client.constant.Constants; -import pub.dtm.client.interfaces.feign.IURIParser; +import pub.dtm.client.interfaces.communication.IURIParser; import pub.dtm.client.model.feign.ServiceMessage; import pub.dtm.client.properties.DtmProperties; import pub.dtm.client.utils.FeignUtils; diff --git a/dtmcli-spring/pom.xml b/dtmcli-spring/pom.xml index e47f7c7..7f927de 100644 --- a/dtmcli-spring/pom.xml +++ b/dtmcli-spring/pom.xml @@ -4,17 +4,20 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> dtmcli-java-parent - pub.dtm - 1.0.0 + io.github.dtm-labs + 2.0.3-Release 4.0.0 dtmcli-spring - 1.0.0 + 2.0.3-Release jar dtmcli-spring + UTF-8 + 1.8 + 1.8 3.1.1 2021.0.1.0 2.1.2.RELEASE @@ -24,15 +27,15 @@ - pub.dtm + io.github.dtm-labs dtmcli-common - 1.0.0 + 2.0.3-Release - pub.dtm + io.github.dtm-labs dtmcli-core - 1.0.0 + 2.0.3-Release diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java b/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java index 041f080..a28b284 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java @@ -24,7 +24,7 @@ package pub.dtm.client; -import pub.dtm.client.interfaces.ICommunicationStub; +import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; import pub.dtm.client.interfaces.dtm.DtmConsumer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -34,10 +34,10 @@ @Component public class DtmClient { @Autowired - private ICommunicationStub communicationStub; + private IDtmCommunicationClient dtmCommunicationClient; - public DtmClient(ICommunicationStub communicationStub) { - this.communicationStub = communicationStub; + public DtmClient(IDtmCommunicationClient dtmCommunicationClient) { + this.dtmCommunicationClient = dtmCommunicationClient; } /** @@ -45,7 +45,7 @@ public DtmClient(ICommunicationStub communicationStub) { * @return gid */ public String tccGlobalTransaction(DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(null, communicationStub); + Tcc tcc = new Tcc(null, dtmCommunicationClient); return tcc.tccGlobalTransaction(function); } @@ -55,7 +55,7 @@ public String tccGlobalTransaction(DtmConsumer function) throws Exception { * @return gid */ public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(gid, communicationStub); + Tcc tcc = new Tcc(gid, dtmCommunicationClient); return tcc.tccGlobalTransaction(function); } @@ -65,7 +65,7 @@ public String tccGlobalTransaction(String gid, DtmConsumer function) throws * @return Saga */ public Saga newSaga(String gid) { - return new Saga(gid, communicationStub); + return new Saga(gid, dtmCommunicationClient); } /** @@ -73,6 +73,6 @@ public Saga newSaga(String gid) { * @return Saga */ public Saga newSaga() { - return new Saga(null, communicationStub); + return new Saga(null, dtmCommunicationClient); } } diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java b/dtmcli-spring/src/main/java/pub/dtm/client/communication/DtmFeignClient.java similarity index 91% rename from dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java rename to dtmcli-spring/src/main/java/pub/dtm/client/communication/DtmFeignClient.java index 7c6d7d8..9a4a1b5 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/feign/DtmFeignClient.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/communication/DtmFeignClient.java @@ -22,11 +22,11 @@ * SOFTWARE. */ -package pub.dtm.client.feign; +package pub.dtm.client.communication; import pub.dtm.client.constant.Constants; import feign.Response; -import pub.dtm.client.interfaces.feign.IDtmFeignClient; +import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; import pub.dtm.client.model.param.OperatorParam; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.SpringQueryMap; @@ -41,7 +41,12 @@ import java.util.Map; @FeignClient(value = "${dtm.service.name}") -public interface DtmFeignClient extends IDtmFeignClient { +public interface DtmFeignClient extends IDtmCommunicationClient { + @Override + default String stubType() { + return "feign-spring"; + } + @Override @GetMapping(Constants.NEW_GID_URL) DtmResponse newGid(); diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java b/dtmcli-spring/src/main/java/pub/dtm/client/communication/URIParser.java similarity index 94% rename from dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java rename to dtmcli-spring/src/main/java/pub/dtm/client/communication/URIParser.java index 389a648..d6b098e 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/feign/URIParser.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/communication/URIParser.java @@ -22,10 +22,10 @@ * SOFTWARE. */ -package pub.dtm.client.feign; +package pub.dtm.client.communication; import pub.dtm.client.constant.Constants; -import pub.dtm.client.interfaces.feign.IURIParser; +import pub.dtm.client.interfaces.communication.IURIParser; import pub.dtm.client.model.feign.ServiceMessage; import pub.dtm.client.utils.FeignUtils; diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java b/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java index 22e8eb8..dcd5c52 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java +++ b/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java @@ -24,9 +24,7 @@ package pub.dtm.client.configuration; -import feign.Logger; -import pub.dtm.client.DtmClient; -import pub.dtm.client.feign.URIParser; +import pub.dtm.client.communication.URIParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -35,13 +33,12 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; -import pub.dtm.client.log.DtmFeignLogger; import pub.dtm.client.properties.DtmProperties; @Component -@ComponentScan({"pub.dtm.client.feign", "pub.dtm.client"}) +@ComponentScan({"pub.dtm.client"}) @Configuration -@EnableFeignClients("pub.dtm.client.feign") +@EnableFeignClients("pub.dtm.client.communication") @EnableConfigurationProperties(DtmProperties.class) public class DtmConfiguration { @Autowired diff --git a/pom.xml b/pom.xml index ba38075..b48857a 100644 --- a/pom.xml +++ b/pom.xml @@ -4,12 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - pub.dtm + io.github.dtm-labs dtmcli-java-parent - 1.0.0 + 2.0.3-Release pom dtmcli-java-parent + The java client for dtm + https://github.com/dtm-labs/dtmcli-java dtmcli-common @@ -92,25 +94,181 @@ - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - ${project.build.sourceEncoding} - - - - org.apache.maven.plugins - maven-resources-plugin - - ${project.build.sourceEncoding} - - - - + + + + MIT + https://spdx.org/licenses/MIT.html + + + + https://github.com/dtm-labs/dtmcli-java.git + https://github.com/dtm-labs/dtmcli-java + + + + horseLk + horsekiao@gmail.com + + Developer + + +8 + + + + + + release + + + + src/main/java + + **/*.properties + **/*.sample + + + + dtmcli-common/src/main/java + + **/*.properties + **/*.sample + + + + dtmcli-core/src/main/java + + **/*.properties + **/*.sample + + + + dtmcli-java/src/main/java + + **/*.properties + **/*.sample + + + dtmcli-spring/src/main/java + + **/*.properties + **/*.sa + + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + ${project.build.sourceEncoding} + + + + package + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + private + true + UTF-8 + UTF-8 + UTF-8 + -Xdoclint:none + /Library/Java/JavaVirtualMachines/jdk1.8.0_261.jdk/Contents/Home/bin/javadoc + + + + + package + + jar + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + verify + + sign + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + 1.8 + 1.8 + true + true + UTF-8 + false + ${project.build.sourceEncoding} + + + + + org.apache.maven.plugins + maven-release-plugin + 2.5.1 + + + + + + ossrh + ossrh + https://s01.oss.sonatype.org/content/repositories/snapshots/ + + + ossrh + ossrh + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 600f6a4fd4d3405dda19e3123ed6daa56d4e71f8 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Mon, 16 May 2022 00:18:45 +0800 Subject: [PATCH 10/24] update to 2.0.4 --- dtmcli-common/pom.xml | 4 ++-- dtmcli-core/pom.xml | 6 +++--- dtmcli-java/pom.xml | 8 ++++---- {dtmcli-spring => dtmcli-springcloud}/pom.xml | 12 ++++++------ .../java/pub/dtm/client/springcloud}/DtmClient.java | 10 +++------- .../springcloud}/communication/DtmFeignClient.java | 8 ++++---- .../client/springcloud}/communication/URIParser.java | 2 +- .../springcloud}/configuration/DtmConfiguration.java | 8 ++++---- .../springcloud}/properties/DtmProperties.java | 2 +- .../src/main/resources/META-INF/spring.factories | 2 +- pom.xml | 4 ++-- 11 files changed, 31 insertions(+), 35 deletions(-) rename {dtmcli-spring => dtmcli-springcloud}/pom.xml (93%) rename {dtmcli-spring/src/main/java/pub/dtm/client => dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud}/DtmClient.java (94%) rename {dtmcli-spring/src/main/java/pub/dtm/client => dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud}/communication/DtmFeignClient.java (98%) rename {dtmcli-spring/src/main/java/pub/dtm/client => dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud}/communication/URIParser.java (97%) rename {dtmcli-spring/src/main/java/pub/dtm/client => dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud}/configuration/DtmConfiguration.java (90%) rename {dtmcli-spring/src/main/java/pub/dtm/client => dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud}/properties/DtmProperties.java (96%) rename {dtmcli-spring => dtmcli-springcloud}/src/main/resources/META-INF/spring.factories (53%) diff --git a/dtmcli-common/pom.xml b/dtmcli-common/pom.xml index 19ce8ea..1b37747 100644 --- a/dtmcli-common/pom.xml +++ b/dtmcli-common/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.0.3-Release + 2.0.4 4.0.0 dtmcli-common - 2.0.3-Release + 2.0.4 jar dtmcli-common diff --git a/dtmcli-core/pom.xml b/dtmcli-core/pom.xml index d0a4432..112ddfc 100644 --- a/dtmcli-core/pom.xml +++ b/dtmcli-core/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.0.3-Release + 2.0.4 4.0.0 dtmcli-core - 2.0.3-Release + 2.0.4 jar dtmcli-core @@ -24,7 +24,7 @@ io.github.dtm-labs dtmcli-common - 2.0.3-Release + 2.0.4 diff --git a/dtmcli-java/pom.xml b/dtmcli-java/pom.xml index d8182df..9290278 100644 --- a/dtmcli-java/pom.xml +++ b/dtmcli-java/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.0.3-Release + 2.0.4 4.0.0 dtmcli-java - 2.0.3-Release + 2.0.4 jar dtmcli-java @@ -24,13 +24,13 @@ io.github.dtm-labs dtmcli-common - 2.0.3-Release + 2.0.4 io.github.dtm-labs dtmcli-core - 2.0.3-Release + 2.0.4 diff --git a/dtmcli-spring/pom.xml b/dtmcli-springcloud/pom.xml similarity index 93% rename from dtmcli-spring/pom.xml rename to dtmcli-springcloud/pom.xml index 7f927de..4e3a3c6 100644 --- a/dtmcli-spring/pom.xml +++ b/dtmcli-springcloud/pom.xml @@ -5,14 +5,14 @@ dtmcli-java-parent io.github.dtm-labs - 2.0.3-Release + 2.0.4 4.0.0 - dtmcli-spring - 2.0.3-Release + dtmcli-springcloud + 2.0.4 jar - dtmcli-spring + dtmcli-springcloud UTF-8 @@ -29,13 +29,13 @@ io.github.dtm-labs dtmcli-common - 2.0.3-Release + 2.0.4 io.github.dtm-labs dtmcli-core - 2.0.3-Release + 2.0.4 diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/DtmClient.java similarity index 94% rename from dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/DtmClient.java index a28b284..982e2b6 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/DtmClient.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/DtmClient.java @@ -22,12 +22,12 @@ * SOFTWARE. */ -package pub.dtm.client; +package pub.dtm.client.springcloud; -import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; -import pub.dtm.client.interfaces.dtm.DtmConsumer; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; +import pub.dtm.client.interfaces.dtm.DtmConsumer; import pub.dtm.client.saga.Saga; import pub.dtm.client.tcc.Tcc; @@ -36,10 +36,6 @@ public class DtmClient { @Autowired private IDtmCommunicationClient dtmCommunicationClient; - public DtmClient(IDtmCommunicationClient dtmCommunicationClient) { - this.dtmCommunicationClient = dtmCommunicationClient; - } - /** * start a tcc transaction without gid, client send a request to dtm svr for obtain a new gid. * @return gid diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/communication/DtmFeignClient.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/DtmFeignClient.java similarity index 98% rename from dtmcli-spring/src/main/java/pub/dtm/client/communication/DtmFeignClient.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/DtmFeignClient.java index 9a4a1b5..04fa15f 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/communication/DtmFeignClient.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/DtmFeignClient.java @@ -22,12 +22,9 @@ * SOFTWARE. */ -package pub.dtm.client.communication; +package pub.dtm.client.springcloud.communication; -import pub.dtm.client.constant.Constants; import feign.Response; -import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; -import pub.dtm.client.model.param.OperatorParam; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.SpringQueryMap; import org.springframework.http.MediaType; @@ -35,6 +32,9 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import pub.dtm.client.constant.Constants; +import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; +import pub.dtm.client.model.param.OperatorParam; import pub.dtm.client.model.responses.DtmResponse; import java.net.URI; diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/communication/URIParser.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/URIParser.java similarity index 97% rename from dtmcli-spring/src/main/java/pub/dtm/client/communication/URIParser.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/URIParser.java index d6b098e..7845e89 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/communication/URIParser.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/URIParser.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.communication; +package pub.dtm.client.springcloud.communication; import pub.dtm.client.constant.Constants; import pub.dtm.client.interfaces.communication.IURIParser; diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/configuration/DtmConfiguration.java similarity index 90% rename from dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/configuration/DtmConfiguration.java index dcd5c52..940db45 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/configuration/DtmConfiguration.java @@ -22,9 +22,9 @@ * SOFTWARE. */ -package pub.dtm.client.configuration; +package pub.dtm.client.springcloud.configuration; -import pub.dtm.client.communication.URIParser; +import pub.dtm.client.springcloud.communication.URIParser; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -33,12 +33,12 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; -import pub.dtm.client.properties.DtmProperties; +import pub.dtm.client.springcloud.properties.DtmProperties; @Component @ComponentScan({"pub.dtm.client"}) @Configuration -@EnableFeignClients("pub.dtm.client.communication") +@EnableFeignClients("pub.dtm.client.springcloud.communication") @EnableConfigurationProperties(DtmProperties.class) public class DtmConfiguration { @Autowired diff --git a/dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/properties/DtmProperties.java similarity index 96% rename from dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/properties/DtmProperties.java index 3f7e5d9..695a6a4 100644 --- a/dtmcli-spring/src/main/java/pub/dtm/client/properties/DtmProperties.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/properties/DtmProperties.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.properties; +package pub.dtm.client.springcloud.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/dtmcli-spring/src/main/resources/META-INF/spring.factories b/dtmcli-springcloud/src/main/resources/META-INF/spring.factories similarity index 53% rename from dtmcli-spring/src/main/resources/META-INF/spring.factories rename to dtmcli-springcloud/src/main/resources/META-INF/spring.factories index f780708..14a43a5 100644 --- a/dtmcli-spring/src/main/resources/META-INF/spring.factories +++ b/dtmcli-springcloud/src/main/resources/META-INF/spring.factories @@ -1 +1 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=pub.dtm.client.configuration.DtmConfiguration \ No newline at end of file +org.springframework.boot.autoconfigure.EnableAutoConfiguration=pub.dtm.client.springcloud.configuration.DtmConfiguration \ No newline at end of file diff --git a/pom.xml b/pom.xml index b48857a..87464b7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.dtm-labs dtmcli-java-parent - 2.0.3-Release + 2.0.4 pom dtmcli-java-parent @@ -16,7 +16,7 @@ dtmcli-common dtmcli-core - dtmcli-spring + dtmcli-springcloud dtmcli-java From a8fb4e19c548bfaee9a4df8e3abb7ea35414d914 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Mon, 16 May 2022 22:57:44 +0800 Subject: [PATCH 11/24] boot2.6.x --- dtmcli-springcloud/pom.xml | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/dtmcli-springcloud/pom.xml b/dtmcli-springcloud/pom.xml index 4e3a3c6..b0b40cf 100644 --- a/dtmcli-springcloud/pom.xml +++ b/dtmcli-springcloud/pom.xml @@ -18,10 +18,11 @@ UTF-8 1.8 1.8 - 3.1.1 - 2021.0.1.0 - 2.1.2.RELEASE + + + 2021.0.1 + 2021.0.1.0 2.6.3 @@ -54,7 +55,7 @@ com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery - ${cloud.nacos.version} + @@ -71,7 +72,7 @@ org.springframework.cloud spring-cloud-starter-openfeign - ${cloud.feign.version} + org.springframework.cloud @@ -89,6 +90,13 @@ pom import + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${alibaba-cloud.version} + pom + import + From 4503805f94b88e8fd47779b2b523751f97801e50 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Mon, 16 May 2022 23:21:17 +0800 Subject: [PATCH 12/24] update readme --- README.md | 58 ++++++++++++++++++++------------------ dtmcli-springcloud/pom.xml | 7 +---- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 12ca8cb..c06d904 100644 --- a/README.md +++ b/README.md @@ -45,29 +45,18 @@ DTM是一款跨语言的开源分布式事务管理器,优雅的解决了幂 ## 使用方式 -### 步骤一:JitPack 存储库添加到您的构建文件 - -Maven: - -```bash - - - jitpack.io - https://jitpack.io - - -``` - -Gradle: - -```bash -allprojects { - repositories { - ... - maven { url 'https://jitpack.io' } - } - } -``` +### 步骤一:确定你需要使用的版本 +1. 您的项目是springcloud项目 +- 您的项目中springboot版本>=2.4.0,请选择dtmcli-springcloud相应的版本直接接入即可 +- 您的项目中的springboot版本<2.4.0,请选择dtmcli-java接入,dtmcli-java也提供了微服务相关的接口,请设置nacos服务中心的相关配置即可使用 +2. 您的项目是普通项目/没有接入微服务的spring(boot)项目 +- 请选择dtmcli-java,并设置相应的配置即可 + +| artifact| version | 适用版本 |备注| +|:-----:|:----:|:----:|:----:| +|dtmcli-springcloud| 2.1.x| 2.6.0 <= springboot version < 2.6.latest| | +|dtmcli-springcloud| 2.1.x| 2.4.0 <= springboot version < 2.5.13| springboot 版本>=2.5.0,需要设置spring.cloud.compatibility-verifier.enabled=false| +|dtmcli-java| 2.1.x| others| | ### 步骤二:添加依赖项 @@ -75,9 +64,9 @@ Maven: ```bash - com.github.yedf - dtmcli-java - Tag + io.github.dtm-labs + dtmcli-springcloud + ${dtmcli.version} ``` @@ -85,10 +74,25 @@ Gradle: ```bash dependencies { - implementation 'com.github.yedf:dtmcli-java:Tag' + implementation 'io.github.dtm-labs:dtmcli-springcloud:${dtmcli.version}' } ``` +### 步骤三:设置dtmcli-java配置 +如果您引入了dtmcli-java,则需要新建一个`dtm-conf.properties`配置文件 +- 情形一:您引入了nacos等服务中心组件的配置文件 +``` +serverAddr=127.0.0.1:8848 +username=nacos +password=nacos +namespace=c3dc917d-906a-429d-90a9-85012b41014e +dtm.service.name=dtmService +dtm.service.registryType=nacos +``` +- 情形二:您直连dtmsvr +``` +dtm.ipport=127.0.0.1:36789 +``` ## 示例 ```bash diff --git a/dtmcli-springcloud/pom.xml b/dtmcli-springcloud/pom.xml index b0b40cf..fdb9803 100644 --- a/dtmcli-springcloud/pom.xml +++ b/dtmcli-springcloud/pom.xml @@ -18,9 +18,7 @@ UTF-8 1.8 1.8 - - - + 2021.0.1 2021.0.1.0 2.6.3 @@ -55,7 +53,6 @@ com.alibaba.cloud spring-cloud-starter-alibaba-nacos-discovery - @@ -72,12 +69,10 @@ org.springframework.cloud spring-cloud-starter-openfeign - org.springframework.cloud spring-cloud-loadbalancer - From 32d715de11891b87d3c05bde50ab94a4c92740fb Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Tue, 17 May 2022 22:28:33 +0800 Subject: [PATCH 13/24] upgrade version --- dtmcli-common/pom.xml | 4 ++-- dtmcli-core/pom.xml | 6 +++--- dtmcli-java/pom.xml | 8 ++++---- dtmcli-springcloud/pom.xml | 8 ++++---- .../java/pub/dtm/client/{springcloud => }/DtmClient.java | 2 +- .../{springcloud => }/communication/DtmFeignClient.java | 2 +- .../client/{springcloud => }/communication/URIParser.java | 2 +- .../{springcloud => }/configuration/DtmConfiguration.java | 8 ++++---- .../{springcloud => }/properties/DtmProperties.java | 2 +- .../src/main/resources/META-INF/spring.factories | 2 +- pom.xml | 2 +- 11 files changed, 23 insertions(+), 23 deletions(-) rename dtmcli-springcloud/src/main/java/pub/dtm/client/{springcloud => }/DtmClient.java (98%) rename dtmcli-springcloud/src/main/java/pub/dtm/client/{springcloud => }/communication/DtmFeignClient.java (98%) rename dtmcli-springcloud/src/main/java/pub/dtm/client/{springcloud => }/communication/URIParser.java (97%) rename dtmcli-springcloud/src/main/java/pub/dtm/client/{springcloud => }/configuration/DtmConfiguration.java (90%) rename dtmcli-springcloud/src/main/java/pub/dtm/client/{springcloud => }/properties/DtmProperties.java (96%) diff --git a/dtmcli-common/pom.xml b/dtmcli-common/pom.xml index 1b37747..c9f97ea 100644 --- a/dtmcli-common/pom.xml +++ b/dtmcli-common/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.0.4 + 2.1.0 4.0.0 dtmcli-common - 2.0.4 + 2.1.0 jar dtmcli-common diff --git a/dtmcli-core/pom.xml b/dtmcli-core/pom.xml index 112ddfc..9ff5b1b 100644 --- a/dtmcli-core/pom.xml +++ b/dtmcli-core/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.0.4 + 2.1.0 4.0.0 dtmcli-core - 2.0.4 + 2.1.0 jar dtmcli-core @@ -24,7 +24,7 @@ io.github.dtm-labs dtmcli-common - 2.0.4 + 2.1.0 diff --git a/dtmcli-java/pom.xml b/dtmcli-java/pom.xml index 9290278..fe8f5fb 100644 --- a/dtmcli-java/pom.xml +++ b/dtmcli-java/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.0.4 + 2.1.0 4.0.0 dtmcli-java - 2.0.4 + 2.1.0 jar dtmcli-java @@ -24,13 +24,13 @@ io.github.dtm-labs dtmcli-common - 2.0.4 + 2.1.0 io.github.dtm-labs dtmcli-core - 2.0.4 + 2.1.0 diff --git a/dtmcli-springcloud/pom.xml b/dtmcli-springcloud/pom.xml index fdb9803..11abf08 100644 --- a/dtmcli-springcloud/pom.xml +++ b/dtmcli-springcloud/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.0.4 + 2.1.0 4.0.0 dtmcli-springcloud - 2.0.4 + 2.1.0.2 jar dtmcli-springcloud @@ -28,13 +28,13 @@ io.github.dtm-labs dtmcli-common - 2.0.4 + 2.1.0 io.github.dtm-labs dtmcli-core - 2.0.4 + 2.1.0 diff --git a/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/DtmClient.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/DtmClient.java similarity index 98% rename from dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/DtmClient.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/DtmClient.java index 982e2b6..3a0c34a 100644 --- a/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/DtmClient.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/DtmClient.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.springcloud; +package pub.dtm.client; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/DtmFeignClient.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/communication/DtmFeignClient.java similarity index 98% rename from dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/DtmFeignClient.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/communication/DtmFeignClient.java index 04fa15f..25a6996 100644 --- a/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/DtmFeignClient.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/communication/DtmFeignClient.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.springcloud.communication; +package pub.dtm.client.communication; import feign.Response; import org.springframework.cloud.openfeign.FeignClient; diff --git a/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/URIParser.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/communication/URIParser.java similarity index 97% rename from dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/URIParser.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/communication/URIParser.java index 7845e89..d6b098e 100644 --- a/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/communication/URIParser.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/communication/URIParser.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.springcloud.communication; +package pub.dtm.client.communication; import pub.dtm.client.constant.Constants; import pub.dtm.client.interfaces.communication.IURIParser; diff --git a/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/configuration/DtmConfiguration.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java similarity index 90% rename from dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/configuration/DtmConfiguration.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java index 940db45..4a05b44 100644 --- a/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/configuration/DtmConfiguration.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java @@ -22,9 +22,10 @@ * SOFTWARE. */ -package pub.dtm.client.springcloud.configuration; +package pub.dtm.client.configuration; -import pub.dtm.client.springcloud.communication.URIParser; +import pub.dtm.client.communication.URIParser; +import pub.dtm.client.properties.DtmProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -33,12 +34,11 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; -import pub.dtm.client.springcloud.properties.DtmProperties; @Component @ComponentScan({"pub.dtm.client"}) @Configuration -@EnableFeignClients("pub.dtm.client.springcloud.communication") +@EnableFeignClients("pub.dtm.client.communication") @EnableConfigurationProperties(DtmProperties.class) public class DtmConfiguration { @Autowired diff --git a/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/properties/DtmProperties.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/properties/DtmProperties.java similarity index 96% rename from dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/properties/DtmProperties.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/properties/DtmProperties.java index 695a6a4..3f7e5d9 100644 --- a/dtmcli-springcloud/src/main/java/pub/dtm/client/springcloud/properties/DtmProperties.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/properties/DtmProperties.java @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.springcloud.properties; +package pub.dtm.client.properties; import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; diff --git a/dtmcli-springcloud/src/main/resources/META-INF/spring.factories b/dtmcli-springcloud/src/main/resources/META-INF/spring.factories index 14a43a5..f780708 100644 --- a/dtmcli-springcloud/src/main/resources/META-INF/spring.factories +++ b/dtmcli-springcloud/src/main/resources/META-INF/spring.factories @@ -1 +1 @@ -org.springframework.boot.autoconfigure.EnableAutoConfiguration=pub.dtm.client.springcloud.configuration.DtmConfiguration \ No newline at end of file +org.springframework.boot.autoconfigure.EnableAutoConfiguration=pub.dtm.client.configuration.DtmConfiguration \ No newline at end of file diff --git a/pom.xml b/pom.xml index 87464b7..184b473 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.dtm-labs dtmcli-java-parent - 2.0.4 + 2.1.0 pom dtmcli-java-parent From 6cf770389267471649d5d6d9d474fa0daa6d6e53 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Wed, 18 May 2022 00:42:42 +0800 Subject: [PATCH 14/24] upgrade version --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c06d904..3f61250 100644 --- a/README.md +++ b/README.md @@ -54,9 +54,9 @@ DTM是一款跨语言的开源分布式事务管理器,优雅的解决了幂 | artifact| version | 适用版本 |备注| |:-----:|:----:|:----:|:----:| -|dtmcli-springcloud| 2.1.x| 2.6.0 <= springboot version < 2.6.latest| | -|dtmcli-springcloud| 2.1.x| 2.4.0 <= springboot version < 2.5.13| springboot 版本>=2.5.0,需要设置spring.cloud.compatibility-verifier.enabled=false| -|dtmcli-java| 2.1.x| others| | +|dtmcli-springcloud| 2.1.0.1| 2.4.0 <= springboot version < 2.5.13| springboot 版本>=2.5.0,需要设置spring.cloud.compatibility-verifier.enabled=false| +|dtmcli-springcloud| 2.1.0.2| 2.6.0 <= springboot version < 2.6.latest| | +|dtmcli-java| 2.1.0| others| | ### 步骤二:添加依赖项 @@ -129,7 +129,11 @@ dtm.ipport=127.0.0.1:36789 ### 完整示例 +#### dtmcli-java使用示例 [dtmcli-java-sample](https://github.com/dtm-labs/dtmcli-java-sample) +[dtmcli-java-sample-use-configuration](https://github.com/horseLk/dtmcli-java-conf) +#### dtmcli-springcloud使用示例 +[dtmcli-java-spring-sample](https://github.com/dtm-labs/dtmcli-java-spring-sample) ### License From eeff36034efd705a64feb7598697e7febbffb0a8 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Wed, 18 May 2022 01:12:29 +0800 Subject: [PATCH 15/24] update reademe --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f61250..eecfa20 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ dtm.ipport=127.0.0.1:36789 #### dtmcli-java使用示例 [dtmcli-java-sample](https://github.com/dtm-labs/dtmcli-java-sample) -[dtmcli-java-sample-use-configuration](https://github.com/horseLk/dtmcli-java-conf) +[dtmcli-java-sample-use-configuration](https://github.com/horseLk/dtmcli-java-sample-with-conf) #### dtmcli-springcloud使用示例 [dtmcli-java-spring-sample](https://github.com/dtm-labs/dtmcli-java-spring-sample) From 005303a2945bdd229243a6796c7d3bd1048f3eff Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Wed, 18 May 2022 23:10:26 +0800 Subject: [PATCH 16/24] add server center plugin --- dtmcli-springcloud/pom.xml | 27 -------- eureka-plugin/pom.xml | 61 ++++++++++++++++ .../configuration/EurekaConfiguration.java | 11 +++ nacos-plugin/pom.xml | 69 +++++++++++++++++++ pom.xml | 2 + 5 files changed, 143 insertions(+), 27 deletions(-) create mode 100644 eureka-plugin/pom.xml create mode 100644 eureka-plugin/src/main/java/pub/dtm/client/configuration/EurekaConfiguration.java create mode 100644 nacos-plugin/pom.xml diff --git a/dtmcli-springcloud/pom.xml b/dtmcli-springcloud/pom.xml index 11abf08..a46bcb6 100644 --- a/dtmcli-springcloud/pom.xml +++ b/dtmcli-springcloud/pom.xml @@ -50,30 +50,10 @@ true - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - org.springframework.cloud - spring-cloud-starter-netflix-ribbon - - - com.netflix.ribbon - ribbon - - - - org.springframework.cloud spring-cloud-starter-openfeign - - org.springframework.cloud - spring-cloud-loadbalancer - @@ -85,13 +65,6 @@ pom import - - com.alibaba.cloud - spring-cloud-alibaba-dependencies - ${alibaba-cloud.version} - pom - import - diff --git a/eureka-plugin/pom.xml b/eureka-plugin/pom.xml new file mode 100644 index 0000000..ea11d35 --- /dev/null +++ b/eureka-plugin/pom.xml @@ -0,0 +1,61 @@ + + + + dtmcli-java-parent + io.github.dtm-labs + 2.1.0 + + 4.0.0 + + eureka-plugin + 2.1.0 + jar + nacos-plugin + + + UTF-8 + 1.8 + 1.8 + + 2021.0.1 + 2.6.3 + + + + + org.springframework.boot + spring-boot-starter + ${springboot.version} + + + + org.springframework.boot + spring-boot-configuration-processor + ${springboot.version} + true + + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + \ No newline at end of file diff --git a/eureka-plugin/src/main/java/pub/dtm/client/configuration/EurekaConfiguration.java b/eureka-plugin/src/main/java/pub/dtm/client/configuration/EurekaConfiguration.java new file mode 100644 index 0000000..070b634 --- /dev/null +++ b/eureka-plugin/src/main/java/pub/dtm/client/configuration/EurekaConfiguration.java @@ -0,0 +1,11 @@ +package pub.dtm.client.configuration; + +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; + +/** + * @author horseLk + * @date 2022-05-18 22:40 + */ +@EnableEurekaClient +public class EurekaConfiguration { +} diff --git a/nacos-plugin/pom.xml b/nacos-plugin/pom.xml new file mode 100644 index 0000000..06cd18c --- /dev/null +++ b/nacos-plugin/pom.xml @@ -0,0 +1,69 @@ + + + + dtmcli-java-parent + io.github.dtm-labs + 2.1.0 + + 4.0.0 + + nacos-plugin + 2.1.0 + jar + nacos-plugin + + + UTF-8 + 1.8 + 1.8 + + 2021.0.1 + 2021.0.1.0 + + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + + org.springframework.cloud + spring-cloud-starter-netflix-ribbon + + + com.netflix.ribbon + ribbon + + + + + + org.springframework.cloud + spring-cloud-loadbalancer + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${alibaba-cloud.version} + pom + import + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 184b473..5037ece 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,8 @@ dtmcli-core dtmcli-springcloud dtmcli-java + nacos-plugin + eureka-plugin From 8888e09f7732ac849b9434d8fc03825445642386 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Thu, 19 May 2022 23:19:30 +0800 Subject: [PATCH 17/24] upgrade --- dtmcli-common/pom.xml | 4 +-- dtmcli-core/pom.xml | 6 ++-- dtmcli-java/pom.xml | 8 +++--- dtmcli-springcloud/pom.xml | 23 +++------------ eureka-plugin/pom.xml | 22 ++------------- .../main/resources/META-INF/spring.factories | 1 + nacos-plugin/pom.xml | 28 ++----------------- pom.xml | 20 ++++++++++++- 8 files changed, 38 insertions(+), 74 deletions(-) create mode 100644 eureka-plugin/src/main/resources/META-INF/spring.factories diff --git a/dtmcli-common/pom.xml b/dtmcli-common/pom.xml index c9f97ea..5b45adc 100644 --- a/dtmcli-common/pom.xml +++ b/dtmcli-common/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.0 + 2.1.1 4.0.0 dtmcli-common - 2.1.0 + 2.1.1 jar dtmcli-common diff --git a/dtmcli-core/pom.xml b/dtmcli-core/pom.xml index 9ff5b1b..dbdb56c 100644 --- a/dtmcli-core/pom.xml +++ b/dtmcli-core/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.0 + 2.1.1 4.0.0 dtmcli-core - 2.1.0 + 2.1.1 jar dtmcli-core @@ -24,7 +24,7 @@ io.github.dtm-labs dtmcli-common - 2.1.0 + 2.1.1 diff --git a/dtmcli-java/pom.xml b/dtmcli-java/pom.xml index fe8f5fb..1ce28fe 100644 --- a/dtmcli-java/pom.xml +++ b/dtmcli-java/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.0 + 2.1.1 4.0.0 dtmcli-java - 2.1.0 + 2.1.1 jar dtmcli-java @@ -24,13 +24,13 @@ io.github.dtm-labs dtmcli-common - 2.1.0 + 2.1.1 io.github.dtm-labs dtmcli-core - 2.1.0 + 2.1.1 diff --git a/dtmcli-springcloud/pom.xml b/dtmcli-springcloud/pom.xml index a46bcb6..b9208da 100644 --- a/dtmcli-springcloud/pom.xml +++ b/dtmcli-springcloud/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.0 + 2.1.1 4.0.0 dtmcli-springcloud - 2.1.0.2 + 2.1.1.2 jar dtmcli-springcloud @@ -19,8 +19,6 @@ 1.8 1.8 - 2021.0.1 - 2021.0.1.0 2.6.3 @@ -28,13 +26,13 @@ io.github.dtm-labs dtmcli-common - 2.1.0 + 2.1.1 io.github.dtm-labs dtmcli-core - 2.1.0 + 2.1.1 @@ -56,17 +54,4 @@ - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - \ No newline at end of file diff --git a/eureka-plugin/pom.xml b/eureka-plugin/pom.xml index ea11d35..854e4b8 100644 --- a/eureka-plugin/pom.xml +++ b/eureka-plugin/pom.xml @@ -5,21 +5,20 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.0 + 2.1.1 4.0.0 eureka-plugin - 2.1.0 + 2.1.1.2 jar - nacos-plugin + eureka-plugin UTF-8 1.8 1.8 - 2021.0.1 2.6.3 @@ -43,19 +42,4 @@ spring-cloud-starter-netflix-eureka-client - - - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - \ No newline at end of file diff --git a/eureka-plugin/src/main/resources/META-INF/spring.factories b/eureka-plugin/src/main/resources/META-INF/spring.factories new file mode 100644 index 0000000..ed9756f --- /dev/null +++ b/eureka-plugin/src/main/resources/META-INF/spring.factories @@ -0,0 +1 @@ +org.springframework.boot.autoconfigure.EnableAutoConfiguration=pub.dtm.client.configuration.EurekaConfiguration \ No newline at end of file diff --git a/nacos-plugin/pom.xml b/nacos-plugin/pom.xml index 06cd18c..d310087 100644 --- a/nacos-plugin/pom.xml +++ b/nacos-plugin/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.0 + 2.1.1 4.0.0 nacos-plugin - 2.1.0 + 2.1.1.2 jar nacos-plugin @@ -18,9 +18,6 @@ UTF-8 1.8 1.8 - - 2021.0.1 - 2021.0.1.0 @@ -45,25 +42,4 @@ spring-cloud-loadbalancer - - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - com.alibaba.cloud - spring-cloud-alibaba-dependencies - ${alibaba-cloud.version} - pom - import - - - - \ No newline at end of file diff --git a/pom.xml b/pom.xml index 5037ece..0f215b1 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.dtm-labs dtmcli-java-parent - 2.1.0 + 2.1.1 pom dtmcli-java-parent @@ -35,6 +35,8 @@ 3.14.9 1.4.2 1.7.30 + 2021.0.1 + 2021.0.1.0 @@ -93,6 +95,22 @@ slf4j-api ${slf4j.version} + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${alibaba-cloud.version} + pom + import + From 1b4e31d186bd45c038cc18a055dd1ca851538c34 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Fri, 20 May 2022 23:48:01 +0800 Subject: [PATCH 18/24] fix --- LICENSE | 2 +- .../pub/dtm/client/constant/Constants.java | 2 +- .../client/constant/ParamFieldConstants.java | 2 +- .../pub/dtm/client/enums/TransTypeEnum.java | 2 +- .../client/exception/FailureException.java | 2 +- .../client/interfaces/dtm/DtmConsumer.java | 2 +- .../IDtmServerStub.java} | 8 +++--- .../{communication => stub}/IURIParser.java | 4 +-- .../pub/dtm/client/log/DtmFeignLogger.java | 2 +- .../pub/dtm/client/model/dtm/TransBase.java | 2 +- .../client/model/feign/ServiceMessage.java | 2 +- .../dtm/client/model/param/OperatorParam.java | 2 +- .../client/model/param/SagaOperatorParam.java | 2 +- .../client/model/param/TccOperatorParam.java | 2 +- .../client/model/responses/DtmResponse.java | 2 +- .../java/pub/dtm/client/utils/FeignUtils.java | 4 +-- .../java/pub/dtm/client/utils/HttpUtils.java | 2 +- .../java/pub/dtm/client/utils/JsonUtils.java | 2 +- .../pub/dtm/client/barrier/BarrierParam.java | 2 +- .../pub/dtm/client/barrier/BranchBarrier.java | 2 +- .../dtm/client/base/BranchIdGenerator.java | 2 +- .../main/java/pub/dtm/client/saga/Saga.java | 14 +++++----- .../src/main/java/pub/dtm/client/tcc/Tcc.java | 28 +++++++++---------- .../main/java/pub/dtm/client/DtmClient.java | 26 ++++++++--------- .../dtm/client/properties/DtmProperties.java | 8 +++++- .../DtmFeignClient.java | 13 ++++++--- .../{communication => stub}/URIParser.java | 11 ++++++-- .../java/pub/dtm/client/utils/NacosUtils.java | 7 ++++- .../main/java/pub/dtm/client/DtmClient.java | 19 ++++++++----- .../configuration/DtmConfiguration.java | 11 ++++++-- .../dtm/client/properties/DtmProperties.java | 7 ++++- .../DtmFeignClient.java | 13 ++++++--- .../{communication => stub}/URIParser.java | 11 ++++++-- .../configuration/EurekaConfiguration.java | 27 +++++++++++++++++- 34 files changed, 159 insertions(+), 88 deletions(-) rename dtmcli-common/src/main/java/pub/dtm/client/interfaces/{communication/IDtmCommunicationClient.java => stub/IDtmServerStub.java} (91%) rename dtmcli-common/src/main/java/pub/dtm/client/interfaces/{communication => stub}/IURIParser.java (95%) rename dtmcli-java/src/main/java/pub/dtm/client/{communication => stub}/DtmFeignClient.java (91%) rename dtmcli-java/src/main/java/pub/dtm/client/{communication => stub}/URIParser.java (91%) rename dtmcli-springcloud/src/main/java/pub/dtm/client/{communication => stub}/DtmFeignClient.java (92%) rename dtmcli-springcloud/src/main/java/pub/dtm/client/{communication => stub}/URIParser.java (90%) diff --git a/LICENSE b/LICENSE index 5dabd2b..9161855 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2022 yedf +Copyright (c) 2022 dtm-labs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java b/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java index 1beb3f5..a0fb213 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/constant/Constants.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java b/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java index eea3fb4..0a38075 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/constant/ParamFieldConstants.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java b/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java index 77c64d3..21d881b 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/enums/TransTypeEnum.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java b/dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java index de02747..c5dc22a 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/exception/FailureException.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java index 35dd954..0d7034e 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/dtm/DtmConsumer.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IDtmCommunicationClient.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/stub/IDtmServerStub.java similarity index 91% rename from dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IDtmCommunicationClient.java rename to dtmcli-common/src/main/java/pub/dtm/client/interfaces/stub/IDtmServerStub.java index 9e61358..8d9cd64 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IDtmCommunicationClient.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/stub/IDtmServerStub.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.interfaces.communication; +package pub.dtm.client.interfaces.stub; import feign.Response; import pub.dtm.client.model.param.OperatorParam; @@ -32,11 +32,11 @@ import java.util.Map; /** - * A feign client interface for dtm svr, we designed different implements for different client. + * A stub interface for dtm svr, different client has different implements. * * @author horseLk */ -public interface IDtmCommunicationClient { +public interface IDtmServerStub { /** * get stubType * @return type diff --git a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IURIParser.java b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/stub/IURIParser.java similarity index 95% rename from dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IURIParser.java rename to dtmcli-common/src/main/java/pub/dtm/client/interfaces/stub/IURIParser.java index d994fca..3a77e8b 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/interfaces/communication/IURIParser.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/interfaces/stub/IURIParser.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.interfaces.communication; +package pub.dtm.client.interfaces.stub; import pub.dtm.client.model.feign.ServiceMessage; diff --git a/dtmcli-common/src/main/java/pub/dtm/client/log/DtmFeignLogger.java b/dtmcli-common/src/main/java/pub/dtm/client/log/DtmFeignLogger.java index fb1a27b..ebd1d7c 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/log/DtmFeignLogger.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/log/DtmFeignLogger.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java b/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java index 9a3070a..89c5397 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/dtm/TransBase.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java b/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java index 34a824c..4d570be 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/feign/ServiceMessage.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java b/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java index f523278..efa334d 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/param/OperatorParam.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/param/SagaOperatorParam.java b/dtmcli-common/src/main/java/pub/dtm/client/model/param/SagaOperatorParam.java index 6a25dad..cbe06ae 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/model/param/SagaOperatorParam.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/param/SagaOperatorParam.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/param/TccOperatorParam.java b/dtmcli-common/src/main/java/pub/dtm/client/model/param/TccOperatorParam.java index 1bb4175..11d3b6c 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/model/param/TccOperatorParam.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/param/TccOperatorParam.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java b/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java index 8ad9a68..799a8ad 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/model/responses/DtmResponse.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java b/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java index 9bf5aa3..45a9544 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/utils/FeignUtils.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -27,7 +27,7 @@ import pub.dtm.client.constant.Constants; import pub.dtm.client.exception.FailureException; import feign.Response; -import pub.dtm.client.interfaces.communication.IURIParser; +import pub.dtm.client.interfaces.stub.IURIParser; import pub.dtm.client.model.feign.ServiceMessage; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; diff --git a/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java b/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java index f04d24e..94a9e68 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/utils/HttpUtils.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-common/src/main/java/pub/dtm/client/utils/JsonUtils.java b/dtmcli-common/src/main/java/pub/dtm/client/utils/JsonUtils.java index ca381c2..9bf435b 100644 --- a/dtmcli-common/src/main/java/pub/dtm/client/utils/JsonUtils.java +++ b/dtmcli-common/src/main/java/pub/dtm/client/utils/JsonUtils.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java index e2d65c8..2af09f2 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BarrierParam.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java index ac976b8..05ed66c 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/barrier/BranchBarrier.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java b/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java index c76fee2..3725ab3 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/base/BranchIdGenerator.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java b/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java index 723843e..e23bde1 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/saga/Saga.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -32,7 +32,7 @@ import pub.dtm.client.constant.ParamFieldConstants; import pub.dtm.client.enums.TransTypeEnum; import pub.dtm.client.exception.FailureException; -import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; +import pub.dtm.client.interfaces.stub.IDtmServerStub; import pub.dtm.client.model.dtm.TransBase; import pub.dtm.client.model.feign.ServiceMessage; import pub.dtm.client.model.param.SagaOperatorParam; @@ -58,7 +58,7 @@ public class Saga extends TransBase { private static final String CONCURRENT = "concurrent"; - private IDtmCommunicationClient dtmCommunicationClient; + private IDtmServerStub dtmServerStub; private boolean concurrent; @@ -78,11 +78,11 @@ public class Saga extends TransBase { private List payloads = new ArrayList<>(); - public Saga(String gid, IDtmCommunicationClient dtmCommunicationClient) { + public Saga(String gid, IDtmServerStub dtmServerStub) { super(gid, TransTypeEnum.SAGA, false); this.concurrent = false; this.orders = new HashMap<>(); - this.dtmCommunicationClient = dtmCommunicationClient; + this.dtmServerStub = dtmServerStub; } public Saga add(ServiceMessage action, ServiceMessage compensate, Object postData) { @@ -114,7 +114,7 @@ public Saga add(String action, String compensate, Object postData) { public String submit() throws Exception { if (StringUtils.isEmpty(this.getGid())) { - this.setGid(FeignUtils.parseGid(dtmCommunicationClient.newGid())); + this.setGid(FeignUtils.parseGid(dtmServerStub.newGid())); } addConcurrentContext(); SagaOperatorParam operatorParam = new SagaOperatorParam(this.getGid(), TransTypeEnum.SAGA, this.getSteps(), @@ -122,7 +122,7 @@ public String submit() throws Exception { this.getRetryInterval(), this.getPassthroughHeaders(), this.getBranchHeaders()); try { - dtmCommunicationClient.submit(operatorParam); + dtmServerStub.submit(operatorParam); } catch (Exception e) { log.error("saga transaction submit failed, transaction gid is {}", this.getGid()); throw new FailureException(e); diff --git a/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java index 5a30c4a..1f36242 100644 --- a/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java +++ b/dtmcli-core/src/main/java/pub/dtm/client/tcc/Tcc.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -30,7 +30,7 @@ import pub.dtm.client.constant.ParamFieldConstants; import pub.dtm.client.enums.TransTypeEnum; import pub.dtm.client.exception.FailureException; -import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; +import pub.dtm.client.interfaces.stub.IDtmServerStub; import pub.dtm.client.interfaces.dtm.DtmConsumer; import pub.dtm.client.model.dtm.TransBase; import pub.dtm.client.model.feign.ServiceMessage; @@ -68,16 +68,16 @@ public class Tcc extends TransBase { /** * feign client */ - private IDtmCommunicationClient dtmCommunicationClient; + private IDtmServerStub dtmServerStub; - public Tcc(String gid, IDtmCommunicationClient dtmCommunicationClient) { + public Tcc(String gid, IDtmServerStub dtmServerStub) { super(gid, TransTypeEnum.TCC, false); this.branchIdGenerator = new BranchIdGenerator(Constants.EMPTY_STRING); - this.dtmCommunicationClient = dtmCommunicationClient; + this.dtmServerStub = dtmServerStub; } - public void setdtmCommunicationClient(IDtmCommunicationClient dtmCommunicationClient) { - this.dtmCommunicationClient = dtmCommunicationClient; + public void setDtmServerStub(IDtmServerStub dtmServerStub) { + this.dtmServerStub = dtmServerStub; } /** @@ -89,12 +89,12 @@ public void setdtmCommunicationClient(IDtmCommunicationClient dtmCommunicationCl public String tccGlobalTransaction(DtmConsumer consumer) throws Exception { // if tcc's gid is empty, need to request a new gid from dtm svr if (StringUtils.isEmpty(this.getGid())) { - this.setGid(FeignUtils.parseGid(dtmCommunicationClient.newGid())); + this.setGid(FeignUtils.parseGid(dtmServerStub.newGid())); } log.info("the tcc transaction's gid is {}", this.getGid()); OperatorParam operatorParam = new OperatorParam(this.getGid(), TransTypeEnum.TCC); - DtmResponse resp = dtmCommunicationClient.prepare(operatorParam); + DtmResponse resp = dtmServerStub.prepare(operatorParam); log.info("prepare response: {}", resp); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction prepare fail. returned dtm_result is: {}, transaction gid: {}", resp.getDtmResult(), this.getGid()); @@ -102,10 +102,10 @@ public String tccGlobalTransaction(DtmConsumer consumer) throws Exception { } try { consumer.accept(this); - dtmCommunicationClient.submit(operatorParam); + dtmServerStub.submit(operatorParam); } catch (Exception e) { log.error("TCC transaction submit fail, start abort it. transaction gid: {}", this.getGid()); - dtmCommunicationClient.abort(operatorParam); + dtmServerStub.abort(operatorParam); throw new FailureException(e); } return this.getGid(); @@ -128,7 +128,7 @@ public feign.Response callBranch(Object body, ServiceMessage tryMessage, Service TccOperatorParam operatorParam = new TccOperatorParam(this.getGid(), TransTypeEnum.TCC, branchId, Constants.DEFAULT_STATUS, JsonUtils.toJson(body), FeignUtils.generatorURI(confirmMessage, false), FeignUtils.generatorURI(cancelMessage, false)); - DtmResponse resp = dtmCommunicationClient.registerBranch(operatorParam); + DtmResponse resp = dtmServerStub.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); throw new FailureException("TCC Transaction register branch fail"); @@ -140,7 +140,7 @@ public feign.Response callBranch(Object body, ServiceMessage tryMessage, Service paramsMap.put(ParamFieldConstants.BRANCH_ID, branchId); paramsMap.put(ParamFieldConstants.OP, OP); - feign.Response response = dtmCommunicationClient.busiPost(new URI(FeignUtils.generatorURI(tryMessage, true)), + feign.Response response = dtmServerStub.busiPost(new URI(FeignUtils.generatorURI(tryMessage, true)), tryMessage.getPath(), paramsMap, body); log.info("busi post is: {}", response); FeignUtils.checkResult(response); @@ -163,7 +163,7 @@ public Response callBranch(Object body, String tryUrl, String confirmUrl, String TccOperatorParam operatorParam = new TccOperatorParam(this.getGid(), TransTypeEnum.TCC, branchId, Constants.DEFAULT_STATUS, JsonUtils.toJson(body), confirmUrl, cancelUrl); - DtmResponse resp = dtmCommunicationClient.registerBranch(operatorParam); + DtmResponse resp = dtmServerStub.registerBranch(operatorParam); if (!Constants.SUCCESS_RESULT.equals(resp.getDtmResult())) { log.error("TCC transaction register branch fail. transaction gid: {}", this.getGid()); throw new FailureException("TCC Transaction register branch fail"); diff --git a/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java index d23da09..201dd5b 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,11 +28,11 @@ import feign.jackson.JacksonDecoder; import feign.jackson.JacksonEncoder; import pub.dtm.client.constant.Constants; -import pub.dtm.client.communication.DtmFeignClient; +import pub.dtm.client.stub.DtmFeignClient; import feign.Feign; -import pub.dtm.client.communication.URIParser; +import pub.dtm.client.stub.URIParser; import pub.dtm.client.interfaces.dtm.DtmConsumer; -import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; +import pub.dtm.client.interfaces.stub.IDtmServerStub; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,7 +53,7 @@ public class DtmClient { private static final Logger log = LoggerFactory.getLogger(DtmClient.class); - private IDtmCommunicationClient dtmCommunicationClient; + private IDtmServerStub dtmServerStub; public DtmClient() { // init URIParser @@ -77,7 +77,7 @@ public DtmClient() { log.error("can not resolve dtm server message from config file, you can use nacos or redirect configure to config it."); System.exit(-1); } - IDtmCommunicationClient feignClient = Feign + IDtmServerStub feignClient = Feign .builder() .decoder(new JacksonDecoder()) .encoder(new JacksonEncoder()) @@ -90,7 +90,7 @@ public DtmClient() { System.exit(-1); } - this.dtmCommunicationClient = feignClient; + this.dtmServerStub = feignClient; } public DtmClient(String endpoint) { @@ -101,7 +101,7 @@ public DtmClient(String endpoint) { log.error("dtm server endpoint can not be empty."); System.exit(-1); } - IDtmCommunicationClient feignClient = Feign + IDtmServerStub feignClient = Feign .builder() .decoder(new JacksonDecoder()) .encoder(new JacksonEncoder()) @@ -115,7 +115,7 @@ public DtmClient(String endpoint) { System.exit(-1); } - this.dtmCommunicationClient = feignClient; + this.dtmServerStub = feignClient; } private List genClusters(String clusterStr) { @@ -135,7 +135,7 @@ private List genClusters(String clusterStr) { * @throws Exception exception */ public String tccGlobalTransaction(DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(null, dtmCommunicationClient); + Tcc tcc = new Tcc(null, dtmServerStub); return tcc.tccGlobalTransaction(function); } @@ -147,7 +147,7 @@ public String tccGlobalTransaction(DtmConsumer function) throws Exception { * @throws Exception exception */ public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(gid, dtmCommunicationClient); + Tcc tcc = new Tcc(gid, dtmServerStub); return tcc.tccGlobalTransaction(function); } @@ -157,7 +157,7 @@ public String tccGlobalTransaction(String gid, DtmConsumer function) throws * @return Saga */ public Saga newSaga(String gid) { - return new Saga(gid, dtmCommunicationClient); + return new Saga(gid, dtmServerStub); } /** @@ -165,6 +165,6 @@ public Saga newSaga(String gid) { * @return Saga */ public Saga newSaga() { - return new Saga(null, dtmCommunicationClient); + return new Saga(null, dtmServerStub); } } diff --git a/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java b/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java index 06bb7b9..7f8c156 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/properties/DtmProperties.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,6 +28,12 @@ import java.io.IOException; import java.util.Properties; + +/** + * Load properties of dtm server + * + * @author horse + */ public class DtmProperties { private static Properties dtmProperties; diff --git a/dtmcli-java/src/main/java/pub/dtm/client/communication/DtmFeignClient.java b/dtmcli-java/src/main/java/pub/dtm/client/stub/DtmFeignClient.java similarity index 91% rename from dtmcli-java/src/main/java/pub/dtm/client/communication/DtmFeignClient.java rename to dtmcli-java/src/main/java/pub/dtm/client/stub/DtmFeignClient.java index c9e6b5c..1afbeb3 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/communication/DtmFeignClient.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/stub/DtmFeignClient.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.communication; +package pub.dtm.client.stub; import feign.Headers; import feign.Param; @@ -30,15 +30,20 @@ import feign.RequestLine; import feign.Response; import pub.dtm.client.constant.Constants; -import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; +import pub.dtm.client.interfaces.stub.IDtmServerStub; import pub.dtm.client.model.param.OperatorParam; import pub.dtm.client.model.responses.DtmResponse; import java.net.URI; import java.util.Map; +/** + * IDtmServerStub implements for open-feign + * + * @author horse + */ @Headers("Content-Type: application/json") -public interface DtmFeignClient extends IDtmCommunicationClient { +public interface DtmFeignClient extends IDtmServerStub { @Override default String stubType() { return "open-feign"; diff --git a/dtmcli-java/src/main/java/pub/dtm/client/communication/URIParser.java b/dtmcli-java/src/main/java/pub/dtm/client/stub/URIParser.java similarity index 91% rename from dtmcli-java/src/main/java/pub/dtm/client/communication/URIParser.java rename to dtmcli-java/src/main/java/pub/dtm/client/stub/URIParser.java index 912dda8..e62b1b3 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/communication/URIParser.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/stub/URIParser.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,16 +22,21 @@ * SOFTWARE. */ -package pub.dtm.client.communication; +package pub.dtm.client.stub; import com.alibaba.nacos.api.naming.pojo.Instance; import pub.dtm.client.constant.Constants; -import pub.dtm.client.interfaces.communication.IURIParser; +import pub.dtm.client.interfaces.stub.IURIParser; import pub.dtm.client.model.feign.ServiceMessage; import pub.dtm.client.properties.DtmProperties; import pub.dtm.client.utils.FeignUtils; import pub.dtm.client.utils.NacosUtils; +/** + * Parse url to dtm server for java client. + * + * @author horse + */ public class URIParser implements IURIParser { static { FeignUtils.setUriParser(new URIParser()); diff --git a/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java b/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java index 4529176..da45fd8 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/utils/NacosUtils.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -31,6 +31,11 @@ import java.util.List; +/** + * Nacos utils + * + * @author horse + */ public class NacosUtils { private static NamingService namingService; diff --git a/dtmcli-springcloud/src/main/java/pub/dtm/client/DtmClient.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/DtmClient.java index 3a0c34a..20db1e1 100644 --- a/dtmcli-springcloud/src/main/java/pub/dtm/client/DtmClient.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/DtmClient.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -26,22 +26,27 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; +import pub.dtm.client.interfaces.stub.IDtmServerStub; import pub.dtm.client.interfaces.dtm.DtmConsumer; import pub.dtm.client.saga.Saga; import pub.dtm.client.tcc.Tcc; +/** + * dtm client for spring + * + * @author horseLk + */ @Component public class DtmClient { @Autowired - private IDtmCommunicationClient dtmCommunicationClient; + private IDtmServerStub dtmServerStub; /** * start a tcc transaction without gid, client send a request to dtm svr for obtain a new gid. * @return gid */ public String tccGlobalTransaction(DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(null, dtmCommunicationClient); + Tcc tcc = new Tcc(null, dtmServerStub); return tcc.tccGlobalTransaction(function); } @@ -51,7 +56,7 @@ public String tccGlobalTransaction(DtmConsumer function) throws Exception { * @return gid */ public String tccGlobalTransaction(String gid, DtmConsumer function) throws Exception { - Tcc tcc = new Tcc(gid, dtmCommunicationClient); + Tcc tcc = new Tcc(gid, dtmServerStub); return tcc.tccGlobalTransaction(function); } @@ -61,7 +66,7 @@ public String tccGlobalTransaction(String gid, DtmConsumer function) throws * @return Saga */ public Saga newSaga(String gid) { - return new Saga(gid, dtmCommunicationClient); + return new Saga(gid, dtmServerStub); } /** @@ -69,6 +74,6 @@ public Saga newSaga(String gid) { * @return Saga */ public Saga newSaga() { - return new Saga(null, dtmCommunicationClient); + return new Saga(null, dtmServerStub); } } diff --git a/dtmcli-springcloud/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java index 4a05b44..7f53c22 100644 --- a/dtmcli-springcloud/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/configuration/DtmConfiguration.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,7 +24,7 @@ package pub.dtm.client.configuration; -import pub.dtm.client.communication.URIParser; +import pub.dtm.client.stub.URIParser; import pub.dtm.client.properties.DtmProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; @@ -35,10 +35,15 @@ import org.springframework.context.annotation.Configuration; import org.springframework.stereotype.Component; +/** + * Dtm client configuration + * + * @author horse + */ @Component @ComponentScan({"pub.dtm.client"}) @Configuration -@EnableFeignClients("pub.dtm.client.communication") +@EnableFeignClients("pub.dtm.client.stub") @EnableConfigurationProperties(DtmProperties.class) public class DtmConfiguration { @Autowired diff --git a/dtmcli-springcloud/src/main/java/pub/dtm/client/properties/DtmProperties.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/properties/DtmProperties.java index 3f7e5d9..7ecd3b7 100644 --- a/dtmcli-springcloud/src/main/java/pub/dtm/client/properties/DtmProperties.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/properties/DtmProperties.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -27,6 +27,11 @@ import lombok.Data; import org.springframework.boot.context.properties.ConfigurationProperties; +/** + * Load properties of dtm server + * + * @author horse + */ @ConfigurationProperties(prefix = DtmProperties.PREFIX) @Data public class DtmProperties { diff --git a/dtmcli-springcloud/src/main/java/pub/dtm/client/communication/DtmFeignClient.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/stub/DtmFeignClient.java similarity index 92% rename from dtmcli-springcloud/src/main/java/pub/dtm/client/communication/DtmFeignClient.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/stub/DtmFeignClient.java index 25a6996..b1ffe93 100644 --- a/dtmcli-springcloud/src/main/java/pub/dtm/client/communication/DtmFeignClient.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/stub/DtmFeignClient.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,7 +22,7 @@ * SOFTWARE. */ -package pub.dtm.client.communication; +package pub.dtm.client.stub; import feign.Response; import org.springframework.cloud.openfeign.FeignClient; @@ -33,15 +33,20 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import pub.dtm.client.constant.Constants; -import pub.dtm.client.interfaces.communication.IDtmCommunicationClient; +import pub.dtm.client.interfaces.stub.IDtmServerStub; import pub.dtm.client.model.param.OperatorParam; import pub.dtm.client.model.responses.DtmResponse; import java.net.URI; import java.util.Map; +/** + * IdtmServerStub implements for feign-spring + * + * @author horseLk + */ @FeignClient(value = "${dtm.service.name}") -public interface DtmFeignClient extends IDtmCommunicationClient { +public interface DtmFeignClient extends IDtmServerStub { @Override default String stubType() { return "feign-spring"; diff --git a/dtmcli-springcloud/src/main/java/pub/dtm/client/communication/URIParser.java b/dtmcli-springcloud/src/main/java/pub/dtm/client/stub/URIParser.java similarity index 90% rename from dtmcli-springcloud/src/main/java/pub/dtm/client/communication/URIParser.java rename to dtmcli-springcloud/src/main/java/pub/dtm/client/stub/URIParser.java index d6b098e..a3b3bbf 100644 --- a/dtmcli-springcloud/src/main/java/pub/dtm/client/communication/URIParser.java +++ b/dtmcli-springcloud/src/main/java/pub/dtm/client/stub/URIParser.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2022 yedf + * Copyright (c) 2022 dtm-labs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,18 @@ * SOFTWARE. */ -package pub.dtm.client.communication; +package pub.dtm.client.stub; import pub.dtm.client.constant.Constants; -import pub.dtm.client.interfaces.communication.IURIParser; +import pub.dtm.client.interfaces.stub.IURIParser; import pub.dtm.client.model.feign.ServiceMessage; import pub.dtm.client.utils.FeignUtils; +/** + * Parse url to dtm server for spring cloud client. + * + * @author horse + */ public class URIParser implements IURIParser { static { FeignUtils.setUriParser(new URIParser()); diff --git a/eureka-plugin/src/main/java/pub/dtm/client/configuration/EurekaConfiguration.java b/eureka-plugin/src/main/java/pub/dtm/client/configuration/EurekaConfiguration.java index 070b634..f62a267 100644 --- a/eureka-plugin/src/main/java/pub/dtm/client/configuration/EurekaConfiguration.java +++ b/eureka-plugin/src/main/java/pub/dtm/client/configuration/EurekaConfiguration.java @@ -1,10 +1,35 @@ +/* + * MIT License + * + * Copyright (c) 2022 dtm-labs + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package pub.dtm.client.configuration; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; /** + * Eureka configuration + * * @author horseLk - * @date 2022-05-18 22:40 */ @EnableEurekaClient public class EurekaConfiguration { From 38ecfba3ac43bb54d1b01d5ef512dbc7de4ac217 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Sat, 21 May 2022 01:41:54 +0800 Subject: [PATCH 19/24] fix --- dtmcli-common/pom.xml | 4 ++-- dtmcli-core/pom.xml | 6 +++--- dtmcli-java/pom.xml | 8 ++++---- dtmcli-springcloud/pom.xml | 12 ++++-------- eureka-plugin/pom.xml | 8 ++------ nacos-plugin/pom.xml | 4 ++-- pom.xml | 16 +++++++++++++++- 7 files changed, 32 insertions(+), 26 deletions(-) diff --git a/dtmcli-common/pom.xml b/dtmcli-common/pom.xml index 5b45adc..880ebee 100644 --- a/dtmcli-common/pom.xml +++ b/dtmcli-common/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.1 + 2.1.2 4.0.0 dtmcli-common - 2.1.1 + 2.1.2 jar dtmcli-common diff --git a/dtmcli-core/pom.xml b/dtmcli-core/pom.xml index dbdb56c..fc6bb4b 100644 --- a/dtmcli-core/pom.xml +++ b/dtmcli-core/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.1 + 2.1.2 4.0.0 dtmcli-core - 2.1.1 + 2.1.2 jar dtmcli-core @@ -24,7 +24,7 @@ io.github.dtm-labs dtmcli-common - 2.1.1 + 2.1.2 diff --git a/dtmcli-java/pom.xml b/dtmcli-java/pom.xml index 1ce28fe..7b1d514 100644 --- a/dtmcli-java/pom.xml +++ b/dtmcli-java/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.1 + 2.1.2 4.0.0 dtmcli-java - 2.1.1 + 2.1.2 jar dtmcli-java @@ -24,13 +24,13 @@ io.github.dtm-labs dtmcli-common - 2.1.1 + 2.1.2 io.github.dtm-labs dtmcli-core - 2.1.1 + 2.1.2 diff --git a/dtmcli-springcloud/pom.xml b/dtmcli-springcloud/pom.xml index b9208da..0197946 100644 --- a/dtmcli-springcloud/pom.xml +++ b/dtmcli-springcloud/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.1 + 2.1.2 4.0.0 dtmcli-springcloud - 2.1.1.2 + 2.1.2.2 jar dtmcli-springcloud @@ -18,33 +18,29 @@ UTF-8 1.8 1.8 - - 2.6.3 io.github.dtm-labs dtmcli-common - 2.1.1 + 2.1.2 io.github.dtm-labs dtmcli-core - 2.1.1 + 2.1.2 org.springframework.boot spring-boot-starter - ${springboot.version} org.springframework.boot spring-boot-configuration-processor - ${springboot.version} true diff --git a/eureka-plugin/pom.xml b/eureka-plugin/pom.xml index 854e4b8..2149129 100644 --- a/eureka-plugin/pom.xml +++ b/eureka-plugin/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.1 + 2.1.2 4.0.0 eureka-plugin - 2.1.1.2 + 2.1.2.2 jar eureka-plugin @@ -18,21 +18,17 @@ UTF-8 1.8 1.8 - - 2.6.3 org.springframework.boot spring-boot-starter - ${springboot.version} org.springframework.boot spring-boot-configuration-processor - ${springboot.version} true diff --git a/nacos-plugin/pom.xml b/nacos-plugin/pom.xml index d310087..0e86b92 100644 --- a/nacos-plugin/pom.xml +++ b/nacos-plugin/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.1 + 2.1.2 4.0.0 nacos-plugin - 2.1.1.2 + 2.1.2.2 jar nacos-plugin diff --git a/pom.xml b/pom.xml index 0f215b1..d42cbe5 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.dtm-labs dtmcli-java-parent - 2.1.1 + 2.1.2 pom dtmcli-java-parent @@ -35,6 +35,8 @@ 3.14.9 1.4.2 1.7.30 + + 2.6.3 2021.0.1 2021.0.1.0 @@ -96,6 +98,18 @@ ${slf4j.version} + + org.springframework.boot + spring-boot-starter + ${springboot.version} + + + + org.springframework.boot + spring-boot-configuration-processor + ${springboot.version} + + org.springframework.cloud spring-cloud-dependencies From 0a6683faf8c001d7e7998533b363876d5d97b332 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Sat, 21 May 2022 14:42:13 +0800 Subject: [PATCH 20/24] updat reademe --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eecfa20..958ed9f 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ dtm.ipport=127.0.0.1:36789 ### 完整示例 #### dtmcli-java使用示例 -[dtmcli-java-sample](https://github.com/dtm-labs/dtmcli-java-sample) +[dtmcli-java-sample](https://github.com/dtm-labs/dtmcli-java-sample) [dtmcli-java-sample-use-configuration](https://github.com/horseLk/dtmcli-java-sample-with-conf) #### dtmcli-springcloud使用示例 [dtmcli-java-spring-sample](https://github.com/dtm-labs/dtmcli-java-spring-sample) From 1312f977f18db936b4f42d7a7dbf376a19ec375a Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Sun, 22 May 2022 02:07:38 +0800 Subject: [PATCH 21/24] upgrade version --- dtmcli-common/pom.xml | 4 ++-- dtmcli-core/pom.xml | 6 +++--- dtmcli-java/pom.xml | 8 ++++---- dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java | 4 ++++ dtmcli-springcloud/pom.xml | 8 ++++---- eureka-plugin/pom.xml | 4 ++-- nacos-plugin/pom.xml | 4 ++-- pom.xml | 2 +- 8 files changed, 22 insertions(+), 18 deletions(-) diff --git a/dtmcli-common/pom.xml b/dtmcli-common/pom.xml index 880ebee..03535c7 100644 --- a/dtmcli-common/pom.xml +++ b/dtmcli-common/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.2 + 2.1.3 4.0.0 dtmcli-common - 2.1.2 + 2.1.3 jar dtmcli-common diff --git a/dtmcli-core/pom.xml b/dtmcli-core/pom.xml index fc6bb4b..b90f8d8 100644 --- a/dtmcli-core/pom.xml +++ b/dtmcli-core/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.2 + 2.1.3 4.0.0 dtmcli-core - 2.1.2 + 2.1.3 jar dtmcli-core @@ -24,7 +24,7 @@ io.github.dtm-labs dtmcli-common - 2.1.2 + 2.1.3 diff --git a/dtmcli-java/pom.xml b/dtmcli-java/pom.xml index 7b1d514..307cf75 100644 --- a/dtmcli-java/pom.xml +++ b/dtmcli-java/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.2 + 2.1.3 4.0.0 dtmcli-java - 2.1.2 + 2.1.3 jar dtmcli-java @@ -24,13 +24,13 @@ io.github.dtm-labs dtmcli-common - 2.1.2 + 2.1.3 io.github.dtm-labs dtmcli-core - 2.1.2 + 2.1.3 diff --git a/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java index 201dd5b..85085e2 100644 --- a/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java +++ b/dtmcli-java/src/main/java/pub/dtm/client/DtmClient.java @@ -118,6 +118,10 @@ public DtmClient(String endpoint) { this.dtmServerStub = feignClient; } + public DtmClient(IDtmServerStub dtmServerStub) { + this.dtmServerStub = dtmServerStub; + } + private List genClusters(String clusterStr) { if (StringUtils.isEmpty(clusterStr)) { List clusters = new ArrayList<>(); diff --git a/dtmcli-springcloud/pom.xml b/dtmcli-springcloud/pom.xml index 0197946..9e28787 100644 --- a/dtmcli-springcloud/pom.xml +++ b/dtmcli-springcloud/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.2 + 2.1.3 4.0.0 dtmcli-springcloud - 2.1.2.2 + 2.1.3.2 jar dtmcli-springcloud @@ -24,13 +24,13 @@ io.github.dtm-labs dtmcli-common - 2.1.2 + 2.1.3 io.github.dtm-labs dtmcli-core - 2.1.2 + 2.1.3 diff --git a/eureka-plugin/pom.xml b/eureka-plugin/pom.xml index 2149129..e912d16 100644 --- a/eureka-plugin/pom.xml +++ b/eureka-plugin/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.2 + 2.1.3 4.0.0 eureka-plugin - 2.1.2.2 + 2.1.3.2 jar eureka-plugin diff --git a/nacos-plugin/pom.xml b/nacos-plugin/pom.xml index 0e86b92..46371f4 100644 --- a/nacos-plugin/pom.xml +++ b/nacos-plugin/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.2 + 2.1.3 4.0.0 nacos-plugin - 2.1.2.2 + 2.1.3.2 jar nacos-plugin diff --git a/pom.xml b/pom.xml index d42cbe5..a06e556 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.dtm-labs dtmcli-java-parent - 2.1.2 + 2.1.3 pom dtmcli-java-parent From f5c329f36fe65cddb129023e5e4020bcb1a73e54 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Mon, 23 May 2022 01:00:14 +0800 Subject: [PATCH 22/24] fix --- dtmcli-common/pom.xml | 4 ++-- dtmcli-core/pom.xml | 6 +++--- dtmcli-java/pom.xml | 8 ++++---- dtmcli-springcloud/pom.xml | 34 ++++++++++++++++++++++++++++++---- eureka-plugin/pom.xml | 21 +++++++++++++++++++-- nacos-plugin/pom.xml | 29 +++++++++++++++++++++++++++-- pom.xml | 34 +--------------------------------- 7 files changed, 86 insertions(+), 50 deletions(-) diff --git a/dtmcli-common/pom.xml b/dtmcli-common/pom.xml index 03535c7..8f58649 100644 --- a/dtmcli-common/pom.xml +++ b/dtmcli-common/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.3 + 2.1.4 4.0.0 dtmcli-common - 2.1.3 + 2.1.4 jar dtmcli-common diff --git a/dtmcli-core/pom.xml b/dtmcli-core/pom.xml index b90f8d8..574fb5c 100644 --- a/dtmcli-core/pom.xml +++ b/dtmcli-core/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.3 + 2.1.4 4.0.0 dtmcli-core - 2.1.3 + 2.1.4 jar dtmcli-core @@ -24,7 +24,7 @@ io.github.dtm-labs dtmcli-common - 2.1.3 + 2.1.4 diff --git a/dtmcli-java/pom.xml b/dtmcli-java/pom.xml index 307cf75..d09f884 100644 --- a/dtmcli-java/pom.xml +++ b/dtmcli-java/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.3 + 2.1.4 4.0.0 dtmcli-java - 2.1.3 + 2.1.4 jar dtmcli-java @@ -24,13 +24,13 @@ io.github.dtm-labs dtmcli-common - 2.1.3 + 2.1.4 io.github.dtm-labs dtmcli-core - 2.1.3 + 2.1.4 diff --git a/dtmcli-springcloud/pom.xml b/dtmcli-springcloud/pom.xml index 9e28787..4aabfa9 100644 --- a/dtmcli-springcloud/pom.xml +++ b/dtmcli-springcloud/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.3 + 2.1.4 4.0.0 dtmcli-springcloud - 2.1.3.2 + 2.1.4.2 jar dtmcli-springcloud @@ -18,29 +18,35 @@ UTF-8 1.8 1.8 + + 2.6.3 + 2021.0.1 + 2021.0.1.0 io.github.dtm-labs dtmcli-common - 2.1.3 + 2.1.4 io.github.dtm-labs dtmcli-core - 2.1.3 + 2.1.4 org.springframework.boot spring-boot-starter + ${springboot.version} org.springframework.boot spring-boot-configuration-processor + ${springboot.version} true @@ -50,4 +56,24 @@ + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${alibaba-cloud.version} + pom + import + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + \ No newline at end of file diff --git a/eureka-plugin/pom.xml b/eureka-plugin/pom.xml index e912d16..274fb49 100644 --- a/eureka-plugin/pom.xml +++ b/eureka-plugin/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.3 + 2.1.4 4.0.0 eureka-plugin - 2.1.3.2 + 2.1.4.2 jar eureka-plugin @@ -18,17 +18,22 @@ UTF-8 1.8 1.8 + + 2.6.3 + 2021.0.1 org.springframework.boot spring-boot-starter + ${springboot.version} org.springframework.boot spring-boot-configuration-processor + ${springboot.version} true @@ -38,4 +43,16 @@ spring-cloud-starter-netflix-eureka-client + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + \ No newline at end of file diff --git a/nacos-plugin/pom.xml b/nacos-plugin/pom.xml index 46371f4..1c3eceb 100644 --- a/nacos-plugin/pom.xml +++ b/nacos-plugin/pom.xml @@ -5,12 +5,12 @@ dtmcli-java-parent io.github.dtm-labs - 2.1.3 + 2.1.4 4.0.0 nacos-plugin - 2.1.3.2 + 2.1.4.2 jar nacos-plugin @@ -18,6 +18,9 @@ UTF-8 1.8 1.8 + + 2021.0.1 + 2021.0.1.0 @@ -42,4 +45,26 @@ spring-cloud-loadbalancer + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${alibaba-cloud.version} + pom + import + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index a06e556..c81ae7a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.dtm-labs dtmcli-java-parent - 2.1.3 + 2.1.4 pom dtmcli-java-parent @@ -35,10 +35,6 @@ 3.14.9 1.4.2 1.7.30 - - 2.6.3 - 2021.0.1 - 2021.0.1.0 @@ -97,34 +93,6 @@ slf4j-api ${slf4j.version} - - - org.springframework.boot - spring-boot-starter - ${springboot.version} - - - - org.springframework.boot - spring-boot-configuration-processor - ${springboot.version} - - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - com.alibaba.cloud - spring-cloud-alibaba-dependencies - ${alibaba-cloud.version} - pom - import - From a0cbfaf9cced6a3019dca2935fe5dc29f1f70347 Mon Sep 17 00:00:00 2001 From: KuiLiao Date: Mon, 23 May 2022 01:17:08 +0800 Subject: [PATCH 23/24] fix --- dtmcli-springcloud/pom.xml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/dtmcli-springcloud/pom.xml b/dtmcli-springcloud/pom.xml index 4aabfa9..dae4171 100644 --- a/dtmcli-springcloud/pom.xml +++ b/dtmcli-springcloud/pom.xml @@ -21,7 +21,6 @@ 2.6.3 2021.0.1 - 2021.0.1.0 @@ -58,14 +57,6 @@ - - com.alibaba.cloud - spring-cloud-alibaba-dependencies - ${alibaba-cloud.version} - pom - import - - org.springframework.cloud spring-cloud-dependencies From 33063718433e75fa74496ca69efeecf7bd557da2 Mon Sep 17 00:00:00 2001 From: Kui Liao <54488655+horseLk@users.noreply.github.com> Date: Mon, 23 May 2022 22:59:22 +0800 Subject: [PATCH 24/24] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 958ed9f..277143b 100644 --- a/README.md +++ b/README.md @@ -54,9 +54,9 @@ DTM是一款跨语言的开源分布式事务管理器,优雅的解决了幂 | artifact| version | 适用版本 |备注| |:-----:|:----:|:----:|:----:| -|dtmcli-springcloud| 2.1.0.1| 2.4.0 <= springboot version < 2.5.13| springboot 版本>=2.5.0,需要设置spring.cloud.compatibility-verifier.enabled=false| -|dtmcli-springcloud| 2.1.0.2| 2.6.0 <= springboot version < 2.6.latest| | -|dtmcli-java| 2.1.0| others| | +|dtmcli-springcloud| 2.1.4.1| 2.4.0 <= springboot version < 2.5.13| springboot 版本>=2.5.0,需要设置spring.cloud.compatibility-verifier.enabled=false| +|dtmcli-springcloud| 2.1.4.2| 2.6.0 <= springboot version < 2.6.latest| | +|dtmcli-java| 2.1.4| others| | ### 步骤二:添加依赖项 @@ -139,4 +139,4 @@ dtm.ipport=127.0.0.1:36789 [MIT](https://github.com/dtm-labs/dtmcli/blob/master/LICENSE) -[license-badge]: https://img.shields.io/github/license/dtm-labs/dtmcli-py \ No newline at end of file +[license-badge]: https://img.shields.io/github/license/dtm-labs/dtmcli-py