ClusterAgent优化
This commit is contained in:
@@ -9,6 +9,7 @@ import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.atomic.*;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.logging.Level;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.boot.*;
|
||||
@@ -320,20 +321,11 @@ public class CacheClusterAgent extends ClusterAgent implements Resourcable {
|
||||
protected void deregister(NodeServer ns, String protocol, Service service, boolean realCanceled) {
|
||||
String serviceName = generateServiceName(ns, protocol, service);
|
||||
String serviceid = generateServiceId(ns, protocol, service);
|
||||
ClusterEntry currEntry = null;
|
||||
for (final ClusterEntry entry : localEntrys.values()) {
|
||||
if (Objects.equals(entry.serviceName, serviceName) && Objects.equals(entry.serviceid, serviceid)) {
|
||||
currEntry = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Predicate<ClusterEntry> predicate =
|
||||
entry -> Objects.equals(entry.serviceName, serviceName) && Objects.equals(entry.serviceid, serviceid);
|
||||
ClusterEntry currEntry = Utility.find(localEntrys.values(), predicate);
|
||||
if (currEntry == null) {
|
||||
for (final ClusterEntry entry : remoteEntrys.values()) {
|
||||
if (Objects.equals(entry.serviceName, serviceName) && Objects.equals(entry.serviceid, serviceid)) {
|
||||
currEntry = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
currEntry = Utility.find(remoteEntrys.values(), predicate);
|
||||
}
|
||||
source.hdel(serviceName, serviceid);
|
||||
if (realCanceled && currEntry != null) {
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
*/
|
||||
package org.redkale.cluster.spi;
|
||||
|
||||
import static org.redkale.boot.Application.*;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.net.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -16,6 +14,7 @@ import java.util.logging.*;
|
||||
import org.redkale.annotation.*;
|
||||
import org.redkale.annotation.AutoLoad;
|
||||
import org.redkale.boot.*;
|
||||
import static org.redkale.boot.Application.*;
|
||||
import org.redkale.convert.ConvertDisabled;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.inject.ResourceEvent;
|
||||
@@ -203,7 +202,7 @@ public abstract class ClusterAgent {
|
||||
}
|
||||
}
|
||||
ClusterEntry entry = new ClusterEntry(ns, protocol, service);
|
||||
if (entry.serviceName.trim().endsWith(".")) {
|
||||
if (entry.serviceName.endsWith(".")) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -224,9 +223,9 @@ public abstract class ClusterAgent {
|
||||
public abstract CompletableFuture<Set<InetSocketAddress>> queryHttpAddress(
|
||||
String protocol, String module, String resname);
|
||||
|
||||
// 获取SNCP远程服务的可用ip列表 restype: resourceType.getName()
|
||||
// 获取SNCP远程服务的可用ip列表 resType: resourceType.getName()
|
||||
public abstract CompletableFuture<Set<InetSocketAddress>> querySncpAddress(
|
||||
String protocol, String restype, String resname);
|
||||
String protocol, String resType, String resname);
|
||||
|
||||
// 获取远程服务的可用ip列表
|
||||
protected abstract CompletableFuture<Set<InetSocketAddress>> queryAddress(ClusterEntry entry);
|
||||
@@ -287,8 +286,8 @@ public abstract class ClusterAgent {
|
||||
return this.appAddress.getPort();
|
||||
}
|
||||
|
||||
public String generateSncpServiceName(String protocol, String restype, String resname) {
|
||||
return protocol.toLowerCase() + ":" + restype + (Utility.isEmpty(resname) ? "" : ("-" + resname));
|
||||
public String generateSncpServiceName(String protocol, String resType, String resname) {
|
||||
return protocol.toLowerCase() + ":" + resType + (Utility.isEmpty(resname) ? "" : ("-" + resname));
|
||||
}
|
||||
|
||||
// 也会提供给HttpMessageClusterAgent适用
|
||||
|
||||
Reference in New Issue
Block a user