Exemple #1
0
        /// <summary>
        /// Called by the QuartzScheduler before the <see cref="IJobStore"/> is
        /// used, in order to give the it a chance to Initialize.
        /// </summary>
        /// <param name="loadHelper"></param>
        /// <param name="signaler"></param>
        public override void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler signaler)
        {
            if (LockHandler == null)
            {
                // If the user hasn't specified an explicit lock handler,
                // then we ///must/// use DB locks with CMT...
                UseDBLocks = true;
            }

            base.Initialize(loadHelper, signaler);
        }
		/// <summary> Finds a resource with a given name. This method returns null if no
		/// resource with this name is found.
		/// </summary>
		/// <param name="name">name of the desired resource
		/// </param>
		/// <returns> a java.io.InputStream object
		/// </returns>
		public virtual Stream GetResourceAsStream(string name)
		{
			if (bestCandidate != null)
			{
				try
				{
					return bestCandidate.GetResourceAsStream(name);
				}
				catch (Exception)
				{
					bestCandidate = null;
				}
			}

			Stream result = null;
			ITypeLoadHelper loadHelper = null;

			foreach (ITypeLoadHelper lh in loadHelpers)
			{
				loadHelper = lh;

				result = loadHelper.GetResourceAsStream(name);
				if (result != null)
				{
					break;
				}
			}

			bestCandidate = loadHelper;
			return result;
		}
 /// <summary>
 /// Called by the QuartzScheduler before the <see cref="IJobStore"/> is
 /// used, in order to give the it a chance to Initialize.
 /// </summary>
 /// <param name="loadHelper"></param>
 /// <param name="signaler"></param>
 public override void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler signaler)
 {
     base.Initialize(loadHelper, signaler);
 }
        /// <summary>
        /// Called during creation of the <see cref="IScheduler"/> in order to give
        /// the <see cref="ISchedulerPlugin"/> a chance to initialize.
        /// </summary>
        /// <param name="pluginName">The name.</param>
        /// <param name="sched">The scheduler.</param>
        /// <throws>SchedulerConfigException </throws>
        public virtual void Initialize(string pluginName, IScheduler sched)
        {
            name = pluginName;
            scheduler = sched;
            typeLoadHelper = new SimpleTypeLoadHelper();
            typeLoadHelper.Initialize();

            Log.Info("Registering Quartz Job Initialization Plug-in.");

            // Create JobFile objects
            var tokens = fileNames.Split(FileNameDelimiter).Select(x => x.TrimStart());

            foreach (string token in tokens)
            {
                JobFile jobFile = new JobFile(this, token);
                jobFiles.Add(new KeyValuePair<string, JobFile>(jobFile.FilePath, jobFile));
            }
        }
        /// <summary>
        /// Called by the QuartzScheduler before the <see cref="IJobStore" /> is
        /// used, in order to give it a chance to Initialize.
        /// </summary>
        public virtual void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler s)
        {
            if (dataSource == null)
            {
                throw new SchedulerConfigException("DataSource name not set.");
            }

            typeLoadHelper = loadHelper;
            schedSignaler = s;

            // If the user hasn't specified an explicit lock handler, then
            // choose one based on CMT/Clustered/UseDBLocks.
            if (LockHandler == null)
            {
                // If the user hasn't specified an explicit lock handler,
                // then we *must* use DB locks with clustering
                if (Clustered)
                {
                    UseDBLocks = true;
                }

                if (UseDBLocks)
                {
                    if (Delegate is SqlServerDelegate)
                    {
                        if (SelectWithLockSQL == null)
                        {
                            const string DefaultLockSql = "SELECT * FROM {0}LOCKS WITH (UPDLOCK,ROWLOCK) WHERE " + ColumnSchedulerName + " = {1} AND LOCK_NAME = @lockName";
                            Log.InfoFormat("Detected usage of SqlServerDelegate - defaulting 'selectWithLockSQL' to '" + DefaultLockSql + "'.", TablePrefix, "'" + InstanceName + "'");
                            SelectWithLockSQL = DefaultLockSql;
                        }
                    }

                    Log.Info("Using db table-based data access locking (synchronization).");
                    LockHandler = new StdRowLockSemaphore(TablePrefix, InstanceName, SelectWithLockSQL, DbProvider);
                }
                else
                {
                    Log.Info("Using thread monitor-based data access locking (synchronization).");
                    LockHandler = new SimpleSemaphore();
                }
            }
            else
            {
                // be ready to give a friendly warning if SQL Server is used and sub-optimal locking
                if (LockHandler is UpdateLockRowSemaphore && Delegate is SqlServerDelegate)
                {
                    Log.Warn("Detected usage of SqlServerDelegate and UpdateLockRowSemaphore, removing 'quartz.jobStore.lockHandler.type' would allow more efficient SQL Server specific (UPDLOCK,ROWLOCK) row access");
                }
                // be ready to give a friendly warning if SQL Server provider and wrong delegate
                if (DbProvider != null && DbProvider.Metadata.ConnectionType == typeof(SqlConnection) && !(Delegate is SqlServerDelegate))
                {
                    Log.Warn("Detected usage of SQL Server provider without SqlServerDelegate, SqlServerDelegate would provide better performance");
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Select the job to which the trigger is associated.
        /// </summary>
        /// <param name="conn">the DB Connection</param>
        /// <param name="triggerName">the name of the trigger</param>
        /// <param name="groupName">the group containing the trigger</param>
        /// <param name="loadHelper">The load helper.</param>
        /// <returns>The <see cref="JobDetail" /> object associated with the given trigger</returns>
        public virtual JobDetail SelectJobForTrigger(ConnectionAndTransactionHolder conn, string triggerName,
                                                     string groupName,
                                                     ITypeLoadHelper loadHelper)
        {
            using (IDbCommand cmd = PrepareCommand(conn, ReplaceTablePrefix(SqlSelectJobForTrigger)))
            {
                AddCommandParameter(cmd, 1, "triggerName", triggerName);
                AddCommandParameter(cmd, 2, "triggerGroup", groupName);
                using (IDataReader rs = cmd.ExecuteReader())
                {
                    if (rs.Read())
                    {
                        JobDetail job = new JobDetail();
                        job.Name = GetString(rs[0]);
                        job.Group = GetString(rs[1]);
                        job.Durable = GetBoolean(rs[2]);
                        job.JobType = loadHelper.LoadType(GetString(rs[3]));
                        job.RequestsRecovery = GetBoolean(rs[4]);

                        return job;
                    }
                    else
                    {
                        if (logger.IsDebugEnabled)
                        {
                            logger.Debug("No job for trigger '" + groupName + "." + triggerName + "'.");
                        }
                        return null;
                    }
                }
            }
        }
Exemple #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SQLiteDelegate"/> class.
 /// </summary>
 /// <param name="logger">the logger to use during execution</param>
 /// <param name="tablePrefix">the prefix of all table names</param>
 /// <param name="schedName">the scheduler name</param>
 /// <param name="instanceId">The instance id.</param>
 /// <param name="dbProvider">The db provider</param>
 /// <param name="typeLoadHelper">the type loader helper</param>
 /// <param name="useProperties">if set to <c>true</c>, use properties</param>
 public SQLiteDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider,
                       ITypeLoadHelper typeLoadHelper, bool useProperties)
     : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper, useProperties)
 {
 }
        /// <summary>
        /// Called by the QuartzScheduler before the <see cref="IJobStore" /> is
        /// used, in order to give it a chance to Initialize.
        /// </summary>
        public virtual void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler s)
        {
            if (dataSource == null)
            {
                throw new SchedulerConfigException("DataSource name not set.");
            }

            typeLoadHelper = loadHelper;
            signaler = s;


            // If the user hasn't specified an explicit lock handler, then 
            // choose one based on CMT/Clustered/UseDBLocks.
            if (LockHandler == null)
            {
                // If the user hasn't specified an explicit lock handler, 
                // then we *must* use DB locks with clustering
                if (Clustered)
                {
                    UseDBLocks = true;
                }

                if (UseDBLocks)
                {
                    Log.Info("Using db table-based data access locking (synchronization).");
                    LockHandler = new StdRowLockSemaphore(TablePrefix, SelectWithLockSQL, DbProvider);
                }
                else
                {
                    Log.Info("Using thread monitor-based data access locking (synchronization).");
                    LockHandler = new SimpleSemaphore();
                }
            }
        }
