public DiagnosticController(IContentItemRepository repository, IHost host, IDefinitionManager definitions,
            ILinkGenerator linkGenerator, IUrlParser parser, DatabaseSection config, IFlushable flushable, IReplicationStorage repstore, 
            IFileSystemFactory fileSystemFactory)
        {
            _repository = repository;
            _host = host;
            _definitions = definitions;
            _linkGenerator = linkGenerator;
            _parser = parser;
            _flushable = flushable;
            _tablePrefix = config.TablePrefix;

            _repstore = repstore;

            if (_forceWriteLockManager != null) return;

            // Create Force Write Lock Manager
            var storageConfig = (FileSystemNamespace) Enum.Parse(typeof (FileSystemNamespace),
                ConfigurationManager.AppSettings["AzureReplicationStorageContainerName"] ??
                "ReplicationStorageDebug");

            var fileSystem = fileSystemFactory.Create(storageConfig);
            _forceWriteLockManager = new ReplicationForceWriteLockManager(fileSystem);
            _writeLockManager = new ReplicationWriteLockManager(fileSystem);
        }
        public ReplicationManager(
            IPersister persister,
            IItemFinder finder,
            IReplicationStorage repstore,
            IFileSystemFactory fileSystemFactory,
            DatabaseSection dataBaseSection,
            ISecurityManager security,
            IIndexer indexer,    // optional
            IFlushable flushable // optional
            )
        {
            _repstore  = repstore;
            _security  = security;
            _persister = persister;
            _finder    = finder;
            _indexer   = indexer;
            _flushable = flushable;

            // detect sync direction from Database Type and double check via config
            string value = ConfigurationManager.AppSettings["XmlReplication"] ?? "false";

            IsSlave  = value.Equals("Slave", StringComparison.InvariantCultureIgnoreCase) & (dataBaseSection.Flavour == DatabaseFlavour.Xml);
            IsMaster = value.Equals("Master", StringComparison.InvariantCultureIgnoreCase) & !IsSlave;

            if (IsMaster || IsSlave)
            {
                // only initialize if replication is active
                var storageConfig = (FileSystemNamespace)Enum.Parse(typeof(FileSystemNamespace),
                                                                    ConfigurationManager.AppSettings["AzureReplicationStorageContainerName"] ??
                                                                    "ReplicationStorageDebug");

                _fileSystem = fileSystemFactory.Create(storageConfig);

                // constructing these dependencies to ensure same filesystem and simplify construction
                _replicationWriteLockManager = new ReplicationWriteLockManager(_fileSystem);
                _replicationReadLockManager  = new ReplicationReadLockManager(_fileSystem);
            }
            _replicationLogPath = "/_Xml_Sync_Log";
        }
Пример #3
0
        public void Replication_Locks()
        {
            var writeLock = new ReplicationWriteLockManager(fs);
            var writeLock2 = new ReplicationWriteLockManager(fs);
            var readLock = new ReplicationReadLockManager(fs);
            var readLock2 = new ReplicationReadLockManager(fs);

            Assert.IsFalse(writeLock.IsLocked);
            Assert.IsFalse(writeLock2.IsLocked);
            
            Assert.IsTrue(writeLock.Lock());
            // cannot work as it ignores same name Assert.IsTrue(writeLock.IsLocked);
            //Assert.IsFalse(writeLock2.Lock()); // 2nd lock must fail

            writeLock.Unlock();
            Assert.IsFalse(writeLock.IsLocked);
        }
Пример #4
0
        public ReplicationManager(
            IPersister persister,
            IItemFinder finder,
            IReplicationStorage repstore,
            IFileSystemFactory fileSystemFactory,
            DatabaseSection dataBaseSection,
            ISecurityManager security,
            IIndexer indexer, // optional
            IFlushable flushable // optional
            )
        {
            _repstore = repstore;
            _security = security;
            _persister = persister;
            _finder = finder;
            _indexer = indexer;
            _flushable = flushable;

            // detect sync direction from Database Type and double check via config
            string value = ConfigurationManager.AppSettings["XmlReplication"] ?? "false";
            IsSlave = value.Equals("Slave", StringComparison.InvariantCultureIgnoreCase) & (dataBaseSection.Flavour == DatabaseFlavour.Xml);
            IsMaster = value.Equals("Master", StringComparison.InvariantCultureIgnoreCase) & !IsSlave;

            if (IsMaster || IsSlave)
            {
                // only initialize if replication is active
                var storageConfig = (FileSystemNamespace) Enum.Parse(typeof (FileSystemNamespace),
                               ConfigurationManager.AppSettings["AzureReplicationStorageContainerName"] ??
                               "ReplicationStorageDebug");

                _fileSystem = fileSystemFactory.Create(storageConfig);

                // constructing these dependencies to ensure same filesystem and simplify construction
                _replicationWriteLockManager = new ReplicationWriteLockManager(_fileSystem);
                _replicationReadLockManager = new ReplicationReadLockManager(_fileSystem);
            }
            _replicationLogPath = "/_Xml_Sync_Log";
        }