From 8a2a7b52d8802f86f017144df15ef0b4cb95962b Mon Sep 17 00:00:00 2001 From: omwok Date: Fri, 1 Jun 2012 14:31:44 +0700 Subject: [PATCH] add some comment and some clean-up --- src/dotnet/ZooKeeperNet/ClientConnection.cs | 6 +- .../ClientConnectionEventConsumer.cs | 20 +--- .../ClientConnectionRequestProducer.cs | 105 +++++++++--------- src/dotnet/ZooKeeperNet/DataTree.cs | 5 +- .../ZooKeeperNet/IO/EndianBinaryReader.cs | 2 +- src/dotnet/ZooKeeperNet/Packet.cs | 4 +- src/dotnet/ZooKeeperNet/PathUtils.cs | 35 ++++-- src/dotnet/ZooKeeperNet/Quotas.cs | 4 +- src/dotnet/ZooKeeperNet/ZooKeeper.cs | 34 ++---- src/dotnet/ZooKeeperNet/ZooKeeperEx.cs | 2 +- 10 files changed, 100 insertions(+), 117 deletions(-) diff --git a/src/dotnet/ZooKeeperNet/ClientConnection.cs b/src/dotnet/ZooKeeperNet/ClientConnection.cs index a9e6d38feef..78ed3370baf 100644 --- a/src/dotnet/ZooKeeperNet/ClientConnection.cs +++ b/src/dotnet/ZooKeeperNet/ClientConnection.cs @@ -31,7 +31,7 @@ public class ClientConnection : IClientConnection { private static readonly ILog LOG = LogManager.GetLogger(typeof(ClientConnection)); - //doesn't need this restriction, heck no limmit + //TODO find an elegant way to set this parameter public const int packetLen = 4096 * 1024; internal static readonly bool disableAutoWatchReset = false; internal const int maxSpin = 30; @@ -122,7 +122,7 @@ private void CreateProducer() private string SetChrootPath() { - int off = hosts.IndexOf('/'); + int off = hosts.IndexOf(PathUtils.PathSeparatorChar); if (off >= 0) { string path = hosts.Substring(off); @@ -216,6 +216,7 @@ public ReplyHeader SubmitRequest(RequestHeader h, IRecord request, IRecord respo Packet p = QueuePacket(h, r, request, response, null, null, watchRegistration, null, null); SpinWait spin = new SpinWait(); DateTime start = DateTime.Now; + // now wait for reply for the packet while (!p.Finished) { spin.SpinOnce(); @@ -239,7 +240,6 @@ public Packet QueuePacket(RequestHeader h, ReplyHeader r, IRecord request, IReco /// private void InternalDispose() { - //if (!closing) if(Interlocked.CompareExchange(ref isClosed,1,0) == 0) { //closing = true; diff --git a/src/dotnet/ZooKeeperNet/ClientConnectionEventConsumer.cs b/src/dotnet/ZooKeeperNet/ClientConnectionEventConsumer.cs index f03b461e848..818636eb27a 100644 --- a/src/dotnet/ZooKeeperNet/ClientConnectionEventConsumer.cs +++ b/src/dotnet/ZooKeeperNet/ClientConnectionEventConsumer.cs @@ -30,7 +30,7 @@ public class ClientConnectionEventConsumer : IStartable, IDisposable private readonly ClientConnection conn; private readonly Thread eventThread; - + //ConcurrentQueue gives us the non-blocking way of processing, it reduced the contention so much internal readonly ConcurrentQueue waitingEvents = new ConcurrentQueue(); /** This is really the queued session state until the event @@ -52,7 +52,6 @@ public void Start() private static void ProcessWatcher(IEnumerable watchers,WatchedEvent watchedEvent) { - // // each watcher will process the event foreach (IWatcher watcher in watchers) { try @@ -70,13 +69,12 @@ public void PollEvents() { try { - //while (!waitingEvents.IsCompleted) SpinWait spin = new SpinWait(); while(Interlocked.CompareExchange(ref isDisposed, 1, 1) == 0) { try { - ClientConnection.WatcherSetEventPair pair;// = waitingEvents.Take(); + ClientConnection.WatcherSetEventPair pair; if (waitingEvents.TryDequeue(out pair)) ProcessWatcher(pair.Watchers, pair.WatchedEvent); else @@ -131,17 +129,11 @@ private void InternalDispose() { if (Interlocked.CompareExchange(ref isDisposed, 1, 0) == 0) { - //waitingEvents.CompleteAdding(); eventThread.Join(); - while (!waitingEvents.IsEmpty) - { - ClientConnection.WatcherSetEventPair pair;// = waitingEvents.Take(); - if (waitingEvents.TryDequeue(out pair)) - { - ProcessWatcher(pair.Watchers,pair.WatchedEvent); - } - } - //waitingEvents.Dispose(); + //process any unprocessed event + ClientConnection.WatcherSetEventPair pair; + while(waitingEvents.TryDequeue(out pair)) + ProcessWatcher(pair.Watchers, pair.WatchedEvent); } } diff --git a/src/dotnet/ZooKeeperNet/ClientConnectionRequestProducer.cs b/src/dotnet/ZooKeeperNet/ClientConnectionRequestProducer.cs index 6b8394dbcb2..7d81401af0a 100644 --- a/src/dotnet/ZooKeeperNet/ClientConnectionRequestProducer.cs +++ b/src/dotnet/ZooKeeperNet/ClientConnectionRequestProducer.cs @@ -78,14 +78,12 @@ public Packet QueuePacket(RequestHeader h, ReplyHeader r, IRecord request, IReco h.Xid = Xid; Packet p = new Packet(h, r, request, response, null, watchRegistration, clientPath, serverPath); - + if (!zooKeeper.State.IsAlive() || Interlocked.CompareExchange(ref isDisposed, 0, 0) == 1) ConLossPacket(p); else - { + // enqueue the packet when zookeeper is connected outgoingQueue.Enqueue(p); - //queueEvent.Set(); - } return p; } @@ -103,7 +101,6 @@ private void SendRequests() if (client == null) { // don't re-establish connection if we are closing - //if (conn.closing) if(conn.IsClosed) break; @@ -132,14 +129,15 @@ private void SendRequests() } else { + // spin the processor spin.SpinOnce(); if (spin.Count > ClientConnection.maxSpin) + // reset the spinning counter spin.Reset(); } } catch (Exception e) { - //if (conn.closing) if(conn.IsClosed) { if (LOG.IsDebugEnabled) @@ -159,16 +157,22 @@ private void SendRequests() LOG.InfoFormat("{0}{1}", e.Message, RETRY_CONN_MSG); else LOG.WarnFormat("Session 0x{0:X} for server {1}, unexpected error{2}, detail:{3}-{4}", conn.SessionId, null, RETRY_CONN_MSG, e.Message, e.StackTrace); + // a safe-net ...there's a packet about to send when an exception happen if(packet != null) ConLossPacket(packet); + // clean up any queued packet Cleanup(); + // inform client using event about the exception if (zooKeeper.State.IsAlive()) conn.consumer.QueueEvent(new WatchedEvent(KeeperState.Disconnected, EventType.None, null)); } } + // safe-net to ensure everything is clean up properly Cleanup(); - if (zooKeeper.State.IsAlive()) - conn.consumer.QueueEvent(new WatchedEvent(KeeperState.Disconnected, EventType.None, null)); + + // i don't think this is necessary, when we reached this block ....the state is surely not alive + //if (zooKeeper.State.IsAlive()) + // conn.consumer.QueueEvent(new WatchedEvent(KeeperState.Disconnected, EventType.None, null)); if (LOG.IsDebugEnabled) LOG.Debug("SendThread exitedloop."); @@ -180,6 +184,7 @@ private void Cleanup() { try { + // close the connection client.Close(); } catch (IOException e) @@ -192,7 +197,7 @@ private void Cleanup() client = null; } } - Packet pack; + Packet pack; while (pendingQueue.TryDequeue(out pack)) ConLossPacket(pack); @@ -242,12 +247,12 @@ private void StartConnect() client = new TcpClient(); client.LingerState = new LingerOption(false, 0); client.NoDelay = true; - //initialized = + Interlocked.Exchange(ref initialized, 0); IsConnectionClosedByServer = false; - //ConnectSocket(addr); + client.Connect(addr); - //initialized = false; + client.GetStream().BeginRead(incomingBuffer, 0, incomingBuffer.Length, ReceiveAsynch, incomingBuffer); PrimeConnection(); } @@ -256,6 +261,16 @@ private void StartConnect() private int currentLen; + /// + /// process the receiving mechanism in asynchronous manner. + /// Zookeeper server sent data in two main parts + /// part(1) -> contain the length of the part(2) + /// part(2) -> contain the interest information + /// + /// Part(2) may deliver in two or more segments so it is important to + /// handle this situation properly + /// + /// The asynchronous result private void ReceiveAsynch(IAsyncResult ar) { if (Interlocked.CompareExchange(ref isDisposed, 0, 0) == 1) @@ -264,37 +279,43 @@ private void ReceiveAsynch(IAsyncResult ar) try { len = client.GetStream().EndRead(ar); - if (len == 0) //server closed the connection - { + if (len == 0) //server closed the connection... + { zooKeeper.State = ZooKeeper.States.CLOSED; IsConnectionClosedByServer = true; return; } byte[] bData = (byte[])ar.AsyncState; - recvCount++; - if (bData == incomingBuffer) - { + + if (bData == incomingBuffer) // if bData is incoming then surely it is a length information + { currentLen = 0; juteBuffer = null; + // get the length information from the stream juteBuffer = new byte[ReadLength(bData)]; + // try getting other info from the stream client.GetStream().BeginRead(juteBuffer, 0, juteBuffer.Length, ReceiveAsynch, juteBuffer); } - else + else // not an incoming buffer then it is surely a zookeeper process information { if (Interlocked.CompareExchange(ref initialized,1,0) == 0) { + // haven't been initialized so read the authentication negotiation result ReadConnectResult(bData); + // reading length information client.GetStream().BeginRead(incomingBuffer, 0, incomingBuffer.Length, ReceiveAsynch, incomingBuffer); } else { currentLen += len; - if (juteBuffer.Length > currentLen) + if (juteBuffer.Length > currentLen) // stream haven't been completed so read any left bytes client.GetStream().BeginRead(juteBuffer, currentLen, juteBuffer.Length - currentLen, ReceiveAsynch, juteBuffer); else { + // stream is complete so read the response ReadResponse(bData); + // everything is fine, now read the stream again for length information client.GetStream().BeginRead(incomingBuffer, 0, incomingBuffer.Length, ReceiveAsynch, incomingBuffer); } } @@ -306,25 +327,6 @@ private void ReceiveAsynch(IAsyncResult ar) } } - //private void ConnectAsynch(IAsyncResult ar) - //{ - // client.EndConnect(ar); - // ManualResetEvent evt = (ManualResetEvent)ar.AsyncState; - // evt.Set(); - //} - - //private void ConnectSocket(IPEndPoint addr) - //{ - // client.Connect(addr); - //using (ManualResetEvent socketConnectTimeout = new ManualResetEvent(false)) - //{ - // client.BeginConnect(addr.Address, addr.Port, ConnectAsynch, socketConnectTimeout); - // if (socketConnectTimeout.WaitOne(conn.connectTimeout)) - // return; - // throw new InvalidOperationException(string.Format("Could not make socket connection to {0}:{1}", addr.Address, addr.Port)); - //} - //} - private void PrimeConnection() { LOG.InfoFormat("Socket connection established to {0}, initiating session", client.Client.RemoteEndPoint); @@ -336,11 +338,11 @@ private void PrimeConnection() using (EndianBinaryWriter writer = new EndianBinaryWriter(EndianBitConverter.Big, ms, Encoding.UTF8)) { BinaryOutputArchive boa = BinaryOutputArchive.getArchive(writer); - boa.WriteInt(-1, "len"); + boa.WriteInt(-1, "len"); // we'll fill this latter conReq.Serialize(boa, "connect"); ms.Position = 0; - int len = Convert.ToInt32(ms.Length); - writer.Write(len - 4); + int len = Convert.ToInt32(ms.Length); // now we have the real length + writer.Write(len - 4); // write the length info buffer = ms.ToArray(); } outgoingQueue.Enqueue((new Packet(null, null, null, null, buffer, null, null, null))); @@ -368,15 +370,16 @@ private void SendPing() RequestHeader h = new RequestHeader(-2, (int)OpCode.Ping); conn.QueuePacket(h, null, null, null, null, null, null, null, null); } - - // send packet to server - // there's posibility when server closed the socket and client try to send some packet, when this happen it will throw exception - // the exception is either IOException, NullReferenceException and/or ObjectDisposedException - // so it is mandatory to catch these excepetions + + /// + /// send packet to server + /// there's posibility when server closed the socket and client try to send some packet, when this happen it will throw exception + /// the exception is either IOException, NullReferenceException and/or ObjectDisposedException + /// so it is mandatory to catch these excepetions + /// + /// The packet to send private void DoSend(Packet packet) { - //if (client == null) - // throw new IOException("Socket is null!"); if (packet.header != null && packet.header.Type != (int)OpCode.Ping && packet.header.Type != (int)OpCode.Auth) @@ -411,6 +414,7 @@ private void ReadConnectResult(byte[] content) throw new SessionExpiredException(new StringBuilder().AppendFormat("Unable to reconnect to ZooKeeper service, session 0x{0:X} has expired", conn.SessionId).ToString()); } conn.readTimeout = new TimeSpan(0, 0, 0, 0, negotiatedSessionTimeout * 2 / 3); + // commented...we haven't need this information yet... //conn.connectTimeout = new TimeSpan(0, 0, 0, negotiatedSessionTimeout / conn.serverAddrs.Count); conn.SessionId = conRsp.SessionId; conn.SessionPassword = conRsp.Passwd; @@ -457,7 +461,7 @@ private void ReadResponse(byte[] content) { string serverPath = @event.Path; if (serverPath.CompareTo(conn.ChrootPath) == 0) - @event.Path = "/"; + @event.Path = PathUtils.PathSeparator; else @event.Path = serverPath.Substring(conn.ChrootPath.Length); } @@ -527,7 +531,6 @@ private static void FinishPacket(Packet p) p.watchRegistration.Register(p.replyHeader.Err); p.Finished = true; - //conn.consumer.QueuePacket(p); } private int isDisposed = 0; @@ -536,9 +539,7 @@ private void InternalDispose() if (Interlocked.CompareExchange(ref isDisposed, 1, 0) == 0) { zooKeeper.State = ZooKeeper.States.CLOSED; - //queueEvent.Set(); requestThread.Join(); - //queueEvent.Dispose(); incomingBuffer = juteBuffer = null; } } diff --git a/src/dotnet/ZooKeeperNet/DataTree.cs b/src/dotnet/ZooKeeperNet/DataTree.cs index 7ef7de39305..3fabd47a840 100644 --- a/src/dotnet/ZooKeeperNet/DataTree.cs +++ b/src/dotnet/ZooKeeperNet/DataTree.cs @@ -36,10 +36,7 @@ public class DataTree //private ZKWatchManager dataWatches = new ZKWatchManager(); //private ZKWatchManager childWatches = new ZKWatchManager(); - - /** the root of zookeeper tree */ - //private static string rootZookeeper = "/"; - + /** the zookeeper nodes that acts as the management and status node **/ //private static string procZookeeper = Quotas.procZookeeper; diff --git a/src/dotnet/ZooKeeperNet/IO/EndianBinaryReader.cs b/src/dotnet/ZooKeeperNet/IO/EndianBinaryReader.cs index 788fe99b983..58538b7bf73 100644 --- a/src/dotnet/ZooKeeperNet/IO/EndianBinaryReader.cs +++ b/src/dotnet/ZooKeeperNet/IO/EndianBinaryReader.cs @@ -445,7 +445,7 @@ public byte[] ReadBytes(int count) //byte[] copy = new byte[index]; //Buffer.BlockCopy(ret, 0, copy, 0, index); //return copy; - Array.Resize(ref ret, index); + Array.Resize(ref ret, index); // change to array resize...simpler way return ret; } index += read; diff --git a/src/dotnet/ZooKeeperNet/Packet.cs b/src/dotnet/ZooKeeperNet/Packet.cs index 5df63cd499d..fe5a9459e1c 100644 --- a/src/dotnet/ZooKeeperNet/Packet.cs +++ b/src/dotnet/ZooKeeperNet/Packet.cs @@ -71,8 +71,8 @@ internal Packet(RequestHeader header, ReplyHeader replyHeader, IRecord request, request.Serialize(boa, "request"); } ms.Position = 0; - int len = Convert.ToInt32(ms.Length); - writer.Write(len - 4); + int len = Convert.ToInt32(ms.Length); // now we have the real length + writer.Write(len - 4); // update the length info this.data = ms.ToArray(); } } diff --git a/src/dotnet/ZooKeeperNet/PathUtils.cs b/src/dotnet/ZooKeeperNet/PathUtils.cs index a5ec67c4268..bfd06df9ae4 100644 --- a/src/dotnet/ZooKeeperNet/PathUtils.cs +++ b/src/dotnet/ZooKeeperNet/PathUtils.cs @@ -22,12 +22,23 @@ namespace ZooKeeperNet { public static class PathUtils { + /// + /// Path Separator string ("/") + /// + public const string PathSeparator = "/"; + /// + /// Path Separator char ('/') + /// + public const char PathSeparatorChar = '/'; + private const char PathDotChar = '.'; + + /** validate the provided znode path string * @param path znode path string * @param isSequential if the path is being created * with a sequential flag * @throws IllegalArgumentException if the path is invalid - */ + */ public static void ValidatePath(string path, bool isSequential) { ValidatePath(isSequential ? new StringBuilder(path).Append("1").ToString() : path); @@ -37,7 +48,7 @@ public static void ValidatePath(string path, bool isSequential) * Validate the provided znode path string * @param path znode path string * @throws IllegalArgumentException if the path is invalid - */ + **/ public static void ValidatePath(string path) { if (path == null) @@ -48,7 +59,7 @@ public static void ValidatePath(string path) { throw new InvalidOperationException("Path length must be > 0"); } - if (path[0] != '/') + if (path[0] != PathSeparatorChar) { throw new InvalidOperationException( "Path must start with / character"); @@ -57,14 +68,14 @@ public static void ValidatePath(string path) { // done checking - it's the root return; } - if (path[path.Length - 1] == '/') + if (path[path.Length - 1] == PathSeparatorChar) { throw new InvalidOperationException( "Path must not end with / character"); } string reason = null; - char lastc = '/'; + char lastc = PathSeparatorChar; char[] chars = path.ToCharArray(); char c; for (int i = 1; i < chars.Length; lastc = chars[i], i++) @@ -76,26 +87,26 @@ public static void ValidatePath(string path) reason = new StringBuilder("null character not allowed @").Append(i).ToString(); break; } - else if (c == '/' && lastc == '/') + else if (c == PathSeparatorChar && lastc == PathSeparatorChar) { reason = new StringBuilder("empty node name specified @").Append(i).ToString(); break; } - else if (c == '.' && lastc == '.') + else if (c == PathDotChar && lastc == PathDotChar) { - if (chars[i - 2] == '/' && + if (chars[i - 2] == PathSeparatorChar && ((i + 1 == chars.Length) - || chars[i + 1] == '/')) + || chars[i + 1] == PathSeparatorChar)) { reason = new StringBuilder("relative paths not allowed @").Append(i).ToString(); break; } } - else if (c == '.') + else if (c == PathDotChar) { - if (chars[i - 1] == '/' && + if (chars[i - 1] == PathSeparatorChar && ((i + 1 == chars.Length) - || chars[i + 1] == '/')) + || chars[i + 1] == PathSeparatorChar)) { reason = new StringBuilder("relative paths not allowed @").Append(i).ToString(); break; diff --git a/src/dotnet/ZooKeeperNet/Quotas.cs b/src/dotnet/ZooKeeperNet/Quotas.cs index 234ccd7d9e8..579b79b141b 100644 --- a/src/dotnet/ZooKeeperNet/Quotas.cs +++ b/src/dotnet/ZooKeeperNet/Quotas.cs @@ -50,7 +50,7 @@ public static string QuotaPath(string path) { StringBuilder builder = new StringBuilder(quotaZookeeper) .Append(path) - .Append("/") + .Append(PathUtils.PathSeparator) .Append(limitNode); return builder.ToString(); } @@ -65,7 +65,7 @@ public static string StatPath(string path) { StringBuilder builder = new StringBuilder(quotaZookeeper) .Append(path) - .Append("/") + .Append(PathUtils.PathSeparator) .Append(statNode); return builder.ToString(); } diff --git a/src/dotnet/ZooKeeperNet/ZooKeeper.cs b/src/dotnet/ZooKeeperNet/ZooKeeper.cs index cf27b961912..7d6b807fb70 100644 --- a/src/dotnet/ZooKeeperNet/ZooKeeper.cs +++ b/src/dotnet/ZooKeeperNet/ZooKeeper.cs @@ -208,8 +208,8 @@ public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; - if (obj.GetType() != typeof(States)) return false; - return Equals((States)obj); + //if (obj.GetType() != typeof(States)) return false; // don't need this + return Equals((States)obj); // when casting to States, any non-States object will be null } public override int GetHashCode() @@ -350,12 +350,15 @@ public void AddAuthInfo(string scheme, byte[] auth) /// specified during construction). /// /// The watcher. - //[MethodImpl(MethodImplOptions.Synchronized)] - public void Register(IWatcher watcher) + public void Register(IWatcher watcher) // the defaultwatcher is already a full fenced so we don't need to mark the method synchronized { watchManager.DefaultWatcher = watcher; } + /// + /// The State of ZooKeeper connection + /// Thread safe + /// public States State { get @@ -493,10 +496,6 @@ public string Create(string path, byte[] data, IEnumerable acl, CreateMode h.Type = (int)OpCode.Create; CreateRequest request = new CreateRequest(serverPath,data,acl,createMode.Flag); CreateResponse response = new CreateResponse(); - //request.Data = data; - //request.Flags = createMode.Flag; - //request.Path = serverPath; - //request.Acl = acl; ReplyHeader r = cnxn.SubmitRequest(h, request, response, null); if (r.Err != 0) { @@ -535,7 +534,7 @@ public void Delete(string path, int version) // maintain semantics even in chroot case // specifically - root cannot be deleted // I think this makes sense even in chroot case. - if (clientPath.Equals("/")) + if (clientPath.Equals(PathUtils.PathSeparator)) { // a bit of a hack, but delete(/) will never succeed and ensures // that the same semantics are maintained @@ -549,8 +548,6 @@ public void Delete(string path, int version) RequestHeader h = new RequestHeader(); h.Type = (int)OpCode.Delete; DeleteRequest request = new DeleteRequest(serverPath,version); - //request.Path = serverPath; - //request.Version = version; ReplyHeader r = cnxn.SubmitRequest(h, request, null, null); if (r.Err != 0) { @@ -587,8 +584,6 @@ public Stat Exists(string path, IWatcher watcher) RequestHeader h = new RequestHeader(); h.Type = (int)OpCode.Exists; ExistsRequest request = new ExistsRequest(serverPath, watcher != null); - //request.Path = serverPath; - //request.Watch = watcher != null; SetDataResponse response = new SetDataResponse(); ReplyHeader r = cnxn.SubmitRequest(h, request, response, wcb); if (r.Err != 0) @@ -660,8 +655,6 @@ public byte[] GetData(string path, IWatcher watcher, Stat stat) RequestHeader h = new RequestHeader(); h.Type = (int)OpCode.GetData; GetDataRequest request = new GetDataRequest(serverPath, watcher != null); - //request.Path = serverPath; - //request.Watch = watcher != null; GetDataResponse response = new GetDataResponse(); ReplyHeader r = cnxn.SubmitRequest(h, request, response, wcb); if (r.Err != 0) @@ -734,9 +727,6 @@ public Stat SetData(string path, byte[] data, int version) RequestHeader h = new RequestHeader(); h.Type = (int)OpCode.SetData; SetDataRequest request = new SetDataRequest(serverPath,data,version); - //request.Path = serverPath; - //request.Data = data; - //request.Version = version; SetDataResponse response = new SetDataResponse(); ReplyHeader r = cnxn.SubmitRequest(h, request, response, null); if (r.Err != 0) @@ -770,7 +760,6 @@ public IEnumerable GetACL(string path, Stat stat) RequestHeader h = new RequestHeader(); h.Type = (int)OpCode.GetACL; GetACLRequest request = new GetACLRequest(serverPath); - //request.Path = serverPath; GetACLResponse response = new GetACLResponse(); ReplyHeader r = cnxn.SubmitRequest(h, request, response, null); if (r.Err != 0) @@ -814,9 +803,6 @@ public Stat SetACL(string path, IEnumerable acl, int version) RequestHeader h = new RequestHeader(); h.Type = (int)OpCode.SetACL; SetACLRequest request = new SetACLRequest(serverPath,acl,version); - //request.Path = serverPath; - //request.Acl = acl; - //request.Version = version; SetACLResponse response = new SetACLResponse(); ReplyHeader r = cnxn.SubmitRequest(h, request, response, null); if (r.Err != 0) @@ -863,8 +849,6 @@ public IEnumerable GetChildren(string path, IWatcher watcher) RequestHeader h = new RequestHeader(); h.Type = (int)OpCode.GetChildren2; GetChildren2Request request = new GetChildren2Request(serverPath, watcher != null); - //request.Path = serverPath; - //request.Watch = watcher != null; GetChildren2Response response = new GetChildren2Response(); ReplyHeader r = cnxn.SubmitRequest(h, request, response, wcb); if (r.Err != 0) @@ -920,8 +904,6 @@ public IEnumerable GetChildren(string path, IWatcher watcher, Stat stat) RequestHeader h = new RequestHeader(); h.Type = (int)OpCode.GetChildren2; GetChildren2Request request = new GetChildren2Request(serverPath, watcher != null); - //request.Path = serverPath; - //request.Watch = watcher != null; GetChildren2Response response = new GetChildren2Response(); ReplyHeader r = cnxn.SubmitRequest(h, request, response, wcb); if (r.Err != 0) diff --git a/src/dotnet/ZooKeeperNet/ZooKeeperEx.cs b/src/dotnet/ZooKeeperNet/ZooKeeperEx.cs index 4bb6fec487f..87939f55135 100644 --- a/src/dotnet/ZooKeeperNet/ZooKeeperEx.cs +++ b/src/dotnet/ZooKeeperNet/ZooKeeperEx.cs @@ -70,7 +70,7 @@ public static IDisposable AcquireWriteLock(this ReaderWriterLockSlim @lock) public static string Combine(this string parent, string child) { StringBuilder builder = new StringBuilder(parent) - .Append("/") + .Append(PathUtils.PathSeparator) .Append(child); return builder.ToString(); }