public virtual void Handle(ContainerAllocatorEvent @event) { if (@event.GetType() == ContainerAllocator.EventType.ContainerReq) { Log.Info("Processing the event " + @event.ToString()); // Assign the same container ID as the AM ContainerId cID = ContainerId.NewContainerId(GetContext().GetApplicationAttemptId (), this.containerId.GetContainerId()); Container container = recordFactory.NewRecordInstance <Container>(); container.SetId(cID); NodeId nodeId = NodeId.NewInstance(this.nmHost, this.nmPort); container.SetNodeId(nodeId); container.SetContainerToken(null); container.SetNodeHttpAddress(this.nmHost + ":" + this.nmHttpPort); // send the container-assigned event to task attempt if (@event.GetAttemptID().GetTaskId().GetTaskType() == TaskType.Map) { JobCounterUpdateEvent jce = new JobCounterUpdateEvent(@event.GetAttemptID().GetTaskId ().GetJobId()); // TODO Setting OTHER_LOCAL_MAP for now. jce.AddCounterUpdate(JobCounter.OtherLocalMaps, 1); eventHandler.Handle(jce); } eventHandler.Handle(new TaskAttemptContainerAssignedEvent(@event.GetAttemptID(), container, applicationACLs)); } }
public virtual void Handle(ContainerAllocatorEvent @event) { ContainerId cId = ContainerId.NewContainerId(this._enclosing.GetContext().GetApplicationAttemptId (), this.containerCount++); NodeId nodeId = NodeId.NewInstance(MRApp.NmHost, MRApp.NmPort); Resource resource = Resource.NewInstance(1234, 2); ContainerTokenIdentifier containerTokenIdentifier = new ContainerTokenIdentifier( cId, nodeId.ToString(), "user", resource, Runtime.CurrentTimeMillis() + 10000, 42 , 42, Priority.NewInstance(0), 0); Token containerToken = MRApp.NewContainerToken(nodeId, Sharpen.Runtime.GetBytesForString ("password"), containerTokenIdentifier); Container container = Container.NewInstance(cId, nodeId, MRApp.NmHost + ":" + MRApp .NmHttpPort, resource, null, containerToken); JobID id = TypeConverter.FromYarn(MRApp.applicationId); JobId jobId = TypeConverter.ToYarn(id); this._enclosing.GetContext().GetEventHandler().Handle(new JobHistoryEvent(jobId, new NormalizedResourceEvent(TaskType.Reduce, 100))); this._enclosing.GetContext().GetEventHandler().Handle(new JobHistoryEvent(jobId, new NormalizedResourceEvent(TaskType.Map, 100))); this._enclosing.GetContext().GetEventHandler().Handle(new TaskAttemptContainerAssignedEvent (@event.GetAttemptID(), container, null)); }
public void Run() { ContainerAllocatorEvent @event = null; while (!Sharpen.Thread.CurrentThread().IsInterrupted()) { try { if (this._enclosing._enclosing.concurrentRunningTasks < this._enclosing._enclosing .maxConcurrentRunningTasks) { @event = this._enclosing.eventQueue.Take(); ContainerId cId = ContainerId.NewContainerId(this._enclosing._enclosing.GetContext ().GetApplicationAttemptId(), this._enclosing.containerCount++); Container container = MRAppBenchmark.recordFactory.NewRecordInstance <Container>(); container.SetId(cId); NodeId nodeId = NodeId.NewInstance("dummy", 1234); container.SetNodeId(nodeId); container.SetContainerToken(null); container.SetNodeHttpAddress("localhost:8042"); this._enclosing._enclosing.GetContext().GetEventHandler().Handle(new TaskAttemptContainerAssignedEvent (@event.GetAttemptID(), container, null)); this._enclosing._enclosing.concurrentRunningTasks++; } else { Sharpen.Thread.Sleep(1000); } } catch (Exception) { System.Console.Out.WriteLine("Returning, interrupted"); return; } } }