use of com.alibaba.nacos.core.cluster.Member in project nacos by alibaba.
the class ProtocolManager method injectMembers4CP.
private void injectMembers4CP(Config config) {
final Member selfMember = memberManager.getSelf();
final String self = selfMember.getIp() + ":" + Integer.parseInt(String.valueOf(selfMember.getExtendVal(MemberMetaDataConstants.RAFT_PORT)));
Set<String> others = toCPMembersInfo(memberManager.allMembers());
config.setMembers(self, others);
}
use of com.alibaba.nacos.core.cluster.Member in project nacos by alibaba.
the class RaftPeerSet method changePeers.
protected void changePeers(Collection<Member> members) {
Map<String, RaftPeer> tmpPeers = new HashMap<>(members.size());
for (Member member : members) {
final String address = member.getAddress();
if (peers.containsKey(address)) {
tmpPeers.put(address, peers.get(address));
continue;
}
RaftPeer raftPeer = new RaftPeer();
raftPeer.ip = address;
// first time meet the local server:
if (EnvUtil.getLocalAddress().equals(address)) {
raftPeer.term.set(localTerm.get());
}
tmpPeers.put(address, raftPeer);
}
// replace raft peer set:
peers = tmpPeers;
ready = true;
Loggers.RAFT.info("raft peers changed: " + members);
}
use of com.alibaba.nacos.core.cluster.Member in project nacos by alibaba.
the class OperatorController method getHealthyServerList.
/**
* This interface will be removed in a future release.
*
* @param healthy whether only query health server.
* @return "ok"
* @deprecated 1.3.0 This function will be deleted sometime after version 1.3.0
*/
@GetMapping("/servers")
public ObjectNode getHealthyServerList(@RequestParam(required = false) boolean healthy) {
ObjectNode result = JacksonUtils.createEmptyJsonNode();
if (healthy) {
List<Member> healthyMember = memberManager.allMembers().stream().filter(member -> member.getState() == NodeState.UP).collect(ArrayList::new, ArrayList::add, ArrayList::addAll);
result.replace("servers", JacksonUtils.transferToJsonNode(healthyMember));
} else {
result.replace("servers", JacksonUtils.transferToJsonNode(memberManager.allMembers()));
}
return result;
}
Aggregations