示例#1
0
        internal RpbBucketProps ToMessage()
        {
            var message = new RpbBucketProps();

            if (AllowMultiple.HasValue)
            {
                message.allow_mult = AllowMultiple.Value;
            }
            if (NVal.HasValue)
            {
                message.n_val = NVal.Value;
            }
            return(message);
        }
        internal RiakBucketProperties(RpbBucketProps bucketProps)
        {
            NVal          = new NVal(bucketProps.n_val);
            AllowMultiple = bucketProps.allow_mult;
            LastWriteWins = bucketProps.last_write_wins;
            Backend       = bucketProps.backend.FromRiakString();
            NotFoundOk    = bucketProps.notfound_ok;
            BasicQuorum   = bucketProps.basic_quorum;

            HasPrecommit  = bucketProps.has_precommit;
            HasPostcommit = bucketProps.has_postcommit;

            R  = (Quorum)bucketProps.r;
            Rw = (Quorum)bucketProps.rw;
            Dw = (Quorum)bucketProps.dw;
            W  = (Quorum)bucketProps.w;
            Pr = (Quorum)bucketProps.pr;
            Pw = (Quorum)bucketProps.pw;

            LegacySearch = bucketProps.search;

            HasPrecommit  = bucketProps.has_precommit;
            HasPostcommit = bucketProps.has_postcommit;

            var preCommitHooks = bucketProps.precommit;

            if (preCommitHooks.Count > 0)
            {
                PreCommitHooks = preCommitHooks.Select(LoadPreCommitHook).ToList();
            }

            var postCommitHooks = bucketProps.postcommit;

            if (postCommitHooks.Count > 0)
            {
                PostCommitHooks = postCommitHooks.Select(LoadPostCommitHook).ToList();
            }

            ReplicationMode = (RiakConstants.RiakEnterprise.ReplicationMode)bucketProps.repl;

            SearchIndex = bucketProps.search_index.FromRiakString();
            DataType    = bucketProps.datatype.FromRiakString();

            Consistent = bucketProps.consistent;

            if (bucketProps.hll_precisionSpecified)
            {
                HllPrecision = (int)bucketProps.hll_precision;
            }
        }
示例#3
0
        /// <summary>
        /// set bucket properties
        /// </summary>
        /// <param name="bucket"></param>
        /// <param name="properties"></param>
        /// <param name="millisecondsReceiveTimeout"></param>
        /// <param name="asyncState"></param>
        /// <returns></returns>
        public Task SetBucketProperties(string bucket,
                                        RpbBucketProps properties,
                                        int millisecondsReceiveTimeout = 3000,
                                        object asyncState = null)
        {
            var source = new TaskCompletionSource <bool>(asyncState);

            this._socket.Execute <RpbSetBucketReq>(Codes.SetBucketReq, Codes.SetBucketResp,
                                                   new RpbSetBucketReq {
                bucket = bucket.GetBytes(), props = properties
            },
                                                   ex => source.TrySetException(ex),
                                                   () => source.TrySetResult(true),
                                                   millisecondsReceiveTimeout);
            return(source.Task);
        }
        internal RiakBucketProperties(RpbBucketProps bucketProps)
            : this()
        {
            NVal          = bucketProps.n_val;
            AllowMultiple = bucketProps.allow_mult;
            LastWriteWins = bucketProps.last_write_wins;
            Backend       = bucketProps.backend.FromRiakString();
            NotFoundOk    = bucketProps.notfound_ok;
            BasicQuorum   = bucketProps.basic_quorum;

            HasPrecommit  = bucketProps.has_precommit;
            HasPostcommit = bucketProps.has_postcommit;

            RVal  = bucketProps.r;
            RwVal = bucketProps.rw;
            DwVal = bucketProps.dw;
            WVal  = bucketProps.w;
            PrVal = bucketProps.pr;
            PwVal = bucketProps.pw;

            Search = bucketProps.search;

            HasPrecommit  = bucketProps.has_precommit;
            HasPostcommit = bucketProps.has_postcommit;

            var preCommitHooks = bucketProps.precommit;

            if (preCommitHooks.Count > 0)
            {
                PreCommitHooks = preCommitHooks.Select(LoadPreCommitHook).ToList();
            }

            var postCommitHooks = bucketProps.postcommit;

            if (postCommitHooks.Count > 0)
            {
                PostCommitHooks = postCommitHooks.Select(LoadPostCommitHook).ToList();
            }

            ReplicationMode = (RiakConstants.RiakEnterprise.ReplicationMode)bucketProps.repl;
        }
        internal RpbBucketProps ToMessage()
        {
            var message = new RpbBucketProps();

            message.allow_multSpecified = false;
            if (AllowMultiple.HasValue)
            {
                message.allow_mult = AllowMultiple.Value;
            }

            message.n_valSpecified = false;
            if (NVal != null)
            {
                message.n_val = NVal;
            }

            message.last_write_winsSpecified = false;
            if (LastWriteWins.HasValue)
            {
                message.last_write_wins = LastWriteWins.Value;
            }

            message.rSpecified = false;
            if (R != null)
            {
                message.r = R;
            }

            message.rwSpecified = false;
            if (Rw != null)
            {
                message.rw = Rw;
            }

            message.dwSpecified = false;
            if (Dw != null)
            {
                message.dw = Dw;
            }

            message.wSpecified = false;
            if (W != null)
            {
                message.w = W;
            }

            message.prSpecified = false;
            if (Pr != null)
            {
                message.pr = Pr;
            }

            message.pwSpecified = false;
            if (Pw != null)
            {
                message.pw = Pw;
            }

            message.searchSpecified = false;
            if (LegacySearch.HasValue)
            {
                message.search = LegacySearch.Value;
            }

            message.has_precommitSpecified = false;
            if (HasPrecommit.HasValue)
            {
                message.has_precommit = HasPrecommit.Value;
            }

            // Due to the amusing differences between 1.3 and 1.4 we've added
            // this elegant shim to figure out if we should add commit hooks,
            // remove them, or just wander around setting the Search boolean.
            if (addHooks.HasValue)
            {
                if (addHooks.Value)
                {
                    AddPreCommitHook(RiakErlangCommitHook.RiakLegacySearchCommitHook);
                }
                else
                {
                    RemovePreCommitHook(RiakErlangCommitHook.RiakLegacySearchCommitHook);
                }
            }

            if (PreCommitHooks != null)
            {
                PreCommitHooks.ForEach(h =>
                {
                    var hook = h.ToRpbCommitHook();
                    if (!message.precommit.Any(x => Equals(x, hook)))
                    {
                        message.precommit.Add(hook);
                    }
                });
            }

            message.has_postcommitSpecified = false;
            if (HasPostcommit.HasValue)
            {
                message.has_postcommit = HasPostcommit.Value;
            }

            if (PostCommitHooks != null)
            {
                PostCommitHooks.ForEach(h =>
                {
                    var hook = h.ToRpbCommitHook();
                    if (!message.postcommit.Any(x => Equals(x, hook)))
                    {
                        message.postcommit.Add(hook);
                    }
                });
            }

            message.search_indexSpecified = false;
            if (!string.IsNullOrEmpty(SearchIndex))
            {
                message.search_index = SearchIndex.ToRiakString();
            }

            if (HllPrecision.HasValue)
            {
                message.hll_precision = (uint)HllPrecision;
            }

            return(message);
        }
示例#6
0
 internal RiakBucketProperties(RpbBucketProps bucketProps)
     : this()
 {
     AllowMultiple = bucketProps.allow_mult;
     NVal          = bucketProps.n_val;
 }
 internal RiakBucketProperties(RpbBucketProps bucketProps)
     : this()
 {
     AllowMultiple = bucketProps.AllowMultiple;
     NVal          = bucketProps.NVal;
 }
        internal RpbBucketProps ToMessage()
        {
            var message = new RpbBucketProps();

            if (AllowMultiple.HasValue)
            {
                message.allow_mult = AllowMultiple.Value;
            }

            if (NVal.HasValue)
            {
                message.n_val = NVal.Value;
            }

            if (LastWriteWins.HasValue)
            {
                message.last_write_wins = LastWriteWins.Value;
            }

            if (RVal.HasValue)
            {
                message.r = RVal.Value;
            }

            if (RwVal.HasValue)
            {
                message.rw = RwVal.Value;
            }

            if (DwVal.HasValue)
            {
                message.dw = DwVal.Value;
            }

            if (WVal.HasValue)
            {
                message.w = WVal.Value;
            }

            if (PrVal.HasValue)
            {
                message.pr = PrVal.Value;
            }

            if (PwVal.HasValue)
            {
                message.pw = PwVal.Value;
            }

            if (Search.HasValue)
            {
                message.search = Search.Value;
            }

            if (HasPrecommit.HasValue)
            {
                message.has_precommit = HasPrecommit.Value;
            }

            // Due to the amusing differences between 1.3 and 1.4 we've added
            // this elegant shim to figure out if we should add commit hooks,
            // remove them, or just wander around setting the Search boolean.
            if (_addHooks.HasValue)
            {
                if (_addHooks.Value)
                {
                    AddPreCommitHook(RiakErlangCommitHook.RiakSearchCommitHook);
                }
                else
                {
                    RemovePreCommitHook(RiakErlangCommitHook.RiakSearchCommitHook);
                }
            }

            if (PreCommitHooks != null)
            {
                PreCommitHooks.ForEach(h =>
                {
                    var hook = h.ToRpbCommitHook();
                    if (!message.precommit.Any(x => Equals(x, hook)))
                    {
                        message.precommit.Add(hook);
                    }
                });
            }

            if (HasPostcommit.HasValue)
            {
                message.has_postcommit = HasPostcommit.Value;
            }

            if (PostCommitHooks != null)
            {
                PostCommitHooks.ForEach(h =>
                {
                    var hook = h.ToRpbCommitHook();
                    if (!message.postcommit.Any(x => Equals(x, hook)))
                    {
                        message.postcommit.Add(hook);
                    }
                });
            }

            return(message);
        }