Exemplo n.º 1
0
        public void CreateClientWithEmptyOptions()
        {
            GoogleCredential credential = GoogleCredential.GetApplicationDefault();

            invoker = new GcpCallInvoker(Target, credential.ToChannelCredentials());
            client  = new Bigtable.BigtableClient(invoker);

            MutateRowRequest mutateRowRequest = new MutateRowRequest
            {
                TableName = TableName,
                RowKey    = ByteString.CopyFromUtf8(RowKey)
            };

            Mutation mutation = new Mutation
            {
                SetCell = new Mutation.Types.SetCell
                {
                    FamilyName      = ColumnFamily,
                    ColumnQualifier = ByteString.CopyFromUtf8(ColumnQualifier),
                    Value           = ByteString.CopyFromUtf8(TestValue),
                }
            };

            mutateRowRequest.Mutations.Add(mutation);

            client.MutateRow(mutateRowRequest);
            Assert.AreEqual(1, invoker.GetChannelRefsForTest().Count);
        }
Exemplo n.º 2
0
        private void AssertNoAffinity(GcpCallInvoker invoker)
        {
            var channelRefs = invoker.GetChannelRefsForTest();

            Assert.AreEqual(0, channelRefs.Sum(cr => cr.AffinityCount));
            Assert.AreEqual(0, invoker.GetChannelRefsByAffinityKeyForTest().Count);
        }
Exemplo n.º 3
0
        public void CreateSessionWithNewChannel()
        {
            IList <AsyncUnaryCall <Session> > calls = new List <AsyncUnaryCall <Session> >();

            for (int i = 0; i < DefaultMaxChannelsPerTarget; i++)
            {
                var call = client.CreateSessionAsync(
                    new CreateSessionRequest {
                    Database = DatabaseUrl
                });
                calls.Add(call);
                Assert.AreEqual(i + 1, invoker.GetChannelRefsForTest().Count);
            }
            for (int i = 0; i < calls.Count; i++)
            {
                client.DeleteSession(
                    new DeleteSessionRequest {
                    Name = calls[i].ResponseAsync.Result.Name
                });
            }

            calls.Clear();

            for (int i = 0; i < DefaultMaxChannelsPerTarget; i++)
            {
                var call = client.CreateSessionAsync(
                    new CreateSessionRequest {
                    Database = DatabaseUrl
                });
                calls.Add(call);
                Assert.AreEqual(DefaultMaxChannelsPerTarget, invoker.GetChannelRefsForTest().Count);
            }
            for (int i = 0; i < calls.Count; i++)
            {
                client.DeleteSession(
                    new DeleteSessionRequest {
                    Name = calls[i].ResponseAsync.Result.Name
                });
            }
        }
Exemplo n.º 4
0
        private void AssertNoActiveStreams(GcpCallInvoker invoker)
        {
            var channelRefs = invoker.GetChannelRefsForTest();

            Assert.AreEqual(0, channelRefs.Sum(cr => cr.ActiveStreamCount));
        }
Exemplo n.º 5
0
        public void MutateRow()
        {
            MutateRowRequest mutateRowRequest = new MutateRowRequest
            {
                TableName = TableName,
                RowKey    = ByteString.CopyFromUtf8(RowKey)
            };

            Mutation mutation = new Mutation
            {
                SetCell = new Mutation.Types.SetCell
                {
                    FamilyName      = ColumnFamily,
                    ColumnQualifier = ByteString.CopyFromUtf8(ColumnQualifier),
                    Value           = ByteString.CopyFromUtf8(TestValue),
                }
            };

            mutateRowRequest.Mutations.Add(mutation);

            client.MutateRow(mutateRowRequest);
            Assert.AreEqual(1, invoker.GetChannelRefsForTest().Count);
        }