public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, string name, TransportState recievedTransportState = null) { this.Name = name; this.systemConfiguration = systemConfiguration; var storageType = systemConfiguration.FileSystem.DefaultStorageTypeName; storage = CreateTransactionalStorage(storageType, systemConfiguration); search = new IndexStorage(systemConfiguration.FileSystem.IndexStoragePath, systemConfiguration.Settings); sigGenerator = new SigGenerator(); var replicationHiLo = new SynchronizationHiLo(storage); var sequenceActions = new SequenceActions(storage); transportState = recievedTransportState ?? new TransportState(); notificationPublisher = new NotificationPublisher(transportState); fileLockManager = new FileLockManager(); storage.Initialize(); search.Initialize(); var uuidGenerator = new UuidGenerator(sequenceActions); historian = new Historian(storage, replicationHiLo, uuidGenerator); BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024); conflictArtifactManager = new ConflictArtifactManager(storage, search); conflictDetector = new ConflictDetector(); conflictResolver = new ConflictResolver(storage, new CompositionContainer(systemConfiguration.Catalog)); synchronizationTask = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration); storageOperationsTask = new StorageOperationsTask(storage, search, notificationPublisher); metricsCounters = new MetricsCountersManager(); AppDomain.CurrentDomain.ProcessExit += ShouldDispose; AppDomain.CurrentDomain.DomainUnload += ShouldDispose; }
public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, string name, TransportState receivedTransportState = null) { ExtensionsState = new AtomicDictionary <object>(); Name = name; this.systemConfiguration = systemConfiguration; systemConfiguration.Container.SatisfyImportsOnce(this); transportState = receivedTransportState ?? new TransportState(); storage = CreateTransactionalStorage(systemConfiguration); sigGenerator = new SigGenerator(); fileLockManager = new FileLockManager(); BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024); conflictDetector = new ConflictDetector(); conflictResolver = new ConflictResolver(storage, new CompositionContainer(systemConfiguration.Catalog)); notificationPublisher = new NotificationPublisher(transportState); synchronizationTask = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration); metricsCounters = new MetricsCountersManager(); search = new IndexStorage(name, systemConfiguration); conflictArtifactManager = new ConflictArtifactManager(storage, search); storageOperationsTask = new StorageOperationsTask(storage, DeleteTriggers, search, notificationPublisher); AppDomain.CurrentDomain.ProcessExit += ShouldDispose; AppDomain.CurrentDomain.DomainUnload += ShouldDispose; }
private void AssertConflictDetection(string fileName, RavenJObject localMetadata, RavenJObject sourceMetadata, ServerInfo sourceServer, out bool isConflictResolved) { var conflict = ConflictDetector.Check(fileName, localMetadata, sourceMetadata, sourceServer.FileSystemUrl); isConflictResolved = ConflictResolver.IsResolved(localMetadata, conflict); if (conflict != null && !isConflictResolved) { ConflictArtifactManager.Create(fileName, conflict); Publisher.Publish(new ConflictNotification { FileName = fileName, SourceServerUrl = sourceServer.FileSystemUrl, Status = ConflictStatus.Detected, RemoteFileHeader = new FileHeader(fileName, localMetadata) }); Log.Debug( "File '{0}' is in conflict with synchronized version from {1} ({2}). File marked as conflicted, conflict configuration item created", fileName, sourceServer.FileSystemUrl, sourceServer.Id); throw new SynchronizationException(string.Format("File {0} is conflicted", fileName)); } }
public void HasConflict_False() { ICourseRepository courseRepository = new NonConflictingCourseRepo(); ConflictDetectorTests detector = new ConflictDetector(courseRepository); ConflictResult result = detector.FindConflicts(); Assert.IsFalse(result.HasConflicts); }
public void HasConflict_True() { ICourseRepository courseRepository = new ConflictingCourseRepo(); ConflictDetector detector = new ConflictDetector(courseRepository); ConflictResult result = detector.FindConflicts(); Assert.IsTrue(result.HasConflicts); }
private void AssertConflictDetection(string fileName, RavenJObject localMetadata, RavenJObject sourceMetadata, ServerInfo sourceServer, out bool isConflictResolved) { var conflict = ConflictDetector.Check(fileName, localMetadata, sourceMetadata, sourceServer.FileSystemUrl); if (conflict == null) { isConflictResolved = false; return; } isConflictResolved = ConflictResolver.CheckIfResolvedByRemoteStrategy(localMetadata, conflict); if (isConflictResolved) { return; } ConflictResolutionStrategy strategy; if (ConflictResolver.TryResolveConflict(fileName, conflict, localMetadata, sourceMetadata, out strategy)) { switch (strategy) { case ConflictResolutionStrategy.RemoteVersion: Log.Debug("Conflict automatically resolved by choosing remote version of the file {0}", fileName); return; case ConflictResolutionStrategy.CurrentVersion: Storage.Batch(accessor => { accessor.UpdateFileMetadata(fileName, localMetadata); ConflictArtifactManager.Delete(fileName, accessor); }); Log.Debug("Conflict automatically resolved by choosing current version of the file {0}", fileName); throw new ConflictResolvedInFavourOfCurrentVersionException(); } } ConflictArtifactManager.Create(fileName, conflict); Publisher.Publish(new ConflictNotification { FileName = fileName, SourceServerUrl = sourceServer.FileSystemUrl, Status = ConflictStatus.Detected, RemoteFileHeader = new FileHeader(fileName, localMetadata) }); Log.Debug( "File '{0}' is in conflict with synchronized version from {1} ({2}). File marked as conflicted, conflict configuration item created", fileName, sourceServer.FileSystemUrl, sourceServer.Id); throw new SynchronizationException(string.Format("File {0} is conflicted", fileName)); }
public RavenFileSystem(InMemoryRavenConfiguration config, string name, TransportState receivedTransportState = null) { ExtensionsState = new AtomicDictionary <object>(); Name = name; ResourceName = string.Concat(Constants.FileSystem.UrlPrefix, "/", name); configuration = config; try { ValidateStorage(); configuration.Container.SatisfyImportsOnce(this); transportState = receivedTransportState ?? new TransportState(); storage = CreateTransactionalStorage(configuration); sigGenerator = new SigGenerator(); fileLockManager = new FileLockManager(); BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024); conflictDetector = new ConflictDetector(); conflictResolver = new ConflictResolver(storage, new CompositionContainer(configuration.Catalog)); notificationPublisher = new NotificationPublisher(transportState); synchronizationTask = new SynchronizationTask(storage, sigGenerator, notificationPublisher, configuration); metricsCounters = new MetricsCountersManager(); search = new IndexStorage(name, configuration); conflictArtifactManager = new ConflictArtifactManager(storage, search); TimerManager = new ResourceTimerManager(); Tasks = new TaskActions(this, Log); Files = new FileActions(this, Log); Synchronizations = new SynchronizationActions(this, Log); AppDomain.CurrentDomain.ProcessExit += ShouldDispose; AppDomain.CurrentDomain.DomainUnload += ShouldDispose; } catch (Exception e) { Log.ErrorException(string.Format("Could not create file system '{0}'", Name ?? "unknown name"), e); try { Dispose(); } catch (Exception ex) { Log.FatalException("Failed to dispose when already getting an error in file system ctor", ex); } throw; } }
public static void Init() { var storeEvents = WireupEventStore(); var aggregateFactory = new AggregateFactory(); var conflictDetector = new ConflictDetector(); var eventRepository = new EventStoreRepository(storeEvents, aggregateFactory, conflictDetector); _commandHandlerService = new CommandHandlerService(); _commandHandlerService.InitHandlers(eventRepository); }
/// <summary> /// Launches the conflict detector. /// </summary> /// <remarks> /// This method is called by a <see cref="BackgroundWorkerProgressDialog" />. /// </remarks> private void CheckForCriticalRecordConflicts() { m_pfpFormatProvider.Clear(); var lstPlugins = new List <string>(Program.GameMode.PluginManager.SortPluginList(Program.GameMode.PluginManager.ActivePluginList)); m_bwdProgress.OverallProgressMaximum = lstPlugins.Count; var cdrDetector = new ConflictDetector(); cdrDetector.ConflictDetected += cdrDetector_ConflictDetected; cdrDetector.PluginProcessed += cdrDetector_PluginProcessed; cdrDetector.DetectConflicts(lstPlugins); }
public RavenFileSystem(InMemoryRavenConfiguration systemConfiguration, TransportState transportState, string name) { this.Name = name; this.systemConfiguration = systemConfiguration; var storageType = systemConfiguration.DefaultFileSystemStorageTypeName; if (string.Equals(InMemoryRavenConfiguration.VoronTypeName, storageType, StringComparison.OrdinalIgnoreCase) == false) { if (Directory.Exists(systemConfiguration.FileSystemDataDirectory) && Directory.EnumerateFileSystemEntries(systemConfiguration.FileSystemDataDirectory).Any()) { throw new InvalidOperationException( string.Format( "We do not allow to run on a storage engine other then Voron, while we are in the early pre-release phase of RavenDB 3.0. You are currently running on {0}", storageType)); } Trace.WriteLine("Forcing filesystem to run on Voron - pre release behavior only, mind " + Path.GetFileName(Path.GetDirectoryName(systemConfiguration.FileSystemDataDirectory))); storageType = InMemoryRavenConfiguration.VoronTypeName; } storage = CreateTransactionalStorage(storageType, systemConfiguration); search = new IndexStorage(systemConfiguration.FileSystemIndexStoragePath, systemConfiguration.Settings); sigGenerator = new SigGenerator(); var replicationHiLo = new SynchronizationHiLo(storage); var sequenceActions = new SequenceActions(storage); this.transportState = transportState; notificationPublisher = new NotificationPublisher(transportState); fileLockManager = new FileLockManager(); storage.Initialize(); search.Initialize(); var uuidGenerator = new UuidGenerator(sequenceActions); historian = new Historian(storage, replicationHiLo, uuidGenerator); BufferPool = new BufferPool(1024 * 1024 * 1024, 65 * 1024); conflictArtifactManager = new ConflictArtifactManager(storage, search); conflictDetector = new ConflictDetector(); conflictResolver = new ConflictResolver(); synchronizationTask = new SynchronizationTask(storage, sigGenerator, notificationPublisher, systemConfiguration); storageOperationsTask = new StorageOperationsTask(storage, search, notificationPublisher); metricsCounters = new MetricsCountersManager(); AppDomain.CurrentDomain.ProcessExit += ShouldDispose; AppDomain.CurrentDomain.DomainUnload += ShouldDispose; }
protected SynchronizationWorkItem(string fileName, string sourceServerUrl, ITransactionalStorage storage) { Storage = storage; FileName = fileName; FileAndPagesInformation fileAndPages = null; Storage.Batch(accessor => fileAndPages = accessor.GetFile(fileName, 0, 0)); FileMetadata = fileAndPages.Metadata; ServerInfo = new ServerInfo { Id = Storage.Id, FileSystemUrl = sourceServerUrl }; conflictDetector = new ConflictDetector(); conflictResolver = new ConflictResolver(null, null); }
public void Test_Two_Roles_With_Overloaded_Method_No_Conflict() { var targetType = GetType<Empty>(); var detector = new ConflictDetector(targetType); var result = detector.Process(GetType<Role_With_Method_Take_Int32>(), GetType<Role_With_Method_Take_String>()); OperationAssert.IsSuccessful(result); }
public InMemoryDomainRepository(IStoreEvents eventStore, IConstructAggregates aggregateFactory, ConflictDetector conflictDetector) : base(eventStore, aggregateFactory, conflictDetector) { this.EventStore = eventStore; }
public void Test_No_Roles_No_Conflict() { var targetType = GetType<Empty>(); var detector = new ConflictDetector(targetType); var result = detector.Process(); OperationAssert.IsSuccessful(result); }
public void Test_Two_Roles_With_Methods_That_Differ_On_Return_Type_Should_Conflict() { var targetType = GetType<Empty>(); var detector = new ConflictDetector(targetType); var result = detector.Process(GetType<Role_With_Method_Return_Int32>(), GetType<Role_With_Method_Return_String>()); OperationAssert.Failed(result); var messages = result.Messages.ToList(); Assert.AreEqual(1, messages.Count); Assert.AreEqual((int)Error.Code.MethodsWithConflictingSignatures, messages[0].Number); // TODO: add the class' members to the groups // TODO: this message is also valid for when the members differ in accessibility? }
public void Test_Two_Roles_With_Members_With_The_Same_Name_Should_Conflict() { var targetType = GetType<Empty>(); var detector = new ConflictDetector(targetType); var result = detector.Process(GetType<Role_With_Method_Take_String>(), GetType<Role_With_Property_Named_Method>()); OperationAssert.Failed(result); var messages = result.Messages.ToList(); Assert.AreEqual(1, messages.Count); Assert.AreEqual((int)Error.Code.MembersWithSameName, messages[0].Number); }
public void Test_Two_Roles_With_Conflicting_Method() { var targetType = GetType<Empty>(); var detector = new ConflictDetector(targetType); var result = detector.Process(GetType<Role_With_Method>(), GetType<Role_With_Method_2>()); OperationAssert.Failed(result); }
public void Test_Two_Roles_No_Conflicts() { var targetType = GetType<Empty>(); var detector = new ConflictDetector(targetType); var result = detector.Process(GetType<Role_With_Method1>(), GetType<Role_With_Method2>()); OperationAssert.IsSuccessful(result); }
public void Test_Superseded_Role_Method_No_Conflict() { var targetType = GetType<Class_With_Method>(); var detector = new ConflictDetector(targetType); var result = detector.Process(GetType<Role_With_Method>()); OperationAssert.IsSuccessful(result); // TODO: check for warning that the method is not marked [Supersede] in the class? // TODO: check that the method in the group is really superseded! }
public void Test_Role_With_Method_In_Empty_Class_No_Conflict() { var targetType = GetType<Empty>(); var detector = new ConflictDetector(targetType); var result = detector.Process(GetType<Role_With_Method>()); OperationAssert.IsSuccessful(result); }