@@ -748,18 +748,22 @@ class BrokerServer(
748
748
if (replicaManager != null )
749
749
replicaManager.beginControlledShutdown()
750
750
751
- lifecycleManager.beginControlledShutdown()
752
- try {
753
- val controlledShutdownTimeoutMs = deadline - time.milliseconds()
754
- lifecycleManager.controlledShutdownFuture.get(controlledShutdownTimeoutMs, TimeUnit .MILLISECONDS )
755
- } catch {
756
- case _ : TimeoutException =>
757
- error(" Timed out waiting for the controller to approve controlled shutdown" )
758
- case e : Throwable =>
759
- error(" Got unexpected exception waiting for controlled shutdown future" , e)
751
+ if (lifecycleManager != null ) {
752
+ lifecycleManager.beginControlledShutdown()
753
+ try {
754
+ val controlledShutdownTimeoutMs = deadline - time.milliseconds()
755
+ lifecycleManager.controlledShutdownFuture.get(controlledShutdownTimeoutMs, TimeUnit .MILLISECONDS )
756
+ } catch {
757
+ case _ : TimeoutException =>
758
+ error(" Timed out waiting for the controller to approve controlled shutdown" )
759
+ case e : Throwable =>
760
+ error(" Got unexpected exception waiting for controlled shutdown future" , e)
761
+ }
760
762
}
761
763
}
762
- lifecycleManager.beginShutdown()
764
+ if (lifecycleManager != null )
765
+ lifecycleManager.beginShutdown()
766
+
763
767
// Stop socket server to stop accepting any more connections and requests.
764
768
// Socket server will be shutdown towards the end of the sequence.
765
769
if (socketServer != null ) {
@@ -811,8 +815,10 @@ class BrokerServer(
811
815
if (clientToControllerChannelManager != null )
812
816
CoreUtils .swallow(clientToControllerChannelManager.shutdown(), this )
813
817
814
- if (logManager != null )
815
- CoreUtils .swallow(logManager.shutdown(lifecycleManager.brokerEpoch), this )
818
+ if (logManager != null ) {
819
+ val brokerEpoch = if (lifecycleManager != null ) lifecycleManager.brokerEpoch else - 1
820
+ CoreUtils .swallow(logManager.shutdown(brokerEpoch), this )
821
+ }
816
822
817
823
// Close remote log manager to give a chance to any of its underlying clients
818
824
// (especially in RemoteStorageManager and RemoteLogMetadataManager) to close gracefully.
@@ -832,7 +838,9 @@ class BrokerServer(
832
838
833
839
isShuttingDown.set(false )
834
840
835
- CoreUtils .swallow(lifecycleManager.close(), this )
841
+ if (lifecycleManager != null )
842
+ CoreUtils .swallow(lifecycleManager.close(), this )
843
+
836
844
CoreUtils .swallow(config.dynamicConfig.clear(), this )
837
845
Utils .closeQuietly(clientMetricsManager, " client metrics manager" )
838
846
sharedServer.stopForBroker()
0 commit comments