|
|
@ -31,6 +31,7 @@ import org.apache.dolphinscheduler.remote.utils.NettyUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.net.InetSocketAddress; |
|
|
|
import java.net.InetSocketAddress; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
import java.util.concurrent.ExecutionException; |
|
|
|
import java.util.concurrent.ThreadFactory; |
|
|
|
import java.util.concurrent.ThreadFactory; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
|
import java.util.concurrent.atomic.AtomicBoolean; |
|
|
@ -171,16 +172,20 @@ public class NettyClient { |
|
|
|
System.out.println("netty client start"); |
|
|
|
System.out.println("netty client start"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void sendMsg(Host host, RpcRequest request) { |
|
|
|
public Object sendMsg(Host host, RpcRequest request) { |
|
|
|
Channel channel = getChannel(host); |
|
|
|
Channel channel = getChannel(host); |
|
|
|
assert channel != null; |
|
|
|
assert channel != null; |
|
|
|
// ctx.writeAndFlush(Unpooled.copiedBuffer
|
|
|
|
|
|
|
|
RpcFuture future = new RpcFuture(); |
|
|
|
RpcFuture future = new RpcFuture(); |
|
|
|
RpcRequestTable.put(request.getRequestId(), future); |
|
|
|
RpcRequestTable.put(request.getRequestId(), future); |
|
|
|
|
|
|
|
|
|
|
|
channel.writeAndFlush(request); |
|
|
|
channel.writeAndFlush(request); |
|
|
|
// System.out.println();
|
|
|
|
Object result = null; |
|
|
|
// channel.writeAndFlush( ProtoStuffUtils.serialize(request));
|
|
|
|
try { |
|
|
|
|
|
|
|
result=future.get(); |
|
|
|
|
|
|
|
} catch (InterruptedException | ExecutionException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|