/// <exception cref="System.Exception"/> protected internal virtual void VerifyDestroy(DelegationTokenManager tm, Configuration conf) { AbstractDelegationTokenSecretManager sm = tm.GetDelegationTokenSecretManager(); ZKDelegationTokenSecretManager zksm = (ZKDelegationTokenSecretManager)sm; ExecutorService es = zksm.GetListenerThreadPool(); tm.Destroy(); Assert.True(es.IsShutdown()); // wait for the pool to terminate long timeout = conf.GetLong(ZKDelegationTokenSecretManager.ZkDtsmZkShutdownTimeout , ZKDelegationTokenSecretManager.ZkDtsmZkShutdownTimeoutDefault); Thread.Sleep(timeout * 3); Assert.True(es.IsTerminated()); }
private void StopAggregators() { threadPool.Shutdown(); // if recovery on restart is supported then leave outstanding aggregations // to the next restart bool shouldAbort = context.GetNMStateStore().CanRecover() && !context.GetDecommissioned (); // politely ask to finish foreach (AppLogAggregator aggregator in appLogAggregators.Values) { if (shouldAbort) { aggregator.AbortLogAggregation(); } else { aggregator.FinishLogAggregation(); } } while (!threadPool.IsTerminated()) { // wait for all threads to finish foreach (ApplicationId appId in appLogAggregators.Keys) { Log.Info("Waiting for aggregation to complete for " + appId); } try { if (!threadPool.AwaitTermination(30, TimeUnit.Seconds)) { threadPool.ShutdownNow(); } } catch (Exception) { // send interrupt to hurry them along Log.Warn("Aggregation stop interrupted!"); break; } } foreach (ApplicationId appId_1 in appLogAggregators.Keys) { Log.Warn("Some logs may not have been aggregated for " + appId_1); } }