public UnicornDataProvider(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IFieldFilter fieldFilter, IUnicornDataProviderLogger logger, IUnicornDataProviderConfiguration configuration) { Assert.ArgumentNotNull(targetDataStore, "serializationProvider"); Assert.ArgumentNotNull(predicate, "predicate"); Assert.ArgumentNotNull(fieldFilter, "fieldPredicate"); Assert.ArgumentNotNull(logger, "logger"); Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore"); Assert.ArgumentNotNull(configuration, "configuration"); _logger = logger; _configuration = configuration; _predicate = predicate; _fieldFilter = fieldFilter; _targetDataStore = targetDataStore; _sourceDataStore = sourceDataStore; try { _targetDataStore.RegisterForChanges(RemoveItemFromCaches); } catch (NotImplementedException) { // if the data store doesn't implement watching, cool story bruv } }
public UnicornDataProvider(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IFieldFilter fieldFilter, IUnicornDataProviderLogger logger, IUnicornDataProviderConfiguration dataProviderConfiguration, PredicateRootPathResolver rootPathResolver) { Assert.ArgumentNotNull(targetDataStore, "serializationProvider"); Assert.ArgumentNotNull(predicate, "predicate"); Assert.ArgumentNotNull(fieldFilter, "fieldPredicate"); Assert.ArgumentNotNull(logger, "logger"); Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore"); Assert.ArgumentNotNull(dataProviderConfiguration, "configuration"); Assert.ArgumentNotNull(rootPathResolver, "rootPathResolver"); _logger = logger; _dataProviderConfiguration = dataProviderConfiguration; _rootPathResolver = rootPathResolver; _predicate = predicate; _fieldFilter = fieldFilter; _targetDataStore = targetDataStore; _sourceDataStore = sourceDataStore; // enable capturing recycle bin and archive restores to serialize the target item if included EventManager.Subscribe <RestoreItemCompletedEvent>(HandleItemRestored); try { _targetDataStore.RegisterForChanges(RemoveItemFromCaches); } catch (NotImplementedException) { // if the data store doesn't implement watching, cool story bruv } }
public UnicornDataProvider(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IFieldFilter fieldFilter, IUnicornDataProviderLogger logger, IUnicornDataProviderConfiguration dataProviderConfiguration, ISyncConfiguration syncConfiguration, PredicateRootPathResolver rootPathResolver) { Assert.ArgumentNotNull(targetDataStore, nameof(targetDataStore)); Assert.ArgumentNotNull(predicate, nameof(predicate)); Assert.ArgumentNotNull(fieldFilter, nameof(fieldFilter)); Assert.ArgumentNotNull(logger, nameof(logger)); Assert.ArgumentNotNull(sourceDataStore, nameof(sourceDataStore)); Assert.ArgumentNotNull(dataProviderConfiguration, nameof(dataProviderConfiguration)); Assert.ArgumentNotNull(rootPathResolver, nameof(rootPathResolver)); Assert.ArgumentNotNull(syncConfiguration, nameof(syncConfiguration)); _logger = logger; _dataProviderConfiguration = dataProviderConfiguration; _syncConfiguration = syncConfiguration; _rootPathResolver = rootPathResolver; _predicate = predicate; _fieldFilter = fieldFilter; _targetDataStore = targetDataStore; _sourceDataStore = sourceDataStore; // enable capturing recycle bin and archive restores to serialize the target item if included EventManager.Subscribe<RestoreItemCompletedEvent>(HandleItemRestored); try { _targetDataStore.RegisterForChanges(RemoveItemFromCaches); } catch (NotImplementedException) { // if the data store doesn't implement watching, cool story bruv } }
public UnicornDataProvider(ITargetDataStore targetDataStore, ISourceDataStore sourceDataStore, IPredicate predicate, IFieldFilter fieldFilter, IUnicornDataProviderLogger logger, IUnicornDataProviderConfiguration dataProviderConfiguration, PredicateRootPathResolver rootPathResolver) { Assert.ArgumentNotNull(targetDataStore, "serializationProvider"); Assert.ArgumentNotNull(predicate, "predicate"); Assert.ArgumentNotNull(fieldFilter, "fieldPredicate"); Assert.ArgumentNotNull(logger, "logger"); Assert.ArgumentNotNull(sourceDataStore, "sourceDataStore"); Assert.ArgumentNotNull(dataProviderConfiguration, "configuration"); Assert.ArgumentNotNull(rootPathResolver, "rootPathResolver"); _logger = logger; _dataProviderConfiguration = dataProviderConfiguration; _rootPathResolver = rootPathResolver; _predicate = predicate; _fieldFilter = fieldFilter; _targetDataStore = targetDataStore; _sourceDataStore = sourceDataStore; try { _targetDataStore.RegisterForChanges(RemoveItemFromCaches); } catch (NotImplementedException) { // if the data store doesn't implement watching, cool story bruv } }
public SerializationPresetPredicate(XmlNode configNode, IUnicornDataProviderConfiguration dataProviderConfiguration, IConfiguration configuration) { Assert.ArgumentNotNull(configNode, "configNode"); _includeEntries = ParsePreset(configNode); EnsureEntriesExist(configuration?.Name ?? "Unknown"); ValidateExclusionConfiguration(configuration?.Name ?? "Unknown", dataProviderConfiguration?.EnableTransparentSync ?? false); }
public SerializationLoader(ISourceDataStore sourceDataStore, ITargetDataStore targetDataStore, IPredicate predicate, IEvaluator evaluator, ISerializationLoaderLogger logger, ISyncConfiguration syncConfiguration, IUnicornDataProviderConfiguration dataProviderConfiguration, PredicateRootPathResolver predicateRootPathResolver) { Assert.ArgumentNotNull(targetDataStore, nameof(targetDataStore)); Assert.ArgumentNotNull(sourceDataStore, nameof(sourceDataStore)); Assert.ArgumentNotNull(predicate, nameof(predicate)); Assert.ArgumentNotNull(evaluator, nameof(evaluator)); Assert.ArgumentNotNull(logger, nameof(logger)); Assert.ArgumentNotNull(predicateRootPathResolver, nameof(predicateRootPathResolver)); Assert.ArgumentNotNull(syncConfiguration, nameof(syncConfiguration)); Assert.ArgumentNotNull(dataProviderConfiguration, nameof(dataProviderConfiguration)); Logger = logger; SyncConfiguration = syncConfiguration; DataProviderConfiguration = dataProviderConfiguration; PredicateRootPathResolver = predicateRootPathResolver; Evaluator = evaluator; Predicate = predicate; TargetDataStore = targetDataStore; SourceDataStore = sourceDataStore; }
protected virtual void DumpTreeInternal(IItemData root, IPredicate predicate, ITargetDataStore serializationStore, ISourceDataStore sourceDataStore, ILogger logger, IUnicornDataProviderConfiguration dpConfig) { if (dpConfig.EnableTransparentSync) { CacheManager.ClearAllCaches(); // BOOM! This clears all caches before we begin; // because for a TpSync configuration we could have TpSync items in the data cache which 'taint' the reserialize // from being purely database } // we throw items into this queue, and let a thread pool pick up anything available to process in parallel. only the children of queued items are processed, not the item itself var processQueue = new Queue <IItemData>(); using (new UnicornOperationContext()) { var rootResult = DumpItemInternal(root, predicate, serializationStore); if (!rootResult.IsIncluded) { return; } } processQueue.Enqueue(root); IItemData parentItem; while (processQueue.Count > 0) { parentItem = processQueue.Dequeue(); using (new UnicornOperationContext()) // disablers only work on the current thread. So we need to disable on all worker threads { var children = sourceDataStore.GetChildren(parentItem); foreach (var item in children) { // we dump each item in the queue item // we do a whole array of children at a time because this makes the serialization of all children of a given item single threaded // this gives us a deterministic result of naming when name collisions occur, which means trees will not contain random differences // when reserialized (oh joy, that) var dump = DumpItemInternal(item, predicate, serializationStore); if (dump.IsIncluded) { // if the item is included, then we add its children as a queued work item processQueue.Enqueue(item); } else { logger.Warn("[S] {0} because {1}".FormatWith(item.GetDisplayIdentifier(), dump.Justification)); } } } } if (dpConfig.EnableTransparentSync) { CacheManager.ClearAllCaches(); // BOOM! And we clear everything again at the end, because now // for a TpSync configuration we might have DATABASE items in cache where we want TpSync. } }