/// <summary>
        /// Create a node with the given path. The node data will be the given data,
        /// and node acl will be the given acl.
        /// </summary>
        /// <param name="path">The path for the node.</param>
        /// <param name="data">The data for the node.</param>
        /// <param name="acl">The acl for the node.</param>
        /// <param name="createMode">specifying whether the node to be created is ephemeral and/or sequential.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">createMode is null</exception>
        public Task <string> Create(string path, byte[] data, Data.ACL[] acl, Data.CreateMode createMode)
        {
            if (createMode == null)
            {
                throw new ArgumentNullException("createMode");
            }

            var clientPath = path;

            Utils.PathUtils.ValidatePath(clientPath, createMode.Sequential);
            var serverPath = Utils.PathUtils.PrependChroot(this._chrootPath, clientPath);

            return(this.ExecuteAsync <string>(base.NextRequestSeqID(), Data.OpCode.Create,
                                              new Data.CreateRequest(serverPath, data, acl, createMode.Flag),
                                              (src, response) =>
            {
                if (response.HasError())
                {
                    src.TrySetException(response.Error(clientPath));
                    return;
                }

                Data.CreateResponse result = null;
                try { result = Utils.Marshaller.Deserialize <Data.CreateResponse>(response.Payload); }
                catch (Exception ex)
                {
                    src.TrySetException(ex);
                    return;
                }

                src.TrySetResult(Utils.PathUtils.RemoveChroot(this._chrootPath, result.Path));
            }));
        }
Exemple #2
0
 public void CreateItem(string path, byte[] data, CreateMode createMode)
 {
     this.client.Create(path, data, IDs.OPEN_ACL_UNSAFE, createMode).Wait();
 }
        public void CreateItem(string path, byte[] data, CreateMode createMode)
        {
            var normalizedPath = ZookeeperPath.Normalize(path);

            this.innerZookeeper.CreateItem(normalizedPath, data, createMode);
        }