protected override void SetBindings(BinderWithErrorProviderFactory rules, CacheProgress databaseObject) { base.SetBindings(rules, databaseObject); Bind(tbID, "Text", "ID", c => c.ID); Bind(tbName, "Text", "Name", c => c.Name); }
protected override void SetUp() { base.SetUp(); RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataWriter)); RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataInventor)); _lmd = new LoadMetadata(CatalogueRepository, "Ive got a lovely bunch o' coconuts"); _LoadDirectory = LoadDirectory.CreateDirectoryStructure(new DirectoryInfo(TestContext.CurrentContext.TestDirectory), @"EndToEndCacheTest", true); _lmd.LocationOfFlatFiles = _LoadDirectory.RootPath.FullName; _lmd.SaveToDatabase(); Clear(_LoadDirectory); _cata = new Catalogue(CatalogueRepository, "EndToEndCacheTest"); _cata.LoadMetadata_ID = _lmd.ID; _cata.SaveToDatabase(); _lp = new LoadProgress(CatalogueRepository, _lmd); _cp = new CacheProgress(CatalogueRepository, _lp); _lp.OriginDate = new DateTime(2001, 1, 1); _lp.SaveToDatabase(); _testPipeline = new TestDataPipelineAssembler("EndToEndCacheTestPipeline" + Guid.NewGuid(), CatalogueRepository); _testPipeline.ConfigureCacheProgressToUseThePipeline(_cp); _cp.CacheFillProgress = DateTime.Now.AddDays(-NumDaysToCache); _cp.SaveToDatabase(); _cp.SaveToDatabase(); }
public CacheProgressMenu(RDMPContextMenuStripArgs args, CacheProgress cacheProgress) : base(args, cacheProgress) { Add(new ExecuteCommandEditCacheProgress(args.ItemActivator, cacheProgress)); ReBrandActivateAs("Execute Caching", RDMPConcept.CacheProgress, OverlayKind.Execute); }
public override void SetDatabaseObject(IActivateItems activator, CacheProgress databaseObject) { base.SetDatabaseObject(activator, databaseObject); CommonFunctionality.AddHelp(tbCacheProgress, "ICacheProgress.CacheFillProgress"); CommonFunctionality.AddHelp(ddCacheLagDurationType, "ICacheProgress.CacheLagPeriod"); CommonFunctionality.AddHelp(ddCacheLagDelayDurationType, "ICacheProgress.CacheLagPeriodLoadDelay"); CommonFunctionality.AddHelp(tbChunkPeriod, "ICacheProgress.ChunkPeriod"); CommonFunctionality.AddHelp(pPipeline, "ICacheProgress.Pipeline_ID"); _cacheProgress = databaseObject; CommonFunctionality.AddToMenu(new ExecuteCommandExecuteCacheProgress(activator, databaseObject), "Go To Execute"); ragSmiley1.Reset(); try { PopulateCacheProgressPanel(_cacheProgress); } catch (Exception e) { ragSmiley1.Fatal(e); } }
public ExecuteCommandSetPermissionWindow(IActivateItems activator, CacheProgress cacheProgress) : base(activator) { _cacheProgress = cacheProgress; _window = null; if (!activator.CoreChildProvider.AllPermissionWindows.Any()) { SetImpossible("There are no PermissionWindows created yet"); } }
public override void Execute() { base.Execute(); // If the LoadProgress doesn't have a corresponding CacheProgress, create it var cp = new CacheProgress(BasicActivator.RepositoryLocator.CatalogueRepository, _loadProgress); Publish(_loadProgress); Emphasise(cp); }
public override int GetHashCode() { unchecked { int hashCode = CacheProgress.GetHashCode(); hashCode = (hashCode * 397) ^ PermissionWindow.GetHashCode(); hashCode = (hashCode * 397) ^ DirectionIsCacheToPermissionWindow.GetHashCode(); return(hashCode); } }
public int Run(IRDMPPlatformRepositoryServiceLocator repositoryLocator, IDataLoadEventListener listener, ICheckNotifier checkNotifier, GracefulCancellationToken token) { const string dataLoadTask = "caching"; CacheProgress cp = repositoryLocator.CatalogueRepository.GetObjectByID <CacheProgress>(_options.CacheProgress); var defaults = repositoryLocator.CatalogueRepository.GetServerDefaults(); var loggingServer = defaults.GetDefaultFor(PermissableDefaults.LiveLoggingServer_ID); if (loggingServer == null) { throw new NotSupportedException("No default logging server specified, you must specify one in "); } var logManager = new LogManager(loggingServer); logManager.CreateNewLoggingTaskIfNotExists(dataLoadTask); switch (_options.Command) { case CommandLineActivity.run: //Setup dual listeners for the Cache process, one ticks the lifeline one very message and one logs to the logging db var toLog = new ToLoggingDatabaseDataLoadEventListener(this, logManager, dataLoadTask, "Caching " + cp); var forkListener = new ForkDataLoadEventListener(toLog, listener); try { var cachingHost = new CachingHost(repositoryLocator.CatalogueRepository); cachingHost.RetryMode = _options.RetryMode; cachingHost.CacheProgressList = new ICacheProgress[] { cp }.ToList(); //run the cp //By default caching host will block cachingHost.TerminateIfOutsidePermissionWindow = true; cachingHost.Start(forkListener, token); } finally { //finish everything toLog.FinalizeTableLoadInfos(); } break; case CommandLineActivity.check: var checkable = new CachingPreExecutionChecker(cp); checkable.Check(checkNotifier); break; default: throw new ArgumentOutOfRangeException(); } return(0); }
public ExecuteCommandShowCacheFetchFailures(IActivateItems activator, CacheProgress cacheProgress) : base(activator) { _cacheProgress = cacheProgress; _failures = _cacheProgress.CacheFetchFailures.Where(f => f.ResolvedOn == null).ToArray(); if (!_failures.Any()) { SetImpossible("There are no unresolved CacheFetchFailures"); } }
public override void SetDatabaseObject(IActivateItems activator, CacheProgress databaseObject) { base.SetDatabaseObject(activator, databaseObject); _cacheProgress = databaseObject; CommonFunctionality.AddToMenu(new ExecuteCommandEditCacheProgress(activator, databaseObject), "Edit"); CommonFunctionality.AddToMenu(new ExecuteCommandShowCacheFetchFailures(activator, databaseObject), "View Cache Failures"); bool failures = _cacheProgress.CacheFetchFailures.Any(f => f.ResolvedOn == null); cbFailures.Enabled = failures; checkAndExecuteUI1.SetItemActivator(activator); }
public override void Execute() { base.Execute(); if (_cp == null) { _cp = SelectOne <CacheProgress>(Activator.RepositoryLocator.CatalogueRepository); } if (_cp == null) { return; } Activator.Activate <ExecuteCacheProgressUI, CacheProgress>(_cp); }
public void ConfirmLogs_With2CacheProgress_Throws() { var lmd1 = new LoadMetadata(CatalogueRepository, "MyLmd"); var cata = new Catalogue(CatalogueRepository, "myCata"); cata.LoadMetadata_ID = lmd1.ID; cata.LoggingDataTask = "B"; cata.SaveToDatabase(); var lmd2 = new LoadMetadata(CatalogueRepository, "MyLmd"); var cata2 = new Catalogue(CatalogueRepository, "myCata"); cata2.LoadMetadata_ID = lmd2.ID; cata2.LoggingDataTask = "A"; cata2.SaveToDatabase(); var lp1 = new LoadProgress(CatalogueRepository, lmd1); var lp2 = new LoadProgress(CatalogueRepository, lmd2); var cp1 = new CacheProgress(CatalogueRepository, lp1); var cp2 = new CacheProgress(CatalogueRepository, lp2); cp2.Name = "MyCoolCache"; cp2.SaveToDatabase(); var lm = new LogManager(cp1.GetDistinctLoggingDatabase()); lm.CreateNewLoggingTaskIfNotExists(cp1.GetDistinctLoggingTask()); // create a log entry for cp1 only var logEntry = lm.CreateDataLoadInfo(cp1.GetDistinctLoggingTask(), "pack o' cards", cp1.GetLoggingRunName(), null, true); // we mark it as completed successfully - this is a good, happy log entry logEntry.CloseAndMarkComplete(); // The first cache has logged success so should be happy var cmd1 = new ExecuteCommandConfirmLogs(new ThrowImmediatelyActivator(RepositoryLocator), cp1, null); Assert.DoesNotThrow(() => cmd1.Execute()); // The second cache has not logged any successes so should be unhappy var cmd2 = new ExecuteCommandConfirmLogs(new ThrowImmediatelyActivator(RepositoryLocator), cp2, null); var ex = Assert.Throws <LogsNotConfirmedException>(() => cmd2.Execute()); Assert.AreEqual("There are no log entries for MyCoolCache", ex.Message); }
public void up() { RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataWriter)); RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataInventor)); _lmd = new LoadMetadata(CatalogueRepository, "JobDateGenerationStrategyFactoryTestsIntegration"); _lp = new LoadProgress(CatalogueRepository, _lmd); _lp.DataLoadProgress = new DateTime(2001, 1, 1); _lp.SaveToDatabase(); _cp = new CacheProgress(CatalogueRepository, _lp); _server = new DiscoveredServer(new SqlConnectionStringBuilder("server=localhost;initial catalog=fish")); _factory = new JobDateGenerationStrategyFactory(new SingleLoadProgressSelectionStrategy(_lp)); }
public ExecuteCommandPacsFetch(IBasicActivateItems activator, string start, string end, string remoteAeUri, int remotePort, string remoteAeTitle, string localAeUri, int localPort, string localAeTitle, string outDir, int maxRetries) : base(activator) { var startDate = DateTime.Parse(start); var endDate = DateTime.Parse(end); // Make something that kinda looks like a valid DLE load var memory = new MemoryCatalogueRepository(); var lmd = new LoadMetadata(memory); var dir = Directory.CreateDirectory(outDir); var results = LoadDirectory.CreateDirectoryStructure(dir, "out", true); lmd.LocationOfFlatFiles = results.RootPath.FullName; lmd.SaveToDatabase(); var lp = new LoadProgress(memory, lmd); var cp = new CacheProgress(memory, lp); //Create the source component only and a valid request range to fetch _source = new PACSSource { RemoteAEUri = new Uri("http://" + remoteAeUri), RemoteAEPort = remotePort, RemoteAETitle = remoteAeTitle, LocalAEUri = new Uri("http://" + localAeUri), LocalAEPort = localPort, LocalAETitle = localAeTitle, TransferTimeOutInSeconds = 50000, Modality = "ALL", MaxRetries = maxRetries }; //<- rly? its not gonna pass without an http!? _request = new BackfillCacheFetchRequest(BasicActivator.RepositoryLocator.CatalogueRepository, startDate) { ChunkPeriod = endDate.Subtract(startDate), CacheProgress = cp }; //Initialize it _source.PreInitialize(BasicActivator.RepositoryLocator.CatalogueRepository, new ThrowImmediatelyDataLoadEventListener { WriteToConsole = true }); _source.PreInitialize(this, new ThrowImmediatelyDataLoadEventListener { WriteToConsole = true }); }
public ExecuteCommandEditCacheProgress(IActivateItems activator, CacheProgress cacheProgress) : base(activator) { _cacheProgress = cacheProgress; }
public IAtomicCommandWithTarget SetTarget(DatabaseEntity target) { _cacheProgressToSetOnIfAny = target as CacheProgress; return(this); }
public void ConfigureCacheProgressToUseThePipeline(CacheProgress cp) { cp.Pipeline_ID = Pipeline.ID; cp.ChunkPeriod = new TimeSpan(12, 0, 0); cp.SaveToDatabase(); }
public ExecuteCommandExecuteCacheProgress(IActivateItems activator, CacheProgress cp) : base(activator) { _cp = cp; }
public override string ToString() { return(DirectionIsCacheToPermissionWindow ? PermissionWindow.Name : CacheProgress.ToString()); }
public IAtomicCommandWithTarget SetTarget(DatabaseEntity target) { _cp = (CacheProgress)target; return(this); }
public void RunEndToEndDLECacheTest() { RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataWriter)); RepositoryLocator.CatalogueRepository.MEF.AddTypeToCatalogForTesting(typeof(TestDataInventor)); int timeoutInMilliseconds = 120000; var lmd = TestLoadMetadata; LoadProgress lp = new LoadProgress(CatalogueRepository, lmd); lp.DataLoadProgress = new DateTime(2001, 1, 1); lp.DefaultNumberOfDaysToLoadEachTime = 10; lp.SaveToDatabase(); var cp = new CacheProgress(CatalogueRepository, lp); cp.CacheFillProgress = new DateTime(2001, 1, 11); //10 days available to load cp.SaveToDatabase(); var assembler = new TestDataPipelineAssembler("RunEndToEndDLECacheTest pipe", CatalogueRepository); assembler.ConfigureCacheProgressToUseThePipeline(cp); //setup the cache process task var pt = new ProcessTask(CatalogueRepository, lmd, LoadStage.GetFiles); pt.Path = typeof(BasicCacheDataProvider).FullName; pt.ProcessTaskType = ProcessTaskType.DataProvider; pt.SaveToDatabase(); pt.CreateArgumentsForClassIfNotExists <BasicCacheDataProvider>(); var attacher = lmd.ProcessTasks.Single(p => p.ProcessTaskType == ProcessTaskType.Attacher); var patternArgument = (ProcessTaskArgument)attacher.GetAllArguments().Single(a => a.Name.Equals("FilePattern")); patternArgument.SetValue("*.csv"); patternArgument.SaveToDatabase(); //take the forLoading file var csvFile = CreateFileInForLoading("bob.csv", 10, new Random(5000)); //and move it to the cache and give it a date in the range we expect for the cached data csvFile.MoveTo(Path.Combine(LoadDirectory.Cache.FullName, "2001-01-09.csv")); RunDLE(timeoutInMilliseconds); Assert.AreEqual(10, RowsNow - RowsBefore); Assert.AreEqual(0, LoadDirectory.Cache.GetFiles().Count()); Assert.AreEqual(0, LoadDirectory.ForLoading.GetFiles().Count()); Assert.AreEqual(1, LoadDirectory.ForArchiving.GetFiles().Count()); var archiveFile = LoadDirectory.ForArchiving.GetFiles()[0]; Assert.AreEqual(".zip", archiveFile.Extension); //load progress should be updated to the largest date in the cache (2001-01-09) lp.RevertToDatabaseState(); Assert.AreEqual(lp.DataLoadProgress, new DateTime(2001, 01, 09)); cp.DeleteInDatabase(); lp.DeleteInDatabase(); assembler.Destroy(); }
protected bool Equals(PermissionWindowUsedByCacheProgressNode other) { return(CacheProgress.Equals(other.CacheProgress) && PermissionWindow.Equals(other.PermissionWindow) && DirectionIsCacheToPermissionWindow.Equals(other.DirectionIsCacheToPermissionWindow)); }
public void DeleteInDatabase() { CacheProgress.PermissionWindow_ID = null; CacheProgress.SaveToDatabase(); }
public void SaveCacheFillProgress(DateTime cacheFillProgress) { CacheProgress.CacheFillProgress = cacheFillProgress; CacheProgress.SaveToDatabase(); }
public CacheProgressCommand(CacheProgress cacheProgress) { CacheProgress = cacheProgress; }
public PermissionWindowUsedByCacheProgressNode(CacheProgress cacheProgress, PermissionWindow permissionWindow, bool directionIsCacheToPermissionWindow) { CacheProgress = cacheProgress; PermissionWindow = permissionWindow; DirectionIsCacheToPermissionWindow = directionIsCacheToPermissionWindow; }
public CacheProgressCombineable(CacheProgress cacheProgress) { CacheProgress = cacheProgress; }
/// <summary> /// Gets a <see cref="PipelineUser"/> targetting <see cref="CacheProgress.Pipeline_ID"/> /// </summary> /// <param name="cacheProgress"></param> public PipelineUser(CacheProgress cacheProgress) : this(typeof(CacheProgress).GetProperty("Pipeline_ID"), cacheProgress) { }