예제 #1
0
        /// <nodoc />
        public DistributedContentCopier(
            AbsolutePath workingDirectory,
            DistributedContentStoreSettings settings,
            IAbsFileSystem fileSystem,
            IFileCopier <T> fileCopier,
            IFileExistenceChecker <T> fileExistenceChecker,
            IPathTransformer <T> pathTransformer,
            IContentLocationStore contentLocationStore)
        {
            Contract.Requires(settings != null);
            Contract.Requires(settings.ParallelHashingFileSizeBoundary >= -1);

            _settings                   = settings;
            _tempFolderForCopies        = new DisposableDirectory(fileSystem, workingDirectory / "Temp");
            _remoteFileCopier           = fileCopier;
            _remoteFileExistenceChecker = fileExistenceChecker;
            _contentLocationStore       = contentLocationStore;
            _pathTransformer            = pathTransformer;
            _fileSystem                 = fileSystem;

            _workingDirectory = _tempFolderForCopies.Path;

            // TODO: Use hashers from IContentStoreInternal instead?
            _hashers = HashInfoLookup.CreateAll();

            _ioGate         = new SemaphoreSlim(_settings.MaxConcurrentCopyOperations);
            _retryIntervals = settings.RetryIntervalForCopies;
        }
예제 #2
0
        public DistributedContentCopier(
            DistributedContentStoreSettings settings,
            IAbsFileSystem fileSystem,
            IFileCopier <T> fileCopier,
            IFileExistenceChecker <T> fileExistenceChecker,
            IContentCommunicationManager copyRequester,
            IPathTransformer <T> pathTransformer,
            IClock clock)
        {
            Contract.Requires(settings != null);
            Contract.Requires(settings.ParallelHashingFileSizeBoundary >= -1);

            _settings                   = settings;
            _remoteFileCopier           = fileCopier;
            _remoteFileExistenceChecker = fileExistenceChecker;
            _copyRequester              = copyRequester;
            _pathTransformer            = pathTransformer;
            FileSystem                  = fileSystem;
            _clock = clock;

            _ioGate = new SemaphoreSlim(_settings.MaxConcurrentCopyOperations);
            _proactiveCopyIoGate       = new SemaphoreSlim(_settings.MaxConcurrentProactiveCopyOperations);
            _retryIntervals            = settings.RetryIntervalForCopies;
            _maxRetryCount             = settings.MaxRetryCount;
            _timeoutForProactiveCopies = settings.TimeoutForProactiveCopies;
        }
예제 #3
0
 public MetaDataFactory(IPathTransformer pathTransformer
                        , ITagFactory tagFactory
                        )
 {
     this.pathTransformer = pathTransformer;
     this.tagFactory      = tagFactory;
 }
예제 #4
0
        public ConfigurationApplicator(
            IConfigurationProvider configurationProvider,
            IApplicationPathsProvider pathsProvider,
            INotifyIconManager notifyIconManager,
            ISyncthingManager syncthingManager,
            IAutostartProvider autostartProvider,
            IWatchedFolderMonitor watchedFolderMonitor,
            IUpdateManager updateManager,
            IConflictFileWatcher conflictFileWatcher,
            IAlertsManager alertsManager,
            IMeteredNetworkManager meteredNetworkManager,
            IPathTransformer pathTransformer)
        {
            this.configurationProvider = configurationProvider;
            this.configurationProvider.ConfigurationChanged += this.ConfigurationChanged;

            this.pathsProvider         = pathsProvider;
            this.notifyIconManager     = notifyIconManager;
            this.syncthingManager      = syncthingManager;
            this.autostartProvider     = autostartProvider;
            this.watchedFolderMonitor  = watchedFolderMonitor;
            this.updateManager         = updateManager;
            this.conflictFileWatcher   = conflictFileWatcher;
            this.alertsManager         = alertsManager;
            this.meteredNetworkManager = meteredNetworkManager;
            this.pathTransformer       = pathTransformer;

            this.syncthingManager.Folders.FoldersChanged += this.FoldersChanged;
            this.updateManager.VersionIgnored            += this.VersionIgnored;
        }