Exemple #9
0
 /// <summary>
 /// Called by the QuartzScheduler before the <see cref="T:Quartz.Spi.IJobStore"/> is
 ///             used, in order to give the it a chance to Initialize.
 /// here we default triggerLockTime out to 5 mins (number in miliseconds)
 /// default redisLockTimeout to 5 secs (number in miliseconds)
 /// </summary>
 public void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler signaler)
 {
     _storeSchema = new RedisJobStoreSchema(KeyPrefix ?? string.Empty, KeyDelimiter ?? ":");
     _db          = ConnectionMultiplexer.Connect(RedisConfiguration).GetDatabase();
     _storage     = new RedisStorage(_storeSchema, _db, signaler, InstanceId, TriggerLockTimeout ?? 300000, RedisLockTimeout ?? 5000);
 }
Exemple #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SQLiteDelegate"/> class.
 /// </summary>
 /// <param name="logger">the logger to use during execution</param>
 /// <param name="tablePrefix">the prefix of all table names</param>
 /// <param name="schedName">the scheduler name</param>
 /// <param name="instanceId">The instance id.</param>
 /// <param name="dbProvider">The db provider</param>
 /// <param name="typeLoadHelper">the type loader hgelper</param>
 /// <param name="useProperties">if set to <c>true</c>, use properties</param>
 public SQLiteDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider,
                       ITypeLoadHelper typeLoadHelper, bool useProperties)
     : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper, useProperties)
 {
 }
        /// <summary>
        /// Called by the QuartzScheduler before the <see cref="IJobStore" /> is
        /// used, in order to give the it a chance to Initialize.
        /// </summary>
        public void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler s)
        {
            signaler = s;

            BsonSerializer.RegisterSerializer(typeof(JobKey), KeySerializer<JobKey>.Instance);

            BsonSerializer.RegisterSerializer(typeof(TriggerKey), KeySerializer<TriggerKey>.Instance);

            BsonClassMap.RegisterClassMap<AbstractTrigger>(cm =>
            {
                cm.AutoMap();
                cm.UnmapProperty(c => c.Key);
                cm.UnmapProperty(c => c.JobKey);
                cm.UnmapProperty(c => c.Group);
                cm.UnmapProperty(c => c.Name);
                cm.UnmapProperty(c => c.JobGroup);
                cm.UnmapProperty(c => c.JobName);
            });

            BsonClassMap.RegisterClassMap<JobDetailImpl>(cm =>
            {
                cm.AutoMap();
                cm.MapProperty(c => c.JobType).SetSerializer(TypeSerializer.Instance);
                cm.UnmapProperty(c => c.Key);
                cm.UnmapProperty(c => c.Group);
                cm.UnmapProperty(c => c.Name);
            });

            BsonClassMap.RegisterClassMap<BaseCalendar>(cm =>
            {
                cm.MapProperty(c => c.Description);
                cm.MapProperty(c => c.TimeZone);
                cm.SetDiscriminatorIsRequired(true);
                cm.SetIsRootClass(true);
            });

            database = MongoDatabase.Create(ConnectionString);

            // TODO: Ensure indexes ...
            // TODO: Get collections ...
        }
