private string ConstructPythonScript(JobId jobId) { string pythonScript = Properties.Resources.RemoveJobScript; return(string.Format(pythonScript, jobId)); }
private string ConstructPythonScript(JobId jobId) { string pythonScript = Properties.Resources.GetJobStatusScript; return(string.Format(pythonScript, jobId.ClusterId, jobId.ProcessId)); }
public static void SendToChild(JobId jobId, object objectToSend) { if (!isInitialized) { throw new ShappException("before sending a message you have to initialize the CommunicatorWithChildren"); } server.Send(jobIdToSocket[jobId], objectToSend); }
public string GetCounterExample(JobId jid) { var childFilenamesMap = ReadFilenameMapping(jid); // loads the mapping from the child, can be done only after the child completes string counterExampleFilename = GetEffectiveFilename(COUNTER_EXAMPLE_FILE, childFilenamesMap); string counterExample = File.ReadAllText(counterExampleFilename); return(counterExample); }
/// <summary> /// Initializes job's descriptor with its jobId. It is being used mostly by internals of /// the library, but JobDescriptor may be created for an arbitrary job id (e.g. the one /// saved in some file before the program shutdown). /// </summary> /// <param name="jobId">job's id to bound into descriptor</param> public JobDescriptor(JobId jobId) { JobId = jobId; StateListener += JobDescriptorEventLauncher; StateListener += JobDescriptorStateChangeLogger; jobStateFetcher = new JobStateFetcher(jobId); jobRemover = new JobRemover(jobId); SetupJobStatusPoller(); }
public int GetExitCode(JobId jid) { var childFilenamesMap = ReadFilenameMapping(jid); // loads the mapping from the child, can be done only after the child completes // from now, using the files is exaclty mirrored as in the child string exitCodeFilename = GetEffectiveFilename(EXIT_CODE_FILE, childFilenamesMap); int exitCode = int.Parse(File.ReadAllText(exitCodeFilename)); return(exitCode); }
private static Dictionary <String, String> ReadFilenameMapping(JobId jid) { Dictionary <String, String> filenamesMap = new Dictionary <string, string>(); using (StreamReader sr = new StreamReader(string.Format("x_{0}_stdout.out", jid))) { string line; while ((line = sr.ReadLine()) != null) { Regex regex = new Regex(FILENAMES_MAPPING_FORMAT_REGEX); Match match = regex.Match(line); string filename = match.Groups[1].Value; string effectiveFilename = match.Groups[2].Value; filenamesMap.Add(filename, effectiveFilename); } } return(filenamesMap); }
private void JobDescriptorEventLauncher(JobState previous, JobState current, JobId jobId) { switch (current) { case JobState.RUNNING: JobStartedEvent.Set(); break; case JobState.COMPLETED: JobStartedEvent.Set(); JobCompletedEvent.Set(); JobReadyForCommunicationsEvent.Reset(); DisableProbingJobState(); break; case JobState.REMOVED: JobStartedEvent.Set(); JobRemovedEvent.Set(); JobReadyForCommunicationsEvent.Reset(); DisableProbingJobState(); break; } }
/// <summary> /// Constructs the status fetcher for one particular job id. /// </summary> /// <param name="jobId">job's id which state should be watched</param> public JobStateFetcher(JobId jobId) { JobId = jobId; PythonScriptWithFetcher = ConstructPythonScript(jobId); pythonScriptExecutor = new PythonScriptsExecutor(PythonScriptWithFetcher); }
private void JobDescriptorStateChangeLogger(JobState previous, JobState current, JobId jobId) { C.log.Info(string.Format("Job {0} state has changed from {1} to {2}", jobId, previous, current)); }
/// <summary> /// Constructs the job remover for one particular job id. /// </summary> /// <param name="jobId">job's id which state should be removed</param> public JobRemover(JobId jobId) { JobId = jobId; PythonScriptWithRemover = ConstructPythonScript(jobId); pythonScriptExecutor = new PythonScriptsExecutor(PythonScriptWithRemover); }