Exemplo n.º 1
0
        private Task <CalibrateResult> CalibrateAsync(Context context, IQuotaRule rule)
        {
            var operationContext = new OperationContext(context, _token);

            return(operationContext.PerformOperationAsync(
                       Tracer,
                       async() =>
            {
                if (!rule.CanBeCalibrated)
                {
                    return CalibrateResult.CannotCalibrate;
                }

                if (ShouldAbortOperation(context, "Calibrate", out var reason))
                {
                    return new CalibrateResult(reason);
                }

                return await rule.CalibrateAsync();
            }));
Exemplo n.º 2
0
        private Task CalibrateAsync(Context context, IQuotaRule rule)
        {
            var operationContext = new OperationContext(context, _token);

            return(CalibrateCall.RunAsync(_tracer, operationContext, async() =>
            {
                if (!rule.CanBeCalibrated)
                {
                    return CalibrateResult.CannotCalibrate;
                }

                if (_token.IsCancellationRequested)
                {
                    var reason = "Calibrate exiting due to shutdown.";
                    _tracer.Debug(context, reason);
                    return new CalibrateResult(reason);
                }

                var result = await rule.CalibrateAsync();
                _tracer.Debug(context, !result.Succeeded ? result.ErrorMessage : $"New hard limit=[{result.Size}]");

                return result;
            }));
        }
Exemplo n.º 3
0
 /// <inheritdoc />
 internal override bool StopPurging(out string stopReason, out IQuotaRule activeRule)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 4
0
 /// <summary>
 /// Returns true if the purge process should be stopped.
 /// </summary>
 internal abstract bool StopPurging(out string stopReason, out IQuotaRule activeRule);
Exemplo n.º 5
0
 public ForwardingQuotaRule(Func <IQuotaRule> ruleFactory, DisposableDirectory root)
 {
     Rule   = ruleFactory();
     Root   = root;
     _freed = false;
 }
Exemplo n.º 6
0
 /// <nodoc />
 public static bool GetOnlyUnlinked(this IQuotaRule /*Can Be Null*/ rule)
 {
     return(rule?.OnlyUnlinked ?? false);
 }
Exemplo n.º 7
0
 private bool StopPurging(out string stopReason, out IQuotaRule rule) => _quotaKeeper.StopPurging(out stopReason, out rule);