Пример #1
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="taskManager">The <see cref="ITaskManager"/> instance.</param>
 /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
 /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
 public ClientManager(ITaskManager taskManager, ICommonLoggerFactory loggerFactory) : base("Client Manager", loggerFactory)
 {
     if (taskManager == null)
     {
         throw new ArgumentNullException("taskManager");
     }
     this.taskManager = taskManager;
 }
Пример #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
        protected BaseLoggerObject(ICommonLoggerFactory loggerFactory)
        {
            if (loggerFactory == null)
            {
                throw new ArgumentNullException("loggerFactory");
            }

            logger = loggerFactory.Create(GetType());
        }
Пример #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="name">Manager <c>name</c>.</param>
        /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentException">Value cannot be null or empty.</exception>
        protected BaseManager(string name, ICommonLoggerFactory loggerFactory) : base(loggerFactory)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Value cannot be null or empty.", "name");
            }

            Name = name;
        }
Пример #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="jsonSerializerSettings">The <see cref="JsonSerializerSettings"/> instance.</param>
        /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="jsonSerializerSettings"/> is <see langword="null" />.</exception>
        public JsonConverter(JsonSerializerSettings jsonSerializerSettings, ICommonLoggerFactory loggerFactory) : this(loggerFactory)
        {
            if (jsonSerializerSettings == null)
            {
                throw new ArgumentNullException("jsonSerializerSettings");
            }

            this.jsonSerializerSettings = jsonSerializerSettings;
        }
Пример #5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="serverDataContext">The <see cref="IServerDataContext"/> instance.</param>
        /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
        public ServerManager(IServerDataContext serverDataContext, ICommonLoggerFactory loggerFactory)
            : base("Server Manager", loggerFactory)
        {
            if (serverDataContext == null)
            {
                throw new ArgumentNullException("serverDataContext");
            }

            this.serverDataContext = serverDataContext;
            heartbeatLifetime      = TimeSpan.FromSeconds(15); //Move to settings.

            //5 seconds for connection to the SQL.
            sleepTime = TimeSpan.FromSeconds(heartbeatLifetime.Seconds - 10);

            heartbetCancelationCancellationTokenSource = new CancellationTokenSource();
            CancellationToken cancellationToken = heartbetCancelationCancellationTokenSource.Token;

            serverHeartbetTask = new Task(OnHeartbet, cancellationToken);
        }
Пример #6
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
 /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
 public ResourceReaderHelper(ICommonLoggerFactory loggerFactory) : base(loggerFactory)
 {
 }
Пример #7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="sqlSettings">MsSql settings.</param>
 /// <param name="resourceReaderHelper">The <see cref="IResourceReaderHelper"/> instance.</param>
 /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
 /// <exception cref="ArgumentNullException"><paramref name="sqlSettings"/> is <see langword="null" />.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="resourceReaderHelper"/> is <see langword="null" />.</exception>
 public SqlServerInstaller(MsSqlSettings sqlSettings, IResourceReaderHelper resourceReaderHelper, ICommonLoggerFactory loggerFactory) : base(loggerFactory)
 {
     if (sqlSettings == null)
     {
         throw new ArgumentNullException("sqlSettings");
     }
     if (resourceReaderHelper == null)
     {
         throw new ArgumentNullException("resourceReaderHelper");
     }
     this.sqlSettings          = sqlSettings;
     this.resourceReaderHelper = resourceReaderHelper;
 }
Пример #8
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="queueConverter">The <see cref="IQueueConverter"/> instance.</param>
        /// <param name="queueDataContext">The <see cref="IQueueDataContext"/> instance.</param>
        /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
        public QueueManager(IQueueConverter queueConverter, IQueueDataContext queueDataContext, ICommonLoggerFactory loggerFactory)
            : base("QueueManager", loggerFactory)
        {
            if (queueConverter == null)
            {
                throw new ArgumentNullException("queueConverter");
            }
            if (queueDataContext == null)
            {
                throw new ArgumentNullException("queueDataContext");
            }

            this.queueConverter   = queueConverter;
            this.queueDataContext = queueDataContext;
        }
