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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        public override void SetUp()
        {
            base.SetUp();

            // create a filesystem for replication and use it as storage
            fsf     = CreateFileSystemFactory();
            Storage = new ReplicationStorageFileSystemN2(activator, fsf, definitions, persister);

            // create a master replicator
            MasterFlushable = new FakeFlushable();
            Master          = new ReplicationManager(persister, new XmlFinder(repository), Storage, fsf,
                                                     new DatabaseSection(),
                                                     new FakeSecurityManager(),
                                                     null,
                                                     MasterFlushable);
            Master.SetUnitTestMode(true);

            // create a separate slave repository
            SlaveRepo = new XmlContentItemRepository(activator, fs, definitions, null, null);
            var slavesource = TestSupport.SetupContentSource(SlaveRepo);

            SlavePersister = new ContentPersister(slavesource, SlaveRepo);
            new BehaviorInvoker(SlavePersister, new DefinitionMap()).Start();

            // create a slave replicator
            SlaveFlushable = new FakeFlushable();
            Slave          = new ReplicationManager(SlavePersister, new XmlFinder(SlaveRepo), Storage, fsf,
                                                    new DatabaseSection(),
                                                    new FakeSecurityManager(),
                                                    null,
                                                    SlaveFlushable);
            Slave.SetUnitTestMode(false);
        }
예제 #4
0
 public ReplicationManager(
     IPersister persister,
     IItemFinder finder,
     IReplicationStorage repstore,
     IFileSystemFactory fileSystemFactory,
     DatabaseSection dataBaseSection,
     ISecurityManager security
 )
     : this(persister, finder, repstore, fileSystemFactory, dataBaseSection, security, null, null)
 {
     // needed to be able to execute N2 unit tests w/o additional dependecies
 }
 public ReplicationManager(
     IPersister persister,
     IItemFinder finder,
     IReplicationStorage repstore,
     IFileSystemFactory fileSystemFactory,
     DatabaseSection dataBaseSection,
     ISecurityManager security
     )
     : this(persister, finder, repstore, fileSystemFactory, dataBaseSection, security, null, null)
 {
     // needed to be able to execute N2 unit tests w/o additional dependecies
 }
        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";
        }
예제 #7
0
        public override void SetUp()
        {
            base.SetUp();
            
            // create a filesystem for replication and use it as storage
            fsf = CreateFileSystemFactory();
            Storage = new ReplicationStorageFileSystemN2(activator, fsf, definitions, persister);

            // create a master replicator
            MasterFlushable = new FakeFlushable();
            Master = new ReplicationManager(persister, new XmlFinder(repository), Storage, fsf, 
                new DatabaseSection(), 
                new FakeSecurityManager(), 
                null,
                MasterFlushable);
            Master.SetUnitTestMode(true);

            // create a separate slave repository
            SlaveRepo = new XmlContentItemRepository(activator, fs, definitions, null, null);
            var slavesource = TestSupport.SetupContentSource(SlaveRepo);
            SlavePersister = new ContentPersister(slavesource, SlaveRepo);
            new BehaviorInvoker(SlavePersister, new DefinitionMap()).Start();

            // create a slave replicator
            SlaveFlushable = new FakeFlushable();
            Slave = new ReplicationManager(SlavePersister, new XmlFinder(SlaveRepo), Storage, fsf,
                new DatabaseSection(),
                new FakeSecurityManager(),
                null,
                SlaveFlushable);
            Slave.SetUnitTestMode(false);
        }
예제 #8
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";
        }