diff --git a/db/2pigxx.sql b/db/2pigxx.sql
index 2df352ac7..a689e26f1 100644
--- a/db/2pigxx.sql
+++ b/db/2pigxx.sql
@@ -49,7 +49,7 @@ DROP TABLE IF EXISTS `sys_dept`;
CREATE TABLE `sys_dept` (
`dept_id` int(20) NOT NULL AUTO_INCREMENT,
`name` varchar(50) DEFAULT NULL COMMENT '部门名称',
- `sort` int(11) DEFAULT NULL COMMENT '排序',
+ `sort` int(11) DEFAULT '1' COMMENT '排序',
`create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
`del_flag` char(1) DEFAULT '0' COMMENT '是否删除 -1:已删除 0:正常',
@@ -62,7 +62,7 @@ CREATE TABLE `sys_dept` (
-- Records of `sys_dept`
-- ----------------------------
BEGIN;
-INSERT INTO `sys_dept` VALUES ('1', '山东', '1', '2018-01-22 19:00:23', '2019-05-18 14:56:06', '0', '0', '1'), ('2', '沙县国际', '2', '2018-01-22 19:00:38', '2019-05-18 14:12:07', '0', '0', '1'), ('3', '潍坊', '3', '2018-01-22 19:00:44', '2019-05-18 14:56:11', '0', '1', '1'), ('4', '高新', '4', '2018-01-22 19:00:52', '2019-05-18 14:56:09', '0', '3', '1'), ('5', '院校', '5', '2018-01-22 19:00:57', '2019-05-18 14:56:13', '0', '4', '1'), ('6', '潍院', '6', '2018-01-22 19:01:06', '2019-05-18 14:56:16', '1', '5', '1'), ('7', '山东沙县', '7', '2018-01-22 19:01:57', '2019-05-18 14:12:17', '0', '2', '1'), ('8', '潍坊沙县', '8', '2018-01-22 19:02:03', '2019-05-18 14:12:19', '0', '7', '1'), ('9', '高新沙县', '9', '2018-01-22 19:02:14', '2019-05-18 14:12:22', '1', '8', '1'), ('10', '租户2', '1', '2018-11-18 13:27:11', '2019-05-18 14:12:31', '0', '0', '2'), ('11', '院校沙县', '2', '2018-12-10 21:19:26', '2019-05-18 14:12:33', '0', '8', '1'), ('12', '小院沙县', '3', '2019-04-28 17:33:31', '2019-05-18 14:12:36', '0', '11', '1');
+INSERT INTO `sys_dept` VALUES ('1', '山东', '1', '2018-01-22 19:00:23', '2019-05-18 14:56:06', '0', '0', '1'), ('2', '沙县国际', '2', '2018-01-22 19:00:38', '2019-05-18 14:12:07', '0', '0', '1'), ('3', '潍坊', '3', '2018-01-22 19:00:44', '2019-05-18 14:56:11', '0', '1', '1'), ('4', '高新', '4', '2018-01-22 19:00:52', '2019-05-18 14:56:09', '0', '3', '1'), ('5', '院校', '5', '2018-01-22 19:00:57', '2019-05-18 14:56:13', '0', '4', '1'), ('6', '潍院', '6', '2018-01-22 19:01:06', '2019-05-18 14:56:16', '1', '5', '1'), ('7', '山东沙县', '7', '2018-01-22 19:01:57', '2019-05-18 14:12:17', '0', '2', '1'), ('8', '潍坊沙县', '8', '2018-01-22 19:02:03', '2019-05-18 14:12:19', '0', '7', '1'), ('9', '高新沙县', '9', '2018-01-22 19:02:14', '2019-05-18 14:12:22', '1', '8', '1'), ('10', '租户部门', '1', '2018-11-18 13:27:11', '2019-06-06 16:22:58', '0', '0', '2'), ('11', '院校沙县', '2', '2018-12-10 21:19:26', '2019-05-18 14:12:33', '0', '8', '1'), ('12', '小院沙县', '3', '2019-04-28 17:33:31', '2019-05-18 14:12:36', '0', '11', '1');
COMMIT;
-- ----------------------------
@@ -289,7 +289,7 @@ CREATE TABLE `sys_role_menu` (
-- Records of `sys_role_menu`
-- ----------------------------
BEGIN;
-INSERT INTO `sys_role_menu` VALUES ('1', '1000'), ('1', '1100'), ('1', '1101'), ('1', '1102'), ('1', '1103'), ('1', '1200'), ('1', '1201'), ('1', '1202'), ('1', '1203'), ('1', '1300'), ('1', '1301'), ('1', '1302'), ('1', '1303'), ('1', '1304'), ('1', '1400'), ('1', '1401'), ('1', '1402'), ('1', '1403'), ('1', '1500'), ('1', '1501'), ('1', '1502'), ('1', '1503'), ('1', '2000'), ('1', '2100'), ('1', '2101'), ('1', '2200'), ('1', '2201'), ('1', '2202'), ('1', '2203'), ('1', '2210'), ('1', '2211'), ('1', '2212'), ('1', '2213'), ('1', '2300'), ('1', '2400'), ('1', '2401'), ('1', '2402'), ('1', '2403'), ('1', '2500'), ('1', '2501'), ('1', '2502'), ('1', '2503'), ('1', '2600'), ('1', '2601'), ('1', '2700'), ('1', '2800'), ('1', '2810'), ('1', '2820'), ('1', '2830'), ('1', '2840'), ('1', '2850'), ('1', '2860'), ('1', '3000'), ('1', '3100'), ('1', '3110'), ('1', '3200'), ('1', '3300'), ('1', '3400'), ('1', '3500'), ('1', '3600'), ('1', '3601'), ('1', '3620'), ('1', '3630'), ('1', '4000'), ('1', '4100'), ('1', '4101'), ('1', '4200'), ('1', '4201'), ('1', '4300'), ('1', '4301'), ('1', '4302'), ('1', '4303'), ('1', '4400'), ('1', '4401'), ('1', '6000'), ('1', '6100'), ('1', '6101'), ('1', '6102'), ('1', '6103'), ('1', '6200'), ('1', '6201'), ('1', '6202'), ('1', '6203'), ('1', '6300'), ('1', '6301'), ('1', '6302'), ('1', '6303'), ('1', '6304'), ('1', '6305'), ('1', '6400'), ('1', '6401'), ('1', '6402'), ('1', '6500'), ('1', '9999'), ('2', '1000'), ('2', '1100'), ('2', '1101'), ('2', '1102'), ('2', '1103'), ('2', '1200'), ('2', '1201'), ('2', '1202'), ('2', '1203'), ('2', '1300'), ('2', '1301'), ('2', '1302'), ('2', '1303'), ('2', '1304'), ('2', '1400'), ('2', '1401'), ('2', '1402'), ('2', '1403');
+INSERT INTO `sys_role_menu` VALUES ('1', '1000'), ('1', '1100'), ('1', '1101'), ('1', '1102'), ('1', '1103'), ('1', '1200'), ('1', '1201'), ('1', '1202'), ('1', '1203'), ('1', '1300'), ('1', '1301'), ('1', '1302'), ('1', '1303'), ('1', '1304'), ('1', '1400'), ('1', '1401'), ('1', '1402'), ('1', '1403'), ('1', '1500'), ('1', '1501'), ('1', '1502'), ('1', '1503'), ('1', '2000'), ('1', '2100'), ('1', '2101'), ('1', '2200'), ('1', '2201'), ('1', '2202'), ('1', '2203'), ('1', '2210'), ('1', '2211'), ('1', '2212'), ('1', '2213'), ('1', '2300'), ('1', '2400'), ('1', '2401'), ('1', '2402'), ('1', '2403'), ('1', '2500'), ('1', '2501'), ('1', '2502'), ('1', '2503'), ('1', '2600'), ('1', '2601'), ('1', '2700'), ('1', '2800'), ('1', '2810'), ('1', '2820'), ('1', '2830'), ('1', '2840'), ('1', '2850'), ('1', '2860'), ('1', '3000'), ('1', '3100'), ('1', '3110'), ('1', '3200'), ('1', '3300'), ('1', '3400'), ('1', '3500'), ('1', '3600'), ('1', '3601'), ('1', '3620'), ('1', '3630'), ('1', '4000'), ('1', '4100'), ('1', '4101'), ('1', '4200'), ('1', '4201'), ('1', '4300'), ('1', '4301'), ('1', '4302'), ('1', '4303'), ('1', '4400'), ('1', '4401'), ('1', '6000'), ('1', '6100'), ('1', '6101'), ('1', '6102'), ('1', '6103'), ('1', '6200'), ('1', '6201'), ('1', '6202'), ('1', '6203'), ('1', '6300'), ('1', '6301'), ('1', '6302'), ('1', '6303'), ('1', '6304'), ('1', '6305'), ('1', '6400'), ('1', '6401'), ('1', '6402'), ('1', '6500'), ('1', '9999');
COMMIT;
-- ----------------------------
diff --git a/pigx-auth/pom.xml b/pigx-auth/pom.xml
index 3181b8f46..f43211d3c 100644
--- a/pigx-auth/pom.xml
+++ b/pigx-auth/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx
- 3.0.0
+ 3.1.0
pigx-auth
diff --git a/pigx-common/pigx-common-bom/pom.xml b/pigx-common/pigx-common-bom/pom.xml
index a9616d960..0af3a50c6 100644
--- a/pigx-common/pigx-common-bom/pom.xml
+++ b/pigx-common/pigx-common-bom/pom.xml
@@ -16,12 +16,12 @@
pigx 公共版本控制
- 3.0.0
+ 3.1.0
3.1.0
- 1.1.16
+ 1.1.17
8.0.16
1.5.22
- 3.3.0
+ 3.4.0
diff --git a/pigx-common/pigx-common-core/pom.xml b/pigx-common/pigx-common-core/pom.xml
index 20bcde7cb..bd08009d7 100644
--- a/pigx-common/pigx-common-core/pom.xml
+++ b/pigx-common/pigx-common-core/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx-common
- 3.0.0
+ 3.1.0
pigx-common-core
diff --git a/pigx-common/pigx-common-data/pom.xml b/pigx-common/pigx-common-data/pom.xml
index 7681cb3a3..800c3b7a5 100644
--- a/pigx-common/pigx-common-data/pom.xml
+++ b/pigx-common/pigx-common-data/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx-common
- 3.0.0
+ 3.1.0
pigx-common-data
diff --git a/pigx-common/pigx-common-datasource/pom.xml b/pigx-common/pigx-common-datasource/pom.xml
index 32c4c9c41..fa95190b1 100644
--- a/pigx-common/pigx-common-datasource/pom.xml
+++ b/pigx-common/pigx-common-datasource/pom.xml
@@ -5,7 +5,7 @@
pigx-common
com.pig4cloud
- 3.0.0
+ 3.1.0
4.0.0
diff --git a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java
index af25dc51d..6d9338f10 100644
--- a/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java
+++ b/pigx-common/pigx-common-datasource/src/main/java/com/pig4cloud/pigx/common/datasource/config/DynamicDatasourceInterceptor.java
@@ -1,17 +1,15 @@
package com.pig4cloud.pigx.common.datasource.config;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
import com.pig4cloud.pigx.common.datasource.support.DynamicDataSourceContextHolder;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.data.redis.core.HashOperations;
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
/**
* @author lengleng
* @date 2019-05-18
@@ -22,15 +20,18 @@ import org.springframework.web.servlet.HandlerInterceptor;
@Component
@AllArgsConstructor
public class DynamicDatasourceInterceptor implements HandlerInterceptor {
- private final RedisTemplate redisTemplate;
+ /**
+ * TODO 根据上线文判断路由哪个数据库
+ *
+ * @param request
+ * @param response
+ * @param handler
+ * @return
+ */
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
- redisTemplate.setHashValueSerializer(new Jackson2JsonRedisSerializer<>(String.class));
- HashOperations vo = redisTemplate.opsForHash();
-// String dbName = vo.get("db_route_key", 1);
DynamicDataSourceContextHolder.setDataSourceType(1);
- log.info("数据源切换:{}", 1);
return true;
}
diff --git a/pigx-common/pigx-common-gateway/pom.xml b/pigx-common/pigx-common-gateway/pom.xml
index fb0530b99..d36e78c56 100644
--- a/pigx-common/pigx-common-gateway/pom.xml
+++ b/pigx-common/pigx-common-gateway/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx-common
- 3.0.0
+ 3.1.0
pigx-common-gateway
diff --git a/pigx-common/pigx-common-job/pom.xml b/pigx-common/pigx-common-job/pom.xml
index f76d82892..7cd62b509 100644
--- a/pigx-common/pigx-common-job/pom.xml
+++ b/pigx-common/pigx-common-job/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx-common
- 3.0.0
+ 3.1.0
pigx-common-job
diff --git a/pigx-common/pigx-common-log/pom.xml b/pigx-common/pigx-common-log/pom.xml
index 9c47752d2..a682c5cb0 100644
--- a/pigx-common/pigx-common-log/pom.xml
+++ b/pigx-common/pigx-common-log/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx-common
- 3.0.0
+ 3.1.0
pigx-common-log
diff --git a/pigx-common/pigx-common-minio/pom.xml b/pigx-common/pigx-common-minio/pom.xml
index 10db5e14d..a44d3b7e4 100755
--- a/pigx-common/pigx-common-minio/pom.xml
+++ b/pigx-common/pigx-common-minio/pom.xml
@@ -6,7 +6,7 @@
com.pig4cloud
pigx-common
- 3.0.0
+ 3.1.0
pigx-common-minio
diff --git a/pigx-common/pigx-common-security/pom.xml b/pigx-common/pigx-common-security/pom.xml
index 58095bc84..d9a182fd2 100644
--- a/pigx-common/pigx-common-security/pom.xml
+++ b/pigx-common/pigx-common-security/pom.xml
@@ -23,7 +23,7 @@
com.pig4cloud
pigx-common
- 3.0.0
+ 3.1.0
pigx-common-security
diff --git a/pigx-common/pigx-common-swagger/pom.xml b/pigx-common/pigx-common-swagger/pom.xml
index b59063b81..a4d640435 100644
--- a/pigx-common/pigx-common-swagger/pom.xml
+++ b/pigx-common/pigx-common-swagger/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx-common
- 3.0.0
+ 3.1.0
pigx-common-swagger
diff --git a/pigx-common/pigx-common-transaction/pom.xml b/pigx-common/pigx-common-transaction/pom.xml
index b165ce19d..7ab75bb90 100644
--- a/pigx-common/pigx-common-transaction/pom.xml
+++ b/pigx-common/pigx-common-transaction/pom.xml
@@ -5,7 +5,7 @@
com.pig4cloud
pigx-common
- 3.0.0
+ 3.1.0
pigx-common-transaction
diff --git a/pigx-common/pom.xml b/pigx-common/pom.xml
index 99e723dfc..5224cb183 100644
--- a/pigx-common/pom.xml
+++ b/pigx-common/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx
- 3.0.0
+ 3.1.0
pigx-common
diff --git a/pigx-gateway/pom.xml b/pigx-gateway/pom.xml
index ba9c39a12..d4fe19457 100644
--- a/pigx-gateway/pom.xml
+++ b/pigx-gateway/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx
- 3.0.0
+ 3.1.0
pigx-gateway
diff --git a/pigx-register/pom.xml b/pigx-register/pom.xml
index 323247d1a..82544ae73 100755
--- a/pigx-register/pom.xml
+++ b/pigx-register/pom.xml
@@ -18,7 +18,7 @@
com.pig4cloud
pigx
- 3.0.0
+ 3.1.0
pigx-register
diff --git a/pigx-register/src/main/java/com/alibaba/nacos/console/utils/JwtTokenUtils.java b/pigx-register/src/main/java/com/alibaba/nacos/console/utils/JwtTokenUtils.java
index 1057d4620..2671288b9 100755
--- a/pigx-register/src/main/java/com/alibaba/nacos/console/utils/JwtTokenUtils.java
+++ b/pigx-register/src/main/java/com/alibaba/nacos/console/utils/JwtTokenUtils.java
@@ -38,102 +38,102 @@ import java.util.List;
@Component
public class JwtTokenUtils {
- private final Logger log = LoggerFactory.getLogger(JwtTokenUtils.class);
+ private final Logger log = LoggerFactory.getLogger(JwtTokenUtils.class);
- private static final String AUTHORITIES_KEY = "auth";
+ private static final String AUTHORITIES_KEY = "auth";
- /**
- * secret key
- */
- private String secretKey;
+ /**
+ * secret key
+ */
+ private String secretKey;
- /**
- * Token validity time(ms)
- */
- private long tokenValidityInMilliseconds;
+ /**
+ * Token validity time(ms)
+ */
+ private long tokenValidityInMilliseconds;
- @PostConstruct
- public void init() {
- this.secretKey = "SecretKey012345678901234567890123456789012345678901234567890123456789";
- this.tokenValidityInMilliseconds = 1000 * 60 * 30L;
- }
+ @PostConstruct
+ public void init() {
+ this.secretKey = "SecretKey012345678901234567890123456789012345678901234567890123456789";
+ this.tokenValidityInMilliseconds = 1000 * 60 * 30L;
+ }
- /**
- * Create token
- *
- * @param authentication auth info
- * @return token
- */
- public String createToken(Authentication authentication) {
- /**
- * Current time
- */
- long now = (new Date()).getTime();
- /**
- * Validity date
- */
- Date validity;
- validity = new Date(now + this.tokenValidityInMilliseconds);
+ /**
+ * Create token
+ *
+ * @param authentication auth info
+ * @return token
+ */
+ public String createToken(Authentication authentication) {
+ /**
+ * Current time
+ */
+ long now = (new Date()).getTime();
+ /**
+ * Validity date
+ */
+ Date validity;
+ validity = new Date(now + this.tokenValidityInMilliseconds);
- /**
- * create token
- */
- return Jwts.builder()
- .setSubject(authentication.getName())
- .claim(AUTHORITIES_KEY, "")
- .setExpiration(validity)
- .signWith(SignatureAlgorithm.HS256, secretKey)
- .compact();
- }
+ /**
+ * create token
+ */
+ return Jwts.builder()
+ .setSubject(authentication.getName())
+ .claim(AUTHORITIES_KEY, "")
+ .setExpiration(validity)
+ .signWith(SignatureAlgorithm.HS256, secretKey)
+ .compact();
+ }
- /**
- * Get auth Info
- *
- * @param token token
- * @return auth info
- */
- public Authentication getAuthentication(String token) {
- /**
- * parse the payload of token
- */
- Claims claims = Jwts.parser()
- .setSigningKey(secretKey)
- .parseClaimsJws(token)
- .getBody();
+ /**
+ * Get auth Info
+ *
+ * @param token token
+ * @return auth info
+ */
+ public Authentication getAuthentication(String token) {
+ /**
+ * parse the payload of token
+ */
+ Claims claims = Jwts.parser()
+ .setSigningKey(secretKey)
+ .parseClaimsJws(token)
+ .getBody();
- List authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY));
+ List authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get(AUTHORITIES_KEY));
- User principal = new User(claims.getSubject(), "", authorities);
- return new UsernamePasswordAuthenticationToken(principal, "", authorities);
- }
+ User principal = new User(claims.getSubject(), "", authorities);
+ return new UsernamePasswordAuthenticationToken(principal, "", authorities);
+ }
- /**
- * validate token
- *
- * @param token token
- * @return whether valid
- */
- public boolean validateToken(String token) {
- try {
- Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token);
- return true;
- } catch (SignatureException e) {
- log.info("Invalid JWT signature.");
- log.trace("Invalid JWT signature trace: {}", e);
- } catch (MalformedJwtException e) {
- log.info("Invalid JWT token.");
- log.trace("Invalid JWT token trace: {}", e);
- } catch (ExpiredJwtException e) {
- log.info("Expired JWT token.");
- log.trace("Expired JWT token trace: {}", e);
- } catch (UnsupportedJwtException e) {
- log.info("Unsupported JWT token.");
- log.trace("Unsupported JWT token trace: {}", e);
- } catch (IllegalArgumentException e) {
- log.info("JWT token compact of handler are invalid.");
- log.trace("JWT token compact of handler are invalid trace: {}", e);
- }
- return false;
- }
+ /**
+ * validate token
+ *
+ * @param token token
+ * @return whether valid
+ */
+ public boolean validateToken(String token) {
+ try {
+ Jwts.parser().setSigningKey(secretKey).parseClaimsJws(token);
+ return true;
+ } catch (SecurityException e) {
+ log.info("Invalid JWT signature.");
+ log.trace("Invalid JWT signature trace: {}", e);
+ } catch (MalformedJwtException e) {
+ log.info("Invalid JWT token.");
+ log.trace("Invalid JWT token trace: {}", e);
+ } catch (ExpiredJwtException e) {
+ log.info("Expired JWT token.");
+ log.trace("Expired JWT token trace: {}", e);
+ } catch (UnsupportedJwtException e) {
+ log.info("Unsupported JWT token.");
+ log.trace("Unsupported JWT token trace: {}", e);
+ } catch (IllegalArgumentException e) {
+ log.info("JWT token compact of handler are invalid.");
+ log.trace("JWT token compact of handler are invalid trace: {}", e);
+ }
+ return false;
+ }
}
diff --git a/pigx-upms/pigx-upms-api/pom.xml b/pigx-upms/pigx-upms-api/pom.xml
index df9f82ff2..c7e5745d9 100644
--- a/pigx-upms/pigx-upms-api/pom.xml
+++ b/pigx-upms/pigx-upms-api/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx-upms
- 3.0.0
+ 3.1.0
pigx-upms-api
diff --git a/pigx-upms/pigx-upms-biz/pom.xml b/pigx-upms/pigx-upms-biz/pom.xml
index bee4afd42..ad8154c5a 100644
--- a/pigx-upms/pigx-upms-biz/pom.xml
+++ b/pigx-upms/pigx-upms-biz/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx-upms
- 3.0.0
+ 3.1.0
pigx-upms-biz
diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysTenantController.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysTenantController.java
index d5383a05e..277c1493c 100755
--- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysTenantController.java
+++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/controller/SysTenantController.java
@@ -21,11 +21,13 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pig4cloud.pigx.admin.api.entity.SysTenant;
import com.pig4cloud.pigx.admin.service.SysTenantService;
+import com.pig4cloud.pigx.common.core.constant.CacheConstants;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.common.log.annotation.SysLog;
import com.pig4cloud.pigx.common.security.annotation.Inner;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
+import org.springframework.cache.annotation.CacheEvict;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -89,6 +91,7 @@ public class SysTenantController {
*/
@SysLog("修改租户")
@PutMapping
+ @CacheEvict(value = CacheConstants.TENANT_DETAILS)
@PreAuthorize("@pms.hasPermission('admin_systenant_edit')")
public R updateById(@RequestBody SysTenant sysTenant) {
return R.ok(sysTenantService.updateById(sysTenant));
@@ -102,6 +105,7 @@ public class SysTenantController {
*/
@SysLog("删除租户")
@DeleteMapping("/{id}")
+ @CacheEvict(value = CacheConstants.TENANT_DETAILS)
@PreAuthorize("@pms.hasPermission('admin_systenant_del')")
public R removeById(@PathVariable Integer id) {
return R.ok(sysTenantService.removeById(id));
diff --git a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java
index 3d06fe8bc..f3d2266c2 100755
--- a/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java
+++ b/pigx-upms/pigx-upms-biz/src/main/java/com/pig4cloud/pigx/admin/service/impl/SysTenantServiceImpl.java
@@ -19,9 +19,9 @@ package com.pig4cloud.pigx.admin.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pigx.admin.api.entity.*;
-import com.pig4cloud.pigx.admin.api.entity.SysTenant;
import com.pig4cloud.pigx.admin.mapper.SysTenantMapper;
import com.pig4cloud.pigx.admin.service.*;
+import com.pig4cloud.pigx.common.core.constant.CacheConstants;
import com.pig4cloud.pigx.common.core.constant.CommonConstants;
import com.pig4cloud.pigx.common.core.constant.enums.DictTypeEnum;
import com.pig4cloud.pigx.common.core.exception.CheckedException;
@@ -31,10 +31,12 @@ import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.springframework.beans.BeanUtils;
+import org.springframework.cache.annotation.CacheEvict;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import springfox.documentation.annotations.Cacheable;
import java.time.LocalDate;
import java.util.List;
@@ -70,6 +72,7 @@ public class SysTenantServiceImpl extends ServiceImpl getNormal() {
return list(Wrappers.lambdaQuery()
.eq(SysTenant::getStatus, CommonConstants.STATUS_NORMAL)
@@ -94,6 +97,7 @@ public class SysTenantServiceImpl extends ServiceImpl
com.pig4cloud
pigx
- 3.0.0
+ 3.1.0
pigx-upms
diff --git a/pigx-visual/pigx-activiti/pom.xml b/pigx-visual/pigx-activiti/pom.xml
index 139eace01..9dd4ccf99 100644
--- a/pigx-visual/pigx-activiti/pom.xml
+++ b/pigx-visual/pigx-activiti/pom.xml
@@ -23,7 +23,7 @@
com.pig4cloud
pigx-visual
- 3.0.0
+ 3.1.0
pigx-activiti
diff --git a/pigx-visual/pigx-codegen/pom.xml b/pigx-visual/pigx-codegen/pom.xml
index c2e9352f7..89a738620 100755
--- a/pigx-visual/pigx-codegen/pom.xml
+++ b/pigx-visual/pigx-codegen/pom.xml
@@ -6,7 +6,7 @@
com.pig4cloud
pigx-visual
- 3.0.0
+ 3.1.0
pigx-codegen
diff --git a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java
index 7fc8ef8a8..e500c0028 100755
--- a/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java
+++ b/pigx-visual/pigx-codegen/src/main/java/com/pig4cloud/pigx/codegen/PigxCodeGenApplication.java
@@ -29,7 +29,7 @@ import org.springframework.cloud.client.SpringCloudApplication;
* @date 2018/07/29
* 代码生成模块
*/
-@EnableDynamicDataSource //开启动态数据源
+@EnableDynamicDataSource
@EnablePigxSwagger2
@SpringCloudApplication
@EnablePigxFeignClients
diff --git a/pigx-visual/pigx-daemon-elastic-job/pom.xml b/pigx-visual/pigx-daemon-elastic-job/pom.xml
index 800a91a8e..4fe642f26 100644
--- a/pigx-visual/pigx-daemon-elastic-job/pom.xml
+++ b/pigx-visual/pigx-daemon-elastic-job/pom.xml
@@ -23,7 +23,7 @@
com.pig4cloud
pigx-visual
- 3.0.0
+ 3.1.0
pigx-daemon-elastic-job
diff --git a/pigx-visual/pigx-daemon-quartz/pom.xml b/pigx-visual/pigx-daemon-quartz/pom.xml
index 1f1897e60..cc30670e6 100644
--- a/pigx-visual/pigx-daemon-quartz/pom.xml
+++ b/pigx-visual/pigx-daemon-quartz/pom.xml
@@ -5,7 +5,7 @@
com.pig4cloud
pigx-visual
- 3.0.0
+ 3.1.0
4.0.0
diff --git a/pigx-visual/pigx-monitor/pom.xml b/pigx-visual/pigx-monitor/pom.xml
index 03c1e4970..025cb36cc 100644
--- a/pigx-visual/pigx-monitor/pom.xml
+++ b/pigx-visual/pigx-monitor/pom.xml
@@ -24,7 +24,7 @@
com.pig4cloud
pigx-visual
- 3.0.0
+ 3.1.0
pigx-monitor
@@ -36,7 +36,7 @@
com.pig4cloud
pigx-common-core
- 3.0.0
+ 3.1.0
org.springframework.boot
diff --git a/pigx-visual/pigx-mp-manager/pom.xml b/pigx-visual/pigx-mp-manager/pom.xml
index f40bc2cc0..ca95b0855 100755
--- a/pigx-visual/pigx-mp-manager/pom.xml
+++ b/pigx-visual/pigx-mp-manager/pom.xml
@@ -6,7 +6,7 @@
com.pig4cloud
pigx-visual
- 3.0.0
+ 3.1.0
pigx-mp-manager
diff --git a/pigx-visual/pigx-mp-manager/src/main/java/com/pig4cloud/pigx/mp/controller/WxMenuController.java b/pigx-visual/pigx-mp-manager/src/main/java/com/pig4cloud/pigx/mp/controller/WxMenuController.java
index 49024c257..aa087cd5f 100755
--- a/pigx-visual/pigx-mp-manager/src/main/java/com/pig4cloud/pigx/mp/controller/WxMenuController.java
+++ b/pigx-visual/pigx-mp-manager/src/main/java/com/pig4cloud/pigx/mp/controller/WxMenuController.java
@@ -44,13 +44,13 @@ public class WxMenuController {
/**
* 分页查询
*
- * @param page 分页对象
- * @param WxMpMenu lengleng
+ * @param page 分页对象
+ * @param wxMpMenu
* @return
*/
@GetMapping("/page")
- public R getWxMpMenuPage(Page page, WxMpMenu WxMpMenu) {
- return R.ok(wxMenuService.page(page, Wrappers.query(WxMpMenu)));
+ public R getWxMpMenuPage(Page page, WxMpMenu wxMpMenu) {
+ return R.ok(wxMenuService.page(page, Wrappers.query(wxMpMenu)));
}
@@ -68,14 +68,14 @@ public class WxMenuController {
/**
* 新增微信菜单
*
- * @param WxMpMenus 微信菜单列表
+ * @param wxMenu 微信菜单列表
* @return R
*/
@SysLog("新增微信菜单")
@PostMapping("/{appId}")
@PreAuthorize("@pms.hasPermission('mp_wxmenu_add')")
- public R save(@RequestBody JSONObject WxMpMenus, @PathVariable String appId) {
- return R.ok(wxMenuService.save(WxMpMenus, appId));
+ public R save(@RequestBody JSONObject wxMenu, @PathVariable String appId) {
+ return R.ok(wxMenuService.save(wxMenu, appId));
}
/**
diff --git a/pigx-visual/pigx-seata-server/pom.xml b/pigx-visual/pigx-seata-server/pom.xml
deleted file mode 100755
index 1d9c33897..000000000
--- a/pigx-visual/pigx-seata-server/pom.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-
-
-
-
- com.pig4cloud
- pigx-visual
- 3.0.0
-
-
- 4.0.0
- pigx-seata-server
- jar
- pigx-seata-server
-
-
-
- io.seata
- seata-core
- 0.5.2
-
-
- io.seata
- seata-config-all
- 0.5.2
-
-
- io.seata
- seata-discovery-all
- 0.5.2
-
-
-
diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/AbstractTCInboundHandler.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/AbstractTCInboundHandler.java
deleted file mode 100755
index d6655196e..000000000
--- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/AbstractTCInboundHandler.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright 1999-2019 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.server;
-
-import io.seata.common.XID;
-import io.seata.core.exception.AbstractExceptionHandler;
-import io.seata.core.exception.TransactionException;
-import io.seata.core.model.GlobalStatus;
-import io.seata.core.protocol.transaction.BranchRegisterRequest;
-import io.seata.core.protocol.transaction.BranchRegisterResponse;
-import io.seata.core.protocol.transaction.BranchReportRequest;
-import io.seata.core.protocol.transaction.BranchReportResponse;
-import io.seata.core.protocol.transaction.GlobalBeginRequest;
-import io.seata.core.protocol.transaction.GlobalBeginResponse;
-import io.seata.core.protocol.transaction.GlobalCommitRequest;
-import io.seata.core.protocol.transaction.GlobalCommitResponse;
-import io.seata.core.protocol.transaction.GlobalLockQueryRequest;
-import io.seata.core.protocol.transaction.GlobalLockQueryResponse;
-import io.seata.core.protocol.transaction.GlobalRollbackRequest;
-import io.seata.core.protocol.transaction.GlobalRollbackResponse;
-import io.seata.core.protocol.transaction.GlobalStatusRequest;
-import io.seata.core.protocol.transaction.GlobalStatusResponse;
-import io.seata.core.protocol.transaction.TCInboundHandler;
-import io.seata.core.rpc.RpcContext;
-import io.seata.server.session.GlobalSession;
-import io.seata.server.session.SessionHolder;
-
-/**
- * The type Abstract tc inbound handler.
- *
- * @author sharajava
- */
-public abstract class AbstractTCInboundHandler extends AbstractExceptionHandler implements TCInboundHandler {
-
- @Override
- public GlobalBeginResponse handle(GlobalBeginRequest request, final RpcContext rpcContext) {
- GlobalBeginResponse response = new GlobalBeginResponse();
- exceptionHandleTemplate(new AbstractCallback() {
- @Override
- public void execute(GlobalBeginRequest request, GlobalBeginResponse response) throws TransactionException {
- doGlobalBegin(request, response, rpcContext);
- }
- }, request, response);
- return response;
- }
-
- /**
- * Do global begin.
- *
- * @param request the request
- * @param response the response
- * @param rpcContext the rpc context
- * @throws TransactionException the transaction exception
- */
- protected abstract void doGlobalBegin(GlobalBeginRequest request, GlobalBeginResponse response,
- RpcContext rpcContext) throws TransactionException;
-
- @Override
- public GlobalCommitResponse handle(GlobalCommitRequest request, final RpcContext rpcContext) {
- GlobalCommitResponse response = new GlobalCommitResponse();
- exceptionHandleTemplate(new AbstractCallback() {
- @Override
- public void execute(GlobalCommitRequest request, GlobalCommitResponse response)
- throws TransactionException {
- doGlobalCommit(request, response, rpcContext);
- }
- }, request, response);
- return response;
- }
-
- /**
- * Do global commit.
- *
- * @param request the request
- * @param response the response
- * @param rpcContext the rpc context
- * @throws TransactionException the transaction exception
- */
- protected abstract void doGlobalCommit(GlobalCommitRequest request, GlobalCommitResponse response,
- RpcContext rpcContext) throws TransactionException;
-
- @Override
- public GlobalRollbackResponse handle(GlobalRollbackRequest request, final RpcContext rpcContext) {
- GlobalRollbackResponse response = new GlobalRollbackResponse();
- exceptionHandleTemplate(new AbstractCallback() {
- @Override
- public void execute(GlobalRollbackRequest request, GlobalRollbackResponse response)
- throws TransactionException {
- doGlobalRollback(request, response, rpcContext);
- }
-
- @Override
- public void onTransactionException(GlobalRollbackRequest request, GlobalRollbackResponse response,
- TransactionException tex) {
- super.onTransactionException(request, response, tex);
- GlobalSession globalSession = SessionHolder.findGlobalSession(
- XID.getTransactionId(request.getXid()));
- if (globalSession != null) {
- response.setGlobalStatus(globalSession.getStatus());
- } else {
- response.setGlobalStatus(GlobalStatus.Finished);
- }
- }
-
- @Override
- public void onException(GlobalRollbackRequest request, GlobalRollbackResponse response, Exception rex) {
- super.onException(request, response, rex);
- GlobalSession globalSession = SessionHolder.findGlobalSession(
- XID.getTransactionId(request.getXid()));
- if (globalSession != null) {
- response.setGlobalStatus(globalSession.getStatus());
- } else {
- response.setGlobalStatus(GlobalStatus.Finished);
- }
- }
- }, request, response);
- return response;
- }
-
- /**
- * Do global rollback.
- *
- * @param request the request
- * @param response the response
- * @param rpcContext the rpc context
- * @throws TransactionException the transaction exception
- */
- protected abstract void doGlobalRollback(GlobalRollbackRequest request, GlobalRollbackResponse response,
- RpcContext rpcContext) throws TransactionException;
-
- @Override
- public BranchRegisterResponse handle(BranchRegisterRequest request, final RpcContext rpcContext) {
- BranchRegisterResponse response = new BranchRegisterResponse();
- exceptionHandleTemplate(new AbstractCallback() {
- @Override
- public void execute(BranchRegisterRequest request, BranchRegisterResponse response)
- throws TransactionException {
- doBranchRegister(request, response, rpcContext);
- }
- }, request, response);
- return response;
- }
-
- /**
- * Do branch register.
- *
- * @param request the request
- * @param response the response
- * @param rpcContext the rpc context
- * @throws TransactionException the transaction exception
- */
- protected abstract void doBranchRegister(BranchRegisterRequest request, BranchRegisterResponse response,
- RpcContext rpcContext) throws TransactionException;
-
- @Override
- public BranchReportResponse handle(BranchReportRequest request, final RpcContext rpcContext) {
- BranchReportResponse response = new BranchReportResponse();
- exceptionHandleTemplate(new AbstractCallback() {
- @Override
- public void execute(BranchReportRequest request, BranchReportResponse response)
- throws TransactionException {
- doBranchReport(request, response, rpcContext);
- }
- }, request, response);
- return response;
- }
-
- /**
- * Do branch report.
- *
- * @param request the request
- * @param rpcContext the rpc context
- * @throws TransactionException the transaction exception
- */
- protected abstract void doBranchReport(BranchReportRequest request, BranchReportResponse response,
- RpcContext rpcContext)
- throws TransactionException;
-
- @Override
- public GlobalLockQueryResponse handle(GlobalLockQueryRequest request, final RpcContext rpcContext) {
- GlobalLockQueryResponse response = new GlobalLockQueryResponse();
- exceptionHandleTemplate(new AbstractCallback() {
- @Override
- public void execute(GlobalLockQueryRequest request, GlobalLockQueryResponse response)
- throws TransactionException {
- doLockCheck(request, response, rpcContext);
- }
- }, request, response);
- return response;
- }
-
- /**
- * Do lock check.
- *
- * @param request the request
- * @param response the response
- * @param rpcContext the rpc context
- * @throws TransactionException the transaction exception
- */
- protected abstract void doLockCheck(GlobalLockQueryRequest request, GlobalLockQueryResponse response,
- RpcContext rpcContext) throws TransactionException;
-
- @Override
- public GlobalStatusResponse handle(GlobalStatusRequest request, final RpcContext rpcContext) {
- GlobalStatusResponse response = new GlobalStatusResponse();
- exceptionHandleTemplate(new AbstractCallback() {
- @Override
- public void execute(GlobalStatusRequest request, GlobalStatusResponse response)
- throws TransactionException {
- doGlobalStatus(request, response, rpcContext);
- }
- }, request, response);
- return response;
- }
-
- /**
- * Do global status.
- *
- * @param request the request
- * @param response the response
- * @param rpcContext the rpc context
- * @throws TransactionException the transaction exception
- */
- protected abstract void doGlobalStatus(GlobalStatusRequest request, GlobalStatusResponse response,
- RpcContext rpcContext) throws TransactionException;
-
-}
diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/Server.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/Server.java
deleted file mode 100755
index 43df651ee..000000000
--- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/Server.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 1999-2019 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.server;
-
-import io.seata.common.XID;
-import io.seata.common.thread.NamedThreadFactory;
-import io.seata.common.util.NetUtil;
-import io.seata.core.rpc.netty.RpcServer;
-import io.seata.core.rpc.netty.ShutdownHook;
-import io.seata.server.coordinator.DefaultCoordinator;
-import io.seata.server.session.SessionHolder;
-
-import java.io.IOException;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-
-/**
- * The type Server.
- *
- * @author jimin.jm @alibaba-inc.com
- */
-public class Server {
-
- private static final int MIN_SERVER_POOL_SIZE = 10;
- private static final int MAX_SERVER_POOL_SIZE = 50;
- private static final int MAX_TASK_QUEUE_SIZE = 2000;
- private static final int KEEP_ALIVE_TIME = 50;
- private static final int SERVER_DEFAULT_PORT = 8091;
- private static final ThreadPoolExecutor WORKING_THREADS = new ThreadPoolExecutor(MIN_SERVER_POOL_SIZE,
- MAX_SERVER_POOL_SIZE, KEEP_ALIVE_TIME, TimeUnit.SECONDS,
- new LinkedBlockingQueue(MAX_TASK_QUEUE_SIZE),
- new NamedThreadFactory("ServerHandlerThread", MAX_SERVER_POOL_SIZE), new ThreadPoolExecutor.CallerRunsPolicy());
-
- /**
- * The entry point of application.
- *
- * @param args the input arguments
- * @throws IOException the io exception
- */
- public static void main(String[] args) throws IOException {
- RpcServer rpcServer = new RpcServer(WORKING_THREADS);
-
- rpcServer.setListenPort(SERVER_DEFAULT_PORT);
-
- //log store mode : file、db
- String storeMode = "file";
-
- UUIDGenerator.init(1);
- SessionHolder.init(storeMode);
-
- DefaultCoordinator coordinator = new DefaultCoordinator(rpcServer);
- coordinator.init();
- rpcServer.setHandler(coordinator);
- // register ShutdownHook
- ShutdownHook.getInstance().addDisposable(coordinator);
-
- XID.setIpAddress(NetUtil.getLocalIp());
- XID.setPort(rpcServer.getListenPort());
-
- rpcServer.init();
-
- System.exit(0);
- }
-}
diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/UUIDGenerator.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/UUIDGenerator.java
deleted file mode 100755
index efc55e555..000000000
--- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/UUIDGenerator.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright 1999-2019 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.server;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.concurrent.atomic.AtomicLong;
-
-import io.seata.common.exception.ShouldNeverHappenException;
-
-/**
- * The type Uuid generator.
- *
- * @author sharajava
- */
-public class UUIDGenerator {
-
- private static final AtomicLong UUID = new AtomicLong(1000);
- private static int serverNodeId = 1;
- private static final long UUID_INTERNAL = 2000000000;
-
- /**
- * Generate uuid long.
- *
- * @return the long
- */
- public static long generateUUID() {
- long id = UUID.incrementAndGet();
- if (id >= UUID_INTERNAL * (serverNodeId + 1)) {
- synchronized (UUID) {
- if (UUID.get() >= id) {
- id -= UUID_INTERNAL;
- UUID.set(id);
- }
- }
- }
- return id;
- }
-
- /**
- * Gets current uuid.
- *
- * @return the current uuid
- */
- public static long getCurrentUUID() {
- return UUID.get();
- }
-
- /**
- * Sets uuid.
- *
- * @param expect the expect
- * @param update the update
- * @return the uuid
- */
- public static boolean setUUID(long expect, long update) {
- return UUID.compareAndSet(expect, update);
-
- }
-
- /**
- * Init.
- *
- * @param serverNodeId the server node id
- */
- public static void init(int serverNodeId) {
- try {
- UUIDGenerator.serverNodeId = serverNodeId;
- UUID.set(UUID_INTERNAL * serverNodeId);
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
- Calendar cal = Calendar.getInstance();
- Date date = format.parse("2019-01-01");
- cal.setTime(date);
- long base = cal.getTimeInMillis();
- long current = System.currentTimeMillis();
- UUID.addAndGet((current - base) / 1000);
- } catch (ParseException e) {
- throw new ShouldNeverHappenException(e);
- }
- }
-}
diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/Core.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/Core.java
deleted file mode 100755
index 7d34dfee1..000000000
--- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/Core.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 1999-2019 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.server.coordinator;
-
-import io.seata.core.exception.TransactionException;
-import io.seata.core.model.ResourceManagerInbound;
-import io.seata.core.model.ResourceManagerOutbound;
-import io.seata.core.model.TransactionManager;
-import io.seata.server.session.GlobalSession;
-
-/**
- * The interface Core.
- *
- * @author sharajava
- */
-public interface Core extends TransactionManager, ResourceManagerOutbound {
-
- /**
- * Sets resource manager inbound.
- *
- * @param resourceManagerInbound the resource manager inbound
- */
- void setResourceManagerInbound(ResourceManagerInbound resourceManagerInbound);
-
- /**
- * Do global commit.
- *
- * @param globalSession the global session
- * @param retrying the retrying
- * @throws TransactionException the transaction exception
- */
- void doGlobalCommit(GlobalSession globalSession, boolean retrying) throws TransactionException;
-
- /**
- * Do global rollback.
- *
- * @param globalSession the global session
- * @param retrying the retrying
- * @throws TransactionException the transaction exception
- */
- void doGlobalRollback(GlobalSession globalSession, boolean retrying) throws TransactionException;
-}
diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/CoreFactory.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/CoreFactory.java
deleted file mode 100755
index 19e09f70e..000000000
--- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/CoreFactory.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 1999-2019 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.server.coordinator;
-
-/**
- * The type Core factory.
- *
- * @author sharajava
- */
-public class CoreFactory {
-
- private static class SingletonHolder {
- private static Core INSTANCE = new DefaultCore();
- }
-
- /**
- * Get core.
- *
- * @return the core
- */
- public static final Core get() {
- return SingletonHolder.INSTANCE;
- }
-
- /**
- * Just for test mocking
- *
- * @param core the core
- */
- public static void set(Core core) {
- SingletonHolder.INSTANCE = core;
- }
-}
diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.java
deleted file mode 100755
index 024f741a9..000000000
--- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
- * Copyright 1999-2019 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.server.coordinator;
-
-import io.seata.common.XID;
-import io.seata.common.thread.NamedThreadFactory;
-import io.seata.core.exception.TransactionException;
-import io.seata.core.model.BranchStatus;
-import io.seata.core.model.BranchType;
-import io.seata.core.model.GlobalStatus;
-import io.seata.core.model.ResourceManagerInbound;
-import io.seata.core.protocol.AbstractMessage;
-import io.seata.core.protocol.AbstractResultMessage;
-import io.seata.core.protocol.transaction.*;
-import io.seata.core.rpc.Disposable;
-import io.seata.core.rpc.RpcContext;
-import io.seata.core.rpc.ServerMessageSender;
-import io.seata.core.rpc.TransactionMessageHandler;
-import io.seata.core.rpc.netty.RpcServer;
-import io.seata.server.AbstractTCInboundHandler;
-import io.seata.server.session.BranchSession;
-import io.seata.server.session.GlobalSession;
-import io.seata.server.session.SessionHolder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.concurrent.ScheduledThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import static io.seata.core.exception.TransactionExceptionCode.FailedToSendBranchCommitRequest;
-import static io.seata.core.exception.TransactionExceptionCode.FailedToSendBranchRollbackRequest;
-
-/**
- * The type Default coordinator.
- *
- * @author sharajava
- */
-public class DefaultCoordinator extends AbstractTCInboundHandler
- implements TransactionMessageHandler, ResourceManagerInbound, Disposable {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCoordinator.class);
-
- private static final int TIMED_TASK_SHUTDOWN_MAX_WAIT_MILLS = 5000;
-
- private ServerMessageSender messageSender;
-
- private Core core = CoreFactory.get();
-
- /**
- * Instantiates a new Default coordinator.
- *
- * @param messageSender the message sender
- */
- public DefaultCoordinator(ServerMessageSender messageSender) {
- this.messageSender = messageSender;
- core.setResourceManagerInbound(this);
- }
-
- @Override
- protected void doGlobalBegin(GlobalBeginRequest request, GlobalBeginResponse response, RpcContext rpcContext)
- throws TransactionException {
- response.setXid(core.begin(rpcContext.getApplicationId(), rpcContext.getTransactionServiceGroup(),
- request.getTransactionName(), request.getTimeout()));
- }
-
- @Override
- protected void doGlobalCommit(GlobalCommitRequest request, GlobalCommitResponse response, RpcContext rpcContext)
- throws TransactionException {
- response.setGlobalStatus(core.commit(request.getXid()));
-
- }
-
- @Override
- protected void doGlobalRollback(GlobalRollbackRequest request, GlobalRollbackResponse response,
- RpcContext rpcContext) throws TransactionException {
- response.setGlobalStatus(core.rollback(request.getXid()));
-
- }
-
- @Override
- protected void doGlobalStatus(GlobalStatusRequest request, GlobalStatusResponse response, RpcContext rpcContext)
- throws TransactionException {
- response.setGlobalStatus(core.getStatus(request.getXid()));
- }
-
- @Override
- protected void doBranchRegister(BranchRegisterRequest request, BranchRegisterResponse response,
- RpcContext rpcContext) throws TransactionException {
- response.setBranchId(
- core.branchRegister(request.getBranchType(), request.getResourceId(), rpcContext.getClientId(),
- request.getXid(), request.getApplicationData(), request.getLockKey()));
-
- }
-
- @Override
- protected void doBranchReport(BranchReportRequest request, BranchReportResponse response, RpcContext rpcContext)
- throws TransactionException {
- core.branchReport(request.getBranchType(), request.getXid(), request.getBranchId(),
- request.getStatus(),
- request.getApplicationData());
-
- }
-
- @Override
- protected void doLockCheck(GlobalLockQueryRequest request, GlobalLockQueryResponse response, RpcContext rpcContext)
- throws TransactionException {
- response.setLockable(core.lockQuery(request.getBranchType(), request.getResourceId(),
- request.getXid(), request.getLockKey()));
- }
-
- @Override
- public BranchStatus branchCommit(BranchType branchType, String xid, long branchId, String resourceId,
- String applicationData)
- throws TransactionException {
- try {
- BranchCommitRequest request = new BranchCommitRequest();
- request.setXid(xid);
- request.setBranchId(branchId);
- request.setResourceId(resourceId);
- request.setApplicationData(applicationData);
- request.setBranchType(branchType);
-
- GlobalSession globalSession = SessionHolder.findGlobalSession(XID.getTransactionId(xid));
- if(globalSession == null){
- return BranchStatus.PhaseTwo_Committed;
- }
- BranchSession branchSession = globalSession.getBranch(branchId);
-
- BranchCommitResponse response = (BranchCommitResponse)messageSender.sendSyncRequest(resourceId,
- branchSession.getClientId(), request);
- return response.getBranchStatus();
- } catch (IOException e) {
- throw new TransactionException(FailedToSendBranchCommitRequest, branchId + "/" + xid, e);
- } catch (TimeoutException e) {
- throw new TransactionException(FailedToSendBranchCommitRequest, branchId + "/" + xid, e);
- }
- }
-
- @Override
- public BranchStatus branchRollback(BranchType branchType, String xid, long branchId, String resourceId,
- String applicationData)
- throws TransactionException {
- try {
- BranchRollbackRequest
- request = new BranchRollbackRequest();
- request.setXid(xid);
- request.setBranchId(branchId);
- request.setResourceId(resourceId);
- request.setApplicationData(applicationData);
- request.setBranchType(branchType);
-
- GlobalSession globalSession = SessionHolder.findGlobalSession(XID.getTransactionId(xid));
- if(globalSession == null){
- return BranchStatus.PhaseTwo_Rollbacked;
- }
- BranchSession branchSession = globalSession.getBranch(branchId);
-
- BranchRollbackResponse response = (BranchRollbackResponse)messageSender.sendSyncRequest(resourceId,
- branchSession.getClientId(), request);
- return response.getBranchStatus();
- } catch (IOException e) {
- throw new TransactionException(FailedToSendBranchRollbackRequest, branchId + "/" + xid, e);
- } catch (TimeoutException e) {
- throw new TransactionException(FailedToSendBranchRollbackRequest, branchId + "/" + xid, e);
- }
- }
-
- private void timeoutCheck() throws TransactionException {
- Collection allSessions = SessionHolder.getRootSessionManager().allSessions();
- if (allSessions.size() > 0 && LOGGER.isDebugEnabled()) {
- LOGGER.debug("Transaction Timeout Check Begin: " + allSessions.size());
- }
- for (GlobalSession globalSession : allSessions) {
- if (LOGGER.isDebugEnabled()) {
- LOGGER.debug(globalSession.getTransactionId() + " " + globalSession.getStatus() + " " +
- globalSession.getBeginTime() + " " + globalSession.getTimeout());
- }
- boolean shouldTimeout = globalSession.lockAndExcute(() -> {
- if (globalSession.getStatus() != GlobalStatus.Begin || !globalSession.isTimeout()) {
- return false;
- }
- globalSession.close();
- globalSession.changeStatus(GlobalStatus.TimeoutRollbacking);
- return true;
- });
- if (!shouldTimeout) {
- continue;
- }
- LOGGER.info(
- "Global transaction[" + globalSession.getTransactionId() + "] is timeout and will be rolled back.");
-
- globalSession.addSessionLifecycleListener(SessionHolder.getRetryRollbackingSessionManager());
- SessionHolder.getRetryRollbackingSessionManager().addGlobalSession(globalSession);
-
- }
- if (allSessions.size() > 0 && LOGGER.isDebugEnabled()) {
- LOGGER.debug("Transaction Timeout Check End. ");
- }
-
- }
-
- private void handleRetryRollbacking() {
- Collection rollbackingSessions = SessionHolder.getRetryRollbackingSessionManager().allSessions();
- for (GlobalSession rollbackingSession : rollbackingSessions) {
- try {
- core.doGlobalRollback(rollbackingSession, true);
- } catch (TransactionException ex) {
- LOGGER.info("Failed to retry rollbacking [{}] {} {}",
- rollbackingSession.getTransactionId(), ex.getCode(), ex.getMessage());
- }
- }
- }
-
- private void handleRetryCommitting() {
- Collection committingSessions = SessionHolder.getRetryCommittingSessionManager().allSessions();
- for (GlobalSession committingSession : committingSessions) {
- try {
- core.doGlobalCommit(committingSession, true);
- } catch (TransactionException ex) {
- LOGGER.info("Failed to retry committing [{}] {} {}",
- committingSession.getTransactionId(), ex.getCode(), ex.getMessage());
- }
- }
- }
-
- private void handleAsyncCommitting() {
- Collection asyncCommittingSessions = SessionHolder.getAsyncCommittingSessionManager()
- .allSessions();
- for (GlobalSession asyncCommittingSession : asyncCommittingSessions) {
- try {
- core.doGlobalCommit(asyncCommittingSession, true);
- } catch (TransactionException ex) {
- LOGGER.info("Failed to async committing [{}] {} {}",
- asyncCommittingSession.getTransactionId(), ex.getCode(), ex.getMessage());
- }
- }
- }
-
- private ScheduledThreadPoolExecutor retryRollbacking = new ScheduledThreadPoolExecutor(1,
- new NamedThreadFactory("RetryRollbacking", 1));
-
- private ScheduledThreadPoolExecutor retryCommitting = new ScheduledThreadPoolExecutor(1,
- new NamedThreadFactory("RetryCommitting", 1));
-
- private ScheduledThreadPoolExecutor asyncCommitting = new ScheduledThreadPoolExecutor(1,
- new NamedThreadFactory("AsyncCommitting", 1));
-
- private ScheduledThreadPoolExecutor timeoutCheck = new ScheduledThreadPoolExecutor(1,
- new NamedThreadFactory("TxTimeoutCheck", 1));
-
- /**
- * Init.
- */
- public void init() {
- retryRollbacking.scheduleAtFixedRate(new Runnable() {
-
- @Override
- public void run() {
- try {
- handleRetryRollbacking();
- } catch (Exception e) {
- LOGGER.info("Exception retry rollbacking ... ", e);
- }
-
- }
- }, 0, 5, TimeUnit.MILLISECONDS);
-
- retryCommitting.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- handleRetryCommitting();
- } catch (Exception e) {
- LOGGER.info("Exception retry committing ... ", e);
- }
-
- }
- }, 0, 5, TimeUnit.MILLISECONDS);
-
- asyncCommitting.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- handleAsyncCommitting();
- } catch (Exception e) {
- LOGGER.info("Exception async committing ... ", e);
- }
-
- }
- }, 0, 10, TimeUnit.MILLISECONDS);
-
- timeoutCheck.scheduleAtFixedRate(new Runnable() {
- @Override
- public void run() {
- try {
- timeoutCheck();
- } catch (Exception e) {
- LOGGER.info("Exception timeout checking ... ", e);
- }
-
- }
- }, 0, 2, TimeUnit.MILLISECONDS);
- }
-
- @Override
- public AbstractResultMessage onRequest(AbstractMessage request, RpcContext context) {
- if (!(request instanceof AbstractTransactionRequestToTC)) {
- throw new IllegalArgumentException();
- }
- AbstractTransactionRequestToTC transactionRequest = (AbstractTransactionRequestToTC)request;
- transactionRequest.setTCInboundHandler(this);
-
- return transactionRequest.handle(context);
- }
-
- @Override
- public void onResponse(AbstractResultMessage response, RpcContext context) {
- if (!(response instanceof AbstractTransactionResponse)) {
- throw new IllegalArgumentException();
- }
-
- }
-
- @Override
- public void destroy() {
- // 1. first shutdown timed task
- retryRollbacking.shutdown();
- retryCommitting.shutdown();
- asyncCommitting.shutdown();
- timeoutCheck.shutdown();
- try {
- retryRollbacking.awaitTermination(TIMED_TASK_SHUTDOWN_MAX_WAIT_MILLS, TimeUnit.MILLISECONDS);
- retryCommitting.awaitTermination(TIMED_TASK_SHUTDOWN_MAX_WAIT_MILLS, TimeUnit.MILLISECONDS);
- asyncCommitting.awaitTermination(TIMED_TASK_SHUTDOWN_MAX_WAIT_MILLS, TimeUnit.MILLISECONDS);
- timeoutCheck.awaitTermination(TIMED_TASK_SHUTDOWN_MAX_WAIT_MILLS, TimeUnit.MILLISECONDS);
- } catch (InterruptedException ingore) {
-
- }
- // 2. sencond close netty flow
- if (messageSender instanceof RpcServer){
- ((RpcServer) messageSender).destroy();
- }
- // 3. last destory SessionHolder
- SessionHolder.destory();
- }
-}
diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/DefaultCore.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/DefaultCore.java
deleted file mode 100755
index 1ba36763f..000000000
--- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/coordinator/DefaultCore.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright 1999-2019 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.server.coordinator;
-
-import io.seata.common.XID;
-import io.seata.core.exception.TransactionException;
-import io.seata.core.exception.TransactionExceptionCode;
-import io.seata.core.model.BranchStatus;
-import io.seata.core.model.BranchType;
-import io.seata.core.model.GlobalStatus;
-import io.seata.core.model.ResourceManagerInbound;
-import io.seata.server.lock.LockManager;
-import io.seata.server.lock.LockManagerFactory;
-import io.seata.server.session.BranchSession;
-import io.seata.server.session.GlobalSession;
-import io.seata.server.session.SessionHelper;
-import io.seata.server.session.SessionHolder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static io.seata.core.exception.TransactionExceptionCode.BranchTransactionNotExist;
-import static io.seata.core.exception.TransactionExceptionCode.FailedToAddBranch;
-import static io.seata.core.exception.TransactionExceptionCode.GlobalTransactionNotActive;
-import static io.seata.core.exception.TransactionExceptionCode.GlobalTransactionStatusInvalid;
-import static io.seata.core.exception.TransactionExceptionCode.LockKeyConflict;
-
-/**
- * The type Default core.
- *
- * @author sharajava
- */
-public class DefaultCore implements Core {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCore.class);
-
- private LockManager lockManager = LockManagerFactory.get();
-
- private ResourceManagerInbound resourceManagerInbound;
-
- @Override
- public void setResourceManagerInbound(ResourceManagerInbound resourceManagerInbound) {
- this.resourceManagerInbound = resourceManagerInbound;
- }
-
- @Override
- public Long branchRegister(BranchType branchType, String resourceId, String clientId, String xid,
- String applicationData, String lockKeys) throws TransactionException {
- GlobalSession globalSession = assertGlobalSessionNotNull(XID.getTransactionId(xid));
- return globalSession.lockAndExcute(() -> {
- if (!globalSession.isActive()) {
- throw new TransactionException(GlobalTransactionNotActive, "Current Status: " + globalSession.getStatus());
- }
- if (globalSession.getStatus() != GlobalStatus.Begin) {
- throw new TransactionException(GlobalTransactionStatusInvalid,
- globalSession.getStatus() + " while expecting " + GlobalStatus.Begin);
- }
- BranchSession branchSession = SessionHelper.newBranchByGlobal(globalSession, branchType, resourceId,
- applicationData, lockKeys, clientId);
- if (!branchSession.lock()) {
- throw new TransactionException(LockKeyConflict);
- }
- try {
- globalSession.addBranch(branchSession);
- } catch (RuntimeException ex) {
- throw new TransactionException(FailedToAddBranch);
- }
- return branchSession.getBranchId();
- });
- }
-
- private GlobalSession assertGlobalSessionNotNull(long transactionId) throws TransactionException {
- GlobalSession globalSession = SessionHolder.findGlobalSession(transactionId);
- if (globalSession == null) {
- throw new TransactionException(TransactionExceptionCode.GlobalTransactionNotExist, "" + transactionId + "");
- }
- return globalSession;
- }
-
-
- @Override
- public void branchReport(BranchType branchType, String xid, long branchId, BranchStatus status,
- String applicationData) throws TransactionException {
- GlobalSession globalSession = assertGlobalSessionNotNull(XID.getTransactionId(xid));
- BranchSession branchSession = globalSession.getBranch(branchId);
- if (branchSession == null) {
- throw new TransactionException(BranchTransactionNotExist);
- }
- globalSession.changeBranchStatus(branchSession, status);
- }
-
- @Override
- public boolean lockQuery(BranchType branchType, String resourceId, String xid, String lockKeys)
- throws TransactionException {
- if (branchType == BranchType.AT) {
- return lockManager.isLockable(XID.getTransactionId(xid), resourceId, lockKeys);
- } else {
- return true;
- }
-
- }
-
- @Override
- public String begin(String applicationId, String transactionServiceGroup, String name, int timeout)
- throws TransactionException {
- GlobalSession session = GlobalSession.createGlobalSession(
- applicationId, transactionServiceGroup, name, timeout);
- session.addSessionLifecycleListener(SessionHolder.getRootSessionManager());
-
- session.begin();
-
- return XID.generateXID(session.getTransactionId());
- }
-
- @Override
- public GlobalStatus commit(String xid) throws TransactionException {
- GlobalSession globalSession = SessionHolder.findGlobalSession(XID.getTransactionId(xid));
- if (globalSession == null) {
- return GlobalStatus.Finished;
- }
- // just lock changeStatus
- boolean shouldCommit = globalSession.lockAndExcute(() -> {
- globalSession.closeAndClean(); // Highlight: Firstly, close the session, then no more branch can be registered.
- if (globalSession.getStatus() == GlobalStatus.Begin) {
- globalSession.changeStatus(GlobalStatus.Committing);
- return true;
- }
- return false;
- });
- if (!shouldCommit){
- return globalSession.getStatus();
- }
- if (globalSession.canBeCommittedAsync()) {
- asyncCommit(globalSession);
- return GlobalStatus.Committed;
- } else {
- doGlobalCommit(globalSession, false);
- }
- return globalSession.getStatus();
- }
-
- @Override
- public void doGlobalCommit(GlobalSession globalSession, boolean retrying) throws TransactionException {
- for (BranchSession branchSession : globalSession.getSortedBranches()) {
- BranchStatus currentStatus = branchSession.getStatus();
- if (currentStatus == BranchStatus.PhaseOne_Failed) {
- globalSession.removeBranch(branchSession);
- continue;
- }
- try {
- BranchStatus branchStatus = resourceManagerInbound.branchCommit(branchSession.getBranchType(),
- XID.generateXID(branchSession.getTransactionId()), branchSession.getBranchId(),
- branchSession.getResourceId(), branchSession.getApplicationData());
-
- switch (branchStatus) {
- case PhaseTwo_Committed:
- globalSession.removeBranch(branchSession);
- continue;
- case PhaseTwo_CommitFailed_Unretryable:
- if (globalSession.canBeCommittedAsync()) {
- LOGGER.error("By [{}], failed to commit branch {}", branchStatus, branchSession);
- continue;
- } else {
- SessionHelper.endCommitFailed(globalSession);
- LOGGER.error("Finally, failed to commit global[{}] since branch[{}] commit failed",
- globalSession.getTransactionId(), branchSession.getBranchId());
- return;
- }
- default:
- if (!retrying) {
- queueToRetryCommit(globalSession);
- return;
- }
- if (globalSession.canBeCommittedAsync()) {
- LOGGER.error("By [{}], failed to commit branch {}", branchStatus, branchSession);
- continue;
- } else {
- LOGGER.error(
- "Failed to commit global[{}] since branch[{}] commit failed, will retry later.",
- globalSession.getTransactionId(), branchSession.getBranchId());
- return;
- }
-
- }
-
- } catch (Exception ex) {
- LOGGER.error("Exception committing branch {}", branchSession, ex);
- if (!retrying) {
- queueToRetryCommit(globalSession);
- throw new TransactionException(ex);
- }
-
- }
-
- }
- if (globalSession.hasBranch()) {
- LOGGER.info("Global[{}] committing is NOT done.", globalSession.getTransactionId());
- return;
- }
- SessionHelper.endCommitted(globalSession);
- LOGGER.info("Global[{}] committing is successfully done.", globalSession.getTransactionId());
- }
-
- private void asyncCommit(GlobalSession globalSession) throws TransactionException {
- globalSession.addSessionLifecycleListener(SessionHolder.getAsyncCommittingSessionManager());
- SessionHolder.getAsyncCommittingSessionManager().addGlobalSession(globalSession);
- globalSession.changeStatus(GlobalStatus.AsyncCommitting);
- }
-
- private void queueToRetryCommit(GlobalSession globalSession) throws TransactionException {
- globalSession.addSessionLifecycleListener(SessionHolder.getRetryCommittingSessionManager());
- SessionHolder.getRetryCommittingSessionManager().addGlobalSession(globalSession);
- globalSession.changeStatus(GlobalStatus.CommitRetrying);
- }
-
- private void queueToRetryRollback(GlobalSession globalSession) throws TransactionException {
- globalSession.addSessionLifecycleListener(SessionHolder.getRetryRollbackingSessionManager());
- SessionHolder.getRetryRollbackingSessionManager().addGlobalSession(globalSession);
- GlobalStatus currentStatus = globalSession.getStatus();
- if (SessionHelper.isTimeoutGlobalStatus(currentStatus)) {
- globalSession.changeStatus(GlobalStatus.TimeoutRollbackRetrying);
- } else {
- globalSession.changeStatus(GlobalStatus.RollbackRetrying);
- }
- }
-
- @Override
- public GlobalStatus rollback(String xid) throws TransactionException {
- GlobalSession globalSession = SessionHolder.findGlobalSession(XID.getTransactionId(xid));
- if (globalSession == null) {
- return GlobalStatus.Finished;
- }
- // just lock changeStatus
- boolean shouldRollBack = globalSession.lockAndExcute(() -> {
- globalSession.close(); // Highlight: Firstly, close the session, then no more branch can be registered.
- if (globalSession.getStatus() == GlobalStatus.Begin) {
- globalSession.changeStatus(GlobalStatus.Rollbacking);
- return true;
- }
- return false;
- });
- if (!shouldRollBack){
- return globalSession.getStatus();
- }
-
- doGlobalRollback(globalSession, false);
- return globalSession.getStatus();
- }
-
- @Override
- public void doGlobalRollback(GlobalSession globalSession, boolean retrying) throws TransactionException {
- for (BranchSession branchSession : globalSession.getReverseSortedBranches()) {
- BranchStatus currentBranchStatus = branchSession.getStatus();
- if (currentBranchStatus == BranchStatus.PhaseOne_Failed) {
- globalSession.removeBranch(branchSession);
- continue;
- }
- try {
- BranchStatus branchStatus = resourceManagerInbound.branchRollback(branchSession.getBranchType(),
- XID.generateXID(branchSession.getTransactionId()), branchSession.getBranchId(),
- branchSession.getResourceId(), branchSession.getApplicationData());
-
- switch (branchStatus) {
- case PhaseTwo_Rollbacked:
- globalSession.removeBranch(branchSession);
- LOGGER.error("Successfully rolled back branch " + branchSession);
- continue;
- case PhaseTwo_RollbackFailed_Unretryable:
- SessionHelper.endRollbackFailed(globalSession);
- LOGGER.error("Failed to rollback global[" + globalSession.getTransactionId() + "] since branch["
- + branchSession.getBranchId() + "] rollback failed");
- return;
- default:
- LOGGER.info("Failed to rollback branch " + branchSession);
- if (!retrying) {
- queueToRetryRollback(globalSession);
- }
- return;
-
- }
- } catch (Exception ex) {
- LOGGER.error("Exception rollbacking branch " + branchSession, ex);
- if (!retrying) {
- queueToRetryRollback(globalSession);
- }
- throw new TransactionException(ex);
- }
-
- }
- SessionHelper.endRollbacked(globalSession);
- }
-
- @Override
- public GlobalStatus getStatus(String xid) throws TransactionException {
- GlobalSession globalSession = SessionHolder.findGlobalSession(XID.getTransactionId(xid));
- return globalSession.getStatus();
- }
-}
diff --git a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/lock/DefaultLockManagerImpl.java b/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/lock/DefaultLockManagerImpl.java
deleted file mode 100755
index a0c576c84..000000000
--- a/pigx-visual/pigx-seata-server/src/main/java/io/seata/server/lock/DefaultLockManagerImpl.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright 1999-2019 Seata.io Group.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package io.seata.server.lock;
-
-import io.netty.util.internal.ConcurrentSet;
-import io.seata.common.exception.ShouldNeverHappenException;
-import io.seata.common.util.StringUtils;
-import io.seata.core.exception.TransactionException;
-import io.seata.server.session.BranchSession;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * The type Default lock manager.
- *
- * @author sharajava
- */
-public class DefaultLockManagerImpl implements LockManager {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(DefaultLockManagerImpl.class);
-
- private static final int BUCKET_PER_TABLE = 128;
-
- private static final
- ConcurrentHashMap>>>
- LOCK_MAP = new ConcurrentHashMap>>>();
-
- @Override
- public boolean acquireLock(BranchSession branchSession) throws TransactionException {
- String resourceId = branchSession.getResourceId();
- long transactionId = branchSession.getTransactionId();
- ConcurrentHashMap>> dbLockMap = LOCK_MAP.get(resourceId);
- if (dbLockMap == null) {
- LOCK_MAP.putIfAbsent(resourceId,
- new ConcurrentHashMap>>());
- dbLockMap = LOCK_MAP.get(resourceId);
- }
- ConcurrentHashMap