public virtual void TestStopThreads() { DelegationTokenManager tm1 = null; string connectString = zkServer.GetConnectString(); // let's make the update interval short and the shutdown interval // comparatively longer, so if the update thread runs after shutdown, // it will cause an error. long updateIntervalSeconds = 1; long shutdownTimeoutMillis = updateIntervalSeconds * 1000 * 5; Configuration conf = GetSecretConf(connectString); conf.SetLong(DelegationTokenManager.UpdateInterval, updateIntervalSeconds); conf.SetLong(DelegationTokenManager.RemovalScanInterval, updateIntervalSeconds); conf.SetLong(DelegationTokenManager.RenewInterval, updateIntervalSeconds); conf.SetLong(ZKDelegationTokenSecretManager.ZkDtsmZkShutdownTimeout, shutdownTimeoutMillis ); tm1 = new DelegationTokenManager(conf, new Text("foo")); tm1.Init(); Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier> token = (Org.Apache.Hadoop.Security.Token.Token <DelegationTokenIdentifier>)tm1.CreateToken(UserGroupInformation.GetCurrentUser( ), "foo"); NUnit.Framework.Assert.IsNotNull(token); AbstractDelegationTokenSecretManager sm = tm1.GetDelegationTokenSecretManager(); ZKDelegationTokenSecretManager zksm = (ZKDelegationTokenSecretManager)sm; ExecutorService es = zksm.GetListenerThreadPool(); es.Submit(new _Callable_300(shutdownTimeoutMillis)); // force this to be shutdownNow tm1.Destroy(); }
public virtual SecretKey GetKey() { if (keyBytes == null || keyBytes.Length == 0) { return(null); } else { SecretKey key = AbstractDelegationTokenSecretManager.CreateSecretKey(keyBytes); return(key); } }
/// <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()); }
internal ExpiredTokenRemover(AbstractDelegationTokenSecretManager <TokenIdent> _enclosing ) { this._enclosing = _enclosing; }