Exemplo n.º 1
0
        private HllResponse SaveHll(string key = null)
        {
            var updateBuilder = new UpdateHll.Builder(DefaultAdds)
                                .WithBucketType(BucketType)
                                .WithBucket(Bucket)
                                .WithTimeout(TimeSpan.FromMilliseconds(20000));

            if (!string.IsNullOrEmpty(key))
            {
                updateBuilder.WithKey(key);
            }

            UpdateHll  cmd  = updateBuilder.Build();
            RiakResult rslt = client.Execute(cmd);

            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);

            HllResponse response = cmd.Response;

            Keys.Add(response.Key);
            Assert.IsNull(response.Context);
            return(response);
        }
Exemplo n.º 2
0
        public void Should_Build_DtUpdateReq_Correctly()
        {
            var updateHllCommandBuilder = new UpdateHll.Builder(DefaultAdds);

            var q1 = new Quorum(1);
            var q2 = new Quorum(2);
            var q3 = new Quorum(3);

            updateHllCommandBuilder
            .WithBucketType(BucketType)
            .WithBucket(Bucket)
            .WithKey(Key)
            .WithW(q3)
            .WithPW(q1)
            .WithDW(q2)
            .WithReturnBody(true)
            .WithTimeout(TimeSpan.FromSeconds(20));

            UpdateHll updateHllCommand = updateHllCommandBuilder.Build();

            DtUpdateReq protobuf = (DtUpdateReq)updateHllCommand.ConstructRequest(false);

            Assert.AreEqual(Encoding.UTF8.GetBytes(BucketType), protobuf.type);
            Assert.AreEqual(Encoding.UTF8.GetBytes(Bucket), protobuf.bucket);
            Assert.AreEqual(Encoding.UTF8.GetBytes(Key), protobuf.key);
            Assert.AreEqual((uint)q3, protobuf.w);
            Assert.AreEqual((uint)q1, protobuf.pw);
            Assert.AreEqual((uint)q2, protobuf.dw);
            Assert.IsTrue(protobuf.return_body);
            Assert.IsFalse(protobuf.include_context);
            Assert.AreEqual(20000, protobuf.timeout);

            HllOp hllOpMsg = protobuf.op.hll_op;

            Assert.AreEqual(DefaultAdds, hllOpMsg.adds);
        }
Exemplo n.º 3
0
        public void Should_Build_DtUpdateReq_Correctly()
        {
            var updateHllCommandBuilder = new UpdateHll.Builder(DefaultAdds);

            var q1 = new Quorum(1);
            var q2 = new Quorum(2);
            var q3 = new Quorum(3);

            updateHllCommandBuilder
                .WithBucketType(BucketType)
                .WithBucket(Bucket)
                .WithKey(Key)
                .WithW(q3)
                .WithPW(q1)
                .WithDW(q2)
                .WithReturnBody(true)
                .WithTimeout(TimeSpan.FromSeconds(20));

            UpdateHll updateHllCommand = updateHllCommandBuilder.Build();

            DtUpdateReq protobuf = (DtUpdateReq)updateHllCommand.ConstructRequest(false);

            Assert.AreEqual(Encoding.UTF8.GetBytes(BucketType), protobuf.type);
            Assert.AreEqual(Encoding.UTF8.GetBytes(Bucket), protobuf.bucket);
            Assert.AreEqual(Encoding.UTF8.GetBytes(Key), protobuf.key);
            Assert.AreEqual((uint)q3, protobuf.w);
            Assert.AreEqual((uint)q1, protobuf.pw);
            Assert.AreEqual((uint)q2, protobuf.dw);
            Assert.IsTrue(protobuf.return_body);
            Assert.IsFalse(protobuf.include_context);
            Assert.AreEqual(20000, protobuf.timeout);

            HllOp hllOpMsg = protobuf.op.hll_op;

            Assert.AreEqual(DefaultAdds, hllOpMsg.adds);
        }
        private HllResponse SaveHll(string key = null)
        {
            var updateBuilder = new UpdateHll.Builder(DefaultAdds)
                .WithBucketType(BucketType)
                .WithBucket(Bucket)
                .WithTimeout(TimeSpan.FromMilliseconds(20000));

            if (!string.IsNullOrEmpty(key))
            {
                updateBuilder.WithKey(key);
            }

            UpdateHll cmd = updateBuilder.Build();
            RiakResult rslt = client.Execute(cmd);
            Assert.IsTrue(rslt.IsSuccess, rslt.ErrorMessage);

            HllResponse response = cmd.Response;
            Keys.Add(response.Key);
            Assert.IsNull(response.Context);
            return response;
        }