Command IManagerCoreServices.GetWorkerState(string workerId) { WorkerRunner workerRunner = FindWorkerRunner(workerId); if (null != workerRunner) { return(workerRunner.Command); } Tracer.Error("WorkerManager got GetWorkerState from worker {0}, but it does not know about worker with that name!", workerId); return(Command.Cancel); }
WorkAssignment IManagerCoreServices.GetWorkAssignment(string workerId) { WorkerRunner workerRunner = FindWorkerRunner(workerId); if (null != workerRunner) { return(workerRunner.WorkAssignment); } Tracer.Error("WorkerManager got GetWorkRequest from worker {0}, but it does not know about worker with that name!", workerId); return(null); }
// Returns false when runningJob is ready to be removed from the list of running jobs and disposed private bool StopWorkersForJob(RunningJob runningJob) { Tracer.Info("Stopping workers for a job. PipelineId = {0}", runningJob.PipelineId); runningJob.State = RunningJob.States.ReadyForDispose; // Just an unconfirmed attempt so far if (runningJob.Sections != null) { foreach (JobSection jobSection in runningJob.Sections) { foreach (string workerID in jobSection.WorkerIDs) { WorkerRunner workerRunner = FindWorkerRunner(workerID); if (null == workerRunner) { continue; } if (workerRunner.IsPresent) { //Tracer.Trace("StopWorkersForJob: Worker {0} is still active. Commanding it to quit.", workerRunner.WorkAssignment.WorkerId); workerRunner.Command = Command.Cancel; runningJob.State = RunningJob.States.WaitingForWorkersToQuit; } else { Tracer.Info("StopWorkersForJob: Worker {0} quit. Removing worker runner object.", workerRunner.WorkAssignment.WorkerId); AllWorkerRunners.Remove(workerRunner.WorkAssignment.WorkerId); workerRunner.CommittableTransaction.Commit(); workerRunner.CommittableTransaction.Dispose(); } } } } //Tracer.Trace("runningJob.PipelineId = {0}, runningJob.State = {1}", runningJob.PipelineId, runningJob.State.ToString()); if (runningJob.State == RunningJob.States.ReadyForDispose) { // TODO: Properly dispose JobSections here Tracer.Info("Disposed its resources pertained to job with PipelineId = {0}", runningJob.PipelineId); return(false); } return(true); }
internal void EmployWorker(WorkerCard workerCard, WorkAssignment workAssignment, CommittableTransaction committableTransaction) { WorkerRunner workerRunner = null; switch (workAssignment.WorkRequest.WorkerIsolationLevel) { case WorkerIsolationLevel.SeparateAppDomain: workerRunner = new WorkerRunnerAppDomain(workerCard, workAssignment, committableTransaction); break; case WorkerIsolationLevel.SeparateProcess: workerRunner = new WorkerRunnerProcess(workerCard, workAssignment, committableTransaction); // Debug //workerRunner = new WorkerRunnerThread(workerCard, WorkAssignment, committableTransaction); break; case WorkerIsolationLevel.SeparateThread: case WorkerIsolationLevel.Default: default: workerRunner = new WorkerRunnerThread(workerCard, workAssignment, committableTransaction); break; } try { AllWorkerRunners.Add(workAssignment.WorkerId, workerRunner); } catch (Exception ex) { Tracer.Error("AllWorkerRunners.Add({0}) caused exception: {1}", workAssignment.WorkerId, ex); foreach (string workerId in AllWorkerRunners.Keys) { Tracer.Error("AllWorkerRunners contains worker {0}", workerId); } throw; } workerRunner.Run(); }
private void UpdateRunningJob(RunningJob runningJob, OpenJob openJob) { if (runningJob != null) { if (runningJob.Sections != null) { foreach (JobSection jobSection in runningJob.Sections) { foreach (string workerID in jobSection.WorkerIDs) { WorkerRunner workerRunner = FindWorkerRunner(workerID); if (null != workerRunner) { workerRunner.Command = openJob.Command; } } } } if (openJob.Command == Command.Run) { EmployWorkersForJob(runningJob); } } }