Exemplo n.º 1
0
        public static void AddToEngine(RFEngineDefinition engineConfig, string connectionString, string environment)
        {
            var heartbeater = engineConfig.AddProcess(
                processName: "System Monitor",
                description: "Sends heartbeats to support dashboard",
                processor: () => new RFSystemMonitor(new RFSystemMonitor.Config
            {
                ConnectionString   = connectionString,
                PublishToDashboard = RFSettings.GetAppSetting("RFMonitors.PublishToDashboard", false),
                DashboardURL       = RFSettings.GetAppSetting("RFMonitors.DashboardURL", null),
                Environment        = environment,
                StateKey           = RFStateKey.CreateKey(engineConfig.KeyDomain, engineConfig.EngineName, "System Monitor", null)
            }));

            // scheduler to kick off monitoring
            var monitoringScheduler = engineConfig.AddProcess(
                processName: "Trigger Monitoring",
                description: "Timed trigger for system monitoring",
                processor: () => new RFSchedulerProcessor(new RFSchedulerConfig
            {
                Schedules = new List <RFSchedulerSchedule> {
                    new RFIntervalSchedule(new TimeSpan(0, RFSettings.GetAppSetting("RFMonitors.PublishMinutes", 5), 0))
                },
                Range = RFWeeklyWindow.AllWeek(),
                //IntervalKey = engineConfig.IntervalDocumentKey(),
                TriggerKey = RFSchedulerTriggerKey.Create(engineConfig.KeyDomain, MonitoringTriggers.Heartbeat)
            }));

            engineConfig.AddIntervalTrigger(monitoringScheduler);

            engineConfig.AddCatalogUpdateTrigger <RFSchedulerTriggerKey>(t => t.TriggerName == MonitoringTriggers.Heartbeat, heartbeater);
        }
Exemplo n.º 2
0
        public RFEngineDefinition BuildEngine(string database, string environment)
        {
            var keyDomain = new RFSimpleKeyDomain("TEST");

            var engineConfig = RFEngineDefinition.Create(
                "TestEngine",
                keyDomain,
                intervalSeconds: 1,
                maxRuntime: TimeSpan.FromMinutes(20));

            // interval and direct dependency

            engineConfig.AddIntervalTrigger(
                engineConfig.AddProcess("Interval test", "Checks for internal", () => new ActionProcessor((c) =>
                                                                                                          c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "IntervalTest", TestKeys.Key1, null), "Complete")
                                                                                                          )));

            engineConfig.AddProcessWithCatalogTrigger <RFEngineProcessorKeyParam>("Interval sink", "Step 2", () => new ActionProcessor((c) =>
                                                                                                                                       c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "IntervalTest", TestKeys.Key2, null), "Complete")),
                                                                                  RFGenericCatalogKey.Create(keyDomain, "IntervalTest", TestKeys.Key1, null));

            // direct and indirect dependency test (A -> B -> C) with reverse

            var graph = engineConfig.CreateGraph("TestGraph");

            graph.AddProcess("A1", "A1", () => new AppendProcessor(new AppendProcessor.Config {
                Append = "A"
            }))
            .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "S", TestKeys.Key1, null), RFDateBehaviour.Exact)
            .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key1, null), RFDateBehaviour.Exact)
            .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "A_Counter", TestKeys.Key1, null), RFDateBehaviour.Exact);

            graph.AddProcess("B1", "B1", () => new AppendProcessor(new AppendProcessor.Config {
                Append = "B"
            }))
            .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key1, null), RFDateBehaviour.Exact)
            .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "Z", TestKeys.Key1, null), RFDateBehaviour.Exact)
            .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "B_Counter", TestKeys.Key1, null), RFDateBehaviour.Exact);

            graph.AddProcess("C1", "C1", () => new AppendProcessor(new AppendProcessor.Config {
                Append = "C"
            }))
            .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key1, null), RFDateBehaviour.Exact)
            .Map(d => d.Input2, RFGenericCatalogKey.Create(keyDomain, "Z", TestKeys.Key1, null), RFDateBehaviour.Exact)
            .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "E", TestKeys.Key1, null), RFDateBehaviour.Exact)
            .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "C_Counter", TestKeys.Key1, null), RFDateBehaviour.Exact);

            // reverse

            graph.AddProcess("A2", "A2", () => new AppendProcessor(new AppendProcessor.Config {
                Append = "C"
            }))
            .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key2, null), RFDateBehaviour.Exact)
            .Map(d => d.Input2, RFGenericCatalogKey.Create(keyDomain, "Z", TestKeys.Key2, null), RFDateBehaviour.Exact)
            .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "E", TestKeys.Key2, null), RFDateBehaviour.Exact)
            .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "C_Counter", TestKeys.Key2, null), RFDateBehaviour.Exact);

            graph.AddProcess("B2", "B2", () => new AppendProcessor(new AppendProcessor.Config {
                Append = "B"
            }))
            .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key2, null), RFDateBehaviour.Exact)
            .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "Z", TestKeys.Key2, null), RFDateBehaviour.Exact)
            .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "B_Counter", TestKeys.Key2, null), RFDateBehaviour.Exact);

            graph.AddProcess("C2", "C2", () => new AppendProcessor(new AppendProcessor.Config {
                Append = "A"
            }))
            .Map(d => d.Input1, RFGenericCatalogKey.Create(keyDomain, "S", TestKeys.Key2, null), RFDateBehaviour.Exact)
            .Map(d => d.Output, RFGenericCatalogKey.Create(keyDomain, "Y", TestKeys.Key2, null), RFDateBehaviour.Exact)
            .Map(d => d.Counter, RFGenericCatalogKey.Create(keyDomain, "A_Counter", TestKeys.Key2, null), RFDateBehaviour.Exact);

            // tasks

            var task1 = engineConfig.AddProcess("Task 1 Process", "Task 1", () => new ActionProcessor((c) =>
                                                                                                      c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "Task 1 Result", TestKeys.Key1, null), "Complete")));

            var task2 = engineConfig.AddProcess("Task 2 Process", "Task 2", () => new ActionProcessor((c) =>
                                                                                                      c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "Task 2 Result", TestKeys.Key1, null), "Complete")));

            var task3 = engineConfig.AddProcess("Task 3 Process", "Task 3", () => new ActionProcessor((c) =>
                                                                                                      c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "Task 3 Result", TestKeys.Key1, null), "Complete")));

            engineConfig.AddScheduledTask("Task 1", new RFIntervalSchedule(new TimeSpan(0, 0, 1)).Single(), RFWeeklyWindow.AllWeek(), task1, false);

            engineConfig.AddChainedTask("Task 2", task1, task2, false);

            engineConfig.AddTriggeredTask("Task 3", RFGenericCatalogKey.Create(keyDomain, "Task 2 Result", TestKeys.Key1, null), task3);

            // queued trigger test
            var queuedTrigger = engineConfig.AddProcess("Queued Trigger Process", "Queued Trigger Process", () => new ActionProcessor((c) =>
            {
                var _in = c.LoadDocumentContent <string>(RFGenericCatalogKey.Create(keyDomain, "Queued Trigger", TestKeys.Key1, null)) ?? String.Empty;
                _in    += "Start";
                Thread.Sleep(TimeSpan.FromSeconds(3));
                _in += "Stop";
                c.SaveDocument(RFGenericCatalogKey.Create(keyDomain, "Queued Trigger", TestKeys.Key1, null), _in);
            }));

            engineConfig.AddTriggeredTask("Queued Scheduler", RFGenericCatalogKey.Create(keyDomain, "Trigger Key", TestEngine.TestKeys.Key1, null), queuedTrigger);

            // transaction
            engineConfig.AddProcess("Transaction Tester", "Tests SQL+MSMQ Transaction", () => new TransactionProcessor(
                                        RFGenericCatalogKey.Create(keyDomain, "Transaction", "Test1", null),
                                        RFGenericCatalogKey.Create(keyDomain, "Transaction", "Test2", null)));

            return(engineConfig);
        }