Exemple #12
0
 /// <summary>
 /// Called by the QuartzScheduler before the <see cref="IJobStore"/> is
 /// used, in order to give the it a chance to Initialize.
 /// </summary>
 /// <param name="loadHelper"></param>
 /// <param name="signaler"></param>
 public override void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler signaler)
 {
     base.Initialize(loadHelper, signaler);
 }
Exemple #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PostgreSQLDelegate"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="tablePrefix">The table prefix.</param>
 /// <param name="schedName">the scheduler name</param>
 /// <param name="instanceId">The instance id.</param>
 /// <param name="dbProvider">The db provider.</param>
 /// <param name="typeLoadHelper">the type loader helper</param>
 public PostgreSQLDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper)
     : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper)
 {
 }
Exemple #14
0
 /// <summary>
 /// Constructor for XMLSchedulingDataProcessor.
 /// </summary>
 public XMLSchedulingDataProcessor(ITypeLoadHelper typeLoadHelper)
 {
     this.typeLoadHelper = typeLoadHelper;
 }
		/// <summary>
		/// Return the class with the given name.
		/// </summary>
		public virtual Type LoadType(string name)
		{
			if (bestCandidate != null)
			{
				try
				{
					return bestCandidate.LoadType(name);
				}
				catch (Exception)
				{
					bestCandidate = null;
				}
			}

			Exception cnfe = null;
			Type clazz = null;

			foreach (ITypeLoadHelper loadHelper in loadHelpers)
			{
				try
				{
					clazz = loadHelper.LoadType(name);
					if (clazz != null)
					{
						break;
					}
					bestCandidate = loadHelper;
				}
				catch (Exception e)
				{
					cnfe = e;
				}
			}

			if (clazz == null)
			{
                if (cnfe == null)
                {
                    cnfe = new Exception("Could not load requested type: " + name);
                }

				throw cnfe;
			}

			return clazz;
		}