예제 #5
0
        /// <nodoc />
        public DistributedContentCopier(
            AbsolutePath workingDirectory,
            DistributedContentStoreSettings settings,
            IAbsFileSystem fileSystem,
            IFileCopier <T> fileCopier,
            IFileExistenceChecker <T> fileExistenceChecker,
            ICopyRequester copyRequester,
            IPathTransformer <T> pathTransformer,
            IContentLocationStore contentLocationStore)
        {
            Contract.Requires(settings != null);
            Contract.Requires(settings.ParallelHashingFileSizeBoundary >= -1);

            _settings                   = settings;
            _tempFolderForCopies        = new DisposableDirectory(fileSystem, workingDirectory / "Temp");
            _remoteFileCopier           = fileCopier;
            _remoteFileExistenceChecker = fileExistenceChecker;
            _copyRequester              = copyRequester;
            _contentLocationStore       = contentLocationStore;
            _pathTransformer            = pathTransformer;
            _fileSystem                 = fileSystem;

            _workingDirectory = _tempFolderForCopies.Path;

            _ioGate = new SemaphoreSlim(_settings.MaxConcurrentCopyOperations);
            _proactiveCopyIoGate       = new SemaphoreSlim(_settings.MaxConcurrentProactiveCopyOperations);
            _retryIntervals            = settings.RetryIntervalForCopies;
            _maxRetryCount             = settings.MaxRetryCount;
            _timeoutForPoractiveCopies = settings.TimeoutForProactiveCopies;
        }
        public DirectoryService(IDirectoryInfoFactory directoryInfoFactory
                                , IPathTransformer pathTransformer
                                )
        {
            this.directoryInfoFactory = directoryInfoFactory;
            this.pathTransformer      = pathTransformer;

            this.Self = this;
        }
예제 #7
0
 public DirectoryStructureReplicator(IPathTransformer pathTransformer
                                     , IDirectoryTraverser inputDirectoryTraverser
                                     , string outputPath
                                     )
 {
     this.PathTransformer         = pathTransformer;
     this.InputDirectoryTraverser = inputDirectoryTraverser;
     this.OutputPath = outputPath;
 }
예제 #8
0
 /// <nodoc />
 public DistributedContentStore(
     byte[] localMachineLocation,
     Func <NagleQueue <ContentHash>, DistributedEvictionSettings, ContentStoreSettings, TrimBulkAsync, IContentStore> innerContentStoreFunc,
     IContentLocationStoreFactory contentLocationStoreFactory,
     IFileExistenceChecker <T> fileExistenceChecker,
     IFileCopier <T> fileCopier,
     IPathTransformer <T> pathTransform,
     ICopyRequester copyRequester,
     ReadOnlyDistributedContentSession <T> .ContentAvailabilityGuarantee contentAvailabilityGuarantee,
     AbsolutePath tempFolderForCopies,
     IAbsFileSystem fileSystem,
     int locationStoreBatchSize,
     IReadOnlyList <TimeSpan> retryIntervalForCopies = null,
     PinConfiguration pinConfiguration = null,
     int?replicaCreditInMinutes        = null,
     IClock clock = null,
     bool enableRepairHandling                 = false,
     TimeSpan?contentHashBumpTime              = null,
     bool useTrustedHash                       = false,
     int trustedHashFileSizeBoundary           = -1,
     long parallelHashingFileSizeBoundary      = -1,
     int maxConcurrentCopyOperations           = 512,
     ContentStoreSettings contentStoreSettings = null,
     bool enableProactiveCopy                  = false)
     : this(
         localMachineLocation,
         innerContentStoreFunc,
         contentLocationStoreFactory,
         fileExistenceChecker,
         fileCopier,
         pathTransform,
         copyRequester,
         contentAvailabilityGuarantee,
         tempFolderForCopies,
         fileSystem,
         locationStoreBatchSize,
         new DistributedContentStoreSettings()
 {
     UseTrustedHash = useTrustedHash,
     TrustedHashFileSizeBoundary = trustedHashFileSizeBoundary,
     ParallelHashingFileSizeBoundary = parallelHashingFileSizeBoundary,
     MaxConcurrentCopyOperations = maxConcurrentCopyOperations,
     RetryIntervalForCopies = retryIntervalForCopies,
     PinConfiguration = pinConfiguration,
     EnableProactiveCopy = enableProactiveCopy
 },
         replicaCreditInMinutes,
         clock,
         enableRepairHandling,
         contentHashBumpTime,
         contentStoreSettings)
 {
     // This constructor is used from tests,
     // so we need to complete _postInitializationCompletion when startup is done.
     _setPostInitializationCompletionAfterStartup = true;
 }
