[Optimize] RpcClient constructor (#8113)
* optimize RpcClient constructor * edit RpcClient.java
This commit is contained in:
parent
dba1cf56f0
commit
44850cc732
@ -68,7 +68,7 @@ public abstract class RpcClient implements Closeable {
|
|||||||
|
|
||||||
private ServerListFactory serverListFactory;
|
private ServerListFactory serverListFactory;
|
||||||
|
|
||||||
protected LinkedBlockingQueue<ConnectionEvent> eventLinkedBlockingQueue = new LinkedBlockingQueue<>();
|
protected BlockingQueue<ConnectionEvent> eventLinkedBlockingQueue = new LinkedBlockingQueue<>();
|
||||||
|
|
||||||
protected volatile AtomicReference<RpcClientStatus> rpcClientStatus = new AtomicReference<>(
|
protected volatile AtomicReference<RpcClientStatus> rpcClientStatus = new AtomicReference<>(
|
||||||
RpcClientStatus.WAIT_INIT);
|
RpcClientStatus.WAIT_INIT);
|
||||||
@ -115,22 +115,21 @@ public abstract class RpcClient implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RpcClient(String name) {
|
public RpcClient(String name) {
|
||||||
this.name = name;
|
this(name, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RpcClient(ServerListFactory serverListFactory) {
|
public RpcClient(ServerListFactory serverListFactory) {
|
||||||
|
this(null, serverListFactory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RpcClient(String name, ServerListFactory serverListFactory) {
|
||||||
|
this.name = name;
|
||||||
|
if (serverListFactory != null) {
|
||||||
this.serverListFactory = serverListFactory;
|
this.serverListFactory = serverListFactory;
|
||||||
rpcClientStatus.compareAndSet(RpcClientStatus.WAIT_INIT, RpcClientStatus.INITIALIZED);
|
rpcClientStatus.compareAndSet(RpcClientStatus.WAIT_INIT, RpcClientStatus.INITIALIZED);
|
||||||
LoggerUtils.printIfInfoEnabled(LOGGER, "RpcClient init in constructor, ServerListFactory = {}",
|
LoggerUtils.printIfInfoEnabled(LOGGER, "RpcClient init in constructor, ServerListFactory = {}",
|
||||||
serverListFactory.getClass().getName());
|
serverListFactory.getClass().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public RpcClient(String name, ServerListFactory serverListFactory) {
|
|
||||||
this(name);
|
|
||||||
this.serverListFactory = serverListFactory;
|
|
||||||
rpcClientStatus.compareAndSet(RpcClientStatus.WAIT_INIT, RpcClientStatus.INITIALIZED);
|
|
||||||
LoggerUtils.printIfInfoEnabled(LOGGER, "RpcClient init in constructor, ServerListFactory = {}",
|
|
||||||
serverListFactory.getClass().getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user