fix: fix member remove

This commit is contained in:
chuntaojun 2020-05-14 19:55:47 +08:00
commit a37d6afe35
7 changed files with 310 additions and 47 deletions

View File

@ -25,6 +25,7 @@ class EditInstanceDialog extends React.Component {
static propTypes = {
serviceName: PropTypes.string,
clusterName: PropTypes.string,
groupName: PropTypes.string,
openLoading: PropTypes.string,
closeLoading: PropTypes.string,
getInstanceList: PropTypes.func,
@ -54,7 +55,14 @@ class EditInstanceDialog extends React.Component {
}
onConfirm() {
const { serviceName, clusterName, getInstanceList, openLoading, closeLoading } = this.props;
const {
serviceName,
clusterName,
groupName,
getInstanceList,
openLoading,
closeLoading,
} = this.props;
const { ip, port, ephemeral, weight, enabled, metadataText } = this.state.editInstance;
request({
method: 'PUT',
@ -62,6 +70,7 @@ class EditInstanceDialog extends React.Component {
data: {
serviceName,
clusterName,
groupName,
ip,
port,
ephemeral,

View File

@ -78,13 +78,14 @@ class InstanceTable extends React.Component {
switchState(index, record) {
const { instance } = this.state;
const { ip, port, ephemeral, weight, enabled, metadata } = record;
const { clusterName, serviceName } = this.props;
const { clusterName, serviceName, groupName } = this.props;
request({
method: 'PUT',
url: 'v1/ns/instance',
data: {
serviceName,
clusterName,
groupName,
ip,
port,
ephemeral,
@ -112,7 +113,7 @@ class InstanceTable extends React.Component {
render() {
const { locale = {} } = this.props;
const { clusterName, serviceName } = this.props;
const { clusterName, serviceName, groupName } = this.props;
const { instance, pageSize, loading } = this.state;
return instance.count ? (
<div>
@ -178,6 +179,7 @@ class InstanceTable extends React.Component {
ref={this.editInstanceDialog}
serviceName={serviceName}
clusterName={clusterName}
groupName={groupName}
openLoading={() => this.openLoading()}
closeLoading={() => this.closeLoading()}
getInstanceList={() => this.getInstanceList()}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -269,7 +269,7 @@ public class ServerMemberManager
.warn("[serverlist] self ip {} not in serverlist {}", self, members);
}
boolean hasChange = false;
boolean hasChange = members.size() == serverList.size();
ConcurrentSkipListMap<String, Member> tmpMap = new ConcurrentSkipListMap();
Set<String> tmpAddressInfo = new ConcurrentHashSet<>();
for (Member member : members) {

View File

@ -62,7 +62,7 @@ public class CoreOpsController {
@GetMapping(value = "/idInfo")
public RestResult<Map<String, Map<Object, Object>>> idInfo() {
Map<String, Map<Object, Object>> info = new HashMap<>(8);
Map<String, Map<Object, Object>> info = new HashMap<>(10);
idGeneratorManager.getGeneratorMap()
.forEach(
(resource, idGenerator) -> info.put(resource, idGenerator.info()));

View File

@ -514,8 +514,8 @@ public class JRaftServer {
}
boolean peerChange(JRaftMaintainService maintainService, Set<String> newPeers) {
Set<String> oldPeers = this.raftConfig.getMembers();
oldPeers.remove(newPeers);
Set<String> oldPeers = new HashSet<>(this.raftConfig.getMembers());
oldPeers.removeAll(newPeers);
if (oldPeers.isEmpty()) {
return true;
@ -526,16 +526,14 @@ public class JRaftServer {
multiRaftGroup.forEach(new BiConsumer<String, RaftGroupTuple>() {
@Override
public void accept(String group, RaftGroupTuple tuple) {
final Node node = tuple.getNode();
if (!node.isLeader()) {
return;
}
Map<String, String> params = new HashMap<>();
params.put(JRaftConstants.GROUP_ID, group);
params.put(JRaftConstants.REMOVE_PEERS, Joiner.on(",").join(waitRemove));
RestResult<String> result = maintainService.execute(params);
if (result.ok()) {
successCnt.incrementAndGet();
} else {
Loggers.RAFT.error("Node removal failed : {}", result);
}
}
});