예제 #9
0
 public ShortcutEmbryo(IPathTransformer pathTransformer
                       , IFileInfo fileInfo
                       , string inputBasePath
                       , string outputPath
                       )
 {
     this.PathTransformer = pathTransformer;
     this.FileInfo        = fileInfo;
     this.InputBasePath   = inputBasePath;
     this.OutputPath      = outputPath;
 }
 public TestDistributedContentCopier(
     AbsolutePath workingDirectory,
     DistributedContentStoreSettings settings,
     IAbsFileSystem fileSystem,
     IFileCopier <AbsolutePath> fileCopier,
     IFileExistenceChecker <AbsolutePath> fileExistenceChecker,
     IContentCommunicationManager copyRequester,
     IPathTransformer <AbsolutePath> pathTransformer,
     IContentLocationStore contentLocationStore)
     : base(workingDirectory, settings, fileSystem, fileCopier, fileExistenceChecker, copyRequester, pathTransformer, TestSystemClock.Instance, contentLocationStore)
 {
 }
예제 #11
0
        /// <summary>
        /// Initialize new instance of <see cref="MoviebaseApp"/>.
        /// </summary>
        private MoviebaseApp()
        {
            _dal             = new MoviebaseDAL();
            _pathTransformer = new PathTransformer();

            _fileScanner   = new FileScanner();
            _fileAnalyzer  = new FileAnalyzer(new CompositeTitleProvider());
            _fileOrganizer = new FileOrganizer(new FolderCleaner(), _pathTransformer);

            _apiClient = new TMDbClient(GlobalSettings.Default.ApiKey);

            ReloadSettings();
        }
 public TestDistributedContentCopier(
     AbsolutePath workingDirectory,
     DistributedContentStoreSettings settings,
     IAbsFileSystem fileSystem,
     IRemoteFileCopier <AbsolutePath> fileCopier,
     IFileExistenceChecker <AbsolutePath> fileExistenceChecker,
     IContentCommunicationManager copyRequester,
     IPathTransformer <AbsolutePath> pathTransformer)
     : base(settings, fileSystem, fileCopier, fileExistenceChecker, copyRequester, pathTransformer, TestSystemClock.Instance)
 {
     Settings        = settings;
     WorkingFolder   = workingDirectory;
     PathTransformer = pathTransformer as NoOpPathTransformer;
 }
        public MetaData(IPathTransformer pathTransformer
                        , ITag tag
                        , string inputBasePath
                        , string inputFilePath
                        , string outputBasePath
                        )
        {
            this.PathTransformer = pathTransformer;

            this.Tag            = tag;
            this.InputBasePath  = inputBasePath;
            this.InputFilePath  = inputFilePath;
            this.OutputBasePath = outputBasePath;

            this.OutputFilePath = new Lazy <string>(this.CreateOutputFilePath);
        }
예제 #14
0
        public ConfigurationProvider(IApplicationPathsProvider paths, IFilesystemProvider filesystemProvider, IPathTransformer pathTransformer)
        {
            this.paths           = paths;
            this.filesystem      = filesystemProvider;
            this.pathTransformer = pathTransformer;
            this.eventDispatcher = new SynchronizedEventDispatcher(this);

            this.migrations = new Func <XDocument, XDocument>[]
            {
                this.MigrateV1ToV2,
                this.MigrateV2ToV3,
                this.MigrateV3ToV4,
                this.MigrateV4ToV5,
                this.MigrateV5ToV6,
                this.MigrateV6ToV7,
                this.MigrateV7ToV8,
                this.MigrateV8ToV9,
                this.MigrateV9ToV10,
            };
        }
