/// <summary> /// Lazily initializes the internal data structure for tracking the specified /// phase and step. /// </summary> /// <remarks> /// Lazily initializes the internal data structure for tracking the specified /// phase and step. Returns either the newly initialized data structure or the /// existing one. Initialization is atomic, so there is no risk of lost updates /// even if multiple threads attempt to initialize the same step simultaneously. /// </remarks> /// <param name="phase">Phase to initialize</param> /// <param name="step">Step to initialize</param> /// <returns>StepTracking newly initialized, or existing if found</returns> private StepTracking LazyInitStep(Phase phase, Step step) { ConcurrentMap <Step, StepTracking> steps = phases[phase].steps; if (!steps.Contains(step)) { steps.PutIfAbsent(step, new StepTracking()); } return(steps[step]); }
protected internal override void RebootNodeStatusUpdaterAndRegisterWithRM() { ConcurrentMap <ContainerId, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container > containers = this._enclosing.GetNMContext().GetContainers(); try { try { if (this._enclosing.containersShouldBePreserved) { NUnit.Framework.Assert.IsFalse(containers.IsEmpty()); NUnit.Framework.Assert.IsTrue(containers.Contains(this._enclosing.existingCid)); NUnit.Framework.Assert.AreEqual(ContainerState.Running, containers[this._enclosing .existingCid].CloneAndGetContainerStatus().GetState()); } else { // ensure that containers are empty or are completed before // restart nodeStatusUpdater if (!containers.IsEmpty()) { NUnit.Framework.Assert.AreEqual(ContainerState.Complete, containers[this._enclosing .existingCid].CloneAndGetContainerStatus().GetState()); } } base.RebootNodeStatusUpdaterAndRegisterWithRM(); } catch (Exception ae) { Sharpen.Runtime.PrintStackTrace(ae); this._enclosing._enclosing.assertionFailedInThread.Set(true); } finally { this._enclosing._enclosing.syncBarrier.Await(); } } catch (Exception) { } catch (BrokenBarrierException) { } catch (Exception ae) { Sharpen.Runtime.PrintStackTrace(ae); this._enclosing._enclosing.assertionFailedInThread.Set(true); } }
/// <exception cref="System.IO.IOException"/> public virtual JvmTask GetTask(JvmContext context) { // A rough imitation of code from TaskTracker. JVMId jvmId = context.jvmId; Log.Info("JVM with ID : " + jvmId + " asked for a task"); JvmTask jvmTask = null; // TODO: Is it an authorized container to get a task? Otherwise return null. // TODO: Child.java's firstTaskID isn't really firstTaskID. Ask for update // to jobId and task-type. WrappedJvmID wJvmID = new WrappedJvmID(jvmId.GetJobId(), jvmId.isMap, jvmId.GetId ()); // Try to look up the task. We remove it directly as we don't give // multiple tasks to a JVM if (!jvmIDToActiveAttemptMap.Contains(wJvmID)) { Log.Info("JVM with ID: " + jvmId + " is invalid and will be killed."); jvmTask = TaskForInvalidJvm; } else { if (!launchedJVMs.Contains(wJvmID)) { jvmTask = null; Log.Info("JVM with ID: " + jvmId + " asking for task before AM launch registered. Given null task" ); } else { // remove the task as it is no more needed and free up the memory. // Also we have already told the JVM to process a task, so it is no // longer pending, and further request should ask it to exit. Task task = Sharpen.Collections.Remove(jvmIDToActiveAttemptMap, wJvmID); launchedJVMs.Remove(wJvmID); Log.Info("JVM with ID: " + jvmId + " given task: " + task.GetTaskID()); task.SetEncryptedSpillKey(encryptedSpillKey); jvmTask = new JvmTask(task, false); } } return(jvmTask); }
/// <exception cref="System.IO.IOException"/> protected internal virtual void CheckRemoveFromClusterNodeLabels(ICollection <string > labelsToRemove) { if (null == labelsToRemove || labelsToRemove.IsEmpty()) { return; } // Check if label to remove doesn't existed or null/empty, will throw // exception if any of labels to remove doesn't meet requirement foreach (string label in labelsToRemove) { label = NormalizeLabel(label); if (label == null || label.IsEmpty()) { throw new IOException("Label to be removed is null or empty"); } if (!labelCollections.Contains(label)) { throw new IOException("Node label=" + label + " to be removed doesn't existed in cluster " + "node labels collection."); } } }