Exemplo n.º 3
0
        public static void AddToEngine(RFEngineDefinition engineConfig, string connectionString)
        {
            var logMaintainer = engineConfig.AddProcess(
                processName: "Log Maintainer",
                description: "Maintains system log files",
                processor: () => new RFLogMaintainer(new RFLogMaintainer.Config
            {
                ConnectionString       = connectionString,
                LogArchiveDirectory    = RFSettings.GetAppSetting("RFMaintainers.LogArchiveDirectory", null),
                LogDirectories         = (RFSettings.GetAppSetting("RFMaintainers.LogDirectories", "")).Split(';'),
                SystemLogRetentionDays = RFSettings.GetAppSetting("RFMaintainers.SystemLogRetentionDays", 7),
                MaintainLogFiles       = RFSettings.GetAppSetting("RFMaintainers.MaintainLogFiles", false),
                MaintainSystemLog      = RFSettings.GetAppSetting("RFMaintainers.MaintainSystemLog", false),
                MaintainDispatchQueue  = RFSettings.GetAppSetting("RFMaintainers.MaintainDispatchQueue", false)
            }));

            var catalogMaintainer = engineConfig.AddProcess(
                processName: "Catalog Maintainer",
                description: "Maintains data catalog",
                processor: () => new RFSQLCatalogMaintainer(new RFSQLCatalogMaintainer.Config
            {
                ConnectionString = connectionString,
                MaintainCatalog  = RFSettings.GetAppSetting("RFMaintainers.MaintainCatalog", false)
            }));

            var databaseMaintainer = engineConfig.AddProcess(
                processName: "Database Maintainer",
                description: "Maintains database backups",
                processor: () => new RFDatabaseMaintainer(new RFDatabaseMaintainer.Config
            {
                ConnectionString      = connectionString,
                MaintainDatabase      = RFSettings.GetAppSetting("RFMaintainers.MaintainDatabase", false),
                BackupDirectory       = RFSettings.GetAppSetting("RFMaintainers.BackupDirectory", null),
                WeeklyRotation        = RFSettings.GetAppSetting("RFMaintainers.WeeklyRotation", false),
                BackupPassword        = RFSettings.GetAppSetting("RFMaintainers.BackupPassword", null),
                WorkingDirectoryLocal = RFSettings.GetAppSetting("RFMaintainers.WorkingDirectoryLocal", null),
                WorkingDirectoryUNC   = RFSettings.GetAppSetting("RFMaintainers.WorkingDirectoryUNC", null),
                OptimizeDatabase      = RFSettings.GetAppSetting("RFMaintainers.OptimizeDatabase", false)
            }));

            var    maintenanceTime       = new TimeSpan(0, 15, 0);
            string maintenanceTimeConfig = RFSettings.GetAppSetting("RFMaintainers.MaintenanceTime", null);

            if (!string.IsNullOrWhiteSpace(maintenanceTimeConfig))
            {
                maintenanceTime = TimeSpan.ParseExact(maintenanceTimeConfig, @"hh\:mm", null);
            }

            engineConfig.AddScheduledTask("Daily Maintenance: Logs", new RFDailySchedule(maintenanceTime).Single(), RFWeeklyWindow.TueSat(), logMaintainer, true);
            engineConfig.AddChainedTask("Daily Maintenance: Catalog", logMaintainer, catalogMaintainer, true);
            engineConfig.AddChainedTask("Daily Maintenance: Backup", catalogMaintainer, databaseMaintainer, true);
        }