3535import org .apache .iotdb .mpp .rpc .thrift .IDataNodeRPCService .Processor ;
3636import org .apache .iotdb .rpc .DeepCopyRpcTransportFactory ;
3737
38+ import java .util .concurrent .atomic .AtomicReference ;
39+
3840public class DataNodeInternalRPCService extends ThriftService
3941 implements DataNodeInternalRPCServiceMBean {
4042
4143 private static final IoTDBConfig config = IoTDBDescriptor .getInstance ().getConfig ();
4244 private static final CommonConfig commonConfig = CommonDescriptor .getInstance ().getConfig ();
4345
44- private DataNodeInternalRPCServiceImpl impl ;
46+ private final AtomicReference < DataNodeInternalRPCServiceImpl > impl = new AtomicReference <>() ;
4547
4648 private DataNodeInternalRPCService () {}
4749
@@ -51,11 +53,10 @@ public ServiceType getID() {
5153 }
5254
5355 @ Override
54- public void initTProcessor ()
55- throws ClassNotFoundException , IllegalAccessException , InstantiationException {
56- impl = new DataNodeInternalRPCServiceImpl ();
56+ public void initTProcessor () {
57+ impl .compareAndSet (null , new DataNodeInternalRPCServiceImpl ());
5758 initSyncedServiceImpl (null );
58- processor = new Processor <>(impl );
59+ processor = new Processor <>(impl . get () );
5960 }
6061
6162 @ Override
@@ -108,7 +109,8 @@ public int getBindPort() {
108109 }
109110
110111 public DataNodeInternalRPCServiceImpl getImpl () {
111- return impl ;
112+ impl .compareAndSet (null , new DataNodeInternalRPCServiceImpl ());
113+ return impl .get ();
112114 }
113115
114116 private static class DataNodeInternalRPCServiceHolder {
0 commit comments