Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: add console transaction control #7024

Open
wants to merge 17 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ public interface ConfigurationKeys {
*/
String DISTRIBUTED_LOCK_DB_TABLE = STORE_DB_PREFIX + "distributedLockTable";

/**
* the constant AUTO_RESTART_TIME
*/
String AUTO_RESTART_TIME = SERVER_PREFIX + "autoRestartTime";

/**
* the constant AUTO_RESTART_PERIOD
*/
String AUTO_RESTART_PERIOD = SERVER_PREFIX + "autoRestartPeriod";

/**
* The constant STORE_DB_DATASOURCE_TYPE.
*/
Expand Down
5 changes: 5 additions & 0 deletions common/src/main/java/org/apache/seata/common/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,11 @@ public interface Constants {
*/
String AUTO_COMMIT = "autoCommit";

/**
* The constant AUTO_RESTART_SESSION
*/
String AUTO_RESTART_SESSION = "autoRestartSession";

/**
* The constant SKIP_CHECK_LOCK
*/
Expand Down
10 changes: 10 additions & 0 deletions common/src/main/java/org/apache/seata/common/DefaultValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -501,4 +501,14 @@ public interface DefaultValues {
* The constant DEFAULT_RAFT_SSL_ENABLED.
*/
boolean DEFAULT_RAFT_SSL_ENABLED = false;

/**
* The constant DEFAULT_AUTO_RESTART_TIME
*/
long DEFAULT_AUTO_RESTART_TIME = 24 * 60 * 60 * 1000;

/**
* The constant DEFAULT_AUTO_RESTART_PERIOD
*/
long DEFAULT_AUTO_RESTART_PERIOD = 60 * 60 * 1000;
}
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 = "400";


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
10 changes: 10 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,14 @@ const enUs: ILocale = {
showBranchSessionTitle: 'View branch session',
showGlobalLockTitle: 'View global lock',
branchSessionDialogTitle: 'Branch session info',
deleteGlobalSessionTitle: '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',
stopBranchSessionTitle: 'Stop branch session retry',
startBranchSessionTitle: 'Start branch session retry',
},
GlobalLockInfo: {
title: 'GlobalLockInfo',
Expand All @@ -69,6 +77,8 @@ const enUs: ILocale = {
inputFilterPlaceholder: 'Please enter filter criteria',
resetButtonLabel: 'Reset',
searchButtonLabel: 'Search',
operateTitle: 'operate',
deleteGlobalLockTitle: 'Delete global lock',
},
};

Expand Down
10 changes: 10 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,14 @@ const zhCn: ILocale = {
showBranchSessionTitle: '查看分支信息',
showGlobalLockTitle: '查看全局锁',
branchSessionDialogTitle: '分支事务信息',
deleteGlobalSessionTitle: '删除全局事务',
stopGlobalSessionTitle: '停止全局事务重试',
startGlobalSessionTitle: '开启全局事务重试',
sendGlobalSessionTitle: '提交或回滚全局事务',
changeGlobalSessionTitle: '更新全局事务状态',
deleteBranchSessionTitle: '删除分支事务',
stopBranchSessionTitle: '停止分支事务重启',
startBranchSessionTitle: '开启分支事务重试',
},
GlobalLockInfo: {
title: '全局锁信息',
Expand All @@ -69,6 +77,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