예제 #1
0
        internal void RemoveFromTracker(
            [DefaultValue((uint)7089), Description("GRPC port")] uint grpcPort)
        {
            Initialize();

            // We need to initialize this here because there's no codepath otherwise.
            GrpcEnvironment.Initialize();

            var context     = new Context(_logger);
            var retryPolicy = RetryPolicyFactory.GetLinearPolicy(ex => ex is ClientCanRetryException, (int)_retryCount, TimeSpan.FromSeconds(_retryIntervalSeconds));

            _logger.Debug("Begin repair handling...");

            // This action is synchronous to make sure the calling application doesn't exit before the method returns.
            using (var rpcClient = new GrpcRepairClient(grpcPort))
            {
                var removeFromTrackerResult = retryPolicy.ExecuteAsync(() => rpcClient.RemoveFromTrackerAsync(context), _cancellationToken).Result;
                if (!removeFromTrackerResult.Succeeded)
                {
                    throw new CacheException(removeFromTrackerResult.ErrorMessage);
                }
                else
                {
                    _logger.Debug($"Repair handling succeeded. Removed {removeFromTrackerResult.Data} hashes from the content tracker.");
                }

                var shutdownResult = rpcClient.ShutdownAsync(context).Result;
                if (!shutdownResult.Succeeded)
                {
                    throw new CacheException(shutdownResult.ErrorMessage);
                }
            }
        }
예제 #2
0
        internal void RemoveFromTracker(
            [DefaultValue((uint)7089), Description("GRPC port")] uint grpcPort)
        {
            Initialize();

            var context     = new Context(_logger);
            var retryPolicy = new RetryPolicy(
                new TransientErrorDetectionStrategy(),
                new FixedInterval("RetryInterval", (int)_retryCount, TimeSpan.FromSeconds(_retryIntervalSeconds), false));

            _logger.Debug("Begin repair handling...");

            // This action is synchronous to make sure the calling application doesn't exit before the method returns.
            using (var rpcClient = new GrpcRepairClient(grpcPort))
            {
                var removeFromTrackerResult = retryPolicy.ExecuteAsync(() => rpcClient.RemoveFromTrackerAsync(context)).Result;
                if (!removeFromTrackerResult.Succeeded)
                {
                    throw new CacheException(removeFromTrackerResult.ErrorMessage);
                }
                else
                {
                    _logger.Debug($"Repair handling succeeded. Removed {removeFromTrackerResult.Data} hashes from the content tracker.");
                }

                var shutdownResult = rpcClient.ShutdownAsync(context).Result;
                if (!shutdownResult.Succeeded)
                {
                    throw new CacheException(shutdownResult.ErrorMessage);
                }
            }
        }
예제 #3
0
        public Task RepairHandlerGetsResponse()
        {
            return(RunServerTestAsync(new Context(Logger), async(context, configuration) =>
            {
                var client = new GrpcRepairClient(configuration.GrpcPort);

                var removeFromTrackerResult = await client.RemoveFromTrackerAsync(context);
                removeFromTrackerResult.ShouldBeError();
                Assert.Equal("Repair handling not enabled.", removeFromTrackerResult.ErrorMessage);

                var sr = await client.ShutdownAsync(context);
                sr.ShouldBeSuccess();
            }));
        }