public _Thread_151(ZKRMStateStore store, string path, AtomicBoolean assertionFailedInThread ) { this.store = store; this.path = path; this.assertionFailedInThread = assertionFailedInThread; }
/// <exception cref="System.Exception"/> public virtual RMStateStore GetRMStateStore(Configuration conf) { string workingZnode = "/Test"; conf.Set(YarnConfiguration.RmZkAddress, this._enclosing.hostPort); conf.Set(YarnConfiguration.ZkRmStateStoreParentPath, workingZnode); this.store = new TestZKRMStateStoreZKClientConnections.TestZKClient.TestZKRMStateStore (this, conf, workingZnode); return(this.store); }
/// <exception cref="System.Exception"/> public virtual void TestZKSessionTimeout() { TestZKRMStateStoreZKClientConnections.TestZKClient zkClientTester = new TestZKRMStateStoreZKClientConnections.TestZKClient (this); string path = "/test"; YarnConfiguration conf = new YarnConfiguration(); conf.SetInt(YarnConfiguration.RmZkTimeoutMs, ZkTimeoutMs); ZKRMStateStore store = (ZKRMStateStore)zkClientTester.GetRMStateStore(conf); RMStateStoreTestBase.TestDispatcher dispatcher = new RMStateStoreTestBase.TestDispatcher (); store.SetRMDispatcher(dispatcher); // a hack to trigger expired event zkClientTester.forExpire = true; // trigger watch store.CreateWithRetries(path, null, ZooDefs.Ids.OpenAclUnsafe, CreateMode.Persistent ); store.GetDataWithRetries(path, true); store.SetDataWithRetries(path, Sharpen.Runtime.GetBytesForString("bytes"), 0); zkClientTester.syncBarrier.Await(); // after this point, expired event has already been processed. try { byte[] ret = store.GetDataWithRetries(path, false); NUnit.Framework.Assert.AreEqual("bytes", Sharpen.Runtime.GetStringForBytes(ret)); } catch (Exception e) { string error = "New session creation failed"; Log.Error(error, e); NUnit.Framework.Assert.Fail(error); } // send Disconnected event from old client session to ZKRMStateStore // check the current client session is not affected. NUnit.Framework.Assert.IsTrue(zkClientTester.oldWatcher != null); WatchedEvent disconnectedEvent = new WatchedEvent(Watcher.Event.EventType.None, Watcher.Event.KeeperState .Disconnected, null); zkClientTester.oldWatcher.Process(disconnectedEvent); NUnit.Framework.Assert.IsTrue(store.zkClient != null); zkClientTester.watcher.Process(disconnectedEvent); NUnit.Framework.Assert.IsTrue(store.zkClient == null); WatchedEvent connectedEvent = new WatchedEvent(Watcher.Event.EventType.None, Watcher.Event.KeeperState .SyncConnected, null); zkClientTester.watcher.Process(connectedEvent); NUnit.Framework.Assert.IsTrue(store.zkClient != null); NUnit.Framework.Assert.IsTrue(store.zkClient == store.activeZkClient); }
public virtual void TestZKRetryInterval() { TestZKRMStateStoreZKClientConnections.TestZKClient zkClientTester = new TestZKRMStateStoreZKClientConnections.TestZKClient (this); YarnConfiguration conf = new YarnConfiguration(); ZKRMStateStore store = (ZKRMStateStore)zkClientTester.GetRMStateStore(conf); NUnit.Framework.Assert.AreEqual(YarnConfiguration.DefaultRmZkRetryIntervalMs, store .zkRetryInterval); store.Stop(); conf.SetBoolean(YarnConfiguration.RmHaEnabled, true); store = (ZKRMStateStore)zkClientTester.GetRMStateStore(conf); NUnit.Framework.Assert.AreEqual(YarnConfiguration.DefaultRmZkTimeoutMs / YarnConfiguration .DefaultZkRmNumRetries, store.zkRetryInterval); store.Stop(); }
private void InitStore(string hostPort) { Optional <string> optHostPort = Optional.FromNullable(hostPort); RMContext rmContext = Org.Mockito.Mockito.Mock <RMContext>(); conf = new YarnConfiguration(); conf.Set(YarnConfiguration.RmZkAddress, optHostPort.Or(this.hostPort)); conf.Set(YarnConfiguration.ZkRmStateStoreParentPath, workingZnode); store = new ZKRMStateStore(); store.Init(conf); store.Start(); Org.Mockito.Mockito.When(rmContext.GetStateStore()).ThenReturn(store); appTokenMgr = new AMRMTokenSecretManager(conf, rmContext); appTokenMgr.Start(); clientToAMTokenMgr = new ClientToAMTokenSecretManagerInRM(); }
/// <exception cref="System.Exception"/> public virtual void TestZKClientDisconnectAndReconnect() { TestZKRMStateStoreZKClientConnections.TestZKClient zkClientTester = new TestZKRMStateStoreZKClientConnections.TestZKClient (this); string path = "/test"; YarnConfiguration conf = new YarnConfiguration(); conf.SetInt(YarnConfiguration.RmZkTimeoutMs, ZkTimeoutMs); ZKRMStateStore store = (ZKRMStateStore)zkClientTester.GetRMStateStore(conf); RMStateStoreTestBase.TestDispatcher dispatcher = new RMStateStoreTestBase.TestDispatcher (); store.SetRMDispatcher(dispatcher); // trigger watch store.CreateWithRetries(path, null, ZooDefs.Ids.OpenAclUnsafe, CreateMode.Persistent ); store.GetDataWithRetries(path, true); store.SetDataWithRetries(path, Sharpen.Runtime.GetBytesForString("newBytes"), 0); StopServer(); AtomicBoolean isSucceeded = new AtomicBoolean(false); zkClientTester.watcher.WaitForDisconnected(ZkOpWaitTime); Sharpen.Thread thread = new _Thread_190(store, path, isSucceeded); thread.Start(); // ZKRMStateStore Session restored StartServer(); zkClientTester.watcher.WaitForConnected(ZkOpWaitTime); byte[] ret = null; try { ret = store.GetDataWithRetries(path, true); } catch (Exception e) { string error = "ZKRMStateStore Session restore failed"; Log.Error(error, e); NUnit.Framework.Assert.Fail(error); } NUnit.Framework.Assert.AreEqual("newBytes", Sharpen.Runtime.GetStringForBytes(ret )); thread.Join(); NUnit.Framework.Assert.IsTrue(isSucceeded.Get()); }
/// <exception cref="System.Exception"/> public virtual void TestZKClientRetry() { TestZKRMStateStoreZKClientConnections.TestZKClient zkClientTester = new TestZKRMStateStoreZKClientConnections.TestZKClient (this); string path = "/test"; YarnConfiguration conf = new YarnConfiguration(); conf.SetInt(YarnConfiguration.RmZkTimeoutMs, ZkTimeoutMs); conf.SetLong(YarnConfiguration.RmZkRetryIntervalMs, 100); ZKRMStateStore store = (ZKRMStateStore)zkClientTester.GetRMStateStore(conf); RMStateStoreTestBase.TestDispatcher dispatcher = new RMStateStoreTestBase.TestDispatcher (); store.SetRMDispatcher(dispatcher); AtomicBoolean assertionFailedInThread = new AtomicBoolean(false); StopServer(); Sharpen.Thread clientThread = new _Thread_151(store, path, assertionFailedInThread ); Sharpen.Thread.Sleep(2000); StartServer(); clientThread.Join(); NUnit.Framework.Assert.IsFalse(assertionFailedInThread.Get()); }
public _Thread_190(ZKRMStateStore store, string path, AtomicBoolean isSucceeded) { this.store = store; this.path = path; this.isSucceeded = isSucceeded; }