public virtual void Teardown() { if (null != zkc) { zkc.Close(); } if (null != bkjm) { bkjm.Close(); } }
public virtual void Teardown() { zkc.Close(); if (newBookie != null) { newBookie.Shutdown(); } }
/// <summary>Check that a number of bookies are available</summary> /// <param name="count">number of bookies required</param> /// <param name="timeout">number of seconds to wait for bookies to start</param> /// <exception cref="System.IO.IOException">if bookies are not started by the time the timeout hits /// </exception> /// <exception cref="System.Exception"/> internal virtual int CheckBookiesUp(int count, int timeout) { ZooKeeper zkc = ConnectZooKeeper(); try { int mostRecentSize = 0; for (int i = 0; i < timeout; i++) { try { IList <string> children = zkc.GetChildren("/ledgers/available", false); mostRecentSize = children.Count; // Skip 'readonly znode' which is used for keeping R-O bookie details if (children.Contains("readonly")) { mostRecentSize = children.Count - 1; } if (Log.IsDebugEnabled()) { Log.Debug("Found " + mostRecentSize + " bookies up, " + "waiting for " + count); if (Log.IsTraceEnabled()) { foreach (string child in children) { Log.Trace(" server: " + child); } } } if (mostRecentSize == count) { break; } } catch (KeeperException) { } // ignore Sharpen.Thread.Sleep(1000); } return(mostRecentSize); } finally { zkc.Close(); } }
public virtual void TestEmptyInputStream() { ZooKeeper zk = BKJMUtil.ConnectZooKeeper(); BookKeeper bkc = new BookKeeper(new ClientConfiguration(), zk); try { LedgerHandle lh = bkc.CreateLedger(BookKeeper.DigestType.Crc32, Sharpen.Runtime.GetBytesForString ("foobar")); lh.Close(); EditLogLedgerMetadata metadata = new EditLogLedgerMetadata("/foobar", HdfsConstants .NamenodeLayoutVersion, lh.GetId(), unchecked ((int)(0x1234))); try { new BookKeeperEditLogInputStream(lh, metadata, -1); NUnit.Framework.Assert.Fail("Shouldn't get this far, should have thrown"); } catch (IOException ioe) { NUnit.Framework.Assert.IsTrue(ioe.Message.Contains("Invalid first bk entry to read" )); } metadata = new EditLogLedgerMetadata("/foobar", HdfsConstants.NamenodeLayoutVersion , lh.GetId(), unchecked ((int)(0x1234))); try { new BookKeeperEditLogInputStream(lh, metadata, 0); NUnit.Framework.Assert.Fail("Shouldn't get this far, should have thrown"); } catch (IOException ioe) { NUnit.Framework.Assert.IsTrue(ioe.Message.Contains("Invalid first bk entry to read" )); } } finally { bkc.Close(); zk.Close(); } }