예제 #15
0
        /// <nodoc />
        public DistributedContentStore(
            byte[] localMachineLocation,
            Func <NagleQueue <ContentHash>, DistributedEvictionSettings, ContentStoreSettings, TrimBulkAsync, IContentStore> innerContentStoreFunc,
            IContentLocationStoreFactory contentLocationStoreFactory,
            IFileExistenceChecker <T> fileExistenceChecker,
            IFileCopier <T> fileCopier,
            IPathTransformer <T> pathTransform,
            ICopyRequester copyRequester,
            ReadOnlyDistributedContentSession <T> .ContentAvailabilityGuarantee contentAvailabilityGuarantee,
            AbsolutePath tempFolderForCopies,
            IAbsFileSystem fileSystem,
            int locationStoreBatchSize,
            DistributedContentStoreSettings settings,
            int?replicaCreditInMinutes = null,
            IClock clock = null,
            bool enableRepairHandling    = false,
            TimeSpan?contentHashBumpTime = null,
            ContentStoreSettings contentStoreSettings = null)
        {
            Contract.Requires(settings != null);

            LocalMachineLocation          = new MachineLocation(localMachineLocation);
            _enableRepairHandling         = enableRepairHandling;
            _contentLocationStoreFactory  = contentLocationStoreFactory;
            _contentAvailabilityGuarantee = contentAvailabilityGuarantee;
            _locationStoreBatchSize       = locationStoreBatchSize;

            contentStoreSettings = contentStoreSettings ?? ContentStoreSettings.DefaultSettings;
            _settings            = settings;

            // Queue is created in unstarted state because the eviction function
            // requires the context passed at startup.
            _evictionNagleQueue = NagleQueue <ContentHash> .CreateUnstarted(
                Redis.RedisContentLocationStoreConstants.BatchDegreeOfParallelism,
                Redis.RedisContentLocationStoreConstants.BatchInterval,
                _locationStoreBatchSize);

            _distributedCopierFactory = (contentLocationStore) =>
            {
                return(new DistributedContentCopier <T>(
                           tempFolderForCopies,
                           _settings,
                           fileSystem,
                           fileCopier,
                           fileExistenceChecker,
                           copyRequester,
                           pathTransform,
                           contentLocationStore));
            };

            _enableDistributedEviction = replicaCreditInMinutes != null;
            var distributedEvictionSettings = _enableDistributedEviction ? SetUpDistributedEviction(replicaCreditInMinutes, locationStoreBatchSize) : null;

            var enableTouch = contentHashBumpTime.HasValue;

            if (enableTouch)
            {
                _contentTrackerUpdater = new ContentTrackerUpdater(ScheduleBulkTouch, contentHashBumpTime.Value, clock: clock);
            }

            TrimBulkAsync trimBulkAsync = null;

            InnerContentStore = innerContentStoreFunc(_evictionNagleQueue, distributedEvictionSettings, contentStoreSettings, trimBulkAsync);

            if (settings.PinConfiguration?.UsePinCache == true)
            {
                _pinCache = new PinCache(clock: clock);
            }
        }
예제 #16
0
 /// <summary>
 /// Initialize new instance of <see cref="FileOrganizer"/>.
 /// </summary>
 /// <param name="cleaner">Folder cleaner instance.</param>
 /// <param name="fileNameTransformer">Path tokenizer instance.</param>
 public FileOrganizer(IFolderCleaner cleaner, IPathTransformer fileNameTransformer)
 {
     _cleaner             = cleaner;
     _fileNameTransformer = fileNameTransformer;
 }
예제 #17
0
 public ApplicationPathsProvider(IPathTransformer pathTransformer)
 {
     this.pathTransformer = pathTransformer;
 }