mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-13 22:09:00 +08:00
♻️ Refactoring code. javaformat
This commit is contained in:
1 parent
510061cc75
commit
4600e21f3d
97 files changed
+10718
-10585
No files matched your search
+3
-3
@@ -23,14 +23,14 @@ import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* Branch Session Controller
|
||||
*
|
||||
* @author zhongxiang.wang
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("console/branchSession")
|
||||
public class BranchSessionController {
|
||||
|
||||
@Resource(type = BranchSessionService.class)
|
||||
private BranchSessionService branchSessionService;
|
||||
|
||||
@Resource(type = BranchSessionService.class)
|
||||
private BranchSessionService branchSessionService;
|
||||
|
||||
}
|
||||
+12
-12
@@ -26,26 +26,26 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
|
||||
/**
|
||||
* Global Lock Controller
|
||||
*
|
||||
* @author zhongxiang.wang
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/console/globalLock")
|
||||
public class GlobalLockController {
|
||||
|
||||
@Resource(type = GlobalLockService.class)
|
||||
private GlobalLockService globalLockService;
|
||||
@Resource(type = GlobalLockService.class)
|
||||
private GlobalLockService globalLockService;
|
||||
|
||||
/**
|
||||
* Query locks by param
|
||||
* @param param the param
|
||||
* @return the list of GlobalLockVO
|
||||
*/
|
||||
@GetMapping("query")
|
||||
public PageResult<GlobalLockVO> query(@ModelAttribute GlobalLockParam param) {
|
||||
return globalLockService.query(param);
|
||||
}
|
||||
/**
|
||||
* Query locks by param
|
||||
* @param param the param
|
||||
* @return the list of GlobalLockVO
|
||||
*/
|
||||
@GetMapping("query")
|
||||
public PageResult<GlobalLockVO> query(@ModelAttribute GlobalLockParam param) {
|
||||
return globalLockService.query(param);
|
||||
}
|
||||
|
||||
}
|
||||
+12
-11
@@ -28,23 +28,24 @@ import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* Global Session Controller
|
||||
*
|
||||
* @author zhongxiang.wang
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/v1/console/globalSession")
|
||||
public class GlobalSessionController {
|
||||
|
||||
@Resource(type = GlobalSessionService.class)
|
||||
private GlobalSessionService globalSessionService;
|
||||
@Resource(type = GlobalSessionService.class)
|
||||
private GlobalSessionService globalSessionService;
|
||||
|
||||
/**
|
||||
* Query all globalSession
|
||||
* @param param param for query globalSession
|
||||
* @return the list of GlobalSessionVO
|
||||
*/
|
||||
@GetMapping("query")
|
||||
public PageResult<GlobalSessionVO> query(@ModelAttribute GlobalSessionParam param) {
|
||||
return globalSessionService.query(param);
|
||||
}
|
||||
/**
|
||||
* Query all globalSession
|
||||
* @param param param for query globalSession
|
||||
* @return the list of GlobalSessionVO
|
||||
*/
|
||||
@GetMapping("query")
|
||||
public PageResult<GlobalSessionVO> query(@ModelAttribute GlobalSessionParam param) {
|
||||
return globalSessionService.query(param);
|
||||
}
|
||||
|
||||
}
|
||||
+42
-39
@@ -51,51 +51,54 @@ import static io.seata.common.DefaultValues.DEFAULT_STORE_DB_BRANCH_TABLE;
|
||||
@ConditionalOnExpression("#{'db'.equals('${sessionMode}')}")
|
||||
public class BranchSessionDBServiceImpl implements BranchSessionService {
|
||||
|
||||
private String branchTable;
|
||||
private String branchTable;
|
||||
|
||||
private String dbType;
|
||||
private String dbType;
|
||||
|
||||
private DataSource dataSource;
|
||||
private DataSource dataSource;
|
||||
|
||||
public BranchSessionDBServiceImpl() {
|
||||
Configuration configuration = ConfigurationFactory.getInstance();
|
||||
branchTable = configuration.getConfig(ConfigurationKeys.STORE_DB_BRANCH_TABLE, DEFAULT_STORE_DB_BRANCH_TABLE);
|
||||
dbType = configuration.getConfig(ConfigurationKeys.STORE_DB_TYPE);
|
||||
if (StringUtils.isBlank(dbType)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_TYPE + " should not be blank");
|
||||
}
|
||||
String dbDataSource = configuration.getConfig(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE);
|
||||
if (StringUtils.isBlank(dbDataSource)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE + " should not be blank");
|
||||
}
|
||||
dataSource = EnhancedServiceLoader.load(DataSourceProvider.class, dbDataSource).provide();
|
||||
}
|
||||
public BranchSessionDBServiceImpl() {
|
||||
Configuration configuration = ConfigurationFactory.getInstance();
|
||||
branchTable = configuration.getConfig(ConfigurationKeys.STORE_DB_BRANCH_TABLE, DEFAULT_STORE_DB_BRANCH_TABLE);
|
||||
dbType = configuration.getConfig(ConfigurationKeys.STORE_DB_TYPE);
|
||||
if (StringUtils.isBlank(dbType)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_TYPE + " should not be blank");
|
||||
}
|
||||
String dbDataSource = configuration.getConfig(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE);
|
||||
if (StringUtils.isBlank(dbDataSource)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE + " should not be blank");
|
||||
}
|
||||
dataSource = EnhancedServiceLoader.load(DataSourceProvider.class, dbDataSource).provide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<BranchSessionVO> queryByXid(String xid) {
|
||||
if (StringUtils.isBlank(xid)) {
|
||||
throw new IllegalArgumentException("xid should not be blank");
|
||||
}
|
||||
@Override
|
||||
public PageResult<BranchSessionVO> queryByXid(String xid) {
|
||||
if (StringUtils.isBlank(xid)) {
|
||||
throw new IllegalArgumentException("xid should not be blank");
|
||||
}
|
||||
|
||||
String whereCondition = " where xid = ? ";
|
||||
String branchSessionSQL = LogStoreSqlsFactory.getLogStoreSqls(dbType).getAllBranchSessionSQL(branchTable, whereCondition);
|
||||
String whereCondition = " where xid = ? ";
|
||||
String branchSessionSQL = LogStoreSqlsFactory.getLogStoreSqls(dbType).getAllBranchSessionSQL(branchTable,
|
||||
whereCondition);
|
||||
|
||||
List<BranchSessionVO> list = new ArrayList<>();
|
||||
ResultSet rs = null;
|
||||
List<BranchSessionVO> list = new ArrayList<>();
|
||||
ResultSet rs = null;
|
||||
|
||||
try (Connection conn = dataSource.getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement(branchSessionSQL)) {
|
||||
ps.setObject(1, xid);
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
list.add(BranchSessionVO.convert(rs));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new StoreException(e);
|
||||
} finally {
|
||||
IOUtil.close(rs);
|
||||
}
|
||||
return PageResult.success(list, list.size(), 0, 0, 0);
|
||||
}
|
||||
try (Connection conn = dataSource.getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement(branchSessionSQL)) {
|
||||
ps.setObject(1, xid);
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
list.add(BranchSessionVO.convert(rs));
|
||||
}
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new StoreException(e);
|
||||
}
|
||||
finally {
|
||||
IOUtil.close(rs);
|
||||
}
|
||||
return PageResult.success(list, list.size(), 0, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
+79
-78
@@ -42,7 +42,6 @@ import java.util.List;
|
||||
|
||||
import static io.seata.common.DefaultValues.DEFAULT_LOCK_DB_TABLE;
|
||||
|
||||
|
||||
/**
|
||||
* Global Lock DB ServiceImpl
|
||||
*
|
||||
@@ -54,92 +53,94 @@ import static io.seata.common.DefaultValues.DEFAULT_LOCK_DB_TABLE;
|
||||
@ConditionalOnExpression("#{'db'.equals('${lockMode}')}")
|
||||
public class GlobalLockDBServiceImpl implements GlobalLockService {
|
||||
|
||||
private String lockTable;
|
||||
private String lockTable;
|
||||
|
||||
private String dbType;
|
||||
private String dbType;
|
||||
|
||||
private DataSource dataSource;
|
||||
private DataSource dataSource;
|
||||
|
||||
public GlobalLockDBServiceImpl() {
|
||||
Configuration configuration = ConfigurationFactory.getInstance();
|
||||
lockTable = configuration.getConfig(ConfigurationKeys.LOCK_DB_TABLE, DEFAULT_LOCK_DB_TABLE);
|
||||
dbType = configuration.getConfig(ConfigurationKeys.STORE_DB_TYPE);
|
||||
if (StringUtils.isBlank(dbType)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_TYPE + " should not be blank");
|
||||
}
|
||||
String dbDataSource = configuration.getConfig(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE);
|
||||
if (StringUtils.isBlank(dbDataSource)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE + " should not be blank");
|
||||
}
|
||||
dataSource = EnhancedServiceLoader.load(DataSourceProvider.class, dbDataSource).provide();
|
||||
}
|
||||
public GlobalLockDBServiceImpl() {
|
||||
Configuration configuration = ConfigurationFactory.getInstance();
|
||||
lockTable = configuration.getConfig(ConfigurationKeys.LOCK_DB_TABLE, DEFAULT_LOCK_DB_TABLE);
|
||||
dbType = configuration.getConfig(ConfigurationKeys.STORE_DB_TYPE);
|
||||
if (StringUtils.isBlank(dbType)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_TYPE + " should not be blank");
|
||||
}
|
||||
String dbDataSource = configuration.getConfig(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE);
|
||||
if (StringUtils.isBlank(dbDataSource)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE + " should not be blank");
|
||||
}
|
||||
dataSource = EnhancedServiceLoader.load(DataSourceProvider.class, dbDataSource).provide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<GlobalLockVO> query(GlobalLockParam param) {
|
||||
PageUtil.checkParam(param.getPageNum(), param.getPageSize());
|
||||
@Override
|
||||
public PageResult<GlobalLockVO> query(GlobalLockParam param) {
|
||||
PageUtil.checkParam(param.getPageNum(), param.getPageSize());
|
||||
|
||||
List<Object> sqlParamList = new ArrayList<>();
|
||||
String whereCondition = this.getWhereConditionByParam(param, sqlParamList);
|
||||
List<Object> sqlParamList = new ArrayList<>();
|
||||
String whereCondition = this.getWhereConditionByParam(param, sqlParamList);
|
||||
|
||||
String sourceSql = LockStoreSqlFactory.getLogStoreSql(dbType).getAllLockSql(lockTable, whereCondition);
|
||||
String queryLockSql = PageUtil.pageSql(sourceSql, dbType, param.getPageNum(), param.getPageSize());
|
||||
String lockCountSql = PageUtil.countSql(sourceSql, dbType);
|
||||
String sourceSql = LockStoreSqlFactory.getLogStoreSql(dbType).getAllLockSql(lockTable, whereCondition);
|
||||
String queryLockSql = PageUtil.pageSql(sourceSql, dbType, param.getPageNum(), param.getPageSize());
|
||||
String lockCountSql = PageUtil.countSql(sourceSql, dbType);
|
||||
|
||||
List<GlobalLockVO> list = new ArrayList<>();
|
||||
int count = 0;
|
||||
List<GlobalLockVO> list = new ArrayList<>();
|
||||
int count = 0;
|
||||
|
||||
ResultSet rs = null;
|
||||
ResultSet countRs = null;
|
||||
ResultSet rs = null;
|
||||
ResultSet countRs = null;
|
||||
|
||||
try (Connection conn = dataSource.getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement(queryLockSql);
|
||||
PreparedStatement countPs = conn.prepareStatement(lockCountSql)) {
|
||||
PageUtil.setObject(ps, sqlParamList);
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
list.add(GlobalLockVO.convert(rs));
|
||||
}
|
||||
PageUtil.setObject(countPs, sqlParamList);
|
||||
countRs = countPs.executeQuery();
|
||||
if (countRs.next()) {
|
||||
count = countRs.getInt(1);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new StoreException(e);
|
||||
} finally {
|
||||
IOUtil.close(rs, countRs);
|
||||
}
|
||||
return PageResult.success(list, count, param.getPageNum(), param.getPageSize());
|
||||
}
|
||||
try (Connection conn = dataSource.getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement(queryLockSql);
|
||||
PreparedStatement countPs = conn.prepareStatement(lockCountSql)) {
|
||||
PageUtil.setObject(ps, sqlParamList);
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
list.add(GlobalLockVO.convert(rs));
|
||||
}
|
||||
PageUtil.setObject(countPs, sqlParamList);
|
||||
countRs = countPs.executeQuery();
|
||||
if (countRs.next()) {
|
||||
count = countRs.getInt(1);
|
||||
}
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new StoreException(e);
|
||||
}
|
||||
finally {
|
||||
IOUtil.close(rs, countRs);
|
||||
}
|
||||
return PageResult.success(list, count, param.getPageNum(), param.getPageSize());
|
||||
}
|
||||
|
||||
private String getWhereConditionByParam(GlobalLockParam param, List<Object> sqlParamList) {
|
||||
StringBuilder whereConditionBuilder = new StringBuilder();
|
||||
if (StringUtils.isNotBlank(param.getXid())) {
|
||||
whereConditionBuilder.append(" and xid = ? ");
|
||||
sqlParamList.add(param.getXid());
|
||||
}
|
||||
if (StringUtils.isNotBlank(param.getTableName())) {
|
||||
whereConditionBuilder.append(" and table_name = ? ");
|
||||
sqlParamList.add(param.getTableName());
|
||||
}
|
||||
if (StringUtils.isNotBlank(param.getTransactionId())) {
|
||||
whereConditionBuilder.append(" and transaction_id = ? ");
|
||||
sqlParamList.add(param.getTransactionId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(param.getBranchId())) {
|
||||
whereConditionBuilder.append(" and branch_id = ? ");
|
||||
sqlParamList.add(param.getBranchId());
|
||||
}
|
||||
if (param.getTimeStart() != null) {
|
||||
whereConditionBuilder.append(" and gmt_create >= ? ");
|
||||
sqlParamList.add(param.getTimeStart());
|
||||
}
|
||||
if (param.getTimeEnd() != null) {
|
||||
whereConditionBuilder.append(" and gmt_create <= ? ");
|
||||
sqlParamList.add(param.getTimeEnd());
|
||||
}
|
||||
String whereCondition = whereConditionBuilder.toString();
|
||||
return whereCondition.replaceFirst("and", "where");
|
||||
}
|
||||
private String getWhereConditionByParam(GlobalLockParam param, List<Object> sqlParamList) {
|
||||
StringBuilder whereConditionBuilder = new StringBuilder();
|
||||
if (StringUtils.isNotBlank(param.getXid())) {
|
||||
whereConditionBuilder.append(" and xid = ? ");
|
||||
sqlParamList.add(param.getXid());
|
||||
}
|
||||
if (StringUtils.isNotBlank(param.getTableName())) {
|
||||
whereConditionBuilder.append(" and table_name = ? ");
|
||||
sqlParamList.add(param.getTableName());
|
||||
}
|
||||
if (StringUtils.isNotBlank(param.getTransactionId())) {
|
||||
whereConditionBuilder.append(" and transaction_id = ? ");
|
||||
sqlParamList.add(param.getTransactionId());
|
||||
}
|
||||
if (StringUtils.isNotBlank(param.getBranchId())) {
|
||||
whereConditionBuilder.append(" and branch_id = ? ");
|
||||
sqlParamList.add(param.getBranchId());
|
||||
}
|
||||
if (param.getTimeStart() != null) {
|
||||
whereConditionBuilder.append(" and gmt_create >= ? ");
|
||||
sqlParamList.add(param.getTimeStart());
|
||||
}
|
||||
if (param.getTimeEnd() != null) {
|
||||
whereConditionBuilder.append(" and gmt_create <= ? ");
|
||||
sqlParamList.add(param.getTimeEnd());
|
||||
}
|
||||
String whereCondition = whereConditionBuilder.toString();
|
||||
return whereCondition.replaceFirst("and", "where");
|
||||
}
|
||||
|
||||
}
|
||||
+88
-86
@@ -58,103 +58,105 @@ import static io.seata.common.DefaultValues.DEFAULT_STORE_DB_GLOBAL_TABLE;
|
||||
@ConditionalOnExpression("#{'db'.equals('${sessionMode}')}")
|
||||
public class GlobalSessionDBServiceImpl implements GlobalSessionService {
|
||||
|
||||
private String globalTable;
|
||||
private String globalTable;
|
||||
|
||||
private String dbType;
|
||||
private String dbType;
|
||||
|
||||
private DataSource dataSource;
|
||||
private DataSource dataSource;
|
||||
|
||||
@Resource(type = BranchSessionService.class)
|
||||
private BranchSessionService branchSessionService;
|
||||
@Resource(type = BranchSessionService.class)
|
||||
private BranchSessionService branchSessionService;
|
||||
|
||||
public GlobalSessionDBServiceImpl() {
|
||||
Configuration configuration = ConfigurationFactory.getInstance();
|
||||
globalTable = configuration.getConfig(ConfigurationKeys.STORE_DB_GLOBAL_TABLE, DEFAULT_STORE_DB_GLOBAL_TABLE);
|
||||
dbType = configuration.getConfig(ConfigurationKeys.STORE_DB_TYPE);
|
||||
if (StringUtils.isBlank(dbType)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_TYPE + " should not be blank");
|
||||
}
|
||||
String dbDataSource = configuration.getConfig(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE);
|
||||
if (StringUtils.isBlank(dbDataSource)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE + " should not be blank");
|
||||
}
|
||||
dataSource = EnhancedServiceLoader.load(DataSourceProvider.class, dbDataSource).provide();
|
||||
}
|
||||
public GlobalSessionDBServiceImpl() {
|
||||
Configuration configuration = ConfigurationFactory.getInstance();
|
||||
globalTable = configuration.getConfig(ConfigurationKeys.STORE_DB_GLOBAL_TABLE, DEFAULT_STORE_DB_GLOBAL_TABLE);
|
||||
dbType = configuration.getConfig(ConfigurationKeys.STORE_DB_TYPE);
|
||||
if (StringUtils.isBlank(dbType)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_TYPE + " should not be blank");
|
||||
}
|
||||
String dbDataSource = configuration.getConfig(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE);
|
||||
if (StringUtils.isBlank(dbDataSource)) {
|
||||
throw new IllegalArgumentException(ConfigurationKeys.STORE_DB_DATASOURCE_TYPE + " should not be blank");
|
||||
}
|
||||
dataSource = EnhancedServiceLoader.load(DataSourceProvider.class, dbDataSource).provide();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<GlobalSessionVO> query(GlobalSessionParam param) {
|
||||
PageUtil.checkParam(param.getPageNum(), param.getPageSize());
|
||||
@Override
|
||||
public PageResult<GlobalSessionVO> query(GlobalSessionParam param) {
|
||||
PageUtil.checkParam(param.getPageNum(), param.getPageSize());
|
||||
|
||||
List<Object> sqlParamList = new ArrayList<>();
|
||||
String whereCondition = getWhereConditionByParam(param, sqlParamList);
|
||||
List<Object> sqlParamList = new ArrayList<>();
|
||||
String whereCondition = getWhereConditionByParam(param, sqlParamList);
|
||||
|
||||
String sourceSql = LogStoreSqlsFactory.getLogStoreSqls(dbType).getAllGlobalSessionSql(globalTable, whereCondition);
|
||||
String querySessionSql = PageUtil.pageSql(sourceSql, dbType, param.getPageNum(), param.getPageSize());
|
||||
String sessionCountSql = PageUtil.countSql(sourceSql, dbType);
|
||||
String sourceSql = LogStoreSqlsFactory.getLogStoreSqls(dbType).getAllGlobalSessionSql(globalTable,
|
||||
whereCondition);
|
||||
String querySessionSql = PageUtil.pageSql(sourceSql, dbType, param.getPageNum(), param.getPageSize());
|
||||
String sessionCountSql = PageUtil.countSql(sourceSql, dbType);
|
||||
|
||||
List<GlobalSessionVO> list = new ArrayList<>();
|
||||
int count = 0;
|
||||
List<GlobalSessionVO> list = new ArrayList<>();
|
||||
int count = 0;
|
||||
|
||||
ResultSet rs = null;
|
||||
ResultSet countRs = null;
|
||||
|
||||
ResultSet rs = null;
|
||||
ResultSet countRs = null;
|
||||
try (Connection conn = dataSource.getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement(querySessionSql);
|
||||
PreparedStatement countPs = conn.prepareStatement(sessionCountSql)) {
|
||||
PageUtil.setObject(ps, sqlParamList);
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
list.add(GlobalSessionVO.convert(rs));
|
||||
}
|
||||
|
||||
try (Connection conn = dataSource.getConnection();
|
||||
PreparedStatement ps = conn.prepareStatement(querySessionSql);
|
||||
PreparedStatement countPs = conn.prepareStatement(sessionCountSql)) {
|
||||
PageUtil.setObject(ps, sqlParamList);
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
list.add(GlobalSessionVO.convert(rs));
|
||||
}
|
||||
PageUtil.setObject(countPs, sqlParamList);
|
||||
countRs = countPs.executeQuery();
|
||||
if (countRs.next()) {
|
||||
count = countRs.getInt(1);
|
||||
}
|
||||
if (param.isWithBranch()) {
|
||||
for (GlobalSessionVO globalSessionVO : list) {
|
||||
PageResult<BranchSessionVO> pageResp = branchSessionService.queryByXid(globalSessionVO.getXid());
|
||||
globalSessionVO.setBranchSessionVOs(new HashSet<>(pageResp.getData()));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e) {
|
||||
throw new StoreException(e);
|
||||
}
|
||||
finally {
|
||||
IOUtil.close(rs, countRs);
|
||||
}
|
||||
return PageResult.success(list, count, param.getPageNum(), param.getPageSize());
|
||||
}
|
||||
|
||||
PageUtil.setObject(countPs, sqlParamList);
|
||||
countRs = countPs.executeQuery();
|
||||
if (countRs.next()) {
|
||||
count = countRs.getInt(1);
|
||||
}
|
||||
if (param.isWithBranch()) {
|
||||
for (GlobalSessionVO globalSessionVO : list) {
|
||||
PageResult<BranchSessionVO> pageResp = branchSessionService.queryByXid(globalSessionVO.getXid());
|
||||
globalSessionVO.setBranchSessionVOs(new HashSet<>(pageResp.getData()));
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new StoreException(e);
|
||||
} finally {
|
||||
IOUtil.close(rs, countRs);
|
||||
}
|
||||
return PageResult.success(list, count, param.getPageNum(), param.getPageSize());
|
||||
}
|
||||
|
||||
private String getWhereConditionByParam(GlobalSessionParam param, List<Object> sqlParamList) {
|
||||
StringBuilder whereConditionBuilder = new StringBuilder();
|
||||
if (StringUtils.isNotBlank(param.getXid())) {
|
||||
whereConditionBuilder.append(" and xid = ? ");
|
||||
sqlParamList.add(param.getXid());
|
||||
}
|
||||
if (StringUtils.isNotBlank(param.getApplicationId())) {
|
||||
whereConditionBuilder.append(" and application_id = ? ");
|
||||
sqlParamList.add(param.getApplicationId());
|
||||
}
|
||||
if (param.getStatus() != null) {
|
||||
whereConditionBuilder.append(" and status = ? ");
|
||||
sqlParamList.add(param.getStatus());
|
||||
}
|
||||
if (StringUtils.isNotBlank(param.getTransactionName())) {
|
||||
whereConditionBuilder.append(" and transaction_name = ? ");
|
||||
sqlParamList.add(param.getTransactionName());
|
||||
}
|
||||
if (param.getTimeStart() != null) {
|
||||
whereConditionBuilder.append(" and gmt_create >= ? ");
|
||||
sqlParamList.add(new Date(param.getTimeStart()));
|
||||
}
|
||||
if (param.getTimeEnd() != null) {
|
||||
whereConditionBuilder.append(" and gmt_create <= ? ");
|
||||
sqlParamList.add(new Date(param.getTimeEnd()));
|
||||
}
|
||||
String whereCondition = whereConditionBuilder.toString();
|
||||
return whereCondition.replaceFirst("and", "where");
|
||||
}
|
||||
private String getWhereConditionByParam(GlobalSessionParam param, List<Object> sqlParamList) {
|
||||
StringBuilder whereConditionBuilder = new StringBuilder();
|
||||
if (StringUtils.isNotBlank(param.getXid())) {
|
||||
whereConditionBuilder.append(" and xid = ? ");
|
||||
sqlParamList.add(param.getXid());
|
||||
}
|
||||
if (StringUtils.isNotBlank(param.getApplicationId())) {
|
||||
whereConditionBuilder.append(" and application_id = ? ");
|
||||
sqlParamList.add(param.getApplicationId());
|
||||
}
|
||||
if (param.getStatus() != null) {
|
||||
whereConditionBuilder.append(" and status = ? ");
|
||||
sqlParamList.add(param.getStatus());
|
||||
}
|
||||
if (StringUtils.isNotBlank(param.getTransactionName())) {
|
||||
whereConditionBuilder.append(" and transaction_name = ? ");
|
||||
sqlParamList.add(param.getTransactionName());
|
||||
}
|
||||
if (param.getTimeStart() != null) {
|
||||
whereConditionBuilder.append(" and gmt_create >= ? ");
|
||||
sqlParamList.add(new Date(param.getTimeStart()));
|
||||
}
|
||||
if (param.getTimeEnd() != null) {
|
||||
whereConditionBuilder.append(" and gmt_create <= ? ");
|
||||
sqlParamList.add(new Date(param.getTimeEnd()));
|
||||
}
|
||||
String whereCondition = whereConditionBuilder.toString();
|
||||
return whereCondition.replaceFirst("and", "where");
|
||||
}
|
||||
|
||||
}
|
||||
+5
-4
@@ -32,8 +32,9 @@ import org.springframework.stereotype.Component;
|
||||
@ConditionalOnExpression("#{'file'.equals('${sessionMode}')}")
|
||||
public class BranchSessionFileServiceImpl implements BranchSessionService {
|
||||
|
||||
@Override
|
||||
public PageResult<BranchSessionVO> queryByXid(String xid) {
|
||||
throw new NotSupportYetException();
|
||||
}
|
||||
@Override
|
||||
public PageResult<BranchSessionVO> queryByXid(String xid) {
|
||||
throw new NotSupportYetException();
|
||||
}
|
||||
|
||||
}
|
||||
+85
-96
@@ -51,120 +51,109 @@ import static java.util.Objects.isNull;
|
||||
@ConditionalOnExpression("#{'file'.equals('${lockMode}')}")
|
||||
public class GlobalLockFileServiceImpl implements GlobalLockService {
|
||||
|
||||
@Override
|
||||
public PageResult<GlobalLockVO> query(GlobalLockParam param) {
|
||||
checkParam(param);
|
||||
@Override
|
||||
public PageResult<GlobalLockVO> query(GlobalLockParam param) {
|
||||
checkParam(param);
|
||||
|
||||
final Collection<GlobalSession> allSessions = SessionHolder.getRootSessionManager().allSessions();
|
||||
final Collection<GlobalSession> allSessions = SessionHolder.getRootSessionManager().allSessions();
|
||||
|
||||
final AtomicInteger total = new AtomicInteger();
|
||||
List<RowLock> result = allSessions
|
||||
.parallelStream()
|
||||
.filter(obtainGlobalSessionPredicate(param))
|
||||
.flatMap(globalSession -> globalSession.getBranchSessions().stream())
|
||||
.filter(obtainBranchSessionPredicate(param))
|
||||
.flatMap(branchSession -> filterAndMap(param, branchSession))
|
||||
.peek(globalSession -> total.incrementAndGet())
|
||||
.collect(Collectors.toList());
|
||||
final AtomicInteger total = new AtomicInteger();
|
||||
List<RowLock> result = allSessions.parallelStream().filter(obtainGlobalSessionPredicate(param))
|
||||
.flatMap(globalSession -> globalSession.getBranchSessions().stream())
|
||||
.filter(obtainBranchSessionPredicate(param))
|
||||
.flatMap(branchSession -> filterAndMap(param, branchSession))
|
||||
.peek(globalSession -> total.incrementAndGet()).collect(Collectors.toList());
|
||||
|
||||
return PageResult.build(convert(result), param.getPageNum(), param.getPageSize());
|
||||
return PageResult.build(convert(result), param.getPageNum(), param.getPageSize());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* filter with tableName and generate RowLock
|
||||
*
|
||||
* @param param the query param
|
||||
* @param branchSession the branch session
|
||||
* @return the RowLock list
|
||||
*/
|
||||
private Stream<RowLock> filterAndMap(GlobalLockParam param, BranchSession branchSession) {
|
||||
/**
|
||||
* filter with tableName and generate RowLock
|
||||
* @param param the query param
|
||||
* @param branchSession the branch session
|
||||
* @return the RowLock list
|
||||
*/
|
||||
private Stream<RowLock> filterAndMap(GlobalLockParam param, BranchSession branchSession) {
|
||||
|
||||
final String tableName = param.getTableName();
|
||||
final String tableName = param.getTableName();
|
||||
|
||||
// get rowLock from branchSession
|
||||
final List<RowLock> rowLocks = LockerManagerFactory.getLockManager().collectRowLocks(branchSession);
|
||||
// get rowLock from branchSession
|
||||
final List<RowLock> rowLocks = LockerManagerFactory.getLockManager().collectRowLocks(branchSession);
|
||||
|
||||
if (StringUtils.isNotBlank(tableName)) {
|
||||
return rowLocks.parallelStream().filter(rowLock -> rowLock.getTableName().contains(param.getTableName()));
|
||||
}
|
||||
if (StringUtils.isNotBlank(tableName)) {
|
||||
return rowLocks.parallelStream().filter(rowLock -> rowLock.getTableName().contains(param.getTableName()));
|
||||
}
|
||||
|
||||
return rowLocks.stream();
|
||||
}
|
||||
return rowLocks.stream();
|
||||
}
|
||||
|
||||
/**
|
||||
* check the param
|
||||
* @param param the param
|
||||
*/
|
||||
private void checkParam(GlobalLockParam param) {
|
||||
if (param.getPageSize() <= 0 || param.getPageNum() <= 0) {
|
||||
throw new IllegalArgumentException("wrong pageSize or pageNum");
|
||||
}
|
||||
|
||||
/**
|
||||
* check the param
|
||||
*
|
||||
* @param param the param
|
||||
*/
|
||||
private void checkParam(GlobalLockParam param) {
|
||||
if (param.getPageSize() <= 0 || param.getPageNum() <= 0) {
|
||||
throw new IllegalArgumentException("wrong pageSize or pageNum");
|
||||
}
|
||||
// verification data type
|
||||
try {
|
||||
Long.parseLong(param.getTransactionId());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
param.setTransactionId(null);
|
||||
}
|
||||
try {
|
||||
Long.parseLong(param.getBranchId());
|
||||
}
|
||||
catch (NumberFormatException e) {
|
||||
param.setBranchId(null);
|
||||
}
|
||||
|
||||
// verification data type
|
||||
try {
|
||||
Long.parseLong(param.getTransactionId());
|
||||
} catch (NumberFormatException e) {
|
||||
param.setTransactionId(null);
|
||||
}
|
||||
try {
|
||||
Long.parseLong(param.getBranchId());
|
||||
} catch (NumberFormatException e) {
|
||||
param.setBranchId(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* obtain the branch session condition
|
||||
* @param param condition for query branch session
|
||||
* @return the filter condition
|
||||
*/
|
||||
private Predicate<? super BranchSession> obtainBranchSessionPredicate(GlobalLockParam param) {
|
||||
return branchSession -> {
|
||||
// transactionId
|
||||
return (isBlank(param.getTransactionId())
|
||||
|| String.valueOf(branchSession.getTransactionId()).contains(param.getTransactionId()))
|
||||
|
||||
}
|
||||
&&
|
||||
// branch id
|
||||
(isBlank(param.getBranchId()) || String.valueOf(branchSession.getBranchId()).contains(param.getBranchId()));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* obtain the branch session condition
|
||||
*
|
||||
* @param param condition for query branch session
|
||||
* @return the filter condition
|
||||
*/
|
||||
private Predicate<? super BranchSession> obtainBranchSessionPredicate(GlobalLockParam param) {
|
||||
return branchSession -> {
|
||||
// transactionId
|
||||
return (isBlank(param.getTransactionId()) ||
|
||||
String.valueOf(branchSession.getTransactionId()).contains(param.getTransactionId()))
|
||||
/**
|
||||
* obtain the global session condition
|
||||
* @param param condition for query global session
|
||||
* @return the filter condition
|
||||
*/
|
||||
private Predicate<? super GlobalSession> obtainGlobalSessionPredicate(GlobalLockParam param) {
|
||||
|
||||
&&
|
||||
// branch id
|
||||
(isBlank(param.getBranchId()) ||
|
||||
String.valueOf(branchSession.getBranchId()).contains(param.getBranchId()))
|
||||
;
|
||||
};
|
||||
}
|
||||
return globalSession -> {
|
||||
// first, there must be withBranchSession
|
||||
return CollectionUtils.isNotEmpty(globalSession.getBranchSessions())
|
||||
|
||||
&&
|
||||
// The second is other conditions
|
||||
// xid
|
||||
(isBlank(param.getXid()) || globalSession.getXid().contains(param.getXid()))
|
||||
|
||||
/**
|
||||
* obtain the global session condition
|
||||
*
|
||||
* @param param condition for query global session
|
||||
* @return the filter condition
|
||||
*/
|
||||
private Predicate<? super GlobalSession> obtainGlobalSessionPredicate(GlobalLockParam param) {
|
||||
|
||||
return globalSession -> {
|
||||
// first, there must be withBranchSession
|
||||
return CollectionUtils.isNotEmpty(globalSession.getBranchSessions())
|
||||
|
||||
&&
|
||||
// The second is other conditions
|
||||
// xid
|
||||
(isBlank(param.getXid()) || globalSession.getXid().contains(param.getXid()))
|
||||
|
||||
&&
|
||||
// timeStart
|
||||
(isNull(param.getTimeStart()) || param.getTimeStart() <= globalSession.getBeginTime())
|
||||
|
||||
&&
|
||||
// timeEnd
|
||||
(isNull(param.getTimeEnd()) || param.getTimeEnd() >= globalSession.getBeginTime());
|
||||
};
|
||||
}
|
||||
&&
|
||||
// timeStart
|
||||
(isNull(param.getTimeStart()) || param.getTimeStart() <= globalSession.getBeginTime())
|
||||
|
||||
&&
|
||||
// timeEnd
|
||||
(isNull(param.getTimeEnd()) || param.getTimeEnd() >= globalSession.getBeginTime());
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
+38
-42
@@ -45,58 +45,54 @@ import static java.util.Objects.isNull;
|
||||
@ConditionalOnExpression("#{'file'.equals('${sessionMode}')}")
|
||||
public class GlobalSessionFileServiceImpl implements GlobalSessionService {
|
||||
|
||||
@Override
|
||||
public PageResult<GlobalSessionVO> query(GlobalSessionParam param) {
|
||||
if (param.getPageSize() <= 0 || param.getPageNum() <= 0) {
|
||||
throw new IllegalArgumentException("wrong pageSize or pageNum");
|
||||
}
|
||||
@Override
|
||||
public PageResult<GlobalSessionVO> query(GlobalSessionParam param) {
|
||||
if (param.getPageSize() <= 0 || param.getPageNum() <= 0) {
|
||||
throw new IllegalArgumentException("wrong pageSize or pageNum");
|
||||
}
|
||||
|
||||
final Collection<GlobalSession> allSessions = SessionHolder.getRootSessionManager().allSessions();
|
||||
final Collection<GlobalSession> allSessions = SessionHolder.getRootSessionManager().allSessions();
|
||||
|
||||
final List<GlobalSession> filteredSessions = allSessions
|
||||
.parallelStream()
|
||||
.filter(obtainPredicate(param))
|
||||
.collect(Collectors.toList());
|
||||
final List<GlobalSession> filteredSessions = allSessions.parallelStream().filter(obtainPredicate(param))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return PageResult.build(SessionConverter.convertGlobalSession(filteredSessions), param.getPageNum(), param.getPageSize());
|
||||
}
|
||||
return PageResult.build(SessionConverter.convertGlobalSession(filteredSessions), param.getPageNum(),
|
||||
param.getPageSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* obtain the condition
|
||||
* @param param condition for query global session
|
||||
* @return the filter condition
|
||||
*/
|
||||
private Predicate<? super GlobalSession> obtainPredicate(GlobalSessionParam param) {
|
||||
|
||||
return session -> {
|
||||
return
|
||||
// xid
|
||||
(isBlank(param.getXid()) || session.getXid().contains(param.getXid()))
|
||||
|
||||
/**
|
||||
* obtain the condition
|
||||
*
|
||||
* @param param condition for query global session
|
||||
* @return the filter condition
|
||||
*/
|
||||
private Predicate<? super GlobalSession> obtainPredicate(GlobalSessionParam param) {
|
||||
&&
|
||||
// applicationId
|
||||
(isBlank(param.getApplicationId()) || session.getApplicationId().contains(param.getApplicationId()))
|
||||
|
||||
return session -> {
|
||||
return
|
||||
// xid
|
||||
(isBlank(param.getXid()) || session.getXid().contains(param.getXid()))
|
||||
&&
|
||||
// status
|
||||
(isNull(param.getStatus()) || Objects.equals(session.getStatus().getCode(), param.getStatus()))
|
||||
|
||||
&&
|
||||
// applicationId
|
||||
(isBlank(param.getApplicationId()) || session.getApplicationId().contains(param.getApplicationId()))
|
||||
&&
|
||||
// transactionName
|
||||
(isBlank(param.getTransactionName()) || session.getTransactionName().contains(param.getTransactionName()))
|
||||
|
||||
&&
|
||||
// status
|
||||
(isNull(param.getStatus()) || Objects.equals(session.getStatus().getCode(), param.getStatus()))
|
||||
&&
|
||||
// timeStart
|
||||
(isNull(param.getTimeStart()) || param.getTimeStart() <= session.getBeginTime())
|
||||
|
||||
&&
|
||||
// transactionName
|
||||
(isBlank(param.getTransactionName()) || session.getTransactionName().contains(param.getTransactionName()))
|
||||
&&
|
||||
// timeEnd
|
||||
(isNull(param.getTimeEnd()) || param.getTimeEnd() >= session.getBeginTime());
|
||||
|
||||
&&
|
||||
// timeStart
|
||||
(isNull(param.getTimeStart()) || param.getTimeStart() <= session.getBeginTime())
|
||||
|
||||
&&
|
||||
// timeEnd
|
||||
(isNull(param.getTimeEnd()) || param.getTimeEnd() >= session.getBeginTime());
|
||||
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
+18
-17
@@ -40,26 +40,27 @@ import java.util.List;
|
||||
@ConditionalOnExpression("#{'redis'.equals('${sessionMode}')}")
|
||||
public class BranchSessionRedisServiceImpl implements BranchSessionService {
|
||||
|
||||
@Override
|
||||
public PageResult<BranchSessionVO> queryByXid(String xid) {
|
||||
if (StringUtils.isBlank(xid)) {
|
||||
return PageResult.success();
|
||||
}
|
||||
@Override
|
||||
public PageResult<BranchSessionVO> queryByXid(String xid) {
|
||||
if (StringUtils.isBlank(xid)) {
|
||||
return PageResult.success();
|
||||
}
|
||||
|
||||
List<BranchSessionVO> branchSessionVos = new ArrayList<>();
|
||||
List<BranchSessionVO> branchSessionVos = new ArrayList<>();
|
||||
|
||||
RedisTransactionStoreManager instance = RedisTransactionStoreManager.getInstance();
|
||||
RedisTransactionStoreManager instance = RedisTransactionStoreManager.getInstance();
|
||||
|
||||
List<BranchTransactionDO> branchSessionDos = instance.findBranchSessionByXid(xid);
|
||||
List<BranchTransactionDO> branchSessionDos = instance.findBranchSessionByXid(xid);
|
||||
|
||||
if (CollectionUtils.isNotEmpty(branchSessionDos)) {
|
||||
for (BranchTransactionDO branchSessionDo : branchSessionDos) {
|
||||
BranchSessionVO branchSessionVO = new BranchSessionVO();
|
||||
BeanUtils.copyProperties(branchSessionDo, branchSessionVO);
|
||||
branchSessionVos.add(branchSessionVO);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(branchSessionDos)) {
|
||||
for (BranchTransactionDO branchSessionDo : branchSessionDos) {
|
||||
BranchSessionVO branchSessionVO = new BranchSessionVO();
|
||||
BeanUtils.copyProperties(branchSessionDo, branchSessionVO);
|
||||
branchSessionVos.add(branchSessionVO);
|
||||
}
|
||||
}
|
||||
|
||||
return PageResult.success(branchSessionVos, branchSessionVos.size(), 0, branchSessionVos.size());
|
||||
}
|
||||
|
||||
return PageResult.success(branchSessionVos, branchSessionVos.size(), 0, branchSessionVos.size());
|
||||
}
|
||||
}
|
||||
+63
-61
@@ -39,6 +39,7 @@ import static io.seata.core.constants.RedisKeyConstants.*;
|
||||
|
||||
/**
|
||||
* Global Lock Redis Service Impl
|
||||
*
|
||||
* @author zhongxiang.wang
|
||||
* @author doubleDimple
|
||||
*/
|
||||
@@ -47,73 +48,74 @@ import static io.seata.core.constants.RedisKeyConstants.*;
|
||||
@ConditionalOnExpression("#{'redis'.equals('${lockMode}')}")
|
||||
public class GlobalLockRedisServiceImpl implements GlobalLockService {
|
||||
|
||||
@Override
|
||||
public PageResult<GlobalLockVO> query(GlobalLockParam param) {
|
||||
@Override
|
||||
public PageResult<GlobalLockVO> query(GlobalLockParam param) {
|
||||
|
||||
int total = 0;
|
||||
List<GlobalLockVO> globalLockVos;
|
||||
checkPage(param);
|
||||
if (isNotBlank(param.getXid())) {
|
||||
globalLockVos = queryGlobalByXid(param.getXid());
|
||||
total = globalLockVos.size();
|
||||
return PageResult.success(globalLockVos,total,param.getPageNum(),param.getPageSize());
|
||||
} else if (isNotBlank(param.getTableName()) && isNotBlank(param.getPk()) && isNotBlank(param.getResourceId())) {
|
||||
//SEATA_ROW_LOCK_jdbc:mysql://116.62.62.26/seata-order^^^order^^^2188
|
||||
String tableName = param.getTableName();
|
||||
String pk = param.getPk();
|
||||
String resourceId = param.getResourceId();
|
||||
globalLockVos = queryGlobalLockByRowKey(buildRowKey(tableName,pk,resourceId));
|
||||
total = globalLockVos.size();
|
||||
return PageResult.success(globalLockVos,total,param.getPageNum(),param.getPageSize());
|
||||
} else {
|
||||
return PageResult.failure(ParameterRequired.getErrCode(),"only three parameters of tableName,pk,resourceId or Xid are supported");
|
||||
}
|
||||
}
|
||||
int total = 0;
|
||||
List<GlobalLockVO> globalLockVos;
|
||||
checkPage(param);
|
||||
if (isNotBlank(param.getXid())) {
|
||||
globalLockVos = queryGlobalByXid(param.getXid());
|
||||
total = globalLockVos.size();
|
||||
return PageResult.success(globalLockVos, total, param.getPageNum(), param.getPageSize());
|
||||
}
|
||||
else if (isNotBlank(param.getTableName()) && isNotBlank(param.getPk()) && isNotBlank(param.getResourceId())) {
|
||||
// SEATA_ROW_LOCK_jdbc:mysql://116.62.62.26/seata-order^^^order^^^2188
|
||||
String tableName = param.getTableName();
|
||||
String pk = param.getPk();
|
||||
String resourceId = param.getResourceId();
|
||||
globalLockVos = queryGlobalLockByRowKey(buildRowKey(tableName, pk, resourceId));
|
||||
total = globalLockVos.size();
|
||||
return PageResult.success(globalLockVos, total, param.getPageNum(), param.getPageSize());
|
||||
}
|
||||
else {
|
||||
return PageResult.failure(ParameterRequired.getErrCode(),
|
||||
"only three parameters of tableName,pk,resourceId or Xid are supported");
|
||||
}
|
||||
}
|
||||
|
||||
private List<GlobalLockVO> queryGlobalLockByRowKey(String buildRowKey) {
|
||||
return readGlobalLockByRowKey(buildRowKey);
|
||||
}
|
||||
private List<GlobalLockVO> queryGlobalLockByRowKey(String buildRowKey) {
|
||||
return readGlobalLockByRowKey(buildRowKey);
|
||||
}
|
||||
|
||||
private String buildRowKey(String tableName, String pk,String resourceId) {
|
||||
return DEFAULT_REDIS_SEATA_ROW_LOCK_PREFIX + resourceId + SPLIT + tableName + SPLIT + pk;
|
||||
}
|
||||
private String buildRowKey(String tableName, String pk, String resourceId) {
|
||||
return DEFAULT_REDIS_SEATA_ROW_LOCK_PREFIX + resourceId + SPLIT + tableName + SPLIT + pk;
|
||||
}
|
||||
|
||||
private List<GlobalLockVO> queryGlobalByXid(String xid) {
|
||||
return readGlobalLockByXid(DEFAULT_REDIS_SEATA_GLOBAL_LOCK_PREFIX + xid);
|
||||
}
|
||||
|
||||
private List<GlobalLockVO> queryGlobalByXid(String xid) {
|
||||
return readGlobalLockByXid(DEFAULT_REDIS_SEATA_GLOBAL_LOCK_PREFIX + xid);
|
||||
}
|
||||
private List<GlobalLockVO> readGlobalLockByXid(String key) {
|
||||
List<GlobalLockVO> vos = new ArrayList<>();
|
||||
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) {
|
||||
Map<String, String> mapGlobalKeys = jedis.hgetAll(key);
|
||||
if (CollectionUtils.isNotEmpty(mapGlobalKeys)) {
|
||||
List<String> rowLockKeys = new ArrayList<>();
|
||||
mapGlobalKeys.forEach((k, v) -> rowLockKeys.addAll(Arrays.asList(v.split(ROW_LOCK_KEY_SPLIT_CHAR))));
|
||||
for (String rowLoclKey : rowLockKeys) {
|
||||
Map<String, String> mapRowLockKey = jedis.hgetAll(rowLoclKey);
|
||||
GlobalLockVO vo = (GlobalLockVO) BeanUtils.mapToObject(mapRowLockKey, GlobalLockVO.class);
|
||||
if (vo != null) {
|
||||
vos.add(vo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<GlobalLockVO> readGlobalLockByXid(String key) {
|
||||
List<GlobalLockVO> vos = new ArrayList<>();
|
||||
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) {
|
||||
Map<String, String> mapGlobalKeys = jedis.hgetAll(key);
|
||||
if (CollectionUtils.isNotEmpty(mapGlobalKeys)) {
|
||||
List<String> rowLockKeys = new ArrayList<>();
|
||||
mapGlobalKeys.forEach((k,v) -> rowLockKeys.addAll(Arrays.asList(v.split(ROW_LOCK_KEY_SPLIT_CHAR))));
|
||||
for (String rowLoclKey : rowLockKeys) {
|
||||
Map<String, String> mapRowLockKey = jedis.hgetAll(rowLoclKey);
|
||||
GlobalLockVO vo = (GlobalLockVO)BeanUtils.mapToObject(mapRowLockKey, GlobalLockVO.class);
|
||||
if (vo != null) {
|
||||
vos.add(vo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return vos;
|
||||
}
|
||||
|
||||
return vos;
|
||||
}
|
||||
|
||||
|
||||
private List<GlobalLockVO> readGlobalLockByRowKey(String key) {
|
||||
List<GlobalLockVO> vos = new ArrayList<>();
|
||||
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) {
|
||||
Map<String, String> map = jedis.hgetAll(key);
|
||||
GlobalLockVO vo = (GlobalLockVO)BeanUtils.mapToObject(map, GlobalLockVO.class);
|
||||
if (vo != null) {
|
||||
vos.add(vo);
|
||||
}
|
||||
}
|
||||
return vos;
|
||||
}
|
||||
private List<GlobalLockVO> readGlobalLockByRowKey(String key) {
|
||||
List<GlobalLockVO> vos = new ArrayList<>();
|
||||
try (Jedis jedis = JedisPooledFactory.getJedisInstance()) {
|
||||
Map<String, String> map = jedis.hgetAll(key);
|
||||
GlobalLockVO vo = (GlobalLockVO) BeanUtils.mapToObject(map, GlobalLockVO.class);
|
||||
if (vo != null) {
|
||||
vos.add(vo);
|
||||
}
|
||||
}
|
||||
return vos;
|
||||
}
|
||||
|
||||
}
|
||||
+55
-49
@@ -41,6 +41,7 @@ import static io.seata.server.storage.SessionConverter.convertToGlobalSessionVo;
|
||||
|
||||
/**
|
||||
* Global Session Redis ServiceImpl
|
||||
*
|
||||
* @author zhongxiang.wang
|
||||
* @author doubleDimple
|
||||
*/
|
||||
@@ -49,62 +50,67 @@ import static io.seata.server.storage.SessionConverter.convertToGlobalSessionVo;
|
||||
@ConditionalOnExpression("#{'redis'.equals('${sessionMode}')}")
|
||||
public class GlobalSessionRedisServiceImpl implements GlobalSessionService {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GlobalSessionRedisServiceImpl.class);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GlobalSessionRedisServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public PageResult<GlobalSessionVO> query(GlobalSessionParam param) {
|
||||
List<GlobalSessionVO> result = new ArrayList<>();
|
||||
Long total = 0L;
|
||||
if (param.getTimeStart() != null || param.getTimeEnd() != null) {
|
||||
//not support time range query
|
||||
LOGGER.debug("not supported according to time range query");
|
||||
return PageResult.failure(ParameterRequired.getErrCode(),"not supported according to time range query");
|
||||
}
|
||||
List<GlobalSession> globalSessions = new ArrayList<>();
|
||||
@Override
|
||||
public PageResult<GlobalSessionVO> query(GlobalSessionParam param) {
|
||||
List<GlobalSessionVO> result = new ArrayList<>();
|
||||
Long total = 0L;
|
||||
if (param.getTimeStart() != null || param.getTimeEnd() != null) {
|
||||
// not support time range query
|
||||
LOGGER.debug("not supported according to time range query");
|
||||
return PageResult.failure(ParameterRequired.getErrCode(), "not supported according to time range query");
|
||||
}
|
||||
List<GlobalSession> globalSessions = new ArrayList<>();
|
||||
|
||||
RedisTransactionStoreManager instance = RedisTransactionStoreManager.getInstance();
|
||||
RedisTransactionStoreManager instance = RedisTransactionStoreManager.getInstance();
|
||||
|
||||
checkPage(param);
|
||||
checkPage(param);
|
||||
|
||||
if (isBlank(param.getXid()) && param.getStatus() == null) {
|
||||
total = instance.countByGlobalSessions(GlobalStatus.values());
|
||||
globalSessions = instance.findGlobalSessionByPage(param.getPageNum(), param.getPageSize(),param.isWithBranch());
|
||||
} else {
|
||||
List<GlobalSession> globalSessionsNew = new ArrayList<>();
|
||||
if (isNotBlank(param.getXid())) {
|
||||
SessionCondition sessionCondition = new SessionCondition();
|
||||
sessionCondition.setXid(param.getXid());
|
||||
sessionCondition.setLazyLoadBranch(!param.isWithBranch());
|
||||
globalSessions = instance.readSession(sessionCondition);
|
||||
total = (long)globalSessions.size();
|
||||
}
|
||||
if (isBlank(param.getXid()) && param.getStatus() == null) {
|
||||
total = instance.countByGlobalSessions(GlobalStatus.values());
|
||||
globalSessions = instance.findGlobalSessionByPage(param.getPageNum(), param.getPageSize(),
|
||||
param.isWithBranch());
|
||||
}
|
||||
else {
|
||||
List<GlobalSession> globalSessionsNew = new ArrayList<>();
|
||||
if (isNotBlank(param.getXid())) {
|
||||
SessionCondition sessionCondition = new SessionCondition();
|
||||
sessionCondition.setXid(param.getXid());
|
||||
sessionCondition.setLazyLoadBranch(!param.isWithBranch());
|
||||
globalSessions = instance.readSession(sessionCondition);
|
||||
total = (long) globalSessions.size();
|
||||
}
|
||||
|
||||
if (param.getStatus() != null && GlobalStatus.get(param.getStatus()) != null) {
|
||||
if (CollectionUtils.isNotEmpty(globalSessions)) {
|
||||
globalSessionsNew = globalSessions.stream().filter(globalSession -> globalSession.getStatus().getCode() == (param.getStatus())).collect(Collectors.toList());
|
||||
total = (long)globalSessionsNew.size();
|
||||
} else {
|
||||
total = instance.countByGlobalSessions(new GlobalStatus[] {GlobalStatus.get(param.getStatus())});
|
||||
globalSessionsNew = instance.readSessionStatusByPage(param);
|
||||
}
|
||||
}
|
||||
if (param.getStatus() != null && GlobalStatus.get(param.getStatus()) != null) {
|
||||
if (CollectionUtils.isNotEmpty(globalSessions)) {
|
||||
globalSessionsNew = globalSessions.stream()
|
||||
.filter(globalSession -> globalSession.getStatus().getCode() == (param.getStatus()))
|
||||
.collect(Collectors.toList());
|
||||
total = (long) globalSessionsNew.size();
|
||||
}
|
||||
else {
|
||||
total = instance.countByGlobalSessions(new GlobalStatus[] { GlobalStatus.get(param.getStatus()) });
|
||||
globalSessionsNew = instance.readSessionStatusByPage(param);
|
||||
}
|
||||
}
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
if (isNotBlank(param.getApplicationId())) {
|
||||
//not support
|
||||
LOGGER.debug("not supported according to applicationId query");
|
||||
}
|
||||
if (isNotBlank(param.getTransactionName())) {
|
||||
//not support
|
||||
LOGGER.debug("not supported according to transactionName query");
|
||||
}
|
||||
}
|
||||
globalSessions = globalSessionsNew.size() > 0 ? globalSessionsNew : globalSessions;
|
||||
}
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
if (isNotBlank(param.getApplicationId())) {
|
||||
// not support
|
||||
LOGGER.debug("not supported according to applicationId query");
|
||||
}
|
||||
if (isNotBlank(param.getTransactionName())) {
|
||||
// not support
|
||||
LOGGER.debug("not supported according to transactionName query");
|
||||
}
|
||||
}
|
||||
globalSessions = globalSessionsNew.size() > 0 ? globalSessionsNew : globalSessions;
|
||||
}
|
||||
|
||||
convertToGlobalSessionVo(result,globalSessions);
|
||||
convertToGlobalSessionVo(result, globalSessions);
|
||||
|
||||
return PageResult.success(result,total.intValue(),param.getPageNum(),param.getPageSize());
|
||||
}
|
||||
return PageResult.success(result, total.intValue(), param.getPageNum(), param.getPageSize());
|
||||
}
|
||||
|
||||
}
|
||||
+74
-72
@@ -21,94 +21,96 @@ import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Global lock param
|
||||
*
|
||||
* @author zhongxiang.wang
|
||||
*/
|
||||
public class GlobalLockParam extends BaseParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 615412528070131284L;
|
||||
private static final long serialVersionUID = 615412528070131284L;
|
||||
|
||||
/**
|
||||
* the xid
|
||||
*/
|
||||
private String xid;
|
||||
/**
|
||||
* the table name
|
||||
*/
|
||||
private String tableName;
|
||||
/**
|
||||
* the transaction id
|
||||
*/
|
||||
private String transactionId;
|
||||
/**
|
||||
* the branch id
|
||||
*/
|
||||
private String branchId;
|
||||
/**
|
||||
* the primary Key
|
||||
*/
|
||||
private String pk;
|
||||
/**
|
||||
* the resourceId
|
||||
*/
|
||||
private String resourceId;
|
||||
/**
|
||||
* the xid
|
||||
*/
|
||||
private String xid;
|
||||
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
/**
|
||||
* the table name
|
||||
*/
|
||||
private String tableName;
|
||||
|
||||
public void setTransactionId(String transactionId) {
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
/**
|
||||
* the transaction id
|
||||
*/
|
||||
private String transactionId;
|
||||
|
||||
public String getBranchId() {
|
||||
return branchId;
|
||||
}
|
||||
/**
|
||||
* the branch id
|
||||
*/
|
||||
private String branchId;
|
||||
|
||||
public void setBranchId(String branchId) {
|
||||
this.branchId = branchId;
|
||||
}
|
||||
/**
|
||||
* the primary Key
|
||||
*/
|
||||
private String pk;
|
||||
|
||||
public String getXid() {
|
||||
return xid;
|
||||
}
|
||||
/**
|
||||
* the resourceId
|
||||
*/
|
||||
private String resourceId;
|
||||
|
||||
public void setXid(String xid) {
|
||||
this.xid = xid;
|
||||
}
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
public void setTransactionId(String transactionId) {
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
public String getBranchId() {
|
||||
return branchId;
|
||||
}
|
||||
|
||||
public String getPk() {
|
||||
return pk;
|
||||
}
|
||||
public void setBranchId(String branchId) {
|
||||
this.branchId = branchId;
|
||||
}
|
||||
|
||||
public void setPk(String pk) {
|
||||
this.pk = pk;
|
||||
}
|
||||
public String getXid() {
|
||||
return xid;
|
||||
}
|
||||
|
||||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
public void setXid(String xid) {
|
||||
this.xid = xid;
|
||||
}
|
||||
|
||||
public void setResourceId(String resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getPk() {
|
||||
return pk;
|
||||
}
|
||||
|
||||
public void setPk(String pk) {
|
||||
this.pk = pk;
|
||||
}
|
||||
|
||||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(String resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalLockParam{" + "xid='" + xid + '\'' + ", tableName='" + tableName + '\'' + ", transactionId='"
|
||||
+ transactionId + '\'' + ", branchId='" + branchId + '\'' + ", pk='" + pk + '\'' + ", resourceId='"
|
||||
+ resourceId + '\'' + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalLockParam{" +
|
||||
"xid='" + xid + '\'' +
|
||||
", tableName='" + tableName + '\'' +
|
||||
", transactionId='" + transactionId + '\'' +
|
||||
", branchId='" + branchId + '\'' +
|
||||
", pk='" + pk + '\'' +
|
||||
", resourceId='" + resourceId + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+63
-63
@@ -21,82 +21,82 @@ import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Global session param
|
||||
*
|
||||
* @author zhongxiang.wang
|
||||
*/
|
||||
public class GlobalSessionParam extends BaseParam implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 115488252809011284L;
|
||||
/**
|
||||
* the xid
|
||||
*/
|
||||
private String xid;
|
||||
/**
|
||||
* the application id
|
||||
*/
|
||||
private String applicationId;
|
||||
/**
|
||||
* the global session status
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* the transaction name
|
||||
*/
|
||||
private String transactionName;
|
||||
/**
|
||||
* if with branch
|
||||
* true: with branch session
|
||||
* false: no branch session
|
||||
*/
|
||||
private boolean withBranch;
|
||||
private static final long serialVersionUID = 115488252809011284L;
|
||||
|
||||
public String getXid() {
|
||||
return xid;
|
||||
}
|
||||
/**
|
||||
* the xid
|
||||
*/
|
||||
private String xid;
|
||||
|
||||
public void setXid(String xid) {
|
||||
this.xid = xid;
|
||||
}
|
||||
/**
|
||||
* the application id
|
||||
*/
|
||||
private String applicationId;
|
||||
|
||||
public String getTransactionName() {
|
||||
return transactionName;
|
||||
}
|
||||
/**
|
||||
* the global session status
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
public void setTransactionName(String transactionName) {
|
||||
this.transactionName = transactionName;
|
||||
}
|
||||
/**
|
||||
* the transaction name
|
||||
*/
|
||||
private String transactionName;
|
||||
|
||||
public String getApplicationId() {
|
||||
return applicationId;
|
||||
}
|
||||
/**
|
||||
* if with branch true: with branch session false: no branch session
|
||||
*/
|
||||
private boolean withBranch;
|
||||
|
||||
public void setApplicationId(String applicationId) {
|
||||
this.applicationId = applicationId;
|
||||
}
|
||||
public String getXid() {
|
||||
return xid;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setXid(String xid) {
|
||||
this.xid = xid;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
public String getTransactionName() {
|
||||
return transactionName;
|
||||
}
|
||||
|
||||
public boolean isWithBranch() {
|
||||
return withBranch;
|
||||
}
|
||||
public void setTransactionName(String transactionName) {
|
||||
this.transactionName = transactionName;
|
||||
}
|
||||
|
||||
public void setWithBranch(boolean withBranch) {
|
||||
this.withBranch = withBranch;
|
||||
}
|
||||
public String getApplicationId() {
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
public void setApplicationId(String applicationId) {
|
||||
this.applicationId = applicationId;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public boolean isWithBranch() {
|
||||
return withBranch;
|
||||
}
|
||||
|
||||
public void setWithBranch(boolean withBranch) {
|
||||
this.withBranch = withBranch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalSessionParam{" + "xid='" + xid + '\'' + ", applicationId='" + applicationId + '\'' + ", status="
|
||||
+ status + ", transactionName='" + transactionName + '\'' + ", withBranch=" + withBranch + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalSessionParam{" +
|
||||
"xid='" + xid + '\'' +
|
||||
", applicationId='" + applicationId + '\'' +
|
||||
", status=" + status +
|
||||
", transactionName='" + transactionName + '\'' +
|
||||
", withBranch=" + withBranch +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+7
-6
@@ -20,15 +20,16 @@ import io.seata.server.console.vo.BranchSessionVO;
|
||||
|
||||
/**
|
||||
* Branch session service
|
||||
*
|
||||
* @author wangzhongxiang
|
||||
*/
|
||||
public interface BranchSessionService {
|
||||
|
||||
/**
|
||||
* Query branch session by xid
|
||||
* @param xid the xid
|
||||
* @return the BranchSessionVO list
|
||||
*/
|
||||
PageResult<BranchSessionVO> queryByXid(String xid);
|
||||
/**
|
||||
* Query branch session by xid
|
||||
* @param xid the xid
|
||||
* @return the BranchSessionVO list
|
||||
*/
|
||||
PageResult<BranchSessionVO> queryByXid(String xid);
|
||||
|
||||
}
|
||||
+7
-8
@@ -19,19 +19,18 @@ import io.seata.console.result.PageResult;
|
||||
import io.seata.server.console.param.GlobalLockParam;
|
||||
import io.seata.server.console.vo.GlobalLockVO;
|
||||
|
||||
|
||||
/**
|
||||
* Global lock service
|
||||
*
|
||||
* @author wangzhongxiang
|
||||
*/
|
||||
public interface GlobalLockService {
|
||||
|
||||
/**
|
||||
* Query locks by param
|
||||
* @param param the param
|
||||
* @return the list of GlobalLockVO
|
||||
*/
|
||||
PageResult<GlobalLockVO> query(GlobalLockParam param);
|
||||
|
||||
/**
|
||||
* Query locks by param
|
||||
* @param param the param
|
||||
* @return the list of GlobalLockVO
|
||||
*/
|
||||
PageResult<GlobalLockVO> query(GlobalLockParam param);
|
||||
|
||||
}
|
||||
+7
-6
@@ -21,15 +21,16 @@ import io.seata.server.console.vo.GlobalSessionVO;
|
||||
|
||||
/**
|
||||
* Global session service
|
||||
*
|
||||
* @author wangzhongxiang
|
||||
*/
|
||||
public interface GlobalSessionService {
|
||||
|
||||
/**
|
||||
* Query global session
|
||||
* @param param the param
|
||||
* @return the GlobalSessionVO list
|
||||
*/
|
||||
PageResult<GlobalSessionVO> query(GlobalSessionParam param);
|
||||
/**
|
||||
* Query global session
|
||||
* @param param the param
|
||||
* @return the GlobalSessionVO list
|
||||
*/
|
||||
PageResult<GlobalSessionVO> query(GlobalSessionParam param);
|
||||
|
||||
}
|
||||
+142
-170
@@ -24,218 +24,190 @@ import java.util.Objects;
|
||||
|
||||
/**
|
||||
* BranchSessionVO
|
||||
*
|
||||
* @author zhongxiang.wang
|
||||
*/
|
||||
public class BranchSessionVO {
|
||||
|
||||
private String xid;
|
||||
private String xid;
|
||||
|
||||
private String transactionId;
|
||||
private String transactionId;
|
||||
|
||||
private String branchId;
|
||||
private String branchId;
|
||||
|
||||
private String resourceGroupId;
|
||||
private String resourceGroupId;
|
||||
|
||||
private String resourceId;
|
||||
private String resourceId;
|
||||
|
||||
private String branchType;
|
||||
private String branchType;
|
||||
|
||||
private Integer status;
|
||||
private Integer status;
|
||||
|
||||
private String clientId;
|
||||
private String clientId;
|
||||
|
||||
private String applicationData;
|
||||
private String applicationData;
|
||||
|
||||
private Long gmtCreate;
|
||||
private Long gmtCreate;
|
||||
|
||||
private Long gmtModified;
|
||||
private Long gmtModified;
|
||||
|
||||
public BranchSessionVO() {
|
||||
|
||||
public BranchSessionVO(){
|
||||
}
|
||||
|
||||
}
|
||||
public BranchSessionVO(String xid, Long transactionId, Long branchId, String resourceGroupId, String resourceId,
|
||||
String branchType, Integer status, String clientId, String applicationData) {
|
||||
this.xid = xid;
|
||||
this.transactionId = String.valueOf(transactionId);
|
||||
this.branchId = String.valueOf(branchId);
|
||||
this.resourceGroupId = resourceGroupId;
|
||||
this.resourceId = resourceId;
|
||||
this.branchType = branchType;
|
||||
this.status = status;
|
||||
this.clientId = clientId;
|
||||
this.applicationData = applicationData;
|
||||
}
|
||||
|
||||
public BranchSessionVO(String xid,
|
||||
Long transactionId,
|
||||
Long branchId,
|
||||
String resourceGroupId,
|
||||
String resourceId,
|
||||
String branchType,
|
||||
Integer status,
|
||||
String clientId,
|
||||
String applicationData) {
|
||||
this.xid = xid;
|
||||
this.transactionId = String.valueOf(transactionId);
|
||||
this.branchId = String.valueOf(branchId);
|
||||
this.resourceGroupId = resourceGroupId;
|
||||
this.resourceId = resourceId;
|
||||
this.branchType = branchType;
|
||||
this.status = status;
|
||||
this.clientId = clientId;
|
||||
this.applicationData = applicationData;
|
||||
}
|
||||
public String getXid() {
|
||||
return xid;
|
||||
}
|
||||
|
||||
public String getXid() {
|
||||
return xid;
|
||||
}
|
||||
public void setXid(String xid) {
|
||||
this.xid = xid;
|
||||
}
|
||||
|
||||
public void setXid(String xid) {
|
||||
this.xid = xid;
|
||||
}
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
public void setTransactionId(Long transactionId) {
|
||||
this.transactionId = String.valueOf(transactionId);
|
||||
}
|
||||
|
||||
public void setTransactionId(Long transactionId) {
|
||||
this.transactionId = String.valueOf(transactionId);
|
||||
}
|
||||
public String getBranchId() {
|
||||
return branchId;
|
||||
}
|
||||
|
||||
public String getBranchId() {
|
||||
return branchId;
|
||||
}
|
||||
public void setBranchId(Long branchId) {
|
||||
this.branchId = String.valueOf(branchId);
|
||||
}
|
||||
|
||||
public void setBranchId(Long branchId) {
|
||||
this.branchId = String.valueOf(branchId);
|
||||
}
|
||||
public String getResourceGroupId() {
|
||||
return resourceGroupId;
|
||||
}
|
||||
|
||||
public String getResourceGroupId() {
|
||||
return resourceGroupId;
|
||||
}
|
||||
public void setResourceGroupId(String resourceGroupId) {
|
||||
this.resourceGroupId = resourceGroupId;
|
||||
}
|
||||
|
||||
public void setResourceGroupId(String resourceGroupId) {
|
||||
this.resourceGroupId = resourceGroupId;
|
||||
}
|
||||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
public void setResourceId(String resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public void setResourceId(String resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
public String getBranchType() {
|
||||
return branchType;
|
||||
}
|
||||
|
||||
public String getBranchType() {
|
||||
return branchType;
|
||||
}
|
||||
public void setBranchType(String branchType) {
|
||||
this.branchType = branchType;
|
||||
}
|
||||
|
||||
public void setBranchType(String branchType) {
|
||||
this.branchType = branchType;
|
||||
}
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
|
||||
public String getClientId() {
|
||||
return clientId;
|
||||
}
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
|
||||
public void setClientId(String clientId) {
|
||||
this.clientId = clientId;
|
||||
}
|
||||
public String getApplicationData() {
|
||||
return applicationData;
|
||||
}
|
||||
|
||||
public String getApplicationData() {
|
||||
return applicationData;
|
||||
}
|
||||
public void setApplicationData(String applicationData) {
|
||||
this.applicationData = applicationData;
|
||||
}
|
||||
|
||||
public void setApplicationData(String applicationData) {
|
||||
this.applicationData = applicationData;
|
||||
}
|
||||
public Long getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
|
||||
public Long getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
public void setGmtCreate(Long gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
public void setGmtCreate(Long gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
public Long getGmtModified() {
|
||||
return gmtModified;
|
||||
}
|
||||
|
||||
public Long getGmtModified() {
|
||||
return gmtModified;
|
||||
}
|
||||
public void setGmtModified(Long gmtModified) {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
|
||||
public void setGmtModified(Long gmtModified) {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
public static BranchSessionVO convert(ResultSet rs) throws SQLException {
|
||||
BranchSessionVO branchSessionVO = new BranchSessionVO();
|
||||
branchSessionVO.setXid(rs.getString(ServerTableColumnsName.BRANCH_TABLE_XID));
|
||||
branchSessionVO.setTransactionId(rs.getLong(ServerTableColumnsName.BRANCH_TABLE_TRANSACTION_ID));
|
||||
branchSessionVO.setBranchId(rs.getLong(ServerTableColumnsName.BRANCH_TABLE_BRANCH_ID));
|
||||
branchSessionVO.setResourceGroupId(rs.getString(ServerTableColumnsName.BRANCH_TABLE_RESOURCE_GROUP_ID));
|
||||
branchSessionVO.setResourceId(rs.getString(ServerTableColumnsName.BRANCH_TABLE_RESOURCE_ID));
|
||||
branchSessionVO.setBranchType(rs.getString(ServerTableColumnsName.BRANCH_TABLE_BRANCH_TYPE));
|
||||
branchSessionVO.setStatus(rs.getInt(ServerTableColumnsName.BRANCH_TABLE_STATUS));
|
||||
branchSessionVO.setClientId(rs.getString(ServerTableColumnsName.BRANCH_TABLE_CLIENT_ID));
|
||||
branchSessionVO.setApplicationData(rs.getString(ServerTableColumnsName.BRANCH_TABLE_APPLICATION_DATA));
|
||||
Date gmtCreateTimestamp = rs.getDate(ServerTableColumnsName.BRANCH_TABLE_GMT_CREATE);
|
||||
if (gmtCreateTimestamp != null) {
|
||||
branchSessionVO.setGmtCreate(gmtCreateTimestamp.getTime());
|
||||
}
|
||||
Date gmtModifiedTimestamp = rs.getDate(ServerTableColumnsName.BRANCH_TABLE_GMT_MODIFIED);
|
||||
if (gmtModifiedTimestamp != null) {
|
||||
branchSessionVO.setGmtModified(gmtModifiedTimestamp.getTime());
|
||||
}
|
||||
return branchSessionVO;
|
||||
}
|
||||
|
||||
public static BranchSessionVO convert(ResultSet rs) throws SQLException {
|
||||
BranchSessionVO branchSessionVO = new BranchSessionVO();
|
||||
branchSessionVO.setXid(rs.getString(ServerTableColumnsName.BRANCH_TABLE_XID));
|
||||
branchSessionVO.setTransactionId(rs.getLong(ServerTableColumnsName.BRANCH_TABLE_TRANSACTION_ID));
|
||||
branchSessionVO.setBranchId(rs.getLong(ServerTableColumnsName.BRANCH_TABLE_BRANCH_ID));
|
||||
branchSessionVO.setResourceGroupId(rs.getString(ServerTableColumnsName.BRANCH_TABLE_RESOURCE_GROUP_ID));
|
||||
branchSessionVO.setResourceId(rs.getString(ServerTableColumnsName.BRANCH_TABLE_RESOURCE_ID));
|
||||
branchSessionVO.setBranchType(rs.getString(ServerTableColumnsName.BRANCH_TABLE_BRANCH_TYPE));
|
||||
branchSessionVO.setStatus(rs.getInt(ServerTableColumnsName.BRANCH_TABLE_STATUS));
|
||||
branchSessionVO.setClientId(rs.getString(ServerTableColumnsName.BRANCH_TABLE_CLIENT_ID));
|
||||
branchSessionVO.setApplicationData(rs.getString(ServerTableColumnsName.BRANCH_TABLE_APPLICATION_DATA));
|
||||
Date gmtCreateTimestamp = rs.getDate(ServerTableColumnsName.BRANCH_TABLE_GMT_CREATE);
|
||||
if (gmtCreateTimestamp != null) {
|
||||
branchSessionVO.setGmtCreate(gmtCreateTimestamp.getTime());
|
||||
}
|
||||
Date gmtModifiedTimestamp = rs.getDate(ServerTableColumnsName.BRANCH_TABLE_GMT_MODIFIED);
|
||||
if (gmtModifiedTimestamp != null) {
|
||||
branchSessionVO.setGmtModified(gmtModifiedTimestamp.getTime());
|
||||
}
|
||||
return branchSessionVO;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
BranchSessionVO that = (BranchSessionVO) o;
|
||||
return Objects.equals(xid, that.xid) && Objects.equals(transactionId, that.transactionId)
|
||||
&& Objects.equals(branchId, that.branchId) && Objects.equals(resourceGroupId, that.resourceGroupId)
|
||||
&& Objects.equals(resourceId, that.resourceId) && Objects.equals(branchType, that.branchType)
|
||||
&& Objects.equals(status, that.status) && Objects.equals(clientId, that.clientId)
|
||||
&& Objects.equals(applicationData, that.applicationData) && Objects.equals(gmtCreate, that.gmtCreate)
|
||||
&& Objects.equals(gmtModified, that.gmtModified);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
BranchSessionVO that = (BranchSessionVO) o;
|
||||
return Objects.equals(xid, that.xid)
|
||||
&& Objects.equals(transactionId, that.transactionId)
|
||||
&& Objects.equals(branchId, that.branchId)
|
||||
&& Objects.equals(resourceGroupId, that.resourceGroupId)
|
||||
&& Objects.equals(resourceId, that.resourceId)
|
||||
&& Objects.equals(branchType, that.branchType)
|
||||
&& Objects.equals(status, that.status)
|
||||
&& Objects.equals(clientId, that.clientId)
|
||||
&& Objects.equals(applicationData, that.applicationData)
|
||||
&& Objects.equals(gmtCreate, that.gmtCreate)
|
||||
&& Objects.equals(gmtModified, that.gmtModified);
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(xid, transactionId, branchId, resourceGroupId, resourceId, branchType, status, clientId,
|
||||
applicationData, gmtCreate, gmtModified);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(xid,
|
||||
transactionId,
|
||||
branchId,
|
||||
resourceGroupId,
|
||||
resourceId,
|
||||
branchType,
|
||||
status,
|
||||
clientId,
|
||||
applicationData,
|
||||
gmtCreate,
|
||||
gmtModified);
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BranchSessionVO{" + "xid='" + xid + '\'' + ", transactionId=" + transactionId + ", branchId=" + branchId
|
||||
+ ", resourceGroupId='" + resourceGroupId + '\'' + ", resourceId='" + resourceId + '\''
|
||||
+ ", branchType='" + branchType + '\'' + ", status=" + status + ", clientId='" + clientId + '\''
|
||||
+ ", applicationData='" + applicationData + '\'' + ", gmtCreate=" + gmtCreate + ", gmtModified="
|
||||
+ gmtModified + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "BranchSessionVO{" +
|
||||
"xid='" + xid + '\'' +
|
||||
", transactionId=" + transactionId +
|
||||
", branchId=" + branchId +
|
||||
", resourceGroupId='" + resourceGroupId + '\'' +
|
||||
", resourceId='" + resourceId + '\'' +
|
||||
", branchType='" + branchType + '\'' +
|
||||
", status=" + status +
|
||||
", clientId='" + clientId + '\'' +
|
||||
", applicationData='" + applicationData + '\'' +
|
||||
", gmtCreate=" + gmtCreate +
|
||||
", gmtModified=" + gmtModified +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+120
-128
@@ -28,169 +28,161 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* GlobalLockVO
|
||||
*
|
||||
* @author zhongxiang.wang
|
||||
* @author miaoxueyu
|
||||
*/
|
||||
public class GlobalLockVO {
|
||||
|
||||
private String xid;
|
||||
private String xid;
|
||||
|
||||
private String transactionId;
|
||||
private String transactionId;
|
||||
|
||||
private String branchId;
|
||||
private String branchId;
|
||||
|
||||
private String resourceId;
|
||||
private String resourceId;
|
||||
|
||||
private String tableName;
|
||||
private String tableName;
|
||||
|
||||
private String pk;
|
||||
private String pk;
|
||||
|
||||
private String rowKey;
|
||||
private String rowKey;
|
||||
|
||||
private Long gmtCreate;
|
||||
private Long gmtCreate;
|
||||
|
||||
private Long gmtModified;
|
||||
private Long gmtModified;
|
||||
|
||||
/**
|
||||
* convert RowLock list to GlobalLockVO list
|
||||
* @param rowLocks the RowLock list
|
||||
* @return the GlobalLockVO list
|
||||
*/
|
||||
public static List<GlobalLockVO> convert(List<RowLock> rowLocks) {
|
||||
if (CollectionUtils.isEmpty(rowLocks)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final List<GlobalLockVO> result = new ArrayList<>(rowLocks.size());
|
||||
for (RowLock rowLock : rowLocks) {
|
||||
result.add(convert(rowLock));
|
||||
}
|
||||
/**
|
||||
* convert RowLock list to GlobalLockVO list
|
||||
* @param rowLocks the RowLock list
|
||||
* @return the GlobalLockVO list
|
||||
*/
|
||||
public static List<GlobalLockVO> convert(List<RowLock> rowLocks) {
|
||||
if (CollectionUtils.isEmpty(rowLocks)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
final List<GlobalLockVO> result = new ArrayList<>(rowLocks.size());
|
||||
for (RowLock rowLock : rowLocks) {
|
||||
result.add(convert(rowLock));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert RowLock to GlobalLockVO
|
||||
* @param rowLock the RowLock
|
||||
* @return the GlobalLockVO
|
||||
*/
|
||||
public static GlobalLockVO convert(RowLock rowLock) {
|
||||
final GlobalLockVO globalLockVO = new GlobalLockVO();
|
||||
globalLockVO.setXid(rowLock.getXid());
|
||||
globalLockVO.setTransactionId(rowLock.getTransactionId());
|
||||
globalLockVO.setBranchId(rowLock.getBranchId());
|
||||
globalLockVO.setResourceId(rowLock.getResourceId());
|
||||
globalLockVO.setTableName(rowLock.getTableName());
|
||||
globalLockVO.setPk(rowLock.getPk());
|
||||
globalLockVO.setRowKey(rowLock.getRowKey());
|
||||
return globalLockVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert RowLock to GlobalLockVO
|
||||
* @param rowLock the RowLock
|
||||
* @return the GlobalLockVO
|
||||
*/
|
||||
public static GlobalLockVO convert(RowLock rowLock) {
|
||||
final GlobalLockVO globalLockVO = new GlobalLockVO();
|
||||
globalLockVO.setXid(rowLock.getXid());
|
||||
globalLockVO.setTransactionId(rowLock.getTransactionId());
|
||||
globalLockVO.setBranchId(rowLock.getBranchId());
|
||||
globalLockVO.setResourceId(rowLock.getResourceId());
|
||||
globalLockVO.setTableName(rowLock.getTableName());
|
||||
globalLockVO.setPk(rowLock.getPk());
|
||||
globalLockVO.setRowKey(rowLock.getRowKey());
|
||||
return globalLockVO;
|
||||
}
|
||||
public String getXid() {
|
||||
return xid;
|
||||
}
|
||||
|
||||
public void setXid(String xid) {
|
||||
this.xid = xid;
|
||||
}
|
||||
|
||||
public String getXid() {
|
||||
return xid;
|
||||
}
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public void setXid(String xid) {
|
||||
this.xid = xid;
|
||||
}
|
||||
public void setTransactionId(Long transactionId) {
|
||||
this.transactionId = String.valueOf(transactionId);
|
||||
}
|
||||
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
public String getBranchId() {
|
||||
return branchId;
|
||||
}
|
||||
|
||||
public void setTransactionId(Long transactionId) {
|
||||
this.transactionId = String.valueOf(transactionId);
|
||||
}
|
||||
public void setBranchId(Long branchId) {
|
||||
this.branchId = String.valueOf(branchId);
|
||||
}
|
||||
|
||||
public String getBranchId() {
|
||||
return branchId;
|
||||
}
|
||||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
public void setBranchId(Long branchId) {
|
||||
this.branchId = String.valueOf(branchId);
|
||||
}
|
||||
public void setResourceId(String resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
|
||||
public String getResourceId() {
|
||||
return resourceId;
|
||||
}
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
public void setResourceId(String resourceId) {
|
||||
this.resourceId = resourceId;
|
||||
}
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
public String getPk() {
|
||||
return pk;
|
||||
}
|
||||
|
||||
public void setTableName(String tableName) {
|
||||
this.tableName = tableName;
|
||||
}
|
||||
public void setPk(String pk) {
|
||||
this.pk = pk;
|
||||
}
|
||||
|
||||
public String getPk() {
|
||||
return pk;
|
||||
}
|
||||
public String getRowKey() {
|
||||
return rowKey;
|
||||
}
|
||||
|
||||
public void setPk(String pk) {
|
||||
this.pk = pk;
|
||||
}
|
||||
public void setRowKey(String rowKey) {
|
||||
this.rowKey = rowKey;
|
||||
}
|
||||
|
||||
public String getRowKey() {
|
||||
return rowKey;
|
||||
}
|
||||
public Long getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
|
||||
public void setRowKey(String rowKey) {
|
||||
this.rowKey = rowKey;
|
||||
}
|
||||
public void setGmtCreate(Long gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
public Long getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
public Long getGmtModified() {
|
||||
return gmtModified;
|
||||
}
|
||||
|
||||
public void setGmtCreate(Long gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
public void setGmtModified(Long gmtModified) {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
|
||||
public Long getGmtModified() {
|
||||
return gmtModified;
|
||||
}
|
||||
public static GlobalLockVO convert(ResultSet rs) throws SQLException {
|
||||
GlobalLockVO globalLockVO = new GlobalLockVO();
|
||||
globalLockVO.setRowKey(rs.getString(ServerTableColumnsName.LOCK_TABLE_ROW_KEY));
|
||||
globalLockVO.setXid(rs.getString(ServerTableColumnsName.LOCK_TABLE_XID));
|
||||
globalLockVO.setTransactionId(rs.getLong(ServerTableColumnsName.LOCK_TABLE_TRANSACTION_ID));
|
||||
globalLockVO.setBranchId(rs.getLong(ServerTableColumnsName.LOCK_TABLE_BRANCH_ID));
|
||||
globalLockVO.setResourceId(rs.getString(ServerTableColumnsName.LOCK_TABLE_RESOURCE_ID));
|
||||
globalLockVO.setTableName(rs.getString(ServerTableColumnsName.LOCK_TABLE_TABLE_NAME));
|
||||
globalLockVO.setPk(rs.getString(ServerTableColumnsName.LOCK_TABLE_PK));
|
||||
Timestamp gmtCreateTimestamp = rs.getTimestamp(ServerTableColumnsName.LOCK_TABLE_GMT_CREATE);
|
||||
if (gmtCreateTimestamp != null) {
|
||||
globalLockVO.setGmtCreate(gmtCreateTimestamp.getTime());
|
||||
}
|
||||
Timestamp gmtModifiedTimestamp = rs.getTimestamp(ServerTableColumnsName.LOCK_TABLE_GMT_MODIFIED);
|
||||
if (gmtModifiedTimestamp != null) {
|
||||
globalLockVO.setGmtModified(gmtModifiedTimestamp.getTime());
|
||||
}
|
||||
return globalLockVO;
|
||||
}
|
||||
|
||||
public void setGmtModified(Long gmtModified) {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalLockVO{" + "xid='" + xid + '\'' + ", transactionId=" + transactionId + ", branchId=" + branchId
|
||||
+ ", resourceId='" + resourceId + '\'' + ", tableName='" + tableName + '\'' + ", pk='" + pk + '\''
|
||||
+ ", rowKey='" + rowKey + '\'' + ", gmtCreate=" + gmtCreate + ", gmtModified=" + gmtModified + '}';
|
||||
}
|
||||
|
||||
public static GlobalLockVO convert(ResultSet rs) throws SQLException {
|
||||
GlobalLockVO globalLockVO = new GlobalLockVO();
|
||||
globalLockVO.setRowKey(rs.getString(ServerTableColumnsName.LOCK_TABLE_ROW_KEY));
|
||||
globalLockVO.setXid(rs.getString(ServerTableColumnsName.LOCK_TABLE_XID));
|
||||
globalLockVO.setTransactionId(rs.getLong(ServerTableColumnsName.LOCK_TABLE_TRANSACTION_ID));
|
||||
globalLockVO.setBranchId(rs.getLong(ServerTableColumnsName.LOCK_TABLE_BRANCH_ID));
|
||||
globalLockVO.setResourceId(rs.getString(ServerTableColumnsName.LOCK_TABLE_RESOURCE_ID));
|
||||
globalLockVO.setTableName(rs.getString(ServerTableColumnsName.LOCK_TABLE_TABLE_NAME));
|
||||
globalLockVO.setPk(rs.getString(ServerTableColumnsName.LOCK_TABLE_PK));
|
||||
Timestamp gmtCreateTimestamp = rs.getTimestamp(ServerTableColumnsName.LOCK_TABLE_GMT_CREATE);
|
||||
if (gmtCreateTimestamp != null) {
|
||||
globalLockVO.setGmtCreate(gmtCreateTimestamp.getTime());
|
||||
}
|
||||
Timestamp gmtModifiedTimestamp = rs.getTimestamp(ServerTableColumnsName.LOCK_TABLE_GMT_MODIFIED);
|
||||
if (gmtModifiedTimestamp != null) {
|
||||
globalLockVO.setGmtModified(gmtModifiedTimestamp.getTime());
|
||||
}
|
||||
return globalLockVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalLockVO{" +
|
||||
"xid='" + xid + '\'' +
|
||||
", transactionId=" + transactionId +
|
||||
", branchId=" + branchId +
|
||||
", resourceId='" + resourceId + '\'' +
|
||||
", tableName='" + tableName + '\'' +
|
||||
", pk='" + pk + '\'' +
|
||||
", rowKey='" + rowKey + '\'' +
|
||||
", gmtCreate=" + gmtCreate +
|
||||
", gmtModified=" + gmtModified +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
+131
-145
@@ -24,194 +24,180 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* GlobalSessionVO
|
||||
*
|
||||
* @author zhongxiang.wang
|
||||
*/
|
||||
public class GlobalSessionVO {
|
||||
|
||||
private String xid;
|
||||
private String xid;
|
||||
|
||||
private String transactionId;
|
||||
private String transactionId;
|
||||
|
||||
private Integer status;
|
||||
private Integer status;
|
||||
|
||||
private String applicationId;
|
||||
private String applicationId;
|
||||
|
||||
private String transactionServiceGroup;
|
||||
private String transactionServiceGroup;
|
||||
|
||||
private String transactionName;
|
||||
private String transactionName;
|
||||
|
||||
private Long timeout;
|
||||
private Long timeout;
|
||||
|
||||
private Long beginTime;
|
||||
private Long beginTime;
|
||||
|
||||
private String applicationData;
|
||||
private String applicationData;
|
||||
|
||||
private Long gmtCreate;
|
||||
private Long gmtCreate;
|
||||
|
||||
private Long gmtModified;
|
||||
private Long gmtModified;
|
||||
|
||||
private Set<BranchSessionVO> branchSessionVOs;
|
||||
private Set<BranchSessionVO> branchSessionVOs;
|
||||
|
||||
public GlobalSessionVO() {
|
||||
|
||||
public GlobalSessionVO() {
|
||||
}
|
||||
|
||||
}
|
||||
public GlobalSessionVO(String xid, Long transactionId, Integer status, String applicationId,
|
||||
String transactionServiceGroup, String transactionName, Long timeout, Long beginTime,
|
||||
String applicationData, Set<BranchSessionVO> branchSessionVOs) {
|
||||
this.xid = xid;
|
||||
this.transactionId = String.valueOf(transactionId);
|
||||
this.status = status;
|
||||
this.applicationId = applicationId;
|
||||
this.transactionServiceGroup = transactionServiceGroup;
|
||||
this.transactionName = transactionName;
|
||||
this.timeout = timeout;
|
||||
this.beginTime = beginTime;
|
||||
this.applicationData = applicationData;
|
||||
this.branchSessionVOs = branchSessionVOs;
|
||||
}
|
||||
|
||||
public GlobalSessionVO(String xid,
|
||||
Long transactionId,
|
||||
Integer status,
|
||||
String applicationId,
|
||||
String transactionServiceGroup,
|
||||
String transactionName,
|
||||
Long timeout,
|
||||
Long beginTime,
|
||||
String applicationData,
|
||||
Set<BranchSessionVO> branchSessionVOs) {
|
||||
this.xid = xid;
|
||||
this.transactionId = String.valueOf(transactionId);
|
||||
this.status = status;
|
||||
this.applicationId = applicationId;
|
||||
this.transactionServiceGroup = transactionServiceGroup;
|
||||
this.transactionName = transactionName;
|
||||
this.timeout = timeout;
|
||||
this.beginTime = beginTime;
|
||||
this.applicationData = applicationData;
|
||||
this.branchSessionVOs = branchSessionVOs;
|
||||
}
|
||||
public String getXid() {
|
||||
return xid;
|
||||
}
|
||||
|
||||
public String getXid() {
|
||||
return xid;
|
||||
}
|
||||
public void setXid(String xid) {
|
||||
this.xid = xid;
|
||||
}
|
||||
|
||||
public void setXid(String xid) {
|
||||
this.xid = xid;
|
||||
}
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
public void setTransactionId(Long transactionId) {
|
||||
this.transactionId = String.valueOf(transactionId);
|
||||
}
|
||||
|
||||
public void setTransactionId(Long transactionId) {
|
||||
this.transactionId = String.valueOf(transactionId);
|
||||
}
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public Integer getStatus() {
|
||||
return status;
|
||||
}
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public void setStatus(Integer status) {
|
||||
this.status = status;
|
||||
}
|
||||
public String getApplicationId() {
|
||||
return applicationId;
|
||||
}
|
||||
|
||||
public String getApplicationId() {
|
||||
return applicationId;
|
||||
}
|
||||
public void setApplicationId(String applicationId) {
|
||||
this.applicationId = applicationId;
|
||||
}
|
||||
|
||||
public void setApplicationId(String applicationId) {
|
||||
this.applicationId = applicationId;
|
||||
}
|
||||
public String getTransactionServiceGroup() {
|
||||
return transactionServiceGroup;
|
||||
}
|
||||
|
||||
public String getTransactionServiceGroup() {
|
||||
return transactionServiceGroup;
|
||||
}
|
||||
public void setTransactionServiceGroup(String transactionServiceGroup) {
|
||||
this.transactionServiceGroup = transactionServiceGroup;
|
||||
}
|
||||
|
||||
public void setTransactionServiceGroup(String transactionServiceGroup) {
|
||||
this.transactionServiceGroup = transactionServiceGroup;
|
||||
}
|
||||
public String getTransactionName() {
|
||||
return transactionName;
|
||||
}
|
||||
|
||||
public String getTransactionName() {
|
||||
return transactionName;
|
||||
}
|
||||
public void setTransactionName(String transactionName) {
|
||||
this.transactionName = transactionName;
|
||||
}
|
||||
|
||||
public void setTransactionName(String transactionName) {
|
||||
this.transactionName = transactionName;
|
||||
}
|
||||
public Long getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
|
||||
public Long getTimeout() {
|
||||
return timeout;
|
||||
}
|
||||
public void setTimeout(Long timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
|
||||
public void setTimeout(Long timeout) {
|
||||
this.timeout = timeout;
|
||||
}
|
||||
public Long getBeginTime() {
|
||||
return beginTime;
|
||||
}
|
||||
|
||||
public Long getBeginTime() {
|
||||
return beginTime;
|
||||
}
|
||||
public void setBeginTime(Long beginTime) {
|
||||
this.beginTime = beginTime;
|
||||
}
|
||||
|
||||
public void setBeginTime(Long beginTime) {
|
||||
this.beginTime = beginTime;
|
||||
}
|
||||
public String getApplicationData() {
|
||||
return applicationData;
|
||||
}
|
||||
|
||||
public String getApplicationData() {
|
||||
return applicationData;
|
||||
}
|
||||
public void setApplicationData(String applicationData) {
|
||||
this.applicationData = applicationData;
|
||||
}
|
||||
|
||||
public void setApplicationData(String applicationData) {
|
||||
this.applicationData = applicationData;
|
||||
}
|
||||
public Long getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
|
||||
public Long getGmtCreate() {
|
||||
return gmtCreate;
|
||||
}
|
||||
public void setGmtCreate(Long gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
public void setGmtCreate(Long gmtCreate) {
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
public Long getGmtModified() {
|
||||
return gmtModified;
|
||||
}
|
||||
|
||||
public Long getGmtModified() {
|
||||
return gmtModified;
|
||||
}
|
||||
public void setGmtModified(Long gmtModified) {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
|
||||
public void setGmtModified(Long gmtModified) {
|
||||
this.gmtModified = gmtModified;
|
||||
}
|
||||
public Set<BranchSessionVO> getBranchSessionVOs() {
|
||||
return branchSessionVOs;
|
||||
}
|
||||
|
||||
public Set<BranchSessionVO> getBranchSessionVOs() {
|
||||
return branchSessionVOs;
|
||||
}
|
||||
public void setBranchSessionVOs(Set<BranchSessionVO> branchSessionVOs) {
|
||||
this.branchSessionVOs = branchSessionVOs;
|
||||
}
|
||||
|
||||
public void setBranchSessionVOs(Set<BranchSessionVO> branchSessionVOs) {
|
||||
this.branchSessionVOs = branchSessionVOs;
|
||||
}
|
||||
public static GlobalSessionVO convert(ResultSet rs) throws SQLException {
|
||||
GlobalSessionVO globalSessionVO = new GlobalSessionVO();
|
||||
globalSessionVO.setXid(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_XID));
|
||||
globalSessionVO.setTransactionId(rs.getLong(ServerTableColumnsName.GLOBAL_TABLE_TRANSACTION_ID));
|
||||
globalSessionVO.setStatus(rs.getInt(ServerTableColumnsName.GLOBAL_TABLE_STATUS));
|
||||
globalSessionVO.setApplicationId(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_APPLICATION_ID));
|
||||
globalSessionVO.setTransactionServiceGroup(
|
||||
rs.getString(ServerTableColumnsName.GLOBAL_TABLE_TRANSACTION_SERVICE_GROUP));
|
||||
globalSessionVO.setTransactionName(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_TRANSACTION_NAME));
|
||||
globalSessionVO.setTimeout(rs.getLong(ServerTableColumnsName.GLOBAL_TABLE_TIMEOUT));
|
||||
globalSessionVO.setBeginTime(rs.getLong(ServerTableColumnsName.GLOBAL_TABLE_BEGIN_TIME));
|
||||
globalSessionVO.setApplicationData(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_APPLICATION_DATA));
|
||||
Timestamp gmtCreateTimestamp = rs.getTimestamp(ServerTableColumnsName.GLOBAL_TABLE_GMT_CREATE);
|
||||
if (gmtCreateTimestamp != null) {
|
||||
globalSessionVO.setGmtCreate(gmtCreateTimestamp.getTime());
|
||||
}
|
||||
Timestamp gmtModifiedTimestamp = rs.getTimestamp(ServerTableColumnsName.GLOBAL_TABLE_GMT_MODIFIED);
|
||||
if (gmtModifiedTimestamp != null) {
|
||||
globalSessionVO.setGmtModified(gmtModifiedTimestamp.getTime());
|
||||
}
|
||||
return globalSessionVO;
|
||||
}
|
||||
|
||||
public static GlobalSessionVO convert(ResultSet rs) throws SQLException {
|
||||
GlobalSessionVO globalSessionVO = new GlobalSessionVO();
|
||||
globalSessionVO.setXid(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_XID));
|
||||
globalSessionVO.setTransactionId(rs.getLong(ServerTableColumnsName.GLOBAL_TABLE_TRANSACTION_ID));
|
||||
globalSessionVO.setStatus(rs.getInt(ServerTableColumnsName.GLOBAL_TABLE_STATUS));
|
||||
globalSessionVO.setApplicationId(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_APPLICATION_ID));
|
||||
globalSessionVO.setTransactionServiceGroup(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_TRANSACTION_SERVICE_GROUP));
|
||||
globalSessionVO.setTransactionName(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_TRANSACTION_NAME));
|
||||
globalSessionVO.setTimeout(rs.getLong(ServerTableColumnsName.GLOBAL_TABLE_TIMEOUT));
|
||||
globalSessionVO.setBeginTime(rs.getLong(ServerTableColumnsName.GLOBAL_TABLE_BEGIN_TIME));
|
||||
globalSessionVO.setApplicationData(rs.getString(ServerTableColumnsName.GLOBAL_TABLE_APPLICATION_DATA));
|
||||
Timestamp gmtCreateTimestamp = rs.getTimestamp(ServerTableColumnsName.GLOBAL_TABLE_GMT_CREATE);
|
||||
if (gmtCreateTimestamp != null) {
|
||||
globalSessionVO.setGmtCreate(gmtCreateTimestamp.getTime());
|
||||
}
|
||||
Timestamp gmtModifiedTimestamp = rs.getTimestamp(ServerTableColumnsName.GLOBAL_TABLE_GMT_MODIFIED);
|
||||
if (gmtModifiedTimestamp != null) {
|
||||
globalSessionVO.setGmtModified(gmtModifiedTimestamp.getTime());
|
||||
}
|
||||
return globalSessionVO;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalSessionVO{" + "xid='" + xid + '\'' + ", transactionId=" + transactionId + ", status=" + status
|
||||
+ ", applicationId='" + applicationId + '\'' + ", transactionServiceGroup='" + transactionServiceGroup
|
||||
+ '\'' + ", transactionName='" + transactionName + '\'' + ", timeout=" + timeout + ", beginTime="
|
||||
+ beginTime + ", applicationData='" + applicationData + '\'' + ", gmtCreate=" + gmtCreate
|
||||
+ ", gmtModified=" + gmtModified + ", branchSessionVOs=" + branchSessionVOs + '}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GlobalSessionVO{" +
|
||||
"xid='" + xid + '\'' +
|
||||
", transactionId=" + transactionId +
|
||||
", status=" + status +
|
||||
", applicationId='" + applicationId + '\'' +
|
||||
", transactionServiceGroup='" + transactionServiceGroup + '\'' +
|
||||
", transactionName='" + transactionName + '\'' +
|
||||
", timeout=" + timeout +
|
||||
", beginTime=" + beginTime +
|
||||
", applicationData='" + applicationData + '\'' +
|
||||
", gmtCreate=" + gmtCreate +
|
||||
", gmtModified=" + gmtModified +
|
||||
", branchSessionVOs=" + branchSessionVOs +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user