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); }
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); } }
public BaseJobSaver GetSaver(JobType.UpdateInfoType type) { if (saveWorkers.ContainsKey(type)) { return(saveWorkers[type]); } return(null); }
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(); }
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); }
// 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; }
public SchedulerWorkItem(int _instanceId, JobType.UpdateInfoType _jobType) { InstanceId = _instanceId; JobType = _jobType; }