Skip to content

Commit

Permalink
feature: add console transaction control (#7024)
Browse files Browse the repository at this point in the history
  • Loading branch information
xjlgod authored Feb 7, 2025
1 parent 67548df commit 0a66e5b
Show file tree
Hide file tree
Showing 49 changed files with 2,148 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class Result<T> implements Serializable {

public static final String SUCCESS_CODE = "200";
public static final String SUCCESS_MSG = "success";
public static final String FAIL_CODE = "500";


private String code = SUCCESS_CODE;
private String message = SUCCESS_MSG;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,18 @@ public static <T> SingleResult<T> failure(Code errorCode) {
return new SingleResult(errorCode.getCode(), errorCode.getMsg());
}

public static <T> SingleResult<T> failure(String msg) {
return new SingleResult<>(FAIL_CODE, msg);
}

public static <T> SingleResult<T> success(T data) {
return new SingleResult<>(SUCCESS_CODE, SUCCESS_MSG,data);
}

public static <T> SingleResult<T> success() {
return new SingleResult<>(SUCCESS_CODE, SUCCESS_MSG, null);
}

public T getData() {
return data;
}
Expand Down
12 changes: 12 additions & 0 deletions console/src/main/resources/static/console-fe/src/locales/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ const enUs: ILocale = {
showBranchSessionTitle: 'View branch session',
showGlobalLockTitle: 'View global lock',
branchSessionDialogTitle: 'Branch session info',
deleteGlobalSessionTitle: 'Delete global session',
forceDeleteGlobalSessionTitle: 'Force delete global session',
stopGlobalSessionTitle: 'Stop global session retry',
startGlobalSessionTitle: 'Start global session retry',
sendGlobalSessionTitle: 'Commit or rollback global session',
changeGlobalSessionTitle: 'Change global session status',
deleteBranchSessionTitle: 'Delete branch session',
forceDeleteBranchSessionTitle: 'force delete branch session',
stopBranchSessionTitle: 'Stop branch session retry',
startBranchSessionTitle: 'Start branch session retry',
},
GlobalLockInfo: {
title: 'GlobalLockInfo',
Expand All @@ -69,6 +79,8 @@ const enUs: ILocale = {
inputFilterPlaceholder: 'Please enter filter criteria',
resetButtonLabel: 'Reset',
searchButtonLabel: 'Search',
operateTitle: 'operate',
deleteGlobalLockTitle: 'Delete global lock',
},
};

Expand Down
12 changes: 12 additions & 0 deletions console/src/main/resources/static/console-fe/src/locales/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ const zhCn: ILocale = {
showBranchSessionTitle: '查看分支信息',
showGlobalLockTitle: '查看全局锁',
branchSessionDialogTitle: '分支事务信息',
deleteGlobalSessionTitle: '删除全局事务',
forceDeleteGlobalSessionTitle: '强制删除全局事务',
stopGlobalSessionTitle: '停止全局事务重试',
startGlobalSessionTitle: '开启全局事务重试',
sendGlobalSessionTitle: '提交或回滚全局事务',
changeGlobalSessionTitle: '更新全局事务状态',
deleteBranchSessionTitle: '删除分支事务',
forceDeleteBranchSessionTitle: '强制删除分支事务',
stopBranchSessionTitle: '停止分支事务重启',
startBranchSessionTitle: '开启分支事务重试',
},
GlobalLockInfo: {
title: '全局锁信息',
Expand All @@ -69,6 +79,8 @@ const zhCn: ILocale = {
inputFilterPlaceholder: '请输入筛选条件',
resetButtonLabel: '重置',
searchButtonLabel: '搜索',
operateTitle: '操作',
deleteGlobalLockTitle: '删除全局锁',
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
* limitations under the License.
*/
import React from 'react';
import { ConfigProvider, Table, Button, DatePicker, Form, Icon, Pagination, Input } from '@alicloud/console-components';
import { ConfigProvider, Table, Button, DatePicker, Form, Icon, Pagination, Input, Dialog, Message } from '@alicloud/console-components';
import Actions, { LinkButton } from '@alicloud/console-components-actions';
import { withRouter } from 'react-router-dom';
import Page from '@/components/Page';
import { GlobalProps } from '@/module';
import styled, { css } from 'styled-components';
import getData, { GlobalLockParam } from '@/service/globalLockInfo';
import getData, {checkData, deleteData, GlobalLockParam } from '@/service/globalLockInfo';
import PropTypes from 'prop-types';
import moment from 'moment';

import './index.scss';
import {get} from "lodash";
import {enUsKey, getCurrentLanguage} from "@/reducers/locale";

const { RangePicker } = DatePicker;
const FormItem = Form.Item;
Expand All @@ -37,7 +39,7 @@ type GlobalLockInfoState = {
globalLockParam: GlobalLockParam;
}

class GlobalLockInfo extends React.Component<GlobalProps, GlobalLockInfoState> {
class GlobalLockInfo extends React.Component<GlobalProps, GlobalLockInfoState> {
static displayName = 'GlobalLockInfo';

static propTypes = {
Expand Down Expand Up @@ -148,12 +150,53 @@ type GlobalLockInfoState = {
this.search();
}

deleteCell = (val: string, index: number, record: any) => {
const {locale = {}} = this.props;
const {
deleteGlobalLockTitle
} = locale;
let width = getCurrentLanguage() === enUsKey ? '120px' : '80px'
return (
<Actions style={{width: width}}>
<Button onClick={() => {
let addWarnning = ''
Dialog.confirm({
title: 'Confirm',
content: 'Are you sure you want to delete the global lock',
onOk: () => {
checkData(record).then((rsp) => {
addWarnning = rsp.data ? 'The branch transactions may be affected' : ''
Dialog.confirm({
title: 'Warnning',
content: <div dangerouslySetInnerHTML={{ __html: 'Dirty write problem exists' + '<br>' + addWarnning }}/>,
onOk: () => {
deleteData(record).then(() => {
Message.success("Delete success")
this.search()
}).catch((rsp) => {
Message.error(get(rsp, 'data.message'))
})
}
})
}).catch((rsp) => {
Message.error(get(rsp, 'data.message'))
})
}
});
}}>
{deleteGlobalLockTitle}
</Button>
</Actions>)
}


render() {
const { locale = {} } = this.props;
const { title, subTitle, createTimeLabel,
inputFilterPlaceholder,
searchButtonLabel,
resetButtonLabel,
operateTitle,
} = locale;
return (
<Page
Expand Down Expand Up @@ -221,27 +264,28 @@ type GlobalLockInfoState = {
</Form>
{/* global lock table */}
<div>
<Table dataSource={this.state.list} loading={this.state.loading}>
<Table.Column title="xid" dataIndex="xid" />
<Table.Column title="transactionId" dataIndex="transactionId" />
<Table.Column title="branchId" dataIndex="branchId" />
<Table.Column title="resourceId" dataIndex="resourceId" />
<Table.Column title="tableName" dataIndex="tableName" />
<Table.Column title="pk" dataIndex="pk" />
<Table.Column title="rowKey" dataIndex="rowKey" />
<Table.Column title="gmtCreate" dataIndex="gmtCreate" />
<Table.Column title="gmtModified" dataIndex="gmtModified" />
</Table>
<Pagination
total={this.state.total}
defaultCurrent={1}
current={this.state.globalLockParam.pageNum}
onChange={this.paginationOnChange}
pageSize={this.state.globalLockParam.pageSize}
pageSizeSelector="dropdown"
pageSizeList={[10, 20, 30, 40, 50]}
onPageSizeChange={this.paginationOnPageSizeChange}
/>
<Table dataSource={this.state.list} loading={this.state.loading}>
<Table.Column title="xid" dataIndex="xid" />
<Table.Column title="transactionId" dataIndex="transactionId" />
<Table.Column title="branchId" dataIndex="branchId" />
<Table.Column title="resourceId" dataIndex="resourceId" />
<Table.Column title="tableName" dataIndex="tableName" />
<Table.Column title="pk" dataIndex="pk" />
<Table.Column title="rowKey" dataIndex="rowKey" />
<Table.Column title="gmtCreate" dataIndex="gmtCreate" />
<Table.Column title="gmtModified" dataIndex="gmtModified" />
<Table.Column title={operateTitle} cell={this.deleteCell}/>
</Table>
<Pagination
total={this.state.total}
defaultCurrent={1}
current={this.state.globalLockParam.pageNum}
onChange={this.paginationOnChange}
pageSize={this.state.globalLockParam.pageSize}
pageSizeSelector="dropdown"
pageSizeList={[10, 20, 30, 40, 50]}
onPageSizeChange={this.paginationOnPageSizeChange}
/>
</div>
</Page>
);
Expand Down
Loading

0 comments on commit 0a66e5b

Please sign in to comment.