/// <summary> /// Initializes the task scheduler with all configured scheduler tasks. /// </summary> /// <param name="dbSet">The set of active Mosaic databases.</param> /// <returns><c>true</c> if initialization was successful;<c>false</c> otherwise.</returns> public bool Initialize(DatabaseSet dbSet) { if (dbSet == null) { throw new ArgumentException("Invalid dbSet specified."); } this.Trace("Initializing task scheduler..."); _taskConverterStreams.Clear(); _taskConverterStreamConfig.Clear(); try { List<Component> componentList = dbSet.Productive.Query<Component>(new CommandFilter("Type", ComponentType.SchedulerTask.ToString())); foreach (Component component in componentList) { if (component.IsActive == false) { continue; } this.Info("Initializing scheduler task '{0}' with ID '{1}'.", component.Description, component.ID); ISchedulerTask task = ComponentLoader.LoadInterface<ISchedulerTask>(component.Assembly, component.ClassName); if (task == null) { this.Fatal("Scheduler task '{0}' with ID '{1}' in assembly '{2}' and class '{3}' could not be found.", component.Description, component.ID, component.Assembly, component.ClassName); return false; } if (task.Initialize(component.ID, dbSet.Productive.Query<ConfigurationValue>(new CommandFilter("ComponentID", component.ID)), dbSet) == false) { this.Error("Initializing scheduler task '{0}' with ID '{1}' failed.", component.Description, component.ID); return false; } List<int> converterConfiguration = new List<int>(); var connectedConverterList = dbSet.Productive.Query<Component>(new CommandFilter("ConnectedComponentID", component.ID)); foreach (var converter in connectedConverterList) { converterConfiguration.Add(converter.ID); } _taskConverterStreams.Add(task, new List<IConverterStream>()); _taskConverterStreamConfig.Add(task, converterConfiguration); } return true; } catch (Exception ex) { this.Error("Initializing scheduler tasks failed.", ex); } return false; }
/// <summary> /// Initializes the connector manager with all configured connectors. /// </summary> /// <param name="dbSet">The set of active Mosaic databases.</param> /// <param name="orchestrationManager">The active orchestration manager to notify about new converter streams.</param> /// <param name="taskScheduler">The active task scheduler to notify about converter streams.</param> /// <returns><c>true</c> if initialization was successful;<c>false</c> otherwise.</returns> public bool Initialize(DatabaseSet dbSet, OrchestrationManager orchestrationManager, TaskScheduler taskScheduler) { if (dbSet == null) { throw new ArgumentException("Invalid dbSet specified."); } if (orchestrationManager == null) { throw new ArgumentException("Invalid orchestrationManager specified."); } if (taskScheduler == null) { throw new ArgumentException("Invalid taskScheduler specified."); } this.Trace("Initializing converter manager..."); _converterList.Clear(); _taskAssignments.Clear(); _orchestrationManager = orchestrationManager; _taskScheduler = taskScheduler; try { List <Component> componentList = dbSet.Productive.Query <Component>(new CommandFilter("Type", ComponentType.Converter.ToString())); foreach (Component component in componentList) { if (component.IsActive == false) { continue; } this.Info("Initializing converter '{0}' with ID '{1}'.", component.Description, component.ID); IConverter converter = ComponentLoader.LoadInterface <IConverter>(component.Assembly, component.ClassName); if (converter == null) { this.Fatal("Converter '{0}' with ID '{1}' in assembly '{2}' and class '{3}' could not be found.", component.Description, component.ID, component.Assembly, component.ClassName); return(false); } if (converter.Initialize(component.ID, dbSet.Productive.Query <ConfigurationValue>(new CommandFilter("ComponentID", component.ID))) == false) { this.Error("Initializing converter '{0}' with ID '{1}' failed.", component.Description, component.ID); return(false); } _converterList.Add(converter); if (component.ConnectedComponentID != 0) { _taskAssignments.Add(converter.ID, component.ConnectedComponentID); } } return(true); } catch (Exception ex) { this.Error("Initializing converters failed.", ex); } return(false); }