Remove some unused classes in pojo.
This commit is contained in:
parent
5c9c35ab22
commit
1fe89a31ec
@ -31,8 +31,6 @@ import com.alibaba.nacos.naming.consistency.RecordListener;
|
|||||||
import com.alibaba.nacos.naming.misc.Loggers;
|
import com.alibaba.nacos.naming.misc.Loggers;
|
||||||
import com.alibaba.nacos.naming.misc.SwitchDomain;
|
import com.alibaba.nacos.naming.misc.SwitchDomain;
|
||||||
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
import com.alibaba.nacos.naming.misc.UtilsAndCommons;
|
||||||
import com.alibaba.nacos.naming.pojo.InstanceOperationContext;
|
|
||||||
import com.alibaba.nacos.naming.pojo.InstanceOperationInfo;
|
|
||||||
import com.alibaba.nacos.naming.push.UdpPushService;
|
import com.alibaba.nacos.naming.push.UdpPushService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@ -49,7 +47,6 @@ import java.util.Set;
|
|||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.ConcurrentSkipListMap;
|
import java.util.concurrent.ConcurrentSkipListMap;
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.alibaba.nacos.naming.misc.UtilsAndCommons.UPDATE_INSTANCE_METADATA_ACTION_REMOVE;
|
import static com.alibaba.nacos.naming.misc.UtilsAndCommons.UPDATE_INSTANCE_METADATA_ACTION_REMOVE;
|
||||||
@ -520,59 +517,6 @@ public class ServiceManager implements RecordListener<Service> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* batch operate kinds of resources.
|
|
||||||
*
|
|
||||||
* @param namespace namespace.
|
|
||||||
* @param operationInfo operation resources description.
|
|
||||||
* @param operateFunction some operation defined by kinds of situation.
|
|
||||||
*/
|
|
||||||
public List<Instance> batchOperate(String namespace, InstanceOperationInfo operationInfo,
|
|
||||||
Function<InstanceOperationContext, List<Instance>> operateFunction) {
|
|
||||||
List<Instance> operatedInstances = new ArrayList<>();
|
|
||||||
try {
|
|
||||||
String serviceName = operationInfo.getServiceName();
|
|
||||||
NamingUtils.checkServiceNameFormat(serviceName);
|
|
||||||
// type: ephemeral/persist
|
|
||||||
InstanceOperationContext operationContext;
|
|
||||||
String type = operationInfo.getConsistencyType();
|
|
||||||
if (!StringUtils.isEmpty(type)) {
|
|
||||||
switch (type) {
|
|
||||||
case UtilsAndCommons.EPHEMERAL:
|
|
||||||
operationContext = new InstanceOperationContext(namespace, serviceName, true, true);
|
|
||||||
operatedInstances.addAll(operateFunction.apply(operationContext));
|
|
||||||
break;
|
|
||||||
case UtilsAndCommons.PERSIST:
|
|
||||||
operationContext = new InstanceOperationContext(namespace, serviceName, false, true);
|
|
||||||
operatedInstances.addAll(operateFunction.apply(operationContext));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Loggers.SRV_LOG
|
|
||||||
.warn("UPDATE-METADATA: services.all value is illegal, it should be ephemeral/persist. ignore the service '"
|
|
||||||
+ serviceName + "'");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
List<Instance> instances = (List<Instance>) operationInfo.getInstances();
|
|
||||||
if (!CollectionUtils.isEmpty(instances)) {
|
|
||||||
//ephemeral:instances or persist:instances
|
|
||||||
Map<Boolean, List<Instance>> instanceMap = instances.stream()
|
|
||||||
.collect(Collectors.groupingBy(ele -> ele.isEphemeral()));
|
|
||||||
|
|
||||||
for (Map.Entry<Boolean, List<Instance>> entry : instanceMap.entrySet()) {
|
|
||||||
operationContext = new InstanceOperationContext(namespace, serviceName, entry.getKey(), false,
|
|
||||||
entry.getValue());
|
|
||||||
operatedInstances.addAll(operateFunction.apply(operationContext));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Loggers.SRV_LOG.warn("UPDATE-METADATA: update metadata failed, ignore the service '" + operationInfo
|
|
||||||
.getServiceName() + "'", e);
|
|
||||||
}
|
|
||||||
return operatedInstances;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare and get new instance list.
|
* Compare and get new instance list.
|
||||||
*
|
*
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1999-2018 Alibaba Group Holding Ltd.
|
|
||||||
*
|
|
||||||
* Licensed 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 com.alibaba.nacos.naming.pojo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cluster state view.
|
|
||||||
*
|
|
||||||
* @author: universefeeler
|
|
||||||
*/
|
|
||||||
public class ClusterStateView {
|
|
||||||
|
|
||||||
private String nodeIp;
|
|
||||||
|
|
||||||
private String nodeState;
|
|
||||||
|
|
||||||
private long clusterTerm;
|
|
||||||
|
|
||||||
private long leaderDueMs;
|
|
||||||
|
|
||||||
private String voteFor;
|
|
||||||
|
|
||||||
private long heartbeatDueMs;
|
|
||||||
|
|
||||||
public long getLeaderDueMs() {
|
|
||||||
return leaderDueMs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLeaderDueMs(long leaderDueMs) {
|
|
||||||
this.leaderDueMs = leaderDueMs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getHeartbeatDueMs() {
|
|
||||||
return heartbeatDueMs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHeartbeatDueMs(long heartbeatDueMs) {
|
|
||||||
this.heartbeatDueMs = heartbeatDueMs;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVoteFor() {
|
|
||||||
return voteFor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVoteFor(String voteFor) {
|
|
||||||
this.voteFor = voteFor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNodeIp() {
|
|
||||||
return nodeIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNodeIp(String nodeIp) {
|
|
||||||
this.nodeIp = nodeIp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNodeState() {
|
|
||||||
return nodeState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNodeState(String nodeState) {
|
|
||||||
this.nodeState = nodeState;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getClusterTerm() {
|
|
||||||
return clusterTerm;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClusterTerm(long clusterTerm) {
|
|
||||||
this.clusterTerm = clusterTerm;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "ClusterStateView{" + "nodeIp='" + nodeIp + '\'' + ", nodeState='" + nodeState + '\'' + ", clusterTerm="
|
|
||||||
+ clusterTerm + ", leaderDueMs=" + leaderDueMs + ", voteFor='" + voteFor + '\'' + ", heartbeatDueMs="
|
|
||||||
+ heartbeatDueMs + '}';
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1999-2018 Alibaba Group Holding Ltd.
|
|
||||||
*
|
|
||||||
* Licensed 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 com.alibaba.nacos.naming.pojo;
|
|
||||||
|
|
||||||
import com.alibaba.nacos.naming.core.Instance;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* InstanceOperationContext. used in instance batch operation's consumer.
|
|
||||||
*
|
|
||||||
* @author horizonzy
|
|
||||||
* @since 1.4.0
|
|
||||||
*/
|
|
||||||
public class InstanceOperationContext {
|
|
||||||
|
|
||||||
public InstanceOperationContext() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public InstanceOperationContext(String namespace, String serviceName, Boolean ephemeral, Boolean all) {
|
|
||||||
this.namespace = namespace;
|
|
||||||
this.serviceName = serviceName;
|
|
||||||
this.ephemeral = ephemeral;
|
|
||||||
this.all = all;
|
|
||||||
}
|
|
||||||
|
|
||||||
public InstanceOperationContext(String namespace, String serviceName, Boolean ephemeral, Boolean all,
|
|
||||||
List<Instance> instances) {
|
|
||||||
this.namespace = namespace;
|
|
||||||
this.serviceName = serviceName;
|
|
||||||
this.ephemeral = ephemeral;
|
|
||||||
this.all = all;
|
|
||||||
this.instances = instances;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String namespace;
|
|
||||||
|
|
||||||
private String serviceName;
|
|
||||||
|
|
||||||
private Boolean ephemeral;
|
|
||||||
|
|
||||||
private Boolean all;
|
|
||||||
|
|
||||||
private List<Instance> instances;
|
|
||||||
|
|
||||||
public String getNamespace() {
|
|
||||||
return namespace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getServiceName() {
|
|
||||||
return serviceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getEphemeral() {
|
|
||||||
return ephemeral;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean getAll() {
|
|
||||||
return all;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Instance> getInstances() {
|
|
||||||
return instances;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,55 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 1999-2018 Alibaba Group Holding Ltd.
|
|
||||||
*
|
|
||||||
* Licensed 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 com.alibaba.nacos.naming.pojo;
|
|
||||||
|
|
||||||
import com.alibaba.nacos.api.naming.pojo.Cluster;
|
|
||||||
import com.alibaba.nacos.api.naming.pojo.Service;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Service manager.
|
|
||||||
*
|
|
||||||
* @author nkorange
|
|
||||||
*/
|
|
||||||
public class ServiceDetailView {
|
|
||||||
|
|
||||||
private Service service;
|
|
||||||
|
|
||||||
private List<Cluster> clusters;
|
|
||||||
|
|
||||||
public Service getService() {
|
|
||||||
return service;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setService(Service service) {
|
|
||||||
this.service = service;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Cluster> getClusters() {
|
|
||||||
return clusters;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClusters(List<Cluster> clusters) {
|
|
||||||
this.clusters = clusters;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "ServiceDetailView{" + "service=" + service + ", clusters=" + clusters + '}';
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user