You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "funky-eyes (via GitHub)" <gi...@apache.org> on 2025/12/19 10:16:02 UTC
[PR] [WIP]feature: console supports creation and modification of transaction groups for Raft clusters [incubator-seata]
funky-eyes opened a new pull request, #7878:
URL: https://github.com/apache/incubator-seata/pull/7878
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Please make sure you have read and understood the contributing guidelines -->
- [ ] I have read the [CONTRIBUTING.md](https://github.com/apache/incubator-seata/blob/2.x/CONTRIBUTING.md) guidelines.
- [ ] I have registered the PR [changes](https://github.com/apache/incubator-seata/tree/2.x/changes).
### Ⅰ. Describe what this PR did
raft cluster:
<img width="2388" height="1114" alt="image" src="https://github.com/user-attachments/assets/349b2d87-dec1-4735-805c-8b44399322b1" />
other cluster:
<img width="2574" height="1028" alt="image" src="https://github.com/user-attachments/assets/74678279-2fea-45ce-af7b-78935b74a097" />
change vgroup
other cluster -> raft cluster
<img width="2838" height="1080" alt="image" src="https://github.com/user-attachments/assets/b6a6d52d-13d1-42a4-8cbf-43be36d62c77" />
raft cluster -> other cluster
<img width="2940" height="1054" alt="image" src="https://github.com/user-attachments/assets/cb1fd8bf-8900-40a9-8951-51b4989e6556" />
### Ⅱ. Does this pull request fix one issue?
<!-- If that, add "fixes #xxx" below in the next line, for example, fixes #97. -->
### Ⅲ. Why don't you add test cases (unit test/integration test)?
### Ⅳ. Describe how to verify it
### Ⅴ. Special notes for reviews
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] [WIP]feature: console supports creation and modification of transaction groups for Raft clusters [incubator-seata]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7878:
URL: https://github.com/apache/incubator-seata/pull/7878#discussion_r2637802265
##########
namingserver/src/main/java/org/apache/seata/namingserver/manager/NamingManager.java:
##########
@@ -182,6 +167,25 @@ public Result<String> createGroup(String namespace, String vGroup, String cluste
public Result<String> createGroup(
String namespace, String vGroup, String clusterName, String unitName, boolean checkExist) {
+ // If unitName is blank, find it from cluster
+ String actualUnitName = unitName;
+ if (StringUtils.isBlank(unitName)) {
+ Map<String, ClusterData> clusterDataMap = namespaceClusterDataMap.get(namespace);
+ if (clusterDataMap != null) {
+ ClusterData clusterData = clusterDataMap.get(clusterName);
+ if (clusterData != null && !CollectionUtils.isEmpty(clusterData.getUnitData())) {
+ Optional<Map.Entry<String, Unit>> optionalEntry =
+ clusterData.getUnitData().entrySet().stream().findFirst();
+ if (optionalEntry.isPresent()) {
+ actualUnitName = optionalEntry.get().getKey();
Review Comment:
The logic for finding a unit when unitName is blank selects the first available unit using stream().findFirst(). This is non-deterministic behavior since the order of entries in a HashMap/ConcurrentHashMap is not guaranteed. For better predictability and stability, consider using a LinkedHashMap or sorting the entries before selecting one, or document that the selection is arbitrary.
```suggestion
Optional<String> optionalUnitName =
clusterData.getUnitData().keySet().stream().sorted().findFirst();
if (optionalUnitName.isPresent()) {
actualUnitName = optionalUnitName.get();
```
##########
console/src/main/resources/static/console-fe/src/pages/TransactionInfo/TransactionInfo.tsx:
##########
@@ -545,7 +564,7 @@ class TransactionInfo extends React.Component<GlobalProps, TransactionInfoState>
startGlobalSessionTitle,
sendGlobalSessionTitle,
changeGlobalSessionTitle,
- } = locale;
+ } = locale.TransactionInfo || {};
Review Comment:
The code uses optional chaining and assumes locale is always defined due to the Redux connection, but in lines 567 and 758, it accesses locale.TransactionInfo without checking if locale exists. While this is likely safe with the Redux setup, defensive coding would suggest adding a fallback (e.g., locale?.TransactionInfo || {}) to prevent potential runtime errors if the Redux state is not properly initialized.
```suggestion
} = locale?.TransactionInfo || {};
```
##########
console/src/main/resources/static/console-fe/src/pages/TransactionInfo/TransactionInfo.tsx:
##########
@@ -1290,7 +1364,9 @@ class TransactionInfo extends React.Component<GlobalProps, TransactionInfoState>
return {
targetNamespace: value,
targetClusters: clusters,
- targetCluster: clusters.length > 0 ? clusters[0] : '',
+ targetCluster: '',
+ targetUnits: [],
+ targetUnit: '',
};
Review Comment:
When targetNamespace is changed, targetCluster is reset to an empty string (line 1367), but the logic doesn't select a default cluster like it does for createNamespace (where createCluster is set to clusters[0]). This inconsistency could lead to user confusion where one dialog pre-selects a cluster and the other doesn't. Consider setting targetCluster to clusters[0] when clusters.length > 0 for a consistent user experience.
##########
console/src/main/resources/static/console-fe/src/pages/TransactionInfo/TransactionInfo.tsx:
##########
@@ -351,14 +356,26 @@ class TransactionInfo extends React.Component<GlobalProps, TransactionInfoState>
loadNamespaces = async () => {
try {
const namespaces = await fetchNamespaceV2();
- const namespaceOptions = new Map<string, { clusters: string[], clusterVgroups: {[key: string]: string[]} }>();
+ const namespaceOptions = new Map<string, NamespaceData>();
+
Object.keys(namespaces).forEach(namespaceKey => {
const namespaceData = namespaces[namespaceKey];
- const clusterVgroups = (namespaceData.clusterVgroups || {}) as {[key: string]: string[]};
- const clusters = Object.keys(clusterVgroups);
+ const clustersData = namespaceData.clusters || {};
+ const clusterVgroups: {[key: string]: string[]} = {};
+ const clusterUnits: {[key: string]: string[]} = {};
+ const clusterTypes: {[key: string]: string} = {};
+ Object.keys(clustersData).forEach(clusterName => {
+ const cluster = clustersData[clusterName];
+ clusterVgroups[clusterName] = cluster.vgroups || [];
+ clusterUnits[clusterName] = cluster.units || [];
+ clusterTypes[clusterName] = cluster.type || 'default';
+ });
+ const clusters = Object.keys(clustersData);
namespaceOptions.set(namespaceKey, {
clusters,
clusterVgroups,
+ clusterUnits,
+ clusterTypes,
});
Review Comment:
The namespace data processing logic is duplicated across three components (TransactionInfo, GlobalLockInfo, and ClusterManager). All three have nearly identical code for parsing namespaces, extracting cluster data, and building the namespaceOptions Map. This logic should be extracted into a shared utility function to improve maintainability and ensure consistency.
##########
namingserver/src/main/java/org/apache/seata/namingserver/manager/NamingManager.java:
##########
@@ -474,6 +478,11 @@ public void instanceHeartBeatCheck() {
public Result<String> changeGroup(String namespace, String vGroup, String clusterName, String unitName) {
long changeTime = System.currentTimeMillis();
ConcurrentMap<String, NamespaceBO> namespaceMap = new ConcurrentHashMap<>(vGroupMap.get(vGroup));
+ Result<String> res = createGroup(namespace, vGroup, clusterName, unitName, false);
+ if (!res.isSuccess()) {
+ LOGGER.error("add vgroup failed! {}", res.getMessage());
+ return res;
+ }
Review Comment:
The order of operations in changeGroup has been reversed - createGroup is now called before collecting existing namespace/cluster mappings. While this change may be intentional to ensure the new group exists before removing the old one, it could lead to a partial state if the subsequent removeGroup operations fail. Consider adding compensating logic or documentation explaining why this order is necessary and how failures are handled.
##########
console/src/main/resources/static/console-fe/src/service/clusterManager.ts:
##########
@@ -31,3 +32,11 @@ export async function fetchClusterData(namespace: string, clusterName: string):
});
return result;
}
+
+export async function changeGroup(namespace: string, clusterName: string, vGroup: string, unitName: string = ''): Promise<any> {
+ const params = { namespace, clusterName, unitName, vGroup };
+ const result = await request.post('/naming/changeGroup', qs.stringify(params), {
+ headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
+ });
+ return result;
+}
Review Comment:
This function is duplicated with the same implementation in transactionInfo.ts (lines 260-266). Consider extracting this common function to a shared location to avoid code duplication and ensure consistency across the codebase.
```suggestion
export async function postChangeGroup(
namespace: string,
clusterName: string,
vGroup: string,
unitName: string = '',
): Promise<any> {
const params = { namespace, clusterName, unitName, vGroup };
const result = await request.post('/naming/changeGroup', qs.stringify(params), {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
return result;
}
export async function changeGroup(namespace: string, clusterName: string, vGroup: string, unitName: string = ''): Promise<any> {
return postChangeGroup(namespace, clusterName, vGroup, unitName);
}
```
##########
console/src/main/resources/static/console-fe/src/pages/TransactionInfo/TransactionInfo.tsx:
##########
@@ -18,11 +18,11 @@ import React from 'react';
import { ConfigProvider, Table, Button, DatePicker, Form, Icon, Switch, Pagination, Dialog, Input, Select, Message } from '@alicloud/console-components';
import Actions, { LinkButton } from '@alicloud/console-components-actions';
import { withRouter } from 'react-router-dom';
+import { connect } from 'react-redux';
import Page from '@/components/Page';
import { GlobalProps } from '@/module';
import getData, { changeGlobalData, deleteBranchData, deleteGlobalData, GlobalSessionParam, sendGlobalCommitOrRollback,
startBranchData, startGlobalData, stopBranchData, stopGlobalData, forceDeleteGlobalData, forceDeleteBranchData, fetchNamespaceV2, addGroup, changeGroup } from '@/service/transactionInfo';
-import PropTypes from 'prop-types';
import moment from 'moment';
Review Comment:
The PropTypes import and static propTypes declaration have been removed but the import is still present in ClusterManager.tsx, GlobalLockInfo.tsx, and Login.tsx. This creates an inconsistency across the codebase. Either remove PropTypes from all components or keep it in all for consistency, especially since TypeScript provides static type checking through the GlobalProps interface.
##########
namingserver/src/main/java/org/apache/seata/namingserver/manager/NamingManager.java:
##########
@@ -587,14 +623,23 @@ private NamespaceData collectNamespaceData() {
Set<String> vgroups = vgroupsMap.get(namespace);
vgroups.add(vGroup);
- // Build cluster to vgroups
+ // Build cluster to vgroups and unit to vgroups mapping
Map<String, Set<String>> clusterVg = clusterVgroupsMap.get(namespace);
+ Map<String, Map<String, Set<String>>> clusterUnitVg = unitVgroupsMap.get(namespace);
+
namespaceBO.getClusterMap().forEach((clusterName, clusterBO) -> {
Set<String> vgSet = clusterVg.computeIfAbsent(clusterName, k -> new HashSet<>());
vgSet.add(vGroup);
+
+ // For each unit in this cluster, add the vgroup
+ Map<String, Set<String>> unitVgMap = clusterUnitVg.computeIfAbsent(clusterName, k -> new HashMap<>());
+ clusterBO.getUnitNames().forEach(unitName -> {
+ Set<String> unitVgSet = unitVgMap.computeIfAbsent(unitName, k -> new HashSet<>());
+ unitVgSet.add(vGroup);
+ });
Review Comment:
The unitVgroupsMap is being collected and passed to NamespaceData constructor but appears to be unused in the namespaceV2() method. The method only uses clustersMap, vgroupsMap, and clusterVgroupsMap when building the response. If unitVgroupsMap is intended for future use or a different API endpoint, consider documenting this or removing it if it's truly unused to avoid confusion.
##########
console/src/main/resources/static/console-fe/src/reducers/locale.ts:
##########
@@ -52,7 +52,7 @@ const getCurrentLanguage = (): string => {
return lang;
}
-const getCurrentLocaleObj = (): any => {
+const getCurrentLocaleObj = (): ILocale => {
Review Comment:
The return type has been weakened from ILocale to any, which removes type safety for locale objects throughout the application. This change should be avoided to maintain type checking. Consider updating the return type to match the actual locale structure being used.
##########
console/src/main/resources/static/console-fe/src/pages/ClusterManager/ClusterManager.tsx:
##########
@@ -215,11 +224,13 @@ class ClusterManager extends React.Component<GlobalProps, ClusterManagerState> {
};
render() {
- const { locale = {} } = this.props;
+ const { locale } = this.props;
const rawLocale = locale.ClusterManager;
const clusterManagerLocale: ClusterManagerLocale = typeof rawLocale === 'object' && rawLocale !== null ? rawLocale : {};
- const { title, subTitle, selectNamespaceFilerPlaceholder, selectClusterFilerPlaceholder, searchButtonLabel, unitName, members, clusterType, view, unitDialogTitle, control, transaction, weight, healthy, term, unit, operations, internal, version, metadata, controlEndpoint, transactionEndpoint, metadataDialogTitle } = clusterManagerLocale;
+ const { title, subTitle, selectNamespaceFilerPlaceholder, selectClusterFilerPlaceholder, searchButtonLabel, unitName, members, clusterType, view, unitDialogTitle, control, transaction, weight, healthy, term, unit, operations, internal, version, metadata, controlEndpoint, transactionEndpoint, metadataDialogTitle, role } = clusterManagerLocale;
Review Comment:
Unused variable unitName.
```suggestion
const { title, subTitle, selectNamespaceFilerPlaceholder, selectClusterFilerPlaceholder, searchButtonLabel, members, clusterType, view, unitDialogTitle, control, transaction, weight, healthy, term, unit, operations, internal, version, metadata, controlEndpoint, transactionEndpoint, metadataDialogTitle, role } = clusterManagerLocale;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] [WIP]feature: console supports creation and modification of transaction groups for Raft clusters [incubator-seata]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7878:
URL: https://github.com/apache/incubator-seata/pull/7878#discussion_r2637776176
##########
namingserver/src/main/java/org/apache/seata/namingserver/manager/NamingManager.java:
##########
@@ -182,6 +167,21 @@ public Result<String> createGroup(String namespace, String vGroup, String cluste
public Result<String> createGroup(
String namespace, String vGroup, String clusterName, String unitName, boolean checkExist) {
+ // If unitName is blank, find it from cluster
+ String actualUnitName = unitName;
+ if (StringUtils.isBlank(unitName)) {
+ Map<String, ClusterData> clusterDataMap = namespaceClusterDataMap.get(namespace);
+ if (clusterDataMap != null) {
+ ClusterData clusterData = clusterDataMap.get(clusterName);
+ if (clusterData != null && !CollectionUtils.isEmpty(clusterData.getUnitData())) {
+ Optional<Map.Entry<String, Unit>> optionalEntry =
+ clusterData.getUnitData().entrySet().stream().findFirst();
+ if (optionalEntry.isPresent()) {
+ actualUnitName = optionalEntry.get().getKey();
+ }
+ }
+ }
+ }
Review Comment:
When unitName is blank and the cluster has no units available, actualUnitName remains blank. This could cause issues when calling the HTTP endpoint if the backend expects a non-empty unit parameter. Consider adding a check to return an error result when actualUnitName is still blank after the fallback logic, or handle this case explicitly.
```suggestion
}
if (StringUtils.isBlank(actualUnitName)) {
LOGGER.error("no available unit for namespace {} and cluster {}", namespace, clusterName);
return new Result<>("400", "no available unit for cluster: " + clusterName);
}
```
##########
console/src/main/resources/static/console-fe/src/reducers/locale.ts:
##########
@@ -25,7 +25,7 @@ const zhCN = Object.assign({}, fusionZhCN, I18N.zhCN);
interface LocaleStateModel {
language: string;
- locale: ILocale;
+ locale: any;
Review Comment:
Changing locale type from ILocale to any weakens type safety. This removes compile-time checks and autocomplete support for locale properties. Consider creating a proper interface or type definition for the locale structure instead of using any.
##########
console/src/main/resources/static/console-fe/src/service/clusterManager.ts:
##########
@@ -31,3 +31,9 @@ export async function fetchClusterData(namespace: string, clusterName: string):
});
return result;
}
+
+export async function changeGroup(namespace: string, clusterName: string, vGroup: string): Promise<any> {
+ const params: any = { namespace, clusterName, vGroup };
+ const result = await request.post('/naming/changeGroup', params);
+ return result;
Review Comment:
The changeGroup function in clusterManager.ts doesn't include headers with Content-Type for form-urlencoded data like addGroup does. The backend expects form-urlencoded data based on the transactionInfo.ts implementation. This inconsistency may cause the request to fail or behave unexpectedly. Ensure the changeGroup function uses the same format as addGroup with qs.stringify and appropriate headers.
##########
namingserver/src/main/java/org/apache/seata/namingserver/manager/NamingManager.java:
##########
@@ -474,6 +474,11 @@ public void instanceHeartBeatCheck() {
public Result<String> changeGroup(String namespace, String vGroup, String clusterName, String unitName) {
long changeTime = System.currentTimeMillis();
ConcurrentMap<String, NamespaceBO> namespaceMap = new ConcurrentHashMap<>(vGroupMap.get(vGroup));
+ Result<String> res = createGroup(namespace, vGroup, clusterName, unitName, false);
+ if (!res.isSuccess()) {
+ LOGGER.error("add vgroup failed!" + res.getMessage());
Review Comment:
The error log message concatenates the result message without proper spacing. Consider using string formatting or adding a space between "add vgroup failed!" and the message to improve log readability.
```suggestion
LOGGER.error("add vgroup failed! {}", res.getMessage());
```
##########
namingserver/src/main/java/org/apache/seata/namingserver/manager/NamingManager.java:
##########
@@ -539,17 +540,50 @@ public SingleResult<Map<String, org.apache.seata.namingserver.entity.vo.v2.Names
// Build NamespaceVOv2
Map<String, org.apache.seata.namingserver.entity.vo.v2.NamespaceVO> namespaceVOs = new HashMap<>();
- data.clustersMap.forEach((namespace, clusters) -> {
+ data.getClustersMap().forEach((namespace, clusters) -> {
org.apache.seata.namingserver.entity.vo.v2.NamespaceVO namespaceVO =
new org.apache.seata.namingserver.entity.vo.v2.NamespaceVO();
- Map<String, List<String>> clusterVgList = new HashMap<>();
- Map<String, Set<String>> clusterVgSet = data.clusterVgroupsMap.get(namespace);
+ Map<String, org.apache.seata.namingserver.entity.vo.v2.ClusterVO> clusterVOMap = new HashMap<>();
+
clusters.forEach(cluster -> {
- Set<String> vgSet = clusterVgSet.get(cluster);
- clusterVgList.put(cluster, vgSet != null ? new ArrayList<>(vgSet) : new ArrayList<>());
+ org.apache.seata.namingserver.entity.vo.v2.ClusterVO clusterVO =
+ new org.apache.seata.namingserver.entity.vo.v2.ClusterVO();
+
+ // Set units and type for this cluster
+ Map<String, ClusterData> clusterDataMap = namespaceClusterDataMap.get(namespace);
+ String clusterType = "default";
+ List<String> unitNames = new ArrayList<>();
+ if (clusterDataMap != null) {
+ ClusterData clusterData = clusterDataMap.get(cluster);
+ if (clusterData != null) {
+ unitNames = clusterData.getUnitData().values().stream()
+ .map(Unit::getUnitName)
+ .collect(Collectors.toList());
+ clusterType = clusterData.getClusterType();
+ clusterVO.setType(clusterType);
+ }
+ }
+ clusterVO.setUnits(unitNames);
+
+ // Set vgroups based on cluster type
+ if ("RAFT".equalsIgnoreCase(clusterType)) {
+ // For RAFT clusters, collect all unique vgroups
+ Map<String, Set<String>> clusterVgSet =
+ data.getClusterVgroupsMap().get(namespace);
+ Set<String> vgSet = clusterVgSet.get(cluster);
+ clusterVO.setVgroups(vgSet != null ? new ArrayList<>(vgSet) : new ArrayList<>());
+ } else {
+ // For non-RAFT clusters, set vgroups directly
+ Map<String, Set<String>> clusterVgSet =
+ data.getClusterVgroupsMap().get(namespace);
+ Set<String> vgSet = clusterVgSet.get(cluster);
+ clusterVO.setVgroups(vgSet != null ? new ArrayList<>(vgSet) : new ArrayList<>());
+ }
Review Comment:
The if-else branches for RAFT and non-RAFT clusters contain identical logic. Both branches retrieve vgroups from the clusterVgroupsMap and set them on the ClusterVO. Consider removing the duplicate logic and consolidating into a single code block since there's no actual difference in behavior between the cluster types here.
```suggestion
// Set vgroups (same logic for all cluster types)
Map<String, Set<String>> clusterVgSet = data.getClusterVgroupsMap().get(namespace);
Set<String> vgSet = clusterVgSet != null ? clusterVgSet.get(cluster) : null;
clusterVO.setVgroups(vgSet != null ? new ArrayList<>(vgSet) : new ArrayList<>());
```
##########
namingserver/src/main/java/org/apache/seata/namingserver/entity/vo/v2/ClusterVO.java:
##########
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.seata.namingserver.entity.vo.v2;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Value Object representing cluster information for the v2 API.
+ * <p>
+ * This class encapsulates the information for a single cluster, including
+ * its associated vgroups, units, and cluster type.
+ */
+public class ClusterVO {
+
+ private List<String> vgroups = new ArrayList<>();
+
+ private Map<String, List<String>> unitVgroups = new HashMap<>();
Review Comment:
The ClusterVO has a unitVgroups field (Map<String, List<String>>) that is initialized but never populated or used. This field should either be populated with the unit-to-vgroups mapping data or removed if not needed.
##########
namingserver/src/main/java/org/apache/seata/namingserver/manager/NamingManager.java:
##########
@@ -515,17 +516,17 @@ public SingleResult<Map<String, NamespaceVO>> namespace() {
NamespaceData data = collectNamespaceData();
Map<String, NamespaceVO> namespaceVOs = new HashMap<>();
- if (data.vgroupsMap.isEmpty()) {
- data.clustersMap.forEach((namespace, clusters) -> {
+ if (data.getVgroupsMap().isEmpty()) {
+ data.getClustersMap().forEach((namespace, clusters) -> {
NamespaceVO namespaceVO = new NamespaceVO();
namespaceVO.setClusters(new ArrayList<>(clusters));
namespaceVOs.put(namespace, namespaceVO);
});
} else {
- data.vgroupsMap.forEach((namespace, vgroups) -> {
+ data.getVgroupsMap().forEach((namespace, vgroups) -> {
NamespaceVO namespaceVO = namespaceVOs.computeIfAbsent(namespace, k -> new NamespaceVO());
- Set<String> clusters = data.clustersMap.get(namespace);
- namespaceVO.setClusters(new ArrayList<>(clusters != null ? clusters : Collections.emptyList()));
+ Set<String> clusters = data.getClustersMap().get(namespace);
+ namespaceVO.setClusters(new ArrayList<>(clusters != null ? clusters : Collections.<String>emptyList()));
Review Comment:
Using explicit type parameter Collections.<String>emptyList() is unnecessary in Java 8+. The type can be inferred as Collections.emptyList() since the context already provides the type information from the ArrayList constructor.
```suggestion
namespaceVO.setClusters(new ArrayList<>(clusters != null ? clusters : Collections.emptyList()));
```
##########
console/src/main/resources/static/console-fe/src/service/transactionInfo.ts:
##########
@@ -248,28 +249,18 @@ export async function startBranchData(params: BranchSessionParam): Promise<any>
return result;
}
-export async function addGroup(namespace: string, clusterName: string, vGroup: string, unitName?: string): Promise<any> {
- let result = await request('/naming/addGroup', {
- method: 'POST',
- params: {
- namespace,
- clusterName,
- vGroup,
- unitName,
- },
+export async function addGroup(namespace: string, clusterName: string, vGroup: string, unitName: string = ''): Promise<any> {
Review Comment:
The function signature has changed from optional unitName parameter (unitName?: string) to required with default empty string (unitName: string = ''). However, the changeGroup function in clusterManager.ts doesn't pass a unitName parameter at all. This will result in the default empty string being used, which may not be the intended behavior for RAFT clusters. Consider ensuring all call sites pass the appropriate unitName when needed.
##########
console/src/main/resources/static/console-fe/src/pages/TransactionInfo/TransactionInfo.tsx:
##########
@@ -1303,14 +1371,36 @@ class TransactionInfo extends React.Component<GlobalProps, TransactionInfoState>
hasClear
placeholder={selectTargetClusterPlaceholder}
onChange={(value: string) => {
- this.setState({ targetCluster: value });
+ this.setState(prevState => {
+ const namespaceData = prevState.namespaceOptions.get(prevState.targetNamespace);
+ const clusterUnits = namespaceData ? namespaceData.clusterUnits : {};
+ const units = clusterUnits[value] || [];
+ return {
+ targetCluster: value,
+ targetUnits: units,
+ targetUnit: units.length > 0 ? units[0] : '',
+ };
+ });
}}
dataSource={this.state.targetClusters.map(value => ({ label: value, value }))}
value={this.state.targetCluster}
/>
</FormItem>
+ {this.state.targetCluster && this.state.namespaceOptions.get(this.state.targetNamespace)?.clusterTypes[this.state.targetCluster] !== 'default' && (
+ <FormItem name="targetUnit" label="targetUnit">
+ <Select
+ hasClear
+ placeholder="Select target unit"
+ onChange={(value: string) => {
+ this.setState({ targetUnit: value });
+ }}
+ dataSource={this.state.targetUnits.map(value => ({ label: value, value }))}
+ value={this.state.targetUnit}
+ />
+ </FormItem>
+ )}
<FormItem>
- <Button type="primary" onClick={this.handleChangeVGroup} disabled={!this.state.selectedVGroup || !this.state.targetNamespace || !this.state.targetCluster}>
+ <Button type="primary" onClick={this.handleChangeVGroup} disabled={!this.state.selectedVGroup || !this.state.targetNamespace || !this.state.targetCluster || (this.state.namespaceOptions.get(this.state.targetNamespace)?.clusterTypes[this.state.targetCluster] !== 'default' && !this.state.targetUnit)}>
Review Comment:
The button's disabled condition is complex and difficult to maintain. Consider extracting this logic into a computed variable or method with a descriptive name to improve readability and maintainability.
##########
console/src/main/resources/static/console-fe/src/pages/ClusterManager/ClusterManager.tsx:
##########
@@ -215,11 +223,14 @@ class ClusterManager extends React.Component<GlobalProps, ClusterManagerState> {
};
render() {
- const { locale = {} } = this.props;
+ const { locale } = this.props;
const rawLocale = locale.ClusterManager;
const clusterManagerLocale: ClusterManagerLocale = typeof rawLocale === 'object' && rawLocale !== null ? rawLocale : {};
const { title, subTitle, selectNamespaceFilerPlaceholder, selectClusterFilerPlaceholder, searchButtonLabel, unitName, members, clusterType, view, unitDialogTitle, control, transaction, weight, healthy, term, unit, operations, internal, version, metadata, controlEndpoint, transactionEndpoint, metadataDialogTitle } = clusterManagerLocale;
const unitData = this.state.clusterData ? Object.entries(this.state.clusterData.unitData || {}) : [];
+ const { namespace } = this.state;
+ const namespaceData = namespace ? this.state.namespaceOptions.get(namespace) : null;
+ const allClusters = namespaceData ? namespaceData.clusters : [];
Review Comment:
Unused variable allClusters.
```suggestion
```
##########
console/src/main/resources/static/console-fe/src/pages/TransactionInfo/TransactionInfo.tsx:
##########
@@ -1303,14 +1371,36 @@ class TransactionInfo extends React.Component<GlobalProps, TransactionInfoState>
hasClear
placeholder={selectTargetClusterPlaceholder}
onChange={(value: string) => {
- this.setState({ targetCluster: value });
+ this.setState(prevState => {
+ const namespaceData = prevState.namespaceOptions.get(prevState.targetNamespace);
+ const clusterUnits = namespaceData ? namespaceData.clusterUnits : {};
+ const units = clusterUnits[value] || [];
+ return {
+ targetCluster: value,
+ targetUnits: units,
+ targetUnit: units.length > 0 ? units[0] : '',
+ };
+ });
}}
dataSource={this.state.targetClusters.map(value => ({ label: value, value }))}
value={this.state.targetCluster}
/>
</FormItem>
+ {this.state.targetCluster && this.state.namespaceOptions.get(this.state.targetNamespace)?.clusterTypes[this.state.targetCluster] !== 'default' && (
+ <FormItem name="targetUnit" label="targetUnit">
+ <Select
+ hasClear
+ placeholder="Select target unit"
Review Comment:
The 'targetUnit' label should follow the same naming convention as other labels in the dialog. Consider using a more descriptive and user-friendly label like 'Target Unit' to match the pattern of other form labels.
```suggestion
<FormItem name="targetUnit" label="Target Unit">
<Select
hasClear
placeholder="Select Target Unit"
```
##########
console/src/main/resources/static/console-fe/src/pages/TransactionInfo/TransactionInfo.tsx:
##########
@@ -892,12 +911,19 @@ class TransactionInfo extends React.Component<GlobalProps, TransactionInfoState>
}
showCreateVGroupDialog = () => {
- this.setState(prevState => ({
- createVGroupDialogVisible: true,
- vGroupName: '',
- createNamespace: prevState.globalSessionParam.namespace || '',
- createCluster: prevState.globalSessionParam.cluster || '',
- }));
+ this.setState(prevState => {
+ const clusters = prevState.globalSessionParam.namespace ? prevState.namespaceOptions.get(prevState.globalSessionParam.namespace)?.clusters || [] : [];
Review Comment:
Unused variable clusters.
```suggestion
```
##########
namingserver/pom.xml:
##########
@@ -276,6 +276,14 @@
</execution>
</executions>
</plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>8</source>
+ <target>8</target>
+ </configuration>
+ </plugin>
Review Comment:
The maven-compiler-plugin configuration is redundant. The parent pom already defines this plugin with the same source/target configuration using properties maven.compiler.source and maven.compiler.target. This duplication should be removed to maintain consistency with the project-wide compiler settings defined in the parent pom.
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] [WIP]feature: console supports creation and modification of transaction groups for Raft clusters [incubator-seata]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #7878:
URL: https://github.com/apache/incubator-seata/pull/7878#issuecomment-3674558718
## [Codecov](https://app.codecov.io/gh/apache/incubator-seata/pull/7878?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 71.20%. Comparing base ([`8629d18`](https://app.codecov.io/gh/apache/incubator-seata/commit/8629d183d072508980bdf37c229cd8c12dddfdf6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`8ee5490`](https://app.codecov.io/gh/apache/incubator-seata/commit/8ee5490b038d2d690a1ad7bf21e2ace69aeaede0?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## 2.x #7878 +/- ##
============================================
+ Coverage 71.10% 71.20% +0.09%
Complexity 797 797
============================================
Files 1294 1294
Lines 49528 49528
Branches 5871 5871
============================================
+ Hits 35216 35264 +48
+ Misses 11403 11355 -48
Partials 2909 2909
```
[see 12 files with indirect coverage changes](https://app.codecov.io/gh/apache/incubator-seata/pull/7878/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
[](https://app.codecov.io/gh/apache/incubator-seata/pull/7878?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
</details>
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org
Re: [PR] feature: console supports creation and modification of transaction groups for Raft clusters [incubator-seata]
Posted by "funky-eyes (via GitHub)" <gi...@apache.org>.
funky-eyes merged PR #7878:
URL: https://github.com/apache/incubator-seata/pull/7878
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org