private synchronized void init ( MasterInquireClient masterInquireClient ) { mMasterInquireClient = masterInquireClient ; mFileSystemMasterClientPool = new FileSystemMasterClientPool ( mClientContext , mMasterInquireClient ) ; mBlockMasterClientPool = new BlockMasterClientPool ( mClientContext , mMasterInquireClient ) ; mClosed . set ( false ) ; if ( mClientContext . getConf ( ) . getBoolean ( PropertyKey . USER_METRICS_COLLECTION_ENABLED ) ) { // setup metrics master client sync mMetricsMasterClient = new MetricsMasterClient ( MasterClientContext . newBuilder ( mClientContext ) . setMasterInquireClient ( mMasterInquireClient ) . build ( ) ) ; mClientMasterSync = new ClientMasterSync ( mMetricsMasterClient , mAppId ) ; mExecutorService = Executors . newFixedThreadPool ( 1 , ThreadFactoryUtils . build ( "metrics-master-heartbeat-%d" , true ) ) ; mExecutorService . submit ( new HeartbeatThread ( HeartbeatContext . MASTER_METRICS_SYNC , mClientMasterSync , ( int ) mClientContext . getConf ( ) . getMs ( PropertyKey . USER_METRICS_HEARTBEAT_INTERVAL_MS ) , mClientContext . getConf ( ) ) ) ; // register the shutdown hook try { Runtime . getRuntime ( ) . addShutdownHook ( new MetricsMasterSyncShutDownHook ( ) ) ; } catch ( IllegalStateException e ) { // this exception is thrown when the system is already in the process of shutting down. In // such a situation, we are about to shutdown anyway and there is no need to register this // shutdown hook } catch ( SecurityException e ) { LOG . info ( "Not registering metrics shutdown hook due to security exception. Regular " + "heartbeats will still be performed to collect metrics data, but no final heartbeat " + "will be performed on JVM exit. Security exception: {}" , e . toString ( ) ) ; } } }
Initializes the context . Only called in the factory methods .