Пример #9
0
        private readonly TimeSpan heartbeatLifetime; //TODO: Should be different for each manager.
        #endregion

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
        public MainManagerManager(ICommonLoggerFactory loggerFactory) : base(loggerFactory)
        {
            managers          = new List <IManager>();
            heartbeatLifetime = TimeSpan.FromSeconds(20); //TODO: Move to settings.
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
 public CachedExpressionCompiler(ICommonLoggerFactory loggerFactory) : base(loggerFactory)
 {
 }
Пример #11
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
 public JsonConverter(ICommonLoggerFactory loggerFactory)
     : base(loggerFactory)
 {
     jsonSerializerSettings = new JsonSerializerSettings();
 }
Пример #12
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
 /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
 public TaskBuilder(ICommonLoggerFactory loggerFactory) : base(loggerFactory)
 {
 }
Пример #13
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
 /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
 public ServerConverter(ICommonLoggerFactory loggerFactory) : base(loggerFactory)
 {
 }
Пример #14
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="jsonConverter">The <see cref="IJsonConverter"/> instance.</param>
        /// <param name="cachedExpressionCompiler">The <see cref="ICachedExpressionCompiler"/> instance.</param>
        /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
        public ExpressionConverter(IJsonConverter jsonConverter, ICachedExpressionCompiler cachedExpressionCompiler, ICommonLoggerFactory loggerFactory)
            : base(loggerFactory)
        {
            if (jsonConverter == null)
            {
                throw new ArgumentNullException("jsonConverter");
            }
            if (cachedExpressionCompiler == null)
            {
                throw new ArgumentNullException("cachedExpressionCompiler");
            }

            this.jsonConverter            = jsonConverter;
            this.cachedExpressionCompiler = cachedExpressionCompiler;
        }
Пример #15
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sqlSettings">Sql settings.</param>
        /// <param name="taskConverter">The <see cref="ITaskConverter"/> instance.</param>
        /// <param name="connectionFactory">The <see cref="ISqlConnectionFactory"/> instance.</param>
        /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="sqlSettings"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="taskConverter"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="connectionFactory"/> is <see langword="null" />.</exception>
        public TaskDataContext(MsSqlSettings sqlSettings, ITaskConverter taskConverter, ISqlConnectionFactory connectionFactory, ICommonLoggerFactory loggerFactory)
            : base(loggerFactory)
        {
            if (sqlSettings == null)
            {
                throw new ArgumentNullException("sqlSettings");
            }
            if (taskConverter == null)
            {
                throw new ArgumentNullException("taskConverter");
            }
            if (connectionFactory == null)
            {
                throw new ArgumentNullException("connectionFactory");
            }

            this.sqlSettings       = sqlSettings;
            this.taskConverter     = taskConverter;
            this.connectionFactory = connectionFactory;
        }
Пример #16
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="sqlSettings">MsSql settings including connection string and different timeouts.</param>
        /// <param name="sqlServerInstaller">The <see cref="ISqlServerInstaller"/> instance.</param>
        /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="sqlSettings"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="sqlServerInstaller"/> is <see langword="null" />.</exception>
        public SqlConnectionFactory(MsSqlSettings sqlSettings, ISqlServerInstaller sqlServerInstaller, ICommonLoggerFactory loggerFactory)
            : base(loggerFactory)
        {
            if (sqlSettings == null)
            {
                throw new ArgumentNullException("sqlSettings");
            }
            if (sqlServerInstaller == null)
            {
                throw new ArgumentNullException("sqlServerInstaller");
            }

            this.sqlSettings = sqlSettings;

            using (IDbConnection connection = CreateDatabaseAndConnection())
            {
                sqlServerInstaller.Install(connection);
            }
        }
Пример #17
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
 /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
 public QueueConverter(ICommonLoggerFactory loggerFactory) : base(loggerFactory)
 {
 }
Пример #18
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="expressionConverter">The <see cref="IExpressionConverter"/> instance.</param>
        /// <param name="taskDataContext">The <see cref="ITaskDataContext"/> instance.</param>
        /// <param name="serverManager">The <see cref="IQueueManager"/> instance.</param>
        /// <param name="queueManager">The <see cref="IServerManager"/> instance.</param>
        /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expressionConverter"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="taskDataContext"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="serverManager"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="queueManager"/> is <see langword="null" />.</exception>
        public TaskManager(TaskManagerConfiguration taskManagerConfiguration, ITaskBuilder taskBuilder, IExpressionConverter expressionConverter, ITaskDataContext taskDataContext, IServerManager serverManager, IQueueManager queueManager, ICommonLoggerFactory loggerFactory)
            : base("Task Manager", loggerFactory)
        {
            if (taskManagerConfiguration == null)
            {
                throw new ArgumentNullException(nameof(taskManagerConfiguration));
            }
            if (taskBuilder == null)
            {
                throw new ArgumentNullException(nameof(taskBuilder));
            }
            if (expressionConverter == null)
            {
                throw new ArgumentNullException("expressionConverter");
            }
            if (taskDataContext == null)
            {
                throw new ArgumentNullException("taskDataContext");
            }
            if (serverManager == null)
            {
                throw new ArgumentNullException("serverManager");
            }
            if (queueManager == null)
            {
                throw new ArgumentNullException("queueManager");
            }

            this.taskBuilder         = taskBuilder;
            this.expressionConverter = expressionConverter;
            this.taskDataContext     = taskDataContext;
            this.serverManager       = serverManager;
            this.queueManager        = queueManager;

            activeTasks = new Dictionary <Int64, IRunningTask>();

            maxRerunCount       = taskManagerConfiguration.MaxRerunAttempts;
            maxTasksPerQueue    = taskManagerConfiguration.MaxTaskPerQueue;
            timeShiftAfterCrash = taskManagerConfiguration.TimeShiftAfterCrash;
            taskManagerState    = taskManagerConfiguration.State;
        }
Пример #19
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="expressionConverter">The <see cref="IExpressionConverter"/> instance.</param>
        /// <param name="jsonConverter">JSON converter.</param>
        /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
        /// <exception cref="ArgumentNullException"><paramref name="expressionConverter"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="jsonConverter"/> is <see langword="null" />.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
        public TaskConverter(IExpressionConverter expressionConverter, IJsonConverter jsonConverter, ICommonLoggerFactory loggerFactory) : base(loggerFactory)
        {
            if (expressionConverter == null)
            {
                throw new ArgumentNullException("expressionConverter");
            }
            if (jsonConverter == null)
            {
                throw new ArgumentNullException("jsonConverter");
            }

            this.expressionConverter = expressionConverter;
            this.jsonConverter       = jsonConverter;
        }
Пример #20
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="loggerFactory">The <see cref="ICommonLoggerFactory"/> instance.</param>
 /// <exception cref="ArgumentNullException"><paramref name="loggerFactory"/> is <see langword="null" />.</exception>
 /// <exception cref="ArgumentException">Value cannot be null or empty.</exception>
 public HistoricalManager(ICommonLoggerFactory loggerFactory) : base("HistoricalManager", loggerFactory)
 {
 }