From 1fe89a31ecb58b5e34baf3ff484b7ad8bc1e7f8e Mon Sep 17 00:00:00 2001 From: KomachiSion Date: Fri, 26 Aug 2022 17:23:25 +0800 Subject: [PATCH] Remove some unused classes in pojo. --- .../nacos/naming/core/ServiceManager.java | 56 ----------- .../nacos/naming/pojo/ClusterStateView.java | 92 ------------------- .../naming/pojo/InstanceOperationContext.java | 79 ---------------- .../nacos/naming/pojo/ServiceDetailView.java | 55 ----------- 4 files changed, 282 deletions(-) delete mode 100644 naming/src/main/java/com/alibaba/nacos/naming/pojo/ClusterStateView.java delete mode 100644 naming/src/main/java/com/alibaba/nacos/naming/pojo/InstanceOperationContext.java delete mode 100644 naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceDetailView.java diff --git a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java index 992acab50..2f170eb25 100644 --- a/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java +++ b/naming/src/main/java/com/alibaba/nacos/naming/core/ServiceManager.java @@ -31,8 +31,6 @@ import com.alibaba.nacos.naming.consistency.RecordListener; import com.alibaba.nacos.naming.misc.Loggers; import com.alibaba.nacos.naming.misc.SwitchDomain; 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 org.springframework.stereotype.Component; @@ -49,7 +47,6 @@ import java.util.Set; import java.util.StringJoiner; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentSkipListMap; -import java.util.function.Function; import java.util.stream.Collectors; import static com.alibaba.nacos.naming.misc.UtilsAndCommons.UPDATE_INSTANCE_METADATA_ACTION_REMOVE; @@ -520,59 +517,6 @@ public class ServiceManager implements RecordListener { 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 batchOperate(String namespace, InstanceOperationInfo operationInfo, - Function> operateFunction) { - List 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 instances = (List) operationInfo.getInstances(); - if (!CollectionUtils.isEmpty(instances)) { - //ephemeral:instances or persist:instances - Map> instanceMap = instances.stream() - .collect(Collectors.groupingBy(ele -> ele.isEphemeral())); - - for (Map.Entry> 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. * diff --git a/naming/src/main/java/com/alibaba/nacos/naming/pojo/ClusterStateView.java b/naming/src/main/java/com/alibaba/nacos/naming/pojo/ClusterStateView.java deleted file mode 100644 index a7dc28534..000000000 --- a/naming/src/main/java/com/alibaba/nacos/naming/pojo/ClusterStateView.java +++ /dev/null @@ -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 + '}'; - } -} diff --git a/naming/src/main/java/com/alibaba/nacos/naming/pojo/InstanceOperationContext.java b/naming/src/main/java/com/alibaba/nacos/naming/pojo/InstanceOperationContext.java deleted file mode 100644 index 7d1ad3b45..000000000 --- a/naming/src/main/java/com/alibaba/nacos/naming/pojo/InstanceOperationContext.java +++ /dev/null @@ -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 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 instances; - - public String getNamespace() { - return namespace; - } - - public String getServiceName() { - return serviceName; - } - - public Boolean getEphemeral() { - return ephemeral; - } - - public Boolean getAll() { - return all; - } - - public List getInstances() { - return instances; - } -} diff --git a/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceDetailView.java b/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceDetailView.java deleted file mode 100644 index 2b879ad01..000000000 --- a/naming/src/main/java/com/alibaba/nacos/naming/pojo/ServiceDetailView.java +++ /dev/null @@ -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 clusters; - - public Service getService() { - return service; - } - - public void setService(Service service) { - this.service = service; - } - - public List getClusters() { - return clusters; - } - - public void setClusters(List clusters) { - this.clusters = clusters; - } - - @Override - public String toString() { - return "ServiceDetailView{" + "service=" + service + ", clusters=" + clusters + '}'; - } -}