Skip to content

Commit

Permalink
Merge pull request #192 from cdmaji/refactor_feature_fix_nacostozk
Browse files Browse the repository at this point in the history
解决nacos->zk时非正常下线server导致的问题
  • Loading branch information
paderlol authored Dec 18, 2020
2 parents ba7be8f + 637cbbe commit fa11559
Show file tree
Hide file tree
Showing 24 changed files with 1,150 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class AddSyncDialog extends React.Component {
visible: false,
destClusterId: '',
groupName: '',
nameSpace: '',
serviceName: '',
sourceClusterId: '',
version: '',
Expand All @@ -31,8 +32,8 @@ class AddSyncDialog extends React.Component {
}

save() {
const { destClusterId, groupName, serviceName, sourceClusterId, version } = this.state;
add({ destClusterId, groupName, serviceName, sourceClusterId, version })
const { destClusterId, groupName, nameSpace, serviceName, sourceClusterId, version } = this.state;
add({ destClusterId, groupName, nameSpace, serviceName, sourceClusterId, version })
.then(() => {
this.props.turnPage(1);
this.close();
Expand Down Expand Up @@ -75,6 +76,11 @@ class AddSyncDialog extends React.Component {
placeholder={locale.groupNamePlaceholder}
onChange={groupName => this.setState({ groupName })}
/>
</FormItem> <FormItem label={`${locale.nameSpace}:`}>
<Input
placeholder={locale.nameSpacePlaceholder}
onChange={nameSpace => this.setState({ nameSpace })}
/>
</FormItem>
{
sourceCluster.clusterType === 'ZK' && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class ServiceSync extends React.Component {
<Table dataSource={taskModels} loading={loading}>
<Table.Column title={locale.serviceName} dataIndex="serviceName" />
<Table.Column title={locale.groupName} dataIndex="groupName" />
<Table.Column title={locale.nameSpace} dataIndex="nameSpace" />
<Table.Column
title={locale.sourceCluster}
dataIndex="sourceClusterId"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const I18N_CONF = {
addSync: 'New Sync',
serviceName: 'Service Name',
groupName: 'Group',
nameSpace: 'Namespace',
sourceCluster: 'Source Cluster',
destCluster: 'Dest Cluster',
instancesCount: 'Instances Count',
Expand All @@ -60,6 +61,8 @@ const I18N_CONF = {
serviceNamePlaceholder: 'Please enter service name',
groupName: 'Group Name',
groupNamePlaceholder: 'Please enter group name',
nameSpace: 'Namespace',
nameSpacePlaceholder: 'Please enter namespace',
sourceCluster: 'Source Cluster',
destCluster: 'Dest Cluster',
version: 'Version',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const I18N_CONF = {
addSync: '新增同步',
serviceName: '服务名',
groupName: '分组',
nameSpace: '命名空间',
sourceCluster: '源集群',
destCluster: '目标集群',
instancesCount: '实例数',
Expand All @@ -60,6 +61,8 @@ const I18N_CONF = {
serviceNamePlaceholder: '请输入服务名',
groupName: '分组名',
groupNamePlaceholder: '请输入分组名',
nameSpace: '命名空间',
nameSpacePlaceholder: '请输入命名空间',
sourceCluster: '源集群',
destCluster: '目标集群',
version: '版本',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.alibaba.nacossync.constant;

/**
* Created by maj on 2020/11/18.
*/
public enum ShardingLogTypeEnum {

ADD("add", "新增"),

DELETE("DELETE", "删除");

private String type;
private String desc;

ShardingLogTypeEnum(String type, String desc) {
this.type = type;
this.desc = desc;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}

public String getDesc() {
return desc;
}

public void setDesc(String desc) {
this.desc = desc;
}

public static boolean contains(String type) {

for (ShardingLogTypeEnum shardingLogTypeEnum : ShardingLogTypeEnum.values()) {

if (shardingLogTypeEnum.getType().equals(type)) {
return true;
}
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@
*/
package com.alibaba.nacossync.extension;

import static com.alibaba.nacossync.util.SkyWalkerUtil.generateSyncKey;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacossync.cache.SkyWalkerCacheServices;
import com.alibaba.nacossync.constant.ClusterTypeEnum;
import com.alibaba.nacossync.extension.annotation.NacosSyncService;
import com.alibaba.nacossync.pojo.model.TaskDO;
import java.util.concurrent.ConcurrentHashMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

import java.util.concurrent.ConcurrentHashMap;

import static com.alibaba.nacossync.util.SkyWalkerUtil.generateSyncKey;

/**
* @author NacosSync
* @version $Id: SyncManagerService.java, v 0.1 2018-09-25 PM5:17 NacosSync Exp $$
Expand All @@ -42,20 +43,17 @@ public class SyncManagerService implements InitializingBean, ApplicationContextA
private ApplicationContext applicationContext;

public SyncManagerService(
SkyWalkerCacheServices skyWalkerCacheServices) {
SkyWalkerCacheServices skyWalkerCacheServices) {
this.skyWalkerCacheServices = skyWalkerCacheServices;
}

public boolean delete(TaskDO taskDO) throws NacosException {

return getSyncService(taskDO.getSourceClusterId(), taskDO.getDestClusterId()).delete(taskDO);

}

public boolean sync(TaskDO taskDO) {

return getSyncService(taskDO.getSourceClusterId(), taskDO.getDestClusterId()).sync(taskDO);

}

@Override
Expand All @@ -80,5 +78,4 @@ public SyncService getSyncService(String sourceClusterId, String destClusterId)

return syncServiceMap.get(generateSyncKey(sourceClusterType, destClusterType));
}

}
Loading

0 comments on commit fa11559

Please sign in to comment.