Пример #1
0
 public string Create(string path, byte[] data, CreateMode mode) 
 {
     return this._zk.Create(path, data, Ids.OPEN_ACL_UNSAFE, mode);
 }
        /// <summary>
        /// Creates znode using given create mode for given path and writes given data to it
        /// </summary>
        /// <param name="path">
        /// The given path.
        /// </param>
        /// <param name="data">
        /// The data to write.
        /// </param>
        /// <param name="mode">
        /// The create mode.
        /// </param>
        /// <returns>
        /// The created znode's path
        /// </returns>
        public string Create(string path, byte[] data, CreateMode mode)
        {
            Guard.NotNullNorEmpty(path, "path");

            this.EnsuresNotDisposedAndNotNull();
            var result = this._zkclient.Create(path, data, Ids.OPEN_ACL_UNSAFE, mode);
            return result;
        }
Пример #3
0
        /// <summary>
        /// Creates znode using given create mode for given path and writes given data to it
        /// </summary>
        /// <param name="path">
        /// The given path.
        /// </param>
        /// <param name="data">
        /// The data to write.
        /// </param>
        /// <param name="mode">
        /// The create mode.
        /// </param>
        /// <returns>
        /// The created znode's path
        /// </returns>
        public string Create(string path, byte[] data, CreateMode mode)
        {
            Guard.Assert<ArgumentException>(() => !string.IsNullOrEmpty(path));

            this.EnsuresNotDisposed();
            return this.Client.Create(path, data, Ids.OPEN_ACL_UNSAFE, mode);
        }
Пример #4
0
 public Task <string> CreateAsync(string path, byte[] data, IEnumerable <ACL> acl, CreateMode createMode)
 {
     return(CreateAsyncInternal(path, data, acl, createMode, sync: false));
 }
Пример #5
0
 public string Create(string path, byte[] data, IEnumerable <ACL> acl, CreateMode createMode)
 {
     return(CreateAsyncInternal(path, data, acl, createMode, sync: true).GetAwaiter().GetResult());
 }
Пример #6
0
        private async Task <string> CreateAsyncInternal(string path, byte[] data, IEnumerable <ACL> acl, CreateMode createMode, bool sync)
        {
            string clientPath = path;

            PathUtils.ValidatePath(clientPath, createMode.Sequential);
            if (acl != null && acl.Count() == 0)
            {
                throw new KeeperException.InvalidACLException();
            }

            string serverPath = PrependChroot(clientPath);

            RequestHeader h = new RequestHeader();

            h.Type = (int)OpCode.Create;
            CreateRequest  request  = new CreateRequest(serverPath, data, acl, createMode.Flag);
            CreateResponse response = new CreateResponse();
            ReplyHeader    r        = sync ? cnxn.SubmitRequest(h, request, response, null)
                : await cnxn.SubmitRequestAsync(h, request, response, null).ConfigureAwait(false);

            if (r.Err != 0)
            {
                throw KeeperException.Create((KeeperException.Code)Enum.ToObject(typeof(KeeperException.Code), r.Err), clientPath);
            }
            return(cnxn.ChrootPath == null ? response.Path : response.Path.Substring(cnxn.ChrootPath.Length));
        }
Пример #7
0
        /// <summary>
        /// Creates znode using given create mode for given path and writes given data to it
        /// </summary>
        /// <param name="path">
        /// The given path.
        /// </param>
        /// <param name="data">
        /// The data to write.
        /// </param>
        /// <param name="mode">
        /// The create mode.
        /// </param>
        /// <returns>
        /// The created znode's path
        /// </returns>
        public string Create(string path, byte[] data, CreateMode mode)
        {
            Guard.NotNullNorEmpty(path, "path");

            this.EnsuresNotDisposed();
            return this.Client.Create(path, data, Ids.OPEN_ACL_UNSAFE, mode);
        }