Exemple #1
0
        static Task <bool> CheckReplicaAsync(ObserveParams observeParams, ObserveSeqno op, int replicaId)
        {
            var cloned  = (ObserveSeqno)op.Clone();
            var replica = observeParams.VBucket.LocateReplica(replicaId);
            var result  = replica.Send(cloned);

            observeParams.CheckMutationLost(result.Value);
            observeParams.CheckPersisted(result.Value);
            observeParams.CheckReplicated(result.Value);
            return(Task.FromResult(observeParams.IsDurabilityMet()));
        }
        /// <summary>
        /// Checks a replica for durability constraints.
        /// </summary>
        /// <param name="observeParams">The observe parameters.</param>
        /// <param name="op">The op.</param>
        /// <param name="replicaId">The replica identifier.</param>
        /// <returns></returns>
        private bool CheckReplica(ObserveParams observeParams, ObserveSeqno op, int replicaId)
        {
            var cloned  = (ObserveSeqno)op.Clone();
            var replica = observeParams.VBucket.LocateReplica(replicaId);
            var result  = replica.Send(cloned);

            observeParams.CheckMutationLost(result);
            observeParams.CheckPersisted(result);
            observeParams.CheckReplicated(result);
            return(observeParams.IsDurabilityMet());
        }
        private async Task <bool> CheckReplicaAsync(ObserveParams observeParams, int replicaId)
        {
            var op = new ObserveSeqno(observeParams.Token, _clusterController.Transcoder, _timeout);

            observeParams.Operation = op;

            var tcs = new TaskCompletionSource <IOperationResult <ObserveSeqnoResponse> >();

            op.Completed = CallbackFactory.CompletedFuncForRetry(_pending, _clusterController, tcs);
            _pending.TryAdd(op.Opaque, op);

            Log.Debug("checking replica {0} - opaque: {1}", replicaId, op.Opaque);
            var replica = observeParams.VBucket.LocateReplica(replicaId);
            await replica.SendAsync(op).ContinueOnAnyContext();

            var response = await tcs.Task.ContinueOnAnyContext();

            observeParams.CheckMutationLost(response);
            observeParams.CheckPersisted(response);
            observeParams.CheckReplicated(response);
            return(observeParams.IsDurabilityMet());
        }
        static Task<bool> CheckReplicaAsync(ObserveParams observeParams, ObserveSeqno op, int replicaId)
        {
            var cloned = (ObserveSeqno)op.Clone();
            var replica = observeParams.VBucket.LocateReplica(replicaId);
            var result = replica.Send(cloned);

            observeParams.CheckMutationLost(result.Value);
            observeParams.CheckPersisted(result.Value);
            observeParams.CheckReplicated(result.Value);
            return Task.FromResult(observeParams.IsDurabilityMet());
        }
        private async Task<bool> CheckReplicaAsync(ObserveParams observeParams, int replicaId)
        {
            var op = new ObserveSeqno(observeParams.Token, _clusterController.Transcoder, _timeout);
            observeParams.Operation = op;

            var tcs = new TaskCompletionSource<IOperationResult<ObserveSeqnoResponse>>();
            op.Completed = CallbackFactory.CompletedFuncForRetry(_pending, _clusterController, tcs);
            _pending.TryAdd(op.Opaque, op);

            Log.Debug(m => m("checking replica {0} - opaque: {1}", replicaId, op.Opaque));
            var replica = observeParams.VBucket.LocateReplica(replicaId);
            await replica.SendAsync(op).ContinueOnAnyContext();
            var response = await tcs.Task.ContinueOnAnyContext();

            observeParams.CheckMutationLost(response);
            observeParams.CheckPersisted(response);
            observeParams.CheckReplicated(response);
            return observeParams.IsDurabilityMet();
        }
        /// <summary>
        /// Checks a replica for durability constraints.
        /// </summary>
        /// <param name="observeParams">The observe parameters.</param>
        /// <param name="op">The op.</param>
        /// <param name="replicaId">The replica identifier.</param>
        /// <returns></returns>
        private bool CheckReplica(ObserveParams observeParams, ObserveSeqno op, int replicaId)
        {
            var cloned = (ObserveSeqno)op.Clone();
            var replica = observeParams.VBucket.LocateReplica(replicaId);
            var result = replica.Send(cloned);

            observeParams.CheckMutationLost(result);
            observeParams.CheckPersisted(result);
            observeParams.CheckReplicated(result);
            return observeParams.IsDurabilityMet();
        }