public static void SubmitAndWait(ClusterSubmitterArgs clusterArgs, IDistributable distributableObj, int maxSubmitAfterTasksFail = 0) { using (ParallelOptionsScope.Suspend()) { int numberOfTries = 0; retry: Submit(clusterArgs, distributableObj); JobWaitingParams jobWaitingParams = WaitForJobInternal(clusterArgs); if (jobWaitingParams.JobState == v2008R2.Properties.JobState.Canceled) { throw new Exception("Job canceled."); } else if (jobWaitingParams.JobState == v2008R2.Properties.JobState.Failed) { if (numberOfTries < maxSubmitAfterTasksFail) { ++numberOfTries; Console.WriteLine("Job failed, trying again..."); goto retry; } throw new Exception("Job failed."); } //HpcLib.HpcLib.CopyFiles(new List<String> { "" }, _remoteTaskOutDir, TASK_OUT_DIR); } }
public bool Refresh() { bool changed = false; ISchedulerCounters counters; using (ParallelOptionsScope.Suspend()) { if (Connect() && null != (counters = GetCounters())) { changed = BusyCores != counters.BusyCores || IdleCores != counters.IdleCores || QueuedTasks != counters.QueuedTasks; BusyCores = counters.BusyCores; IdleCores = counters.IdleCores; QueuedTasks = counters.QueuedTasks; } else { changed = BusyCores != -1; BusyCores = -1; IdleCores = -1; QueuedTasks = -1; } } return(changed); }
private static void SubmitInternal(ClusterSubmitterArgs clusterArgs, IDistributable distributableObj) { lock (_submitterLockObj) // for now, just let one thread submit at a time. { if (clusterArgs.Archive != null) { MBT.Escience.FileUtils.ArchiveExes(clusterArgs.Archive); } //ArgumentCollection argsToUse = (ArgumentCollection)applicationArgs.Clone(); CopyExes(clusterArgs); clusterArgs.StdErrDirName = CreateUniqueDirectory(clusterArgs.ExternalRemoteDirectoryName, "Stderr", clusterArgs.Name); clusterArgs.StdOutDirName = CreateUniqueDirectory(clusterArgs.ExternalRemoteDirectoryName, "Stdout", clusterArgs.Name); if (clusterArgs.CopyInputFiles.Count > 0) { CopyInputFiles(clusterArgs.CopyInputFiles, clusterArgs.ExternalRemoteDirectoryName); } using (ParallelOptionsScope.Suspend()) { switch (clusterArgs.Version) { case 1: SubmitViaAPI1(clusterArgs, distributableObj); break; case 2: Console.Error.WriteLine("Api2 and 3 are the same. Submitting via Api3."); SubmitViaAPI3(clusterArgs, distributableObj); break; case 3: SubmitViaAPI3(clusterArgs, distributableObj); break; default: throw new NotSupportedException(string.Format("Cluster version {0} is not supported.", clusterArgs.Version)); } } Console.WriteLine("Processed job to cluster {0} with path {1}", clusterArgs.Cluster, clusterArgs.ExternalRemoteDirectoryName); Console.WriteLine("Writing log file"); HpcLibSettings.TryWriteToLog(clusterArgs); Console.WriteLine("Writing log entry to cluster directory"); HpcLibSettings.WriteLogEntryToClusterDirectory(clusterArgs); Console.WriteLine("Done"); } return; }
public void ValidateSuspend() { using (ParallelOptionsScope scope = ParallelOptionsScope.Create(Constants.ParallelProcess)) { Assert.IsNotNull(scope); Assert.AreEqual(Constants.ParallelProcess, ParallelOptionsScope.Current.MaxDegreeOfParallelism); Assert.IsTrue(ParallelOptionsScope.Exists); IDisposable disposable = ParallelOptionsScope.Suspend(); Assert.IsFalse(ParallelOptionsScope.Exists); disposable.Dispose(); } ApplicationLog.WriteLine(string.Concat( "ParallelOptionsScope BVT: Validation of Suspend method completed successfully.")); }
private bool Connect() { if (_scheduler != null) { return(true); } bool connected = false; using (ParallelOptionsScope.Suspend()) { connected = HpcLib.TryConnect(Cluster, out _scheduler); } return(connected); }