public virtual void TearDown() { if (zks != null) { ZKDatabase zkDb = zks.GetZKDatabase(); factory.Shutdown(); try { zkDb.Close(); } catch (IOException) { } int Port = System.Convert.ToInt32(hostPort.Split(":")[1]); NUnit.Framework.Assert.IsTrue("waiting for server down", WaitForServerDown("127.0.0.1:" + Port, ConnectionTimeout)); } }
/// <exception cref="System.Exception"/> public static void WaitForActiveLockData(MultithreadedTestUtil.TestContext ctx, ZooKeeperServer zks, string parentDir, byte[] activeData) { long st = Time.Now(); long lastPrint = st; while (true) { if (ctx != null) { ctx.CheckException(); } try { Stat stat = new Stat(); byte[] data = zks.GetZKDatabase().GetData(parentDir + "/" + ActiveStandbyElector. LockFilename, stat, null); if (activeData != null && Arrays.Equals(activeData, data)) { return; } if (Time.Now() > lastPrint + LogIntervalMs) { Log.Info("Cur data: " + StringUtils.ByteToHexString(data)); lastPrint = Time.Now(); } } catch (KeeperException.NoNodeException) { if (activeData == null) { return; } if (Time.Now() > lastPrint + LogIntervalMs) { Log.Info("Cur data: no node"); lastPrint = Time.Now(); } } Thread.Sleep(50); } }
internal static void ShutdownServerInstance(ServerCnxnFactory factory, string hostPort ) { if (factory != null) { ZKDatabase zkDb; { ZooKeeperServer zs = GetServer(factory); zkDb = zs.GetZKDatabase(); } factory.Shutdown(); try { zkDb.Close(); } catch (IOException ie) { Log.Warn("Error closing logs ", ie); } int Port = GetPort(hostPort); Assert.True("waiting for server down", ClientBaseWithFixes.WaitForServerDown ("127.0.0.1:" + Port, ConnectionTimeout)); } }