public async Task CloudQueueClientGetServiceStatsAsync()
        {
            AssertSecondaryEndpoint();

            CloudQueueClient client = GenerateCloudQueueClient();

            client.DefaultRequestOptions.LocationMode = LocationMode.SecondaryOnly;
            TestHelper.VerifyServiceStats(await client.GetServiceStatsAsync());
        }
Пример #2
0
        public void CloudQueueClientGetServiceStatsAsync()
        {
            AssertSecondaryEndpoint();

            CloudQueueClient client = GenerateCloudQueueClient();

            client.LocationMode = LocationMode.SecondaryOnly;
            TestHelper.VerifyServiceStats(client.GetServiceStatsAsync().Result);
        }
        public void CloudQueueClientGetServiceStatsInvalidLocAsync()
        {
            CloudQueueClient client = GenerateCloudQueueClient();

            client.DefaultRequestOptions.LocationMode = LocationMode.PrimaryOnly;
            try
            {
                client.GetServiceStatsAsync();
                Assert.Fail("GetServiceStats should fail and throw an InvalidOperationException.");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(InvalidOperationException));
            }
        }
        /// <summary>
        /// Retrieve statistics related to replication for the Table service
        /// </summary>
        /// <param name="queueClient"></param>
        private static async Task ServiceStatsSample(CloudQueueClient queueClient)
        {
            Console.WriteLine();

            var originalLocation = queueClient.DefaultRequestOptions.LocationMode;

            Console.WriteLine("Service stats:");
            try
            {
                queueClient.DefaultRequestOptions.LocationMode = LocationMode.SecondaryOnly;
                ServiceStats stats = await queueClient.GetServiceStatsAsync();
                Console.WriteLine("    Last sync time: {0}", stats.GeoReplication.LastSyncTime);
                Console.WriteLine("    Status: {0}", stats.GeoReplication.Status);
            }
            catch (StorageException)
            {
                // only works on RA-GRS (Read Access – Geo Redundant Storage)
            }
            finally
            {
                // Restore original value
                queueClient.DefaultRequestOptions.LocationMode = originalLocation;
            }

            Console.WriteLine();
        }