public ZooKeeperResult <string> Create(string path, byte[] data, CreateMode createMode, bool withProtection = false) { LogCreate(path, data, createMode, withProtection); if (data != null && data.Length > maxDataLength) { LogUnreasonableLength(data.Length); return(new ZooKeeperResult <string>(ZooKeeperStatus.BadArguments, path)); } return(ExecuteOperation( path, () => { var builder = Curator.create(); builder = (CreateBuilder)builder.withMode(org.apache.zookeeper.CreateMode.fromFlag((int)createMode)); // (iloktionov): Для sequential-нод может понадобиться защита от false-negative в виде GUID'а в имени ноды. if (withProtection && (createMode == CreateMode.PersistentSequential || createMode == CreateMode.EphemeralSequential)) { builder = (CreateBuilder)builder.withProtection(); } return (string)builder .creatingParentsIfNeeded() .forPath(path, data ?? new byte[0]); })); }