public static void StoreJobTaskOutputFile(GridJobTask task, string file, byte[] data) { CreateTaskDirectoriesIfNotExists(task); var fp = $"{JobsDirectory}\\{task.ParentJob.Name}\\task-{task.TaskId}\\{file}"; File.WriteAllBytes(fp, data); }
public static string ResolveFilePath(GridJob job, GridJobTask task, GridJobFile file) { if (file.ShareMode == EGridJobFileShare.SharedBetweenTasks) { return($"{JobsDirectory}\\{job.Name}\\{file.FileName}"); } return($"{JobsDirectory}\\{job.Name}\\task-{task.TaskId}\\{file.FileName}"); }
public static bool CreateTaskDirectoriesIfNotExists(GridJobTask task) { if (!CheckIfTaskDirectoriesExists(task)) { Directory.CreateDirectory($"{JobsDirectory}\\{task.ParentJob.Name}\\task-{task.TaskId}"); return(true); } return(false); }
public static void CreateDirectoriesForTask(GridJobTask task) { if (CreateTaskDirectoriesIfNotExists(task)) { return; } CleanupDirectory($"{JobsDirectory}\\{task.ParentJob.Name}\\task-{task.TaskId}"); CreateDirectoriesForTask(task); }
public static void StoreJobTaskFile(GridJobTask task, GridJobFile file) { CreateTaskDirectoriesIfNotExists(task); var fp = $"{JobsDirectory}\\{task.ParentJob.Name}\\task-{task.TaskId}\\{file.FileName}"; if (file.ShareMode == EGridJobFileShare.SharedBetweenTasks) { fp = $"{JobsDirectory}\\{task.ParentJob.Name}\\{file.FileName}"; } File.WriteAllBytes(fp, file.Bytes); }
public static bool IsJobTaskFileExistsAndValid(GridJobTask task, GridJobFile jobFile) { var fp = $"{JobsDirectory}\\{task.ParentJob.Name}\\{jobFile.FileName}"; if (jobFile.ShareMode == EGridJobFileShare.SharedBetweenTasks) { if (!File.Exists(fp)) { return(false); } return(CryptoUtils.CrcOfFile(fp) == jobFile.CheckSum); } fp = $"{JobsDirectory}\\{task.ParentJob.Name}\\task-{task.TaskId}\\{jobFile.FileName}"; if (!File.Exists(fp)) { return(false); } return(CryptoUtils.CrcOfFile(fp) == jobFile.CheckSum); }
private static GridJobModule LoadModule(GridJobTask task, GridJobFileLink link) { var moduleFile = task.ParentJob.JobFiles.FirstOrDefault(x => x.FileName == link.FileName); if (moduleFile == null) { throw new GridJobTaskCommandException(task, $"Unable to locate referenced module file {link} in task instance"); } moduleFile.Bytes = File.ReadAllBytes(GridIo.ResolveFilePath(task, moduleFile)); moduleFile.UpdateCheckSum(); Assembly assembly; try { assembly = Assembly.Load(moduleFile.Bytes); } catch (Exception e) { throw new GridJobTaskCommandException(task, $"Unable to load module assembly file {link} when try to execute task", e); } var entryPoint = assembly.GetExportedTypes().FirstOrDefault(t => t.BaseType == typeof(GridJobModule)); if (entryPoint == null) { throw new GridJobTaskCommandException(task, $"Unable to load module {link}: target module do not release {typeof(GridJobModule).FullName} class"); } dynamic obj; try { obj = Activator.CreateInstance(entryPoint, null); } catch (Exception err) { throw new GridJobTaskCommandException(task, $"Unable to load module {link}: unable to create instance of {entryPoint.FullName} module entrypoint class", err); } return((GridJobModule)obj); }
public static bool CheckIfTaskDirectoriesExists(GridJobTask task) { return(Directory.Exists($"{JobsDirectory}\\{task.ParentJob.Name}\\task-{task.TaskId}")); }
public static string ResolveFilePath(GridJobTask task, string fileName) { return($"{JobsDirectory}\\{task.ParentJob.Name}\\task-{task.TaskId}\\{fileName}"); }
public GridJobTaskCommandException(GridJobTask task, string msg, Exception err) : base(msg, err) { Task = task; }
public abstract void ExecuteTask(GridTaskExecutor executor, GridJobTask task, ILog logger);
public void WriteFileOutput(GridJobTask task, string outputFile, string text) { GridIo.StoreJobTaskOutputFile(task, outputFile, Encoding.UTF8.GetBytes(text)); }
public void PrepareJobTaskDirectories(GridJobTask task) { GridIo.CreateDirectoriesForTask(task); }
public string ResolveFilePath(GridJobTask task, string fileName) { return(GridIo.ResolveFilePath(task, fileName)); }
public string ResolveFilePath(GridJobTask task, GridJobFile file) { return(GridIo.ResolveFilePath(task.ParentJob, task, file)); }