Esempio n. 1
0
        public BaseJobUpdater GetUpdater(JobType.UpdateInfoType type)
        {
            //if (updateWorkers.ContainsKey(type)) return updateWorkers[type];

            IConnectionManager  connManager         = new ConnectionManager(logger, encryptionManager);
            InstanceInfoUpdater instanceInfoUpdater = new InstanceInfoUpdater(logger);

            IInstanceDataCollector instanceDataCollector = DependencyConfig.Initialize().Resolve <IInstanceDataCollector>(
                new ParameterOverride("connManager", connManager),
                new ParameterOverride("resourceManager", resourceManager),
                new ParameterOverride("logger", logger));

            //logger.Debug("instanceDataCollector = "+ instanceDataCollector.GetHashCode());

            if (type == JobType.UpdateInfoType.Full)
            {
                return(new FullJobUpdater(instanceInfoUpdater, logger, unitOfWork, connManager, instanceDataCollector));
            }
            if (type == JobType.UpdateInfoType.CheckStatus)
            {
                return(new StatusJobUpdater(instanceInfoUpdater, logger, unitOfWork, connManager, instanceDataCollector));
            }
            if (type == JobType.UpdateInfoType.RemoveInstances)
            {
                return(new RemoveJobUpdater(instanceInfoUpdater, logger, unitOfWork, connManager, instanceDataCollector));
            }

            return(null);
        }
Esempio n. 2
0
        void TryStartDataFlow(JobType.UpdateInfoType jobType)
        {
            if (bufferBlockLowP == null || lowPriorityReadInfoBlock == null || writeInfoBlock == null)
            {
                return;
            }

            logger.Debug("TryStartDataFlow " + jobType);

            //var allInstancesID = unitOfWork.Instances.GetAll().Where(i => i.IsDeleted == false).Select<Instance, int>(i => i.Id);
            var allInstancesID = unitOfWork.Instances.GetAll().Select <Instance, int>(i => i.Id);
            var curCollecting  = nowCollecting.Where(i => i.Value.JobType == jobType).Select <KeyValuePair <long, SchedulerWorkItem>, int>(i => i.Value.InstanceId);

            var idToStartUpdate = allInstancesID.Except <int>(curCollecting);

            foreach (int id in idToStartUpdate)
            {
                SchedulerJob schedulerJob = new SchedulerJob(id, jobWorkers.GetUpdater(jobType), jobWorkers.GetSaver(jobType), jobType);

                while (!bufferBlockLowP.Post(schedulerJob))
                {
                }

                nowCollecting.TryAdd(unchecked (dictionaryKey++), new SchedulerWorkItem(id, jobType));

                // logger.Debug("post to BufferBlock " + jobType + " instanceID=" + id);
            }
        }
Esempio n. 3
0
        public BaseJobSaver GetSaver(JobType.UpdateInfoType type)
        {
            if (saveWorkers.ContainsKey(type))
            {
                return(saveWorkers[type]);
            }

            return(null);
        }
Esempio n. 4
0
        private void CreateJobTypeInDataBase(JobType.UpdateInfoType type, int repeatTime)
        {
            JobType jobType = new JobType();

            jobType.Type             = type;
            jobType.MaxMutualWrites  = Environment.ProcessorCount;
            jobType.MaxParallelReads = Environment.ProcessorCount;
            jobType.RepeatTimeSec    = repeatTime;

            // DALLib.EF.MsSqlMonitorEntities dbContext = new DALLib.EF.MsSqlMonitorEntities();
            context.JobTypes.Add(jobType);
            context.SaveChanges();
        }
Esempio n. 5
0
        public void InstanceUpdateFinished(int instanceID, JobType.UpdateInfoType jobType)
        {
            KeyValuePair <long, SchedulerWorkItem> pair = nowCollecting.FirstOrDefault(x => x.Value.InstanceId == instanceID && x.Value.JobType == jobType);

            if (pair.Value == null)
            {
                return;
            }

            SchedulerWorkItem value;

            nowCollecting.TryRemove(pair.Key, out value);

            logger.Debug("update finished ID= " + value.InstanceId + " jobType=" + value.JobType);
        }
Esempio n. 6
0
        // public SQLTaskScheduler Scheduler { get; set; }



        public SchedulerJob(int instanceID, BaseJobUpdater JobUpdater, BaseJobSaver JobSaver, JobType.UpdateInfoType JobType)
        {
            this.InstanceID = instanceID;
            this.JobUpdater = JobUpdater;
            this.JobType    = JobType;
            // this.Scheduler = Scheduler;
            this.JobSaver   = JobSaver;
            this.JobUpdater = JobUpdater;
        }
Esempio n. 7
0
 public SchedulerWorkItem(int _instanceId, JobType.UpdateInfoType _jobType)
 {
     InstanceId = _instanceId;
     JobType    = _jobType;
 }