Exemple #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OracleDelegate"/> class.
 /// </summary>
 /// <param name="logger">the logger to use during execution</param>
 /// <param name="tablePrefix">the prefix of all table names</param>
 /// <param name="schedName">the scheduler name</param>
 /// <param name="instanceId">The instance id.</param>
 /// <param name="dbProvider">The db provider.</param>
 /// <param name="typeLoadHelper">the type loader helper</param>
 public OracleDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper)
     : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper)
 {
     CreateSqlForSelectNextTriggerToAcquire();
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MySQLDelegate"/> class.
 /// </summary>
 /// <param name="logger">the logger to use during execution</param>
 /// <param name="tablePrefix">the prefix of all table names</param>
 /// <param name="instanceId">The instance id.</param>
 /// <param name="dbProvider">The db provider.</param>
 public MySQLDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper)
     : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper)
 {
 }
Exemple #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlServerDelegate"/> class.
 /// </summary>
 /// <param name="logger">the logger to use during execution</param>
 /// <param name="tablePrefix">the prefix of all table names</param>
 /// <param name="schedName">the scheduler name</param>
 /// <param name="instanceId">The instance id.</param>
 /// <param name="dbProvider">The db provider.</param>
 /// <param name="typeLoadHelper">the type loader helper</param>
 public SqlServerDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper)
     : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper)
 {
     CreateSqlForSelectNextTriggerToAcquire();
 }
        /// <summary>
        /// Called during creation of the <see cref="IScheduler"/> in order to give
        /// the <see cref="ISchedulerPlugin"/> a chance to initialize.
        /// </summary>
        /// <param name="pluginName">The name.</param>
        /// <param name="sched">The scheduler.</param>
        /// <throws>SchedulerConfigException </throws>
        public virtual void Initialize(string pluginName, IScheduler sched)
        {
            name = pluginName;
            scheduler = sched;
            classLoadHelper = new CascadingClassLoadHelper();
            classLoadHelper.Initialize();

            Log.Info("Registering Scheduler Job Initialization Plug-in.");

            // Create JobFile objects
            string[] tokens = fileNames.Split(FileNameDelimiter);

            foreach (string token in tokens)
            {
                JobFile jobFile = new JobFile(this, token);
                jobFiles.Add(jobFile.FilePath, jobFile);
            }
        }
Exemple #20
0
 /// <summary>
 /// Constructor for XMLSchedulingDataProcessor.
 /// </summary>
 public XMLSchedulingDataProcessor(ITypeLoadHelper typeLoadHelper)
 {
     log = LogManager.GetLogger(GetType());
     this.typeLoadHelper = typeLoadHelper;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="OracleDelegate"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="tablePrefix">The table prefix.</param>
 /// <param name="instanceId">The instance id.</param>
 /// <param name="dbProvider">The db provider.</param>
 /// <param name="useProperties">if set to <c>true</c> [use properties].</param>
 public OracleDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper, bool useProperties)
     : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper, useProperties)
 {
     CreateSqlForSelectNextTriggerToAcquire();
 }
Exemple #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SqlServerDelegate"/> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="tablePrefix">The table prefix.</param>
 /// <param name="instanceId">The instance id.</param>
 /// <param name="dbProvider">The db provider.</param>
 /// <param name="useProperties">if set to <c>true</c> [use properties].</param>
 public SqlServerDelegate(ILog logger, string tablePrefix, string schedName, string instanceId, IDbProvider dbProvider, ITypeLoadHelper typeLoadHelper, bool useProperties)
     : base(logger, tablePrefix, schedName, instanceId, dbProvider, typeLoadHelper, useProperties)
 {
     CreateSqlForSelectNextTriggerToAcquire();
 }
Exemple #23
0
        /// <summary>
        /// Select the JobDetail object for a given job name / group name.
        /// </summary>
        /// <param name="conn">The DB Connection.</param>
        /// <param name="jobName">The job name whose listeners are wanted.</param>
        /// <param name="groupName">The group containing the job.</param>
        /// <param name="loadHelper">The load helper.</param>
        /// <returns>The populated JobDetail object.</returns>
        public virtual JobDetail SelectJobDetail(ConnectionAndTransactionHolder conn, string jobName, string groupName,
                                                 ITypeLoadHelper loadHelper)
        {
            using (IDbCommand cmd = PrepareCommand(conn, ReplaceTablePrefix(SqlSelectJobDetail)))
            {
                AddCommandParameter(cmd, 1, "jobName", jobName);
                AddCommandParameter(cmd, 2, "jobGroup", groupName);
                using (IDataReader rs = cmd.ExecuteReader())
                {
                    JobDetail job = null;

                    if (rs.Read())
                    {
                        job = new JobDetail();

                        job.Name = GetString(rs[ColumnJobName]);
                        job.Group = GetString(rs[ColumnJobGroup]);
                        job.Description = GetString(rs[ColumnDescription]);
                        job.JobType = loadHelper.LoadType(GetString(rs[ColumnJobClass]));
                        job.Durable = GetBoolean(rs[ColumnIsDurable]);
                        job.Volatile = GetBoolean(rs[ColumnIsVolatile]);
                        job.RequestsRecovery = GetBoolean(rs[ColumnRequestsRecovery]);

                        IDictionary map;
                        if (CanUseProperties)
                        {
                            map = GetMapFromProperties(rs, 8);
                        }
                        else
                        {
                            map = (IDictionary)GetObjectFromBlob(rs, 8);
                        }

                        if (null != map)
                        {
                            job.JobDataMap = new JobDataMap(map);
                        }
                    }

                    return job;
                }
            }
        }
Exemple #24
0
 /// <summary>
 /// Called by the QuartzScheduler before the <see cref="IJobStore"/> is
 /// used, in order to give the it a chance to Initialize.
 /// </summary>
 /// <param name="loadHelper"></param>
 /// <param name="signaler"></param>
 public override Task Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler signaler)
 {
     base.Initialize(loadHelper, signaler);
     Log.Info("JobStoreTX initialized.");
     return(TaskUtil.CompletedTask);
 }
Exemple #25
0
        /// <summary>
        /// Called by the QuartzScheduler before the <see cref="IJobStore" /> is
        /// used, in order to give it a chance to Initialize.
        /// </summary>
        public virtual void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler s)
        {
            if (dataSource == null)
            {
                throw new SchedulerConfigException("DataSource name not set.");
            }

            typeLoadHelper = loadHelper;
            schedSignaler = s;

            // If the user hasn't specified an explicit lock handler, then
            // choose one based on CMT/Clustered/UseDBLocks.
            if (LockHandler == null)
            {
                // If the user hasn't specified an explicit lock handler,
                // then we *must* use DB locks with clustering
                if (Clustered)
                {
                    UseDBLocks = true;
                }

                if (UseDBLocks)
                {
                    if (Delegate is SqlServerDelegate)
                    {
                        if (SelectWithLockSQL == null)
                        {
                            const string DefaultLockSql = "SELECT * FROM {0}LOCKS WITH (UPDLOCK,ROWLOCK) WHERE " + ColumnSchedulerName + " = {1} AND LOCK_NAME = @lockName";
                            Log.Info("Detected usage of MSSQLDelegate - defaulting 'selectWithLockSQL' to '" + DefaultLockSql + "'.");
                            SelectWithLockSQL = DefaultLockSql;
                        }
                    }

                    Log.Info("Using db table-based data access locking (synchronization).");
                    LockHandler = new StdRowLockSemaphore(TablePrefix, InstanceName, SelectWithLockSQL, DbProvider);
                }
                else
                {
                    Log.Info("Using thread monitor-based data access locking (synchronization).");
                    LockHandler = new SimpleSemaphore();
                }
            }
        }
Exemple #26
0
 /// <summary>
 /// Called by the QuartzScheduler before the <see cref="IJobStore"/> is
 /// used, in order to give the it a chance to Initialize.
 /// </summary>
 /// <param name="loadHelper"></param>
 /// <param name="signaler"></param>
 public override void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler signaler)
 {
     base.Initialize(loadHelper, signaler);
     Log.Info("JobStoreTX initialized.");
 }
 /// <summary>
 /// Called by the QuartzScheduler before the <see cref="IJobStore" /> is
 /// used, in order to give the it a chance to Initialize.
 /// </summary>
 public virtual void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler s)
 {
     signaler = s;
     Log.Info("MongoDB JobStore initialized.");
 }
 /// <summary>
 /// Called by the QuartzScheduler before the <see cref="IJobStore"/> is
 /// used, in order to give the it a chance to Initialize.
 /// </summary>
 /// <param name="loadHelper"></param>
 /// <param name="signaler"></param>
 public override void Initialize(ITypeLoadHelper loadHelper, ISchedulerSignaler signaler)
 {
     base.Initialize(loadHelper, signaler);
     Log.Info("JobStoreTX initialized.");
 }