Skip to content

Commit 0a66e5b

Browse files
authored
feature: add console transaction control (#7024)
1 parent 67548df commit 0a66e5b

File tree

49 files changed

+2148
-106
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2148
-106
lines changed

common/src/main/java/org/apache/seata/common/result/Result.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class Result<T> implements Serializable {
2626

2727
public static final String SUCCESS_CODE = "200";
2828
public static final String SUCCESS_MSG = "success";
29+
public static final String FAIL_CODE = "500";
30+
2931

3032
private String code = SUCCESS_CODE;
3133
private String message = SUCCESS_MSG;

common/src/main/java/org/apache/seata/common/result/SingleResult.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,18 @@ public static <T> SingleResult<T> failure(Code errorCode) {
4747
return new SingleResult(errorCode.getCode(), errorCode.getMsg());
4848
}
4949

50+
public static <T> SingleResult<T> failure(String msg) {
51+
return new SingleResult<>(FAIL_CODE, msg);
52+
}
53+
5054
public static <T> SingleResult<T> success(T data) {
5155
return new SingleResult<>(SUCCESS_CODE, SUCCESS_MSG,data);
5256
}
5357

58+
public static <T> SingleResult<T> success() {
59+
return new SingleResult<>(SUCCESS_CODE, SUCCESS_MSG, null);
60+
}
61+
5462
public T getData() {
5563
return data;
5664
}

console/src/main/resources/static/console-fe/src/locales/en-us.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ const enUs: ILocale = {
6161
showBranchSessionTitle: 'View branch session',
6262
showGlobalLockTitle: 'View global lock',
6363
branchSessionDialogTitle: 'Branch session info',
64+
deleteGlobalSessionTitle: 'Delete global session',
65+
forceDeleteGlobalSessionTitle: 'Force delete global session',
66+
stopGlobalSessionTitle: 'Stop global session retry',
67+
startGlobalSessionTitle: 'Start global session retry',
68+
sendGlobalSessionTitle: 'Commit or rollback global session',
69+
changeGlobalSessionTitle: 'Change global session status',
70+
deleteBranchSessionTitle: 'Delete branch session',
71+
forceDeleteBranchSessionTitle: 'force delete branch session',
72+
stopBranchSessionTitle: 'Stop branch session retry',
73+
startBranchSessionTitle: 'Start branch session retry',
6474
},
6575
GlobalLockInfo: {
6676
title: 'GlobalLockInfo',
@@ -69,6 +79,8 @@ const enUs: ILocale = {
6979
inputFilterPlaceholder: 'Please enter filter criteria',
7080
resetButtonLabel: 'Reset',
7181
searchButtonLabel: 'Search',
82+
operateTitle: 'operate',
83+
deleteGlobalLockTitle: 'Delete global lock',
7284
},
7385
};
7486

console/src/main/resources/static/console-fe/src/locales/zh-cn.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ const zhCn: ILocale = {
6161
showBranchSessionTitle: '查看分支信息',
6262
showGlobalLockTitle: '查看全局锁',
6363
branchSessionDialogTitle: '分支事务信息',
64+
deleteGlobalSessionTitle: '删除全局事务',
65+
forceDeleteGlobalSessionTitle: '强制删除全局事务',
66+
stopGlobalSessionTitle: '停止全局事务重试',
67+
startGlobalSessionTitle: '开启全局事务重试',
68+
sendGlobalSessionTitle: '提交或回滚全局事务',
69+
changeGlobalSessionTitle: '更新全局事务状态',
70+
deleteBranchSessionTitle: '删除分支事务',
71+
forceDeleteBranchSessionTitle: '强制删除分支事务',
72+
stopBranchSessionTitle: '停止分支事务重启',
73+
startBranchSessionTitle: '开启分支事务重试',
6474
},
6575
GlobalLockInfo: {
6676
title: '全局锁信息',
@@ -69,6 +79,8 @@ const zhCn: ILocale = {
6979
inputFilterPlaceholder: '请输入筛选条件',
7080
resetButtonLabel: '重置',
7181
searchButtonLabel: '搜索',
82+
operateTitle: '操作',
83+
deleteGlobalLockTitle: '删除全局锁',
7284
},
7385
};
7486

console/src/main/resources/static/console-fe/src/pages/GlobalLockInfo/GlobalLockInfo.tsx

Lines changed: 68 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,19 @@
1515
* limitations under the License.
1616
*/
1717
import React from 'react';
18-
import { ConfigProvider, Table, Button, DatePicker, Form, Icon, Pagination, Input } from '@alicloud/console-components';
18+
import { ConfigProvider, Table, Button, DatePicker, Form, Icon, Pagination, Input, Dialog, Message } from '@alicloud/console-components';
1919
import Actions, { LinkButton } from '@alicloud/console-components-actions';
2020
import { withRouter } from 'react-router-dom';
2121
import Page from '@/components/Page';
2222
import { GlobalProps } from '@/module';
2323
import styled, { css } from 'styled-components';
24-
import getData, { GlobalLockParam } from '@/service/globalLockInfo';
24+
import getData, {checkData, deleteData, GlobalLockParam } from '@/service/globalLockInfo';
2525
import PropTypes from 'prop-types';
2626
import moment from 'moment';
2727

2828
import './index.scss';
29+
import {get} from "lodash";
30+
import {enUsKey, getCurrentLanguage} from "@/reducers/locale";
2931

3032
const { RangePicker } = DatePicker;
3133
const FormItem = Form.Item;
@@ -37,7 +39,7 @@ type GlobalLockInfoState = {
3739
globalLockParam: GlobalLockParam;
3840
}
3941

40-
class GlobalLockInfo extends React.Component<GlobalProps, GlobalLockInfoState> {
42+
class GlobalLockInfo extends React.Component<GlobalProps, GlobalLockInfoState> {
4143
static displayName = 'GlobalLockInfo';
4244

4345
static propTypes = {
@@ -148,12 +150,53 @@ type GlobalLockInfoState = {
148150
this.search();
149151
}
150152

153+
deleteCell = (val: string, index: number, record: any) => {
154+
const {locale = {}} = this.props;
155+
const {
156+
deleteGlobalLockTitle
157+
} = locale;
158+
let width = getCurrentLanguage() === enUsKey ? '120px' : '80px'
159+
return (
160+
<Actions style={{width: width}}>
161+
<Button onClick={() => {
162+
let addWarnning = ''
163+
Dialog.confirm({
164+
title: 'Confirm',
165+
content: 'Are you sure you want to delete the global lock',
166+
onOk: () => {
167+
checkData(record).then((rsp) => {
168+
addWarnning = rsp.data ? 'The branch transactions may be affected' : ''
169+
Dialog.confirm({
170+
title: 'Warnning',
171+
content: <div dangerouslySetInnerHTML={{ __html: 'Dirty write problem exists' + '<br>' + addWarnning }}/>,
172+
onOk: () => {
173+
deleteData(record).then(() => {
174+
Message.success("Delete success")
175+
this.search()
176+
}).catch((rsp) => {
177+
Message.error(get(rsp, 'data.message'))
178+
})
179+
}
180+
})
181+
}).catch((rsp) => {
182+
Message.error(get(rsp, 'data.message'))
183+
})
184+
}
185+
});
186+
}}>
187+
{deleteGlobalLockTitle}
188+
</Button>
189+
</Actions>)
190+
}
191+
192+
151193
render() {
152194
const { locale = {} } = this.props;
153195
const { title, subTitle, createTimeLabel,
154196
inputFilterPlaceholder,
155197
searchButtonLabel,
156198
resetButtonLabel,
199+
operateTitle,
157200
} = locale;
158201
return (
159202
<Page
@@ -221,27 +264,28 @@ type GlobalLockInfoState = {
221264
</Form>
222265
{/* global lock table */}
223266
<div>
224-
<Table dataSource={this.state.list} loading={this.state.loading}>
225-
<Table.Column title="xid" dataIndex="xid" />
226-
<Table.Column title="transactionId" dataIndex="transactionId" />
227-
<Table.Column title="branchId" dataIndex="branchId" />
228-
<Table.Column title="resourceId" dataIndex="resourceId" />
229-
<Table.Column title="tableName" dataIndex="tableName" />
230-
<Table.Column title="pk" dataIndex="pk" />
231-
<Table.Column title="rowKey" dataIndex="rowKey" />
232-
<Table.Column title="gmtCreate" dataIndex="gmtCreate" />
233-
<Table.Column title="gmtModified" dataIndex="gmtModified" />
234-
</Table>
235-
<Pagination
236-
total={this.state.total}
237-
defaultCurrent={1}
238-
current={this.state.globalLockParam.pageNum}
239-
onChange={this.paginationOnChange}
240-
pageSize={this.state.globalLockParam.pageSize}
241-
pageSizeSelector="dropdown"
242-
pageSizeList={[10, 20, 30, 40, 50]}
243-
onPageSizeChange={this.paginationOnPageSizeChange}
244-
/>
267+
<Table dataSource={this.state.list} loading={this.state.loading}>
268+
<Table.Column title="xid" dataIndex="xid" />
269+
<Table.Column title="transactionId" dataIndex="transactionId" />
270+
<Table.Column title="branchId" dataIndex="branchId" />
271+
<Table.Column title="resourceId" dataIndex="resourceId" />
272+
<Table.Column title="tableName" dataIndex="tableName" />
273+
<Table.Column title="pk" dataIndex="pk" />
274+
<Table.Column title="rowKey" dataIndex="rowKey" />
275+
<Table.Column title="gmtCreate" dataIndex="gmtCreate" />
276+
<Table.Column title="gmtModified" dataIndex="gmtModified" />
277+
<Table.Column title={operateTitle} cell={this.deleteCell}/>
278+
</Table>
279+
<Pagination
280+
total={this.state.total}
281+
defaultCurrent={1}
282+
current={this.state.globalLockParam.pageNum}
283+
onChange={this.paginationOnChange}
284+
pageSize={this.state.globalLockParam.pageSize}
285+
pageSizeSelector="dropdown"
286+
pageSizeList={[10, 20, 30, 40, 50]}
287+
onPageSizeChange={this.paginationOnPageSizeChange}
288+
/>
245289
</div>
246290
</Page>
247291
);

0 commit comments

Comments
 (0)