-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master-2.x-local-dev' into 'master-2.x'
Master 2.x local dev See merge request changming.xie/tcc-transaction!4
- Loading branch information
Showing
44 changed files
with
994 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
tcc-transaction-admin-web/src/pages/tcc/registry/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
import React, {useEffect, useState} from 'react'; | ||
import {registryOnline, registryOffline, registryQueryStatus} from "../../../common/api"; | ||
import {Button, Col, Popconfirm, Row, Space, Table} from "antd"; | ||
|
||
const Page = () => { | ||
const [registryStatusList, setRegistryStatusList] = useState([]); | ||
const [loadingStatus, setLoadingStatus] = useState(false); //加载数据 | ||
|
||
useEffect(() => { | ||
reloadRegistryStatus(0); | ||
}, []); | ||
|
||
const reloadRegistryStatus = (delay) => { | ||
setLoadingStatus(true) | ||
setTimeout(() => { | ||
registryQueryStatus().then(data => { | ||
setLoadingStatus(false) | ||
setRegistryStatusList(data) | ||
}).catch((res) => { | ||
setLoadingStatus(false) | ||
}) | ||
}, delay); | ||
}; | ||
|
||
const columns =[ | ||
{ | ||
title: '实例', | ||
dataIndex: 'instance', | ||
render:(text, record)=>{ | ||
return `${record.ip}:${record.port}` | ||
} | ||
}, | ||
{ | ||
title: '状态', | ||
dataIndex: 'status', | ||
key: 'status', | ||
render: (text, record) => { | ||
switch (text) { | ||
case 1: | ||
return "已上线"; | ||
case 2: | ||
return "已下线"; | ||
case 3: | ||
return "未知"; | ||
default: | ||
return text; | ||
} | ||
} | ||
}, | ||
{ | ||
title: '操作', | ||
key: 'operation', | ||
render: (text,record)=>( | ||
<Space> | ||
{ | ||
record.status !== 1? | ||
<Popconfirm | ||
title="是否执行" | ||
onConfirm={() => { | ||
registryOnline(record.ip, record.port).then(resp => { | ||
reloadRegistryStatus(3000) | ||
}) | ||
}} | ||
okText="是" | ||
cancelText="否"> | ||
<Button size="small" type="primary" danger>上线</Button> | ||
</Popconfirm> | ||
: <></> | ||
} | ||
{ | ||
record.status !== 2? | ||
<Popconfirm | ||
title="警告:实例下线可能会降低整体服务的可用性,请谨慎操作!" | ||
onConfirm={() => { | ||
registryOffline(record.ip,record.port).then(resp => { | ||
reloadRegistryStatus(3000) | ||
}) | ||
}} | ||
okText="确认下线" | ||
cancelText="取消"> | ||
<Button size="small" type="primary" danger>下线</Button> | ||
</Popconfirm> | ||
: <></> | ||
} | ||
</Space> | ||
|
||
) | ||
}, | ||
] | ||
return( | ||
<div> | ||
<Row style={{padding: '12px'}}> | ||
<Col span={23}> | ||
| ||
</Col> | ||
<Col span={1}> | ||
<Button type="primary" | ||
size="small" | ||
onClick={() => reloadRegistryStatus(0)} | ||
disabled={loadingStatus}> | ||
刷新 | ||
</Button> | ||
</Col> | ||
</Row> | ||
<Table rowKey={record => `${record.ip}:${record.port}`} | ||
dataSource={registryStatusList} | ||
columns={columns} | ||
pagination={false} | ||
loading={loadingStatus}/> | ||
</div> | ||
) | ||
} | ||
|
||
export default Page; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tcc-transaction-core/src/main/java/org/mengyun/tcctransaction/dashboard/dto/AddressDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package org.mengyun.tcctransaction.dashboard.dto; | ||
|
||
/** | ||
* @author Nervose.Wu | ||
* @date 2024/2/19 11:23 | ||
*/ | ||
public class AddressDto { | ||
private String ip; | ||
private Integer port; | ||
|
||
public String getIp() { | ||
return ip; | ||
} | ||
|
||
public void setIp(String ip) { | ||
this.ip = ip; | ||
} | ||
|
||
public Integer getPort() { | ||
return port; | ||
} | ||
|
||
public void setPort(Integer port) { | ||
this.port = port; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
...action-core/src/main/java/org/mengyun/tcctransaction/dashboard/dto/RegistryStatusDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package org.mengyun.tcctransaction.dashboard.dto; | ||
|
||
/** | ||
* @author Nervose.Wu | ||
* @date 2024/2/19 10:49 | ||
*/ | ||
public class RegistryStatusDto { | ||
private String ip; | ||
private Integer port; | ||
private Integer status; | ||
|
||
public RegistryStatusDto(String ip, Integer port, Integer status) { | ||
this.ip = ip; | ||
this.port = port; | ||
this.status = status; | ||
} | ||
|
||
public String getIp() { | ||
return ip; | ||
} | ||
|
||
public void setIp(String ip) { | ||
this.ip = ip; | ||
} | ||
|
||
public Integer getPort() { | ||
return port; | ||
} | ||
|
||
public void setPort(Integer port) { | ||
this.port = port; | ||
} | ||
|
||
public Integer getStatus() { | ||
return status; | ||
} | ||
|
||
public void setStatus(Integer status) { | ||
this.status = status; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ore/src/main/java/org/mengyun/tcctransaction/dashboard/service/ServerRegistryService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.mengyun.tcctransaction.dashboard.service; | ||
|
||
import org.mengyun.tcctransaction.dashboard.dto.RegistryStatusDto; | ||
import org.mengyun.tcctransaction.dashboard.dto.ResponseDto; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* @author Nervose.Wu | ||
* @date 2024/2/19 10:56 | ||
*/ | ||
public interface ServerRegistryService { | ||
ResponseDto<List<RegistryStatusDto>> queryStatus(); | ||
|
||
ResponseDto<Void> online(String ip, Integer port); | ||
|
||
ResponseDto<Void> offline(String ip, Integer port); | ||
} |
31 changes: 31 additions & 0 deletions
31
...java/org/mengyun/tcctransaction/dashboard/service/impl/BaseServerRegistryServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.mengyun.tcctransaction.dashboard.service.impl; | ||
|
||
import org.mengyun.tcctransaction.dashboard.dto.RegistryStatusDto; | ||
import org.mengyun.tcctransaction.dashboard.dto.ResponseDto; | ||
import org.mengyun.tcctransaction.dashboard.enums.ResponseCodeEnum; | ||
import org.mengyun.tcctransaction.dashboard.exception.TransactionException; | ||
import org.mengyun.tcctransaction.dashboard.service.ServerRegistryService; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
/** | ||
* @author Nervose.Wu | ||
* @date 2024/2/19 10:59 | ||
*/ | ||
public class BaseServerRegistryServiceImpl implements ServerRegistryService { | ||
@Override | ||
public ResponseDto<List<RegistryStatusDto>> queryStatus() { | ||
return ResponseDto.returnSuccess(Collections.emptyList()); | ||
} | ||
|
||
@Override | ||
public ResponseDto<Void> online(String ip, Integer port) { | ||
throw new TransactionException(ResponseCodeEnum.NOT_SUPPORT); | ||
} | ||
|
||
@Override | ||
public ResponseDto<Void> offline(String ip, Integer port) { | ||
throw new TransactionException(ResponseCodeEnum.NOT_SUPPORT); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.