Search in sources :

Example 6 with RpcException

use of com.jim.framework.rpc.exception.RpcException in project jim-framework by jiangmin168168.

the class RpcClientInvokerManager method getInvoker.

public RpcClientInvoker getInvoker() {
    int size = RpcClientInvokerCache.size();
    while (size <= 0) {
        try {
            this.connect();
            boolean available = waitingForHandler();
            if (available) {
                size = RpcClientInvokerCache.size();
            }
        } catch (InterruptedException e) {
            throw new RpcException(e);
        }
    }
    int index = loadbalanceService.index(size);
    RpcClientInvoker invoker = RpcClientInvokerCache.get(index);
    if (invoker.getChannel().isActive()) {
        return invoker;
    } else {
        RpcClientInvokerCache.removeHandler(invoker);
        logger.info("invoker is not active,so remove it and get next one");
        return this.getInvoker();
    }
}
Also used : RpcException(com.jim.framework.rpc.exception.RpcException)

Aggregations

RpcException (com.jim.framework.rpc.exception.RpcException)6 IOException (java.io.IOException)3 LinkedBuffer (io.protostuff.LinkedBuffer)2 Schema (io.protostuff.Schema)2 RuntimeSchema (io.protostuff.runtime.RuntimeSchema)2 RpcURL (com.jim.framework.rpc.common.RpcURL)1 ConsulRegistryService (com.jim.framework.rpc.registry.ConsulRegistryService)1 RegistryService (com.jim.framework.rpc.registry.RegistryService)1 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 ChannelFuture (io.netty.channel.ChannelFuture)1 EventLoopGroup (io.netty.channel.EventLoopGroup)1 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 List (java.util.List)1 FastClass (org.springframework.cglib.reflect.FastClass)1 FastMethod (org.springframework.cglib.reflect.FastMethod)1