Example #1
0
        public async Task RunTest(Func <OperationContext, PrioritizedCopyScheduler, Task> func)
        {
            var logger           = TestGlobal.Logger;
            var context          = new Context(logger);
            var operationContext = new OperationContext(context);

            var configuration = new CopySchedulerConfiguration()
            {
                Type = CopySchedulerType.Prioritized,
                PrioritizedCopySchedulerConfiguration = new PrioritizedCopySchedulerConfiguration(),
            };

            var scheduler = (configuration.Create(context) as PrioritizedCopyScheduler) !;

            // NOTE: We do not startup the scheduler here in order to avoid launching the background task that
            // effectively schedules copies. This is done only for testing purposes.
            try
            {
                await func(operationContext, scheduler);
            }
            finally
            {
                // We do shut it down, so that any ongoing copies get cancelled
                await scheduler.ShutdownAsync(context).ShouldBeSuccess();
            }
        }
        private static (OperationContext context, PrioritizedCopyScheduler scheduler) CreateContextAndScheduler(
            PrioritizedCopySchedulerConfiguration prioritizedCopySchedulerConfiguration)
        {
            var logger           = TestGlobal.Logger;
            var context          = new Context(logger);
            var operationContext = new OperationContext(context);

            var configuration = new CopySchedulerConfiguration()
            {
                Type = CopySchedulerType.Prioritized,
                PrioritizedCopySchedulerConfiguration =
                    prioritizedCopySchedulerConfiguration ?? new PrioritizedCopySchedulerConfiguration(),
            };

            var scheduler = (PrioritizedCopyScheduler)configuration.Create(context);

            return(operationContext, scheduler);
        }
Example #3
0
        private static DistributedContentStoreSettings CreateDistributedStoreSettings(
            DistributedCacheServiceArguments arguments,
            RedisMemoizationStoreConfiguration redisContentLocationStoreConfiguration)
        {
            var distributedSettings = arguments.Configuration.DistributedContentSettings;

            PinConfiguration pinConfiguration = new PinConfiguration();

            if (distributedSettings.IsPinBetterEnabled)
            {
                ApplyIfNotNull(distributedSettings.PinMinUnverifiedCount, v => pinConfiguration.PinMinUnverifiedCount = v);
                ApplyIfNotNull(distributedSettings.StartCopyWhenPinMinUnverifiedCountThreshold, v => pinConfiguration.AsyncCopyOnPinThreshold = v);
                ApplyIfNotNull(distributedSettings.AsyncCopyOnPinThreshold, v => pinConfiguration.AsyncCopyOnPinThreshold = v);
                ApplyIfNotNull(distributedSettings.MaxIOOperations, v => pinConfiguration.MaxIOOperations = v);
            }

            var distributedContentStoreSettings = new DistributedContentStoreSettings()
            {
                TrustedHashFileSizeBoundary     = distributedSettings.TrustedHashFileSizeBoundary,
                ParallelHashingFileSizeBoundary = distributedSettings.ParallelHashingFileSizeBoundary,
                PinConfiguration                   = pinConfiguration,
                RetryIntervalForCopies             = distributedSettings.RetryIntervalForCopies,
                BandwidthConfigurations            = FromDistributedSettings(distributedSettings.BandwidthConfigurations),
                MaxRetryCount                      = distributedSettings.MaxRetryCount,
                ProactiveCopyMode                  = (ProactiveCopyMode)Enum.Parse(typeof(ProactiveCopyMode), distributedSettings.ProactiveCopyMode),
                PushProactiveCopies                = distributedSettings.PushProactiveCopies,
                ProactiveCopyOnPut                 = distributedSettings.ProactiveCopyOnPut,
                ProactiveCopyOnPin                 = distributedSettings.ProactiveCopyOnPin,
                ProactiveCopyUsePreferredLocations = distributedSettings.ProactiveCopyUsePreferredLocations,
                ProactiveCopyLocationsThreshold    = distributedSettings.ProactiveCopyLocationsThreshold,
                ProactiveCopyRejectOldContent      = distributedSettings.ProactiveCopyRejectOldContent,
                ReplicaCreditInMinutes             = distributedSettings.IsDistributedEvictionEnabled ? distributedSettings.ReplicaCreditInMinutes : null,
                EnableRepairHandling               = distributedSettings.IsRepairHandlingEnabled,
                LocationStoreBatchSize             = distributedSettings.RedisBatchPageSize,
                RestrictedCopyReplicaCount         = distributedSettings.RestrictedCopyReplicaCount,
                CopyAttemptsWithRestrictedReplicas = distributedSettings.CopyAttemptsWithRestrictedReplicas,
                PeriodicCopyTracingInterval        = TimeSpan.FromMinutes(distributedSettings.PeriodicCopyTracingIntervalMinutes),
                AreBlobsSupported                  = redisContentLocationStoreConfiguration.AreBlobsSupported,
                MaxBlobSize = redisContentLocationStoreConfiguration.MaxBlobSize,
                DelayForProactiveReplication  = TimeSpan.FromSeconds(distributedSettings.ProactiveReplicationDelaySeconds),
                ProactiveReplicationCopyLimit = distributedSettings.ProactiveReplicationCopyLimit,
                EnableProactiveReplication    = distributedSettings.EnableProactiveReplication,
                TraceProactiveCopy            = distributedSettings.TraceProactiveCopy,
                ProactiveCopyGetBulkBatchSize = distributedSettings.ProactiveCopyGetBulkBatchSize,
                ProactiveCopyGetBulkInterval  = TimeSpan.FromSeconds(distributedSettings.ProactiveCopyGetBulkIntervalSeconds),
                ProactiveCopyMaxRetries       = distributedSettings.ProactiveCopyMaxRetries,
            };

            ApplyIfNotNull(distributedSettings.GrpcCopyCompressionSizeThreshold, v => distributedContentStoreSettings.GrpcCopyCompressionSizeThreshold = v);
            ApplyEnumIfNotNull <CopyCompression>(distributedSettings.GrpcCopyCompressionAlgorithm, v => distributedContentStoreSettings.GrpcCopyCompressionAlgorithm = v);

            if (distributedSettings.EnableProactiveReplication && redisContentLocationStoreConfiguration.Checkpoint != null)
            {
                distributedContentStoreSettings.ProactiveReplicationInterval = redisContentLocationStoreConfiguration.Checkpoint.RestoreCheckpointInterval;

                ApplyIfNotNull(
                    distributedSettings.ProactiveReplicationIntervalMinutes,
                    value => distributedContentStoreSettings.ProactiveReplicationInterval = TimeSpan.FromMinutes(value));
            }

            ApplyIfNotNull(distributedSettings.MaximumConcurrentPutAndPlaceFileOperations, v => distributedContentStoreSettings.MaximumConcurrentPutAndPlaceFileOperations = v);

            distributedContentStoreSettings.CopyScheduler = CopySchedulerConfiguration.FromDistributedContentSettings(distributedSettings);
            arguments.Overrides.Override(distributedContentStoreSettings);

            ConfigurationPrinter.TraceConfiguration(distributedContentStoreSettings, arguments.Logger);

            return(distributedContentStoreSettings);
        }