diff --git a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServer.java b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServer.java index 289dfa0f..345f5cfa 100644 --- a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServer.java +++ b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServer.java @@ -4,9 +4,9 @@ import java.util.Map; /** - * 连接服务 + * 连接服务。 *

- * 表示服务实例信息 + * A server can be connect. */ public interface ConnectionServer { @@ -17,59 +17,19 @@ static String url(ConnectionServer server) { return server.getHost() + ":" + server.getPort(); } - /** - * 获得服务实例 id - * - * @return 服务实例 id - */ String getInstanceId(); - /** - * 获得服务 id - * - * @return 服务 id - */ String getServiceId(); - /** - * 获得 host - * - * @return host - */ String getHost(); - /** - * 获得 port - * - * @return port - */ int getPort(); - /** - * 获得元数据 - * - * @return 元数据 - */ Map getMetadata(); - /** - * 获得 {@link URI} - * - * @return {@link URI} - */ URI getUri(); - /** - * 获得 Scheme - * - * @return Scheme - */ String getScheme(); - /** - * 是否安全的 - * - * @return 是否安全的 - */ boolean isSecure(); } diff --git a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerImpl.java b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerImpl.java index ad37eb30..43de341b 100644 --- a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerImpl.java +++ b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerImpl.java @@ -6,7 +6,9 @@ import java.util.Map; /** - * {@link ConnectionServer} 的默认实现 + * {@link ConnectionServer} 的默认实现。 + *

+ * Default impl of {@link ConnectionServer}. */ @Data public class ConnectionServerImpl implements ConnectionServer { diff --git a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerManager.java b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerManager.java index 971279c1..a9fd5c57 100644 --- a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerManager.java +++ b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerManager.java @@ -7,54 +7,121 @@ import java.util.List; /** - * {@link ConnectionServer} 提供者 + * 连接服务管理器。 + *

+ * Management of connectable server. */ public interface ConnectionServerManager { + /** + * 添加服务。 + *

+ * Add a server. + */ default void add(ConnectionServer server, ConnectionLoadBalanceConcept concept) { throw new UnsupportedOperationException(); } + /** + * 添加服务。 + *

+ * Add a server. + */ default void add(ConnectionServer server) { add(server, null); } + /** + * 移除服务。 + *

+ * Remove a server. + */ default void remove(ConnectionServer server, ConnectionLoadBalanceConcept concept) { throw new UnsupportedOperationException(); } + /** + * 移除服务。 + *

+ * Remove a server. + */ default void remove(ConnectionServer server) { remove(server, null); } + /** + * 清空服务。 + *

+ * Clear servers. + */ default void clear(ConnectionLoadBalanceConcept concept) { throw new UnsupportedOperationException(); } + /** + * 清空服务。 + *

+ * Clear servers. + */ default void clear() { clear(null); } + /** + * 比较两个服务是否相等。 + *

+ * Compare whether two services are equal. + */ default boolean isEqual(ConnectionServer server1, ConnectionServer server2, ConnectionLoadBalanceConcept concept) { return server1.getHost().equals(server2.getHost()) && server1.getPort() == server2.getPort(); } + /** + * 比较两个服务是否相等。 + *

+ * Compare whether two services are equal. + */ default boolean isEqual(ConnectionServer server1, ConnectionServer server2) { return isEqual(server1, server2, null); } + /** + * 获得本地服务。 + *

+ * Get local server. + */ ConnectionServer getLocal(ConnectionLoadBalanceConcept concept); + /** + * 获得本地服务。 + *

+ * Get local server. + */ default ConnectionServer getLocal() { return getLocal(null); } + /** + * 获得需要连接的服务。 + *

+ * Get servers need connect. + */ List getConnectionServers(ConnectionLoadBalanceConcept concept); + /** + * 获得需要连接的服务。 + *

+ * Get servers need connect. + */ default List getConnectionServers() { return getConnectionServers(null); } + /** + * 连接服务管理器代理。 + *

+ * Delegate of server manager. + */ @Getter @RequiredArgsConstructor class Delegate implements ConnectionServerManager { @@ -64,7 +131,7 @@ class Delegate implements ConnectionServerManager { private final ConnectionServerManager delegate; public static ConnectionServerManager delegate(ConnectionLoadBalanceConcept concept, - ConnectionServerManager delegate) { + ConnectionServerManager delegate) { return new Delegate(concept, delegate); } diff --git a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerManagerFactory.java b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerManagerFactory.java index d9bd30cf..097b84bb 100644 --- a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerManagerFactory.java +++ b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/ConnectionServerManagerFactory.java @@ -2,6 +2,11 @@ import com.github.linyuzai.connection.loadbalance.core.scope.ScopedFactory; +/** + * 连接管理器工厂。 + *

+ * Factory of server manager. + */ public interface ConnectionServerManagerFactory extends ScopedFactory { } diff --git a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/SimpleConnectionServerManager.java b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/SimpleConnectionServerManager.java index 8a180c42..a7246069 100644 --- a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/SimpleConnectionServerManager.java +++ b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/SimpleConnectionServerManager.java @@ -7,7 +7,9 @@ import java.util.concurrent.CopyOnWriteArrayList; /** - * {@link ConnectionServer} 提供者默认实现 + * 连接服务管理器简单实现。 + *

+ * Simple impl of server manager. */ public class SimpleConnectionServerManager implements ConnectionServerManager { diff --git a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/SimpleConnectionServerManagerFactory.java b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/SimpleConnectionServerManagerFactory.java index 1deb6c41..2dfb34a7 100644 --- a/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/SimpleConnectionServerManagerFactory.java +++ b/concept-connection-loadbalance/concept-connection-loadbalance-core/src/main/java/com/github/linyuzai/connection/loadbalance/core/server/SimpleConnectionServerManagerFactory.java @@ -1,5 +1,10 @@ package com.github.linyuzai.connection.loadbalance.core.server; +/** + * {@link SimpleConnectionServerManager} 工厂。 + *

+ * Factory of {@link SimpleConnectionServerManager}. + */ public class SimpleConnectionServerManagerFactory implements ConnectionServerManagerFactory { @Override