コード例 #1
0
        public static (TestDistributedContentCopier, MockFileCopier) CreateMocks(
            IAbsFileSystem fileSystem,
            AbsolutePath rootDirectory,
            TimeSpan retryInterval,
            int retries = 1,
            MachineLocation[] designatedLocations = null)
        {
            var mockFileCopier   = new MockFileCopier();
            var existenceChecker = new TestFileCopier();
            var contentCopier    = new TestDistributedContentCopier(
                rootDirectory,
                // Need to use exactly one retry.
                new DistributedContentStoreSettings()
            {
                RetryIntervalForCopies = Enumerable.Range(0, retries).Select(r => retryInterval).ToArray(),
                PrioritizeDesignatedLocationsOnCopies = designatedLocations != null,
                TrustedHashFileSizeBoundary           = long.MaxValue // Disable trusted hash because we never actually move bytes and thus the hasher thinks there is a mismatch.
            },
                fileSystem,
                mockFileCopier,
                existenceChecker,
                copyRequester: null,
                new TestDistributedContentCopier.NoOpPathTransformer(rootDirectory),
                designatedLocations);

            return(contentCopier, mockFileCopier);
        }
コード例 #2
0
        public static (TestDistributedContentCopier, MockFileCopier) CreateMocks(
            IAbsFileSystem fileSystem,
            AbsolutePath rootDirectory,
            TimeSpan retryInterval,
            int retries = 1,
            int copyAttemptsWithRestrictedReplicas = 0,
            int restrictedCopyReplicaCount         = 3,
            int maxRetryCount = 32)
        {
            var mockFileCopier = new MockFileCopier();
            var contentCopier  = new TestDistributedContentCopier(
                rootDirectory,
                // Need to use exactly one retry.
                new DistributedContentStoreSettings()
            {
                RetryIntervalForCopies             = Enumerable.Range(0, retries).Select(r => retryInterval).ToArray(),
                CopyAttemptsWithRestrictedReplicas = copyAttemptsWithRestrictedReplicas,
                RestrictedCopyReplicaCount         = restrictedCopyReplicaCount,
                TrustedHashFileSizeBoundary        = long.MaxValue, // Disable trusted hash because we never actually move bytes and thus the hasher thinks there is a mismatch.
                MaxRetryCount = maxRetryCount,
            },
                fileSystem,
                mockFileCopier,
                copyRequester: null);

            return(contentCopier, mockFileCopier);
        }
コード例 #3
0
        private async Task <(DistributedContentCopier <AbsolutePath>, MockFileCopier)> CreateAsync(Context context, AbsolutePath rootDirectory, int retries = 1)
        {
            var mockFileCopier   = new MockFileCopier();
            var existenceChecker = new TestFileCopier();
            var contentCopier    = new DistributedContentCopier <AbsolutePath>(
                rootDirectory,
                // Need to use exactly one retry.
                new DistributedContentStoreSettings()
            {
                RetryIntervalForCopies = Enumerable.Range(0, retries).Select(r => TimeSpan.Zero).ToArray()
            },
                FileSystem,
                mockFileCopier,
                existenceChecker,
                new NoOpPathTransformer(rootDirectory),
                new MockContentLocationStore());
            await contentCopier.StartupAsync(context).ThrowIfFailure();

            return(contentCopier, mockFileCopier);
        }