/// <summary>Snippet for GenerateConsistencyToken</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GenerateConsistencyToken()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     string name = "projects/[PROJECT]/instances/[INSTANCE]/tables/[TABLE]";
     // Make the request
     GenerateConsistencyTokenResponse response = bigtableTableAdminClient.GenerateConsistencyToken(name);
 }
Beispiel #2
0
 /// <summary>Snippet for GenerateConsistencyToken</summary>
 /// <remarks>
 /// This snippet has been automatically generated for illustrative purposes only.
 /// It may require modifications to work in your environment.
 /// </remarks>
 public void GenerateConsistencyTokenResourceNames()
 {
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     TableName name = TableName.FromProjectInstanceTable("[PROJECT]", "[INSTANCE]", "[TABLE]");
     // Make the request
     GenerateConsistencyTokenResponse response = bigtableTableAdminClient.GenerateConsistencyToken(name);
 }
Beispiel #3
0
 /// <summary>Snippet for GenerateConsistencyToken</summary>
 public void GenerateConsistencyToken()
 {
     // Snippet: GenerateConsistencyToken(TableName,CallSettings)
     // Create client
     BigtableTableAdminClient bigtableTableAdminClient = BigtableTableAdminClient.Create();
     // Initialize request argument(s)
     TableName name = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]");
     // Make the request
     GenerateConsistencyTokenResponse response = bigtableTableAdminClient.GenerateConsistencyToken(name);
     // End snippet
 }
Beispiel #4
0
        /// <summary>Snippet for GenerateConsistencyTokenAsync</summary>
        /// <remarks>
        /// This snippet has been automatically generated for illustrative purposes only.
        /// It may require modifications to work in your environment.
        /// </remarks>
        public async Task GenerateConsistencyTokenRequestObjectAsync()
        {
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            GenerateConsistencyTokenRequest request = new GenerateConsistencyTokenRequest
            {
                TableName = TableName.FromProjectInstanceTable("[PROJECT]", "[INSTANCE]", "[TABLE]"),
            };
            // Make the request
            GenerateConsistencyTokenResponse response = await bigtableTableAdminClient.GenerateConsistencyTokenAsync(request);
        }
Beispiel #5
0
        /// <summary>Snippet for GenerateConsistencyTokenAsync</summary>
        public async Task GenerateConsistencyTokenAsync()
        {
            // Snippet: GenerateConsistencyTokenAsync(TableName,CallSettings)
            // Additional: GenerateConsistencyTokenAsync(TableName,CancellationToken)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            TableName name = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]");
            // Make the request
            GenerateConsistencyTokenResponse response = await bigtableTableAdminClient.GenerateConsistencyTokenAsync(name);

            // End snippet
        }
Beispiel #6
0
        /// <summary>Snippet for GenerateConsistencyTokenAsync</summary>
        public async Task GenerateConsistencyTokenAsync_RequestObject()
        {
            // Snippet: GenerateConsistencyTokenAsync(GenerateConsistencyTokenRequest,CallSettings)
            // Create client
            BigtableTableAdminClient bigtableTableAdminClient = await BigtableTableAdminClient.CreateAsync();

            // Initialize request argument(s)
            GenerateConsistencyTokenRequest request = new GenerateConsistencyTokenRequest
            {
                TableName = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]"),
            };
            // Make the request
            GenerateConsistencyTokenResponse response = await bigtableTableAdminClient.GenerateConsistencyTokenAsync(request);

            // End snippet
        }
Beispiel #7
0
        public async Task GenerateConsistencyTokenAsync2()
        {
            Mock <BigtableTableAdmin.BigtableTableAdminClient> mockGrpcClient = new Mock <BigtableTableAdmin.BigtableTableAdminClient>(MockBehavior.Strict);
            GenerateConsistencyTokenRequest request = new GenerateConsistencyTokenRequest
            {
                TableName = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]"),
            };
            GenerateConsistencyTokenResponse expectedResponse = new GenerateConsistencyTokenResponse
            {
                ConsistencyToken = "consistencyToken-1090516718",
            };

            mockGrpcClient.Setup(x => x.GenerateConsistencyTokenAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <GenerateConsistencyTokenResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            BigtableTableAdminClient         client   = new BigtableTableAdminClientImpl(mockGrpcClient.Object, null);
            GenerateConsistencyTokenResponse response = await client.GenerateConsistencyTokenAsync(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #8
0
        public void GenerateConsistencyToken2()
        {
            Mock <BigtableTableAdmin.BigtableTableAdminClient> mockGrpcClient = new Mock <BigtableTableAdmin.BigtableTableAdminClient>(MockBehavior.Strict);
            GenerateConsistencyTokenRequest request = new GenerateConsistencyTokenRequest
            {
                TableName = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]"),
            };
            GenerateConsistencyTokenResponse expectedResponse = new GenerateConsistencyTokenResponse
            {
                ConsistencyToken = "consistencyToken-1090516718",
            };

            mockGrpcClient.Setup(x => x.GenerateConsistencyToken(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            BigtableTableAdminClient         client   = new BigtableTableAdminClientImpl(mockGrpcClient.Object, null);
            GenerateConsistencyTokenResponse response = client.GenerateConsistencyToken(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Beispiel #9
0
        public async Task CheckConsistencyAsync()
        {
            // TODO: When replication goes to beta or GA, having something cleaner available than what is below.

            // Snippet: CheckConsistencyAsync(TableName,string,CallSettings)
            // Additional: GenerateConsistencyTokenAsync(TableName,CallSettings)
            BigtableTableAdminClient adminClient = await BigtableTableAdminClient.CreateAsync();

            BigtableTableAdminSettings settings   = BigtableTableAdminSettings.GetDefault();
            CallSettings generateSettings         = settings.GenerateConsistencyTokenSettings;
            CallSettings checkConsistencySettings = settings.CheckConsistencySettings;

            // Create a consistency token for the table.
            TableName tableName = new TableName("[PROJECT]", "[INSTANCE]", "[TABLE]");
            GenerateConsistencyTokenResponse generateResponse =
                await adminClient.GenerateConsistencyTokenAsync(tableName, generateSettings);

            string consistencyToken = generateResponse.ConsistencyToken;

            // Check for consistency for 60 seconds at 10 second intervals.
            TimeSpan pollingTimeout  = TimeSpan.FromSeconds(60);
            TimeSpan pollingInterval = TimeSpan.FromSeconds(10);
            CheckConsistencyResponse checkConsistencyResponse =
                await Polling.PollRepeatedlyAsync(
                    deadline => adminClient.CheckConsistencyAsync(
                        tableName,
                        consistencyToken,
                        checkConsistencySettings.WithEarlierDeadline(deadline, settings.Clock)),
                    response => response.Consistent,
                    settings.Clock,
                    settings.Scheduler,
                    new PollSettings(Expiration.FromTimeout(pollingTimeout), pollingInterval),
                    checkConsistencySettings.CancellationToken ?? CancellationToken.None);

            if (checkConsistencyResponse.Consistent)
            {
                // Replication has caught up.
            }
            // End snippet
        }