fix : Modifying the comment Format (#812)

pull/880/head
pizihao 3 years ago
parent 6051755fee
commit b377a87bd1

@ -24,7 +24,6 @@ import java.io.Closeable;
/**
* the client for RPC, Explain the role of the client in the request
*
*/
public interface Client extends Closeable {

@ -23,7 +23,6 @@ import cn.hippo4j.config.rpc.response.Response;
/**
* Applicable to client connections
*
*/
public interface ClientConnection extends Connection {
@ -38,4 +37,9 @@ public interface ClientConnection extends Connection {
* Get timeout, ms
*/
long timeout();
/**
* SET timeout, ms
*/
void setTimeout(long timeout);
}

@ -42,10 +42,9 @@ import java.util.concurrent.locks.LockSupport;
@Slf4j
public class NettyClientConnection implements ClientConnection {
// TODO InetAddress
String host;
Integer port;
// Obtain the connection timeout period. The default value is 3s
// Obtain the connection timeout period. The default value is 30s
long timeout = 30000L;
Channel channel;
EventLoopGroup worker = new NioEventLoopGroup();
@ -97,6 +96,11 @@ public class NettyClientConnection implements ClientConnection {
return timeout;
}
@Override
public void setTimeout(long timeout) {
this.timeout = timeout;
}
@Override
public void close() {
if (this.channel == null) {

@ -24,7 +24,6 @@ import java.io.IOException;
/**
* The client, which provides a closing mechanism, maintains a persistent connection if not closed
*
*/
public class RPCClient implements Client {

@ -26,7 +26,6 @@ import io.netty.handler.codec.serialization.ObjectDecoder;
/**
* According to the decoder for java objects implemented by ObjectDecoder,
* it is necessary to ensure that the transmitted objects can be serialized
*
*/
public class NettyDecoder extends ObjectDecoder {

@ -27,8 +27,8 @@ import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
* this is a encoder
*
* this is a encoder, For custom gluing and unpacking<br>
* {@link io.netty.handler.codec.serialization.ObjectEncoder}
*/
public class NettyEncoder extends MessageToByteEncoder<Serializable> {

@ -22,7 +22,6 @@ import java.net.InetSocketAddress;
/**
* The adaptation layer of different service centers is used to know
* the host of different services through the registration center
*
*/
public interface DiscoveryAdapter {

@ -18,7 +18,8 @@
package cn.hippo4j.config.rpc.exception;
/**
*
* During decoding and encoding, if an exception occurs, an exception of type {@link CoderException} is thrown,
* which is not different from a {@link RuntimeException}, but is more explicit about the type of exception
*/
public class CoderException extends RuntimeException {

@ -18,7 +18,9 @@
package cn.hippo4j.config.rpc.exception;
/**
*
* If an exception occurs during the connection between the server and the client, an exception of type
* {@link ConnectionException} is thrown, which is not different from {@link RuntimeException}, but is more explicit
* about the type of exception
*/
public class ConnectionException extends RuntimeException {

@ -18,7 +18,8 @@
package cn.hippo4j.config.rpc.exception;
/**
*
* If there is a timeout between the server and the client, you will get a {@link TimeOutException},
* which is not different from {@link RuntimeException}, but it will be more explicit about the type of exception, right
*/
public class TimeOutException extends RuntimeException {

@ -24,7 +24,6 @@ import cn.hippo4j.config.rpc.response.Response;
* The handler in each connection, where the specific behavior of the connection
* must be specified, such as serialization and parsing, requesting and receiving
* requests, and so on
*
*/
public interface ConnectHandler {

@ -21,7 +21,6 @@ import java.io.Closeable;
/**
* Represents a network request connection and provides IO layer support
*
*/
public interface Connection extends Closeable {

@ -28,7 +28,6 @@ import lombok.extern.slf4j.Slf4j;
/**
* Processing by the client connection pool handler to clean the buffer and define new connection properties
*
*/
@Slf4j
public class NettyClientPoolHandler implements ChannelPoolHandler {

@ -27,7 +27,6 @@ import io.netty.channel.ChannelInboundHandlerAdapter;
/**
* Interconnect with the netty mediation layer
*
*/
public class NettyClientTakeHandler extends ChannelInboundHandlerAdapter implements ConnectHandler {

@ -36,7 +36,6 @@ import java.util.List;
/**
* netty adaptation layer
*
*/
public class NettyServerTakeHandler extends ChannelInboundHandlerAdapter implements ConnectHandler {

@ -22,7 +22,6 @@ import cn.hippo4j.config.rpc.response.Response;
/**
* Callback while the connection is in progress
*
*/
public interface ActivePostProcess {

@ -25,7 +25,6 @@ import java.util.Objects;
/**
* default request<br>
* Use the fully qualified name key of the interface and override equals and hashCode
*
*/
public final class DefaultRequest implements Request {

@ -21,7 +21,6 @@ import java.io.Serializable;
/**
* request
*
*/
public interface Request extends Serializable {

@ -25,7 +25,6 @@ import java.util.Objects;
/**
* default request<br>
* Use the fully qualified name key of the interface and override equals and hashCode
*
*/
public class DefaultResponse implements Response {

@ -21,7 +21,6 @@ import java.io.IOException;
/**
* Server Implementation
*
*/
public class RPCServer implements Server {

@ -21,7 +21,6 @@ import java.io.Closeable;
/**
* the service for RPC, Explain the role of the service in the request
*
*/
public interface Server extends Closeable {

@ -21,7 +21,6 @@ import cn.hippo4j.config.rpc.handler.Connection;
/**
* This applies to server-side connections
*
*/
public interface ServerConnection extends Connection {

@ -25,7 +25,6 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* the registration center for Client and Server
*
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class ClassRegistry {

@ -23,7 +23,6 @@ import cn.hippo4j.common.web.exception.IllegalException;
/**
* Simply creating an instance of a class by its name and its specific type,
* and then throwing an exception if it is an interface, is not elegant
*
*/
public class DefaultInstance implements Instance {

@ -19,7 +19,6 @@ package cn.hippo4j.config.rpc.support;
/**
* Instance interface to get an instance
*
*/
public interface Instance {

@ -34,7 +34,6 @@ import java.util.concurrent.TimeUnit;
/**
* This parameter applies only to the connection pool of netty
*
*/
@Slf4j
public class NettyConnectPool {

@ -29,15 +29,13 @@ import java.util.concurrent.ConcurrentHashMap;
/**
* To avoid creating multiple connection pools for the same host:port, save all connection pools of the client
*
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class NettyConnectPoolHolder {
static int maxConnect = 64;
// TODO InetSocketAddress
static Map<String, NettyConnectPool> map = new ConcurrentHashMap<>();
static Map<String, NettyConnectPool> connectPoolMap = new ConcurrentHashMap<>();
private static NettyConnectPool initPool(String host, int port,
long timeout, EventLoopGroup worker) {
@ -52,30 +50,30 @@ public class NettyConnectPoolHolder {
}
/**
* The connection pool mapping may already exist before the connection pool
* mapping is established. In this case, the connection pool is directly overwritten
* The connection pool connectPoolMapping may already exist before the connection pool
* connectPoolMapping is established. In this case, the connection pool is directly overwritten
*
* @param host the host
* @param port the port
* @param pool This parameter applies only to the connection pool of netty
*/
public static void createPool(String host, int port, NettyConnectPool pool) {
map.put(getKey(host, port), pool);
connectPoolMap.put(getKey(host, port), pool);
}
/**
* Gets a connection pool, or null if there is no corresponding mapping
* Gets a connection pool, or null if there is no corresponding connectPoolMapping
*
* @param host the host
* @param port the port
* @return Map to the connection pool
*/
public static NettyConnectPool getPool(String host, int port) {
return map.get(getKey(host, port));
return connectPoolMap.get(getKey(host, port));
}
/**
* Gets a connection pool, and if there is no mapping, creates one with the values provided and joins the mapping
* Gets a connection pool, and if there is no connectPoolMapping, creates one with the values provided and joins the connectPoolMapping
*
* @param host the host
* @param port the port
@ -95,19 +93,19 @@ public class NettyConnectPoolHolder {
}
/**
* Disconnect a connection mapping. This must take effect at the same time as the connection pool is closed
* Disconnect a connection connectPoolMapping. This must take effect at the same time as the connection pool is closed
*
* @param host host
* @param port port
*/
public static void remove(String host, int port) {
map.remove(getKey(host, port));
connectPoolMap.remove(getKey(host, port));
}
/**
* clear
*/
public static void clear() {
map.clear();
connectPoolMap.clear();
}
}

@ -33,11 +33,11 @@ import java.util.Map;
/**
* Add a proxy for the request, {@link Proxy} and {@link InvocationHandler}
*
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class NettyProxyCenter {
// cache
static Map<Class<?>, Object> map = new HashMap<>();
/**

@ -31,7 +31,6 @@ import java.util.concurrent.locks.LockSupport;
* The unique remote call can be determined by the key of request and
* response, and the result of the call is stored in the secondary cache,
* which is convenient for the client to use at any time.
*
*/
@Slf4j
@NoArgsConstructor(access = AccessLevel.PRIVATE)

@ -21,7 +21,6 @@ import cn.hippo4j.common.config.ApplicationContextHolder;
/**
* Adapter Spring, The requested object is managed by spring
*
*/
public class SpringContextInstance implements Instance {

Loading…
Cancel
Save