/// <summary> /// Quick validation on the input to check some obvious fail conditions (fail /// fast) the input and returns the appropriate /// <see cref="Plan"/> /// associated with /// the specified /// <see cref="Org.Apache.Hadoop.Yarn.Server.Resourcemanager.Scheduler.Queue"/> /// or throws an exception message illustrating the /// details of any validation check failures /// </summary> /// <param name="reservationSystem"> /// the /// <see cref="ReservationSystem"/> /// to validate against /// </param> /// <param name="request"> /// the /// <see cref="Org.Apache.Hadoop.Yarn.Api.Protocolrecords.ReservationSubmissionRequest /// "/> /// defining the /// resources required over time for the request /// </param> /// <param name="reservationId"> /// the /// <see cref="Org.Apache.Hadoop.Yarn.Api.Records.ReservationId"/> /// associated with the current /// request /// </param> /// <returns> /// the /// <see cref="Plan"/> /// to submit the request to /// </returns> /// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> public virtual Plan ValidateReservationSubmissionRequest(ReservationSystem reservationSystem , ReservationSubmissionRequest request, ReservationId reservationId) { // Check if it is a managed queue string queueName = request.GetQueue(); if (queueName == null || queueName.IsEmpty()) { string errMsg = "The queue to submit is not specified." + " Please try again with a valid reservable queue."; RMAuditLogger.LogFailure("UNKNOWN", RMAuditLogger.AuditConstants.SubmitReservationRequest , "validate reservation input", "ClientRMService", errMsg); throw RPCUtil.GetRemoteException(errMsg); } Plan plan = reservationSystem.GetPlan(queueName); if (plan == null) { string errMsg = "The specified queue: " + queueName + " is not managed by reservation system." + " Please try again with a valid reservable queue."; RMAuditLogger.LogFailure("UNKNOWN", RMAuditLogger.AuditConstants.SubmitReservationRequest , "validate reservation input", "ClientRMService", errMsg); throw RPCUtil.GetRemoteException(errMsg); } ValidateReservationDefinition(reservationId, request.GetReservationDefinition(), plan, RMAuditLogger.AuditConstants.SubmitReservationRequest); return(plan); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual ReleaseSharedCacheResourceResponse Release(ReleaseSharedCacheResourceRequest request) { ReleaseSharedCacheResourceResponse response = recordFactory.NewRecordInstance <ReleaseSharedCacheResourceResponse >(); UserGroupInformation callerUGI; try { callerUGI = UserGroupInformation.GetCurrentUser(); } catch (IOException ie) { Log.Info("Error getting UGI ", ie); throw RPCUtil.GetRemoteException(ie); } bool removed = this.store.RemoveResourceReference(request.GetResourceKey(), new SharedCacheResourceReference (request.GetAppId(), callerUGI.GetShortUserName()), true); if (removed) { this.metrics.IncCacheRelease(); } return(response); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual UseSharedCacheResourceResponse Use(UseSharedCacheResourceRequest request ) { UseSharedCacheResourceResponse response = recordFactory.NewRecordInstance <UseSharedCacheResourceResponse >(); UserGroupInformation callerUGI; try { callerUGI = UserGroupInformation.GetCurrentUser(); } catch (IOException ie) { Log.Info("Error getting UGI ", ie); throw RPCUtil.GetRemoteException(ie); } string fileName = this.store.AddResourceReference(request.GetResourceKey(), new SharedCacheResourceReference (request.GetAppId(), callerUGI.GetShortUserName())); if (fileName != null) { response.SetPath(GetCacheEntryFilePath(request.GetResourceKey(), fileName)); this.metrics.IncCacheHitCount(); } else { this.metrics.IncCacheMissCount(); } return(response); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> public virtual StartContainersResponse StartContainers(StartContainersRequest requests ) { StartContainersResponse response = TestRPC.recordFactory.NewRecordInstance <StartContainersResponse >(); foreach (StartContainerRequest request in requests.GetStartContainerRequests()) { Token containerToken = request.GetContainerToken(); ContainerTokenIdentifier tokenId = null; try { tokenId = TestRPC.NewContainerTokenIdentifier(containerToken); } catch (IOException e) { throw RPCUtil.GetRemoteException(e); } ContainerStatus status = TestRPC.recordFactory.NewRecordInstance <ContainerStatus> (); status.SetState(ContainerState.Running); status.SetContainerId(tokenId.GetContainerID()); status.SetExitStatus(0); this.statuses.AddItem(status); } return(response); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> public virtual StopContainersResponse StopContainers(StopContainersRequest request ) { lock (this) { foreach (ContainerId containerID in request.GetContainerIds()) { string applicationId = containerID.GetApplicationAttemptId().GetApplicationId().GetId ().ToString(); // Mark the container as COMPLETE IList <Container> applicationContainers = containers[containerID.GetApplicationAttemptId ().GetApplicationId()]; foreach (Container c in applicationContainers) { if (c.GetId().CompareTo(containerID) == 0) { ContainerStatus containerStatus = containerStatusMap[c]; containerStatus.SetState(ContainerState.Complete); containerStatusMap[c] = containerStatus; } } // Send a heartbeat try { Heartbeat(); } catch (IOException ioe) { throw RPCUtil.GetRemoteException(ioe); } // Remove container and update status int ctr = 0; Container container = null; for (IEnumerator <Container> i = applicationContainers.GetEnumerator(); i.HasNext( );) { container = i.Next(); if (container.GetId().CompareTo(containerID) == 0) { i.Remove(); ++ctr; } } if (ctr != 1) { throw new InvalidOperationException("Container " + containerID + " stopped " + ctr + " times!"); } Resources.AddTo(available, container.GetResource()); Resources.SubtractFrom(used, container.GetResource()); if (Log.IsDebugEnabled()) { Log.Debug("stopContainer:" + " node=" + containerManagerAddress + " application=" + applicationId + " container=" + containerID + " available=" + available + " used=" + used); } } return(StopContainersResponse.NewInstance(null, null)); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> private Plan ValidateReservation(ReservationSystem reservationSystem, ReservationId reservationId, string auditConstant) { string message = string.Empty; // check if the reservation id is valid if (reservationId == null) { message = "Missing reservation id." + " Please try again by specifying a reservation id."; RMAuditLogger.LogFailure("UNKNOWN", auditConstant, "validate reservation input", "ClientRMService", message); throw RPCUtil.GetRemoteException(message); } string queueName = reservationSystem.GetQueueForReservation(reservationId); if (queueName == null) { message = "The specified reservation with ID: " + reservationId + " is unknown. Please try again with a valid reservation."; RMAuditLogger.LogFailure("UNKNOWN", auditConstant, "validate reservation input", "ClientRMService", message); throw RPCUtil.GetRemoteException(message); } // check if the associated plan is valid Plan plan = reservationSystem.GetPlan(queueName); if (plan == null) { message = "The specified reservation: " + reservationId + " is not associated with any valid plan." + " Please try again with a valid reservation."; RMAuditLogger.LogFailure("UNKNOWN", auditConstant, "validate reservation input", "ClientRMService", message); throw RPCUtil.GetRemoteException(message); } return(plan); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> public StartContainersResponse StartContainers(StartContainersRequest requests) { StartContainerRequest request = requests.GetStartContainerRequests()[0]; Log.Info("Container started by MyContainerManager: " + request); launched = true; IDictionary <string, string> env = request.GetContainerLaunchContext().GetEnvironment (); Token containerToken = request.GetContainerToken(); ContainerTokenIdentifier tokenId = null; try { tokenId = BuilderUtils.NewContainerTokenIdentifier(containerToken); } catch (IOException e) { throw RPCUtil.GetRemoteException(e); } ContainerId containerId = tokenId.GetContainerID(); containerIdAtContainerManager = containerId.ToString(); attemptIdAtContainerManager = containerId.GetApplicationAttemptId().ToString(); nmHostAtContainerManager = tokenId.GetNmHostAddress(); submitTimeAtContainerManager = long.Parse(env[ApplicationConstants.AppSubmitTimeEnv ]); maxAppAttempts = System.Convert.ToInt32(env[ApplicationConstants.MaxAppAttemptsEnv ]); return(StartContainersResponse.NewInstance(new Dictionary <string, ByteBuffer>(), new AList <ContainerId>(), new Dictionary <ContainerId, SerializedException>())); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> private YarnException LogAndWrapException(IOException ioe, string user, string argName , string msg) { Log.Info("Exception " + msg, ioe); RMAuditLogger.LogFailure(user, argName, string.Empty, "AdminService", "Exception " + msg); return(RPCUtil.GetRemoteException(ioe)); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual UpdateNodeResourceResponse UpdateNodeResource(UpdateNodeResourceRequest request) { string argName = "updateNodeResource"; UserGroupInformation user = CheckAcls(argName); CheckRMStatus(user.GetShortUserName(), argName, "update node resource."); IDictionary <NodeId, ResourceOption> nodeResourceMap = request.GetNodeResourceMap( ); ICollection <NodeId> nodeIds = nodeResourceMap.Keys; // verify nodes are all valid first. // if any invalid nodes, throw exception instead of partially updating // valid nodes. foreach (NodeId nodeId in nodeIds) { RMNode node = this.rmContext.GetRMNodes()[nodeId]; if (node == null) { Log.Error("Resource update get failed on all nodes due to change " + "resource on an unrecognized node: " + nodeId); throw RPCUtil.GetRemoteException("Resource update get failed on all nodes due to change resource " + "on an unrecognized node: " + nodeId); } } // do resource update on each node. // Notice: it is still possible to have invalid NodeIDs as nodes decommission // may happen just at the same time. This time, only log and skip absent // nodes without throwing any exceptions. bool allSuccess = true; foreach (KeyValuePair <NodeId, ResourceOption> entry in nodeResourceMap) { ResourceOption newResourceOption = entry.Value; NodeId nodeId_1 = entry.Key; RMNode node = this.rmContext.GetRMNodes()[nodeId_1]; if (node == null) { Log.Warn("Resource update get failed on an unrecognized node: " + nodeId_1); allSuccess = false; } else { // update resource to RMNode this.rmContext.GetDispatcher().GetEventHandler().Handle(new RMNodeResourceUpdateEvent (nodeId_1, newResourceOption)); Log.Info("Update resource on node(" + node.GetNodeID() + ") with resource(" + newResourceOption .ToString() + ")"); } } if (allSuccess) { RMAuditLogger.LogSuccess(user.GetShortUserName(), argName, "AdminService"); } UpdateNodeResourceResponse response = UpdateNodeResourceResponse.NewInstance(); return(response); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> public virtual StartContainersResponse StartContainers(StartContainersRequest requests ) { lock (this) { foreach (StartContainerRequest request in requests.GetStartContainerRequests()) { Token containerToken = request.GetContainerToken(); ContainerTokenIdentifier tokenId = null; try { tokenId = BuilderUtils.NewContainerTokenIdentifier(containerToken); } catch (IOException e) { throw RPCUtil.GetRemoteException(e); } ContainerId containerID = tokenId.GetContainerID(); ApplicationId applicationId = containerID.GetApplicationAttemptId().GetApplicationId (); IList <Container> applicationContainers = containers[applicationId]; if (applicationContainers == null) { applicationContainers = new AList <Container>(); containers[applicationId] = applicationContainers; } // Sanity check foreach (Container container in applicationContainers) { if (container.GetId().CompareTo(containerID) == 0) { throw new InvalidOperationException("Container " + containerID + " already setup on node " + containerManagerAddress); } } Container container_1 = BuilderUtils.NewContainer(containerID, this.nodeId, nodeHttpAddress , tokenId.GetResource(), null, null); // DKDC - Doesn't matter ContainerStatus containerStatus = BuilderUtils.NewContainerStatus(container_1.GetId (), ContainerState.New, string.Empty, -1000); applicationContainers.AddItem(container_1); containerStatusMap[container_1] = containerStatus; Resources.SubtractFrom(available, tokenId.GetResource()); Resources.AddTo(used, tokenId.GetResource()); if (Log.IsDebugEnabled()) { Log.Debug("startContainer:" + " node=" + containerManagerAddress + " application=" + applicationId + " container=" + container_1 + " available=" + available + " used=" + used); } } StartContainersResponse response = StartContainersResponse.NewInstance(null, null , null); return(response); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> private void AddStartingContainer(NMClientImpl.StartedContainer startedContainer) { if (startedContainers.PutIfAbsent(startedContainer.containerId, startedContainer) != null) { throw RPCUtil.GetRemoteException("Container " + startedContainer.containerId.ToString () + " is already started"); } startedContainers[startedContainer.GetContainerId()] = startedContainer; }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> private UserGroupInformation CheckAcls(string method) { try { return(CheckAccess(method)); } catch (IOException ioe) { throw RPCUtil.GetRemoteException(ioe); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual NodeHeartbeatResponse NodeHeartbeat(NodeHeartbeatRequest request) { YarnServerCommonServiceProtos.NodeHeartbeatRequestProto requestProto = ((NodeHeartbeatRequestPBImpl )request).GetProto(); try { return(new NodeHeartbeatResponsePBImpl(proxy.NodeHeartbeat(null, requestProto))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual RefreshNodesResponse RefreshNodes(RefreshNodesRequest request) { YarnServerResourceManagerServiceProtos.RefreshNodesRequestProto requestProto = (( RefreshNodesRequestPBImpl)request).GetProto(); try { return(new RefreshNodesResponsePBImpl(proxy.RefreshNodes(null, requestProto))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual LocalizerHeartbeatResponse Heartbeat(LocalizerStatus status) { YarnServerNodemanagerServiceProtos.LocalizerStatusProto statusProto = ((LocalizerStatusPBImpl )status).GetProto(); try { return(new LocalizerHeartbeatResponsePBImpl(proxy.Heartbeat(null, statusProto))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual AllocateResponse Allocate(AllocateRequest request) { YarnServiceProtos.AllocateRequestProto requestProto = ((AllocateRequestPBImpl)request ).GetProto(); try { return(new AllocateResponsePBImpl(proxy.Allocate(null, requestProto))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual SCMUploaderNotifyResponse Notify(SCMUploaderNotifyRequest request) { YarnServerCommonServiceProtos.SCMUploaderNotifyRequestProto requestProto = ((SCMUploaderNotifyRequestPBImpl )request).GetProto(); try { return(new SCMUploaderNotifyResponsePBImpl(proxy.Notify(null, requestProto))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual GetContainersResponse GetContainers(GetContainersRequest request) { YarnServiceProtos.GetContainersRequestProto requestProto = ((GetContainersRequestPBImpl )request).GetProto(); try { return(new GetContainersResponsePBImpl(proxy.GetContainers(null, requestProto))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual UseSharedCacheResourceResponse Use(UseSharedCacheResourceRequest request ) { YarnServiceProtos.UseSharedCacheResourceRequestProto requestProto = ((UseSharedCacheResourceRequestPBImpl )request).GetProto(); try { return new UseSharedCacheResourceResponsePBImpl(proxy.Use(null, requestProto)); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return null; } }
public virtual void TestRMConnectionRetry() { // verify the connection exception is thrown // if we haven't exhausted the retry interval ApplicationMasterProtocol mockScheduler = Org.Mockito.Mockito.Mock <ApplicationMasterProtocol >(); Org.Mockito.Mockito.When(mockScheduler.Allocate(Matchers.IsA <AllocateRequest>())) .ThenThrow(RPCUtil.GetRemoteException(new IOException("forcefail"))); Configuration conf = new Configuration(); LocalContainerAllocator lca = new TestLocalContainerAllocator.StubbedLocalContainerAllocator (mockScheduler); lca.Init(conf); lca.Start(); try { lca.Heartbeat(); NUnit.Framework.Assert.Fail("heartbeat was supposed to throw"); } catch (YarnException) { } finally { // YarnException is expected lca.Stop(); } // verify YarnRuntimeException is thrown when the retry interval has expired conf.SetLong(MRJobConfig.MrAmToRmWaitIntervalMs, 0); lca = new TestLocalContainerAllocator.StubbedLocalContainerAllocator(mockScheduler ); lca.Init(conf); lca.Start(); try { lca.Heartbeat(); NUnit.Framework.Assert.Fail("heartbeat was supposed to throw"); } catch (YarnRuntimeException) { } finally { // YarnRuntimeException is expected lca.Stop(); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual RunSharedCacheCleanerTaskResponse RunCleanerTask(RunSharedCacheCleanerTaskRequest request) { YarnServiceProtos.RunSharedCacheCleanerTaskRequestProto requestProto = ((RunSharedCacheCleanerTaskRequestPBImpl )request).GetProto(); try { return(new RunSharedCacheCleanerTaskResponsePBImpl(proxy.RunCleanerTask(null, requestProto ))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual UpdateNodeResourceResponse UpdateNodeResource(UpdateNodeResourceRequest request) { YarnServerResourceManagerServiceProtos.UpdateNodeResourceRequestProto requestProto = ((UpdateNodeResourceRequestPBImpl)request).GetProto(); try { return(new UpdateNodeResourceResponsePBImpl(proxy.UpdateNodeResource(null, requestProto ))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual RegisterApplicationMasterResponse RegisterApplicationMaster(RegisterApplicationMasterRequest request) { YarnServiceProtos.RegisterApplicationMasterRequestProto requestProto = ((RegisterApplicationMasterRequestPBImpl )request).GetProto(); try { return(new RegisterApplicationMasterResponsePBImpl(proxy.RegisterApplicationMaster (null, requestProto))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual KillApplicationResponse ForceKillApplication(KillApplicationRequest request) { YarnServiceProtos.KillApplicationRequestProto requestProto = ((KillApplicationRequestPBImpl )request).GetProto(); try { return(new KillApplicationResponsePBImpl(proxy.ForceKillApplication(null, requestProto ))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual ReservationSubmissionResponse SubmitReservation(ReservationSubmissionRequest request) { YarnServiceProtos.ReservationSubmissionRequestProto requestProto = ((ReservationSubmissionRequestPBImpl )request).GetProto(); try { return(new ReservationSubmissionResponsePBImpl(proxy.SubmitReservation(null, requestProto ))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual MoveApplicationAcrossQueuesResponse MoveApplicationAcrossQueues(MoveApplicationAcrossQueuesRequest request) { YarnServiceProtos.MoveApplicationAcrossQueuesRequestProto requestProto = ((MoveApplicationAcrossQueuesRequestPBImpl )request).GetProto(); try { return(new MoveApplicationAcrossQueuesResponsePBImpl(proxy.MoveApplicationAcrossQueues (null, requestProto))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual CancelDelegationTokenResponse CancelDelegationToken(CancelDelegationTokenRequest request) { SecurityProtos.CancelDelegationTokenRequestProto requestProto = ((CancelDelegationTokenRequestPBImpl )request).GetProto(); try { return(new CancelDelegationTokenResponsePBImpl(proxy.CancelDelegationToken(null, requestProto))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> public virtual AddToClusterNodeLabelsResponse AddToClusterNodeLabels(AddToClusterNodeLabelsRequest request) { YarnServerResourceManagerServiceProtos.AddToClusterNodeLabelsRequestProto requestProto = ((AddToClusterNodeLabelsRequestPBImpl)request).GetProto(); try { return(new AddToClusterNodeLabelsResponsePBImpl(proxy.AddToClusterNodeLabels(null , requestProto))); } catch (ServiceException e) { RPCUtil.UnwrapAndThrowException(e); return(null); } }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> private AMRMTokenIdentifier AuthorizeRequest() { UserGroupInformation remoteUgi; try { remoteUgi = UserGroupInformation.GetCurrentUser(); } catch (IOException e) { string msg = "Cannot obtain the user-name for authorizing ApplicationMaster. " + "Got exception: " + StringUtils.StringifyException(e); Log.Warn(msg); throw RPCUtil.GetRemoteException(msg); } bool tokenFound = false; string message = string.Empty; AMRMTokenIdentifier appTokenIdentifier = null; try { appTokenIdentifier = SelectAMRMTokenIdentifier(remoteUgi); if (appTokenIdentifier == null) { tokenFound = false; message = "No AMRMToken found for user " + remoteUgi.GetUserName(); } else { tokenFound = true; } } catch (IOException) { tokenFound = false; message = "Got exception while looking for AMRMToken for user " + remoteUgi.GetUserName (); } if (!tokenFound) { Log.Warn(message); throw RPCUtil.GetRemoteException(message); } return(appTokenIdentifier); }
/// <exception cref="Org.Apache.Hadoop.Yarn.Exceptions.YarnException"/> /// <exception cref="System.IO.IOException"/> private NMClient MockNMClient(int mode) { NMClient client = Org.Mockito.Mockito.Mock <NMClient>(); switch (mode) { case 0: { Org.Mockito.Mockito.When(client.StartContainer(Matchers.Any <Container>(), Matchers.Any <ContainerLaunchContext>())).ThenReturn(Sharpen.Collections.EmptyMap <string, ByteBuffer >()); Org.Mockito.Mockito.When(client.GetContainerStatus(Matchers.Any <ContainerId>(), Matchers.Any <NodeId>())).ThenReturn(recordFactory.NewRecordInstance <ContainerStatus>()); Org.Mockito.Mockito.DoNothing().When(client).StopContainer(Matchers.Any <ContainerId >(), Matchers.Any <NodeId>()); break; } case 1: { Org.Mockito.Mockito.DoThrow(RPCUtil.GetRemoteException("Start Exception")).When(client ).StartContainer(Matchers.Any <Container>(), Matchers.Any <ContainerLaunchContext> ()); Org.Mockito.Mockito.DoThrow(RPCUtil.GetRemoteException("Query Exception")).When(client ).GetContainerStatus(Matchers.Any <ContainerId>(), Matchers.Any <NodeId>()); Org.Mockito.Mockito.DoThrow(RPCUtil.GetRemoteException("Stop Exception")).When(client ).StopContainer(Matchers.Any <ContainerId>(), Matchers.Any <NodeId>()); break; } case 2: { Org.Mockito.Mockito.When(client.StartContainer(Matchers.Any <Container>(), Matchers.Any <ContainerLaunchContext>())).ThenReturn(Sharpen.Collections.EmptyMap <string, ByteBuffer >()); Org.Mockito.Mockito.When(client.GetContainerStatus(Matchers.Any <ContainerId>(), Matchers.Any <NodeId>())).ThenReturn(recordFactory.NewRecordInstance <ContainerStatus>()); Org.Mockito.Mockito.DoThrow(RPCUtil.GetRemoteException("Stop Exception")).When(client ).StopContainer(Matchers.Any <ContainerId>(), Matchers.Any <NodeId>()); break; } } return(client); }