static Counters getMyCounters() {
    Counter counter = recordFactory.newRecordInstance(Counter.class);
    counter.setName("Mycounter");
    counter.setDisplayName("My counter display name");
    counter.setValue(12345);

    CounterGroup group = recordFactory.newRecordInstance(CounterGroup.class);
    group.setName("MyGroup");
    group.setDisplayName("My groupd display name");
    group.setCounter("myCounter", counter);

    Counters counters = recordFactory.newRecordInstance(Counters.class);
    counters.setCounterGroup("myGroupd", group);
    return counters;
  }
 public QueueAclsInfo[] getQueueAclsForCurrentUser() throws IOException, InterruptedException {
   GetQueueUserAclsInfoRequest request =
       recordFactory.newRecordInstance(GetQueueUserAclsInfoRequest.class);
   List<QueueUserACLInfo> userAcls =
       applicationsManager.getQueueUserAcls(request).getUserAclsInfoList();
   return TypeConverter.fromYarnQueueUserAclsInfo(userAcls);
 }
  private void registerWithRM() throws YarnRemoteException {
    this.resourceTracker = getRMClient();
    LOG.info("Connected to ResourceManager at " + this.rmAddress);

    RegisterNodeManagerRequest request =
        recordFactory.newRecordInstance(RegisterNodeManagerRequest.class);
    request.setHttpPort(this.httpPort);
    request.setResource(this.totalResource);
    request.setNodeId(this.nodeId);
    RegistrationResponse regResponse =
        this.resourceTracker.registerNodeManager(request).getRegistrationResponse();
    // if the Resourcemanager instructs NM to shutdown.
    if (NodeAction.SHUTDOWN.equals(regResponse.getNodeAction())) {
      throw new YarnException(
          "Recieved SHUTDOWN signal from Resourcemanager ,Registration of NodeManager failed");
    }

    if (UserGroupInformation.isSecurityEnabled()) {
      this.secretKeyBytes = regResponse.getSecretKey().array();
    }

    // do this now so that its set before we start heartbeating to RM
    if (UserGroupInformation.isSecurityEnabled()) {
      LOG.info("Security enabled - updating secret keys now");
      // It is expected that status updater is started by this point and
      // RM gives the shared secret in registration during StatusUpdater#start().
      this.containerTokenSecretManager.setSecretKey(
          this.nodeId.toString(), this.getRMNMSharedSecret());
    }
    LOG.info(
        "Registered with ResourceManager as "
            + this.nodeId
            + " with total resource of "
            + this.totalResource);
  }
Пример #4
0
  @Override
  public RefreshNodesResponse refreshNodes(RefreshNodesRequest request)
      throws YarnException, StandbyException {
    String argName = "refreshNodes";
    UserGroupInformation user = checkAcls("refreshNodes");

    if (!isRMActive()) {
      RMAuditLogger.logFailure(
          user.getShortUserName(),
          argName,
          adminAcl.toString(),
          "AdminService",
          "ResourceManager is not active. Can not refresh nodes.");
      throwStandbyException();
    }

    try {
      Configuration conf =
          getConfiguration(
              new Configuration(false), YarnConfiguration.YARN_SITE_CONFIGURATION_FILE);
      rmContext.getNodesListManager().refreshNodes(conf);
      RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService");
      return recordFactory.newRecordInstance(RefreshNodesResponse.class);
    } catch (IOException ioe) {
      LOG.info("Exception refreshing nodes ", ioe);
      RMAuditLogger.logFailure(
          user.getShortUserName(),
          argName,
          adminAcl.toString(),
          "AdminService",
          "Exception refreshing nodes");
      throw RPCUtil.getRemoteException(ioe);
    }
  }
Пример #5
0
  @Override
  public RefreshUserToGroupsMappingsResponse refreshUserToGroupsMappings(
      RefreshUserToGroupsMappingsRequest request) throws YarnException, IOException {
    String argName = "refreshUserToGroupsMappings";
    UserGroupInformation user = checkAcls(argName);

    if (!isRMActive()) {
      RMAuditLogger.logFailure(
          user.getShortUserName(),
          argName,
          adminAcl.toString(),
          "AdminService",
          "ResourceManager is not active. Can not refresh user-groups.");
      throwStandbyException();
    }

    Groups.getUserToGroupsMappingService(
            getConfiguration(
                new Configuration(false), YarnConfiguration.CORE_SITE_CONFIGURATION_FILE))
        .refresh();

    RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService");

    return recordFactory.newRecordInstance(RefreshUserToGroupsMappingsResponse.class);
  }
Пример #6
0
 public static Resource newResource(int memory, int vCores, int gCores) {
   Resource resource = recordFactory.newRecordInstance(Resource.class);
   resource.setMemory(memory);
   resource.setVirtualCores(vCores);
   resource.setGPUCores(gCores);
   return resource;
 }
Пример #7
0
 public static ApplicationSubmissionContext newApplicationSubmissionContext(
     ApplicationId applicationId,
     String applicationName,
     String queue,
     Priority priority,
     ContainerLaunchContext amContainer,
     boolean isUnmanagedAM,
     boolean cancelTokensWhenComplete,
     int maxAppAttempts,
     Resource resource,
     String applicationType) {
   ApplicationSubmissionContext context =
       recordFactory.newRecordInstance(ApplicationSubmissionContext.class);
   context.setApplicationId(applicationId);
   context.setApplicationName(applicationName);
   context.setQueue(queue);
   context.setPriority(priority);
   context.setAMContainerSpec(amContainer);
   context.setUnmanagedAM(isUnmanagedAM);
   context.setCancelTokensWhenComplete(cancelTokensWhenComplete);
   context.setMaxAppAttempts(maxAppAttempts);
   context.setResource(resource);
   context.setApplicationType(applicationType);
   return context;
 }
Пример #8
0
  @Override
  public RefreshServiceAclsResponse refreshServiceAcls(RefreshServiceAclsRequest request)
      throws YarnException, IOException {
    if (!getConfig()
        .getBoolean(CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION, false)) {
      throw RPCUtil.getRemoteException(
          new IOException(
              "Service Authorization ("
                  + CommonConfigurationKeysPublic.HADOOP_SECURITY_AUTHORIZATION
                  + ") not enabled."));
    }

    String argName = "refreshServiceAcls";
    if (!isRMActive()) {
      RMAuditLogger.logFailure(
          UserGroupInformation.getCurrentUser().getShortUserName(),
          argName,
          adminAcl.toString(),
          "AdminService",
          "ResourceManager is not active. Can not refresh Service ACLs.");
      throwStandbyException();
    }

    PolicyProvider policyProvider = RMPolicyProvider.getInstance();
    Configuration conf =
        getConfiguration(
            new Configuration(false), YarnConfiguration.HADOOP_POLICY_CONFIGURATION_FILE);

    refreshServiceAcls(conf, policyProvider);
    rmContext.getClientRMService().refreshServiceAcls(conf, policyProvider);
    rmContext.getApplicationMasterService().refreshServiceAcls(conf, policyProvider);
    rmContext.getResourceTrackerService().refreshServiceAcls(conf, policyProvider);

    return recordFactory.newRecordInstance(RefreshServiceAclsResponse.class);
  }
Пример #9
0
 protected void register() {
   // Register
   InetSocketAddress serviceAddr = null;
   if (clientService != null) {
     serviceAddr = clientService.getBindAddress();
   }
   try {
     RegisterApplicationMasterRequest request =
         recordFactory.newRecordInstance(RegisterApplicationMasterRequest.class);
     if (serviceAddr != null) {
       request.setHost(serviceAddr.getHostName());
       request.setRpcPort(serviceAddr.getPort());
       request.setTrackingUrl(serviceAddr.getHostName() + ":" + clientService.getHttpPort());
     }
     RegisterApplicationMasterResponse response = scheduler.registerApplicationMaster(request);
     maxContainerCapability = response.getMaximumResourceCapability();
     this.context.getClusterInfo().setMaxContainerCapability(maxContainerCapability);
     if (UserGroupInformation.isSecurityEnabled()) {
       setClientToAMToken(response.getClientToAMTokenMasterKey());
     }
     this.applicationACLs = response.getApplicationACLs();
     LOG.info("maxContainerCapability: " + maxContainerCapability.getMemory());
   } catch (Exception are) {
     LOG.error("Exception while registering", are);
     throw new YarnRuntimeException(are);
   }
 }
Пример #10
0
  @Test
  public void testReconnect() throws Exception {
    String hostname1 = "localhost1";
    Resource capability = BuilderUtils.newResource(1024, 1);

    RegisterNodeManagerRequest request1 =
        recordFactory.newRecordInstance(RegisterNodeManagerRequest.class);
    NodeId nodeId1 = NodeId.newInstance(hostname1, 0);
    request1.setNodeId(nodeId1);
    request1.setHttpPort(0);
    request1.setResource(capability);
    resourceTrackerService.registerNodeManager(request1);

    Assert.assertEquals(RMNodeEventType.STARTED, rmNodeEvents.get(0).getType());

    rmNodeEvents.clear();
    resourceTrackerService.registerNodeManager(request1);
    Assert.assertEquals(RMNodeEventType.RECONNECTED, rmNodeEvents.get(0).getType());

    rmNodeEvents.clear();
    resourceTrackerService.registerNodeManager(request1);
    capability = BuilderUtils.newResource(1024, 2);
    request1.setResource(capability);
    Assert.assertEquals(RMNodeEventType.RECONNECTED, rmNodeEvents.get(0).getType());
  }
Пример #11
0
 @SuppressWarnings("resource")
 private void testDeletionofStagingOnUnregistrationFailure(
     int maxAttempts, boolean shouldHaveDeleted) throws IOException {
   conf.set(MRJobConfig.MAPREDUCE_JOB_DIR, stagingJobDir);
   fs = mock(FileSystem.class);
   when(fs.delete(any(Path.class), anyBoolean())).thenReturn(true);
   // Staging Dir exists
   String user = UserGroupInformation.getCurrentUser().getShortUserName();
   Path stagingDir = MRApps.getStagingAreaDir(conf, user);
   when(fs.exists(stagingDir)).thenReturn(true);
   ApplicationId appId = ApplicationId.newInstance(0, 1);
   ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 1);
   JobId jobid = recordFactory.newRecordInstance(JobId.class);
   jobid.setAppId(appId);
   TestMRApp appMaster = new TestMRApp(attemptId, null, JobStateInternal.RUNNING, maxAttempts);
   appMaster.crushUnregistration = true;
   appMaster.init(conf);
   appMaster.start();
   appMaster.shutDownJob();
   ((RunningAppContext) appMaster.getContext()).computeIsLastAMRetry();
   if (shouldHaveDeleted) {
     Assert.assertEquals(new Boolean(true), appMaster.isLastAMRetry());
     verify(fs).delete(stagingJobPath, true);
   } else {
     Assert.assertEquals(new Boolean(false), appMaster.isLastAMRetry());
     verify(fs, never()).delete(stagingJobPath, true);
   }
 }
Пример #12
0
 @Test
 public void testDeletionofStaging() throws IOException {
   conf.set(MRJobConfig.MAPREDUCE_JOB_DIR, stagingJobDir);
   fs = mock(FileSystem.class);
   when(fs.delete(any(Path.class), anyBoolean())).thenReturn(true);
   // Staging Dir exists
   String user = UserGroupInformation.getCurrentUser().getShortUserName();
   Path stagingDir = MRApps.getStagingAreaDir(conf, user);
   when(fs.exists(stagingDir)).thenReturn(true);
   ApplicationId appId = ApplicationId.newInstance(System.currentTimeMillis(), 0);
   ApplicationAttemptId attemptId = ApplicationAttemptId.newInstance(appId, 0);
   JobId jobid = recordFactory.newRecordInstance(JobId.class);
   jobid.setAppId(appId);
   ContainerAllocator mockAlloc = mock(ContainerAllocator.class);
   Assert.assertTrue(MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS > 1);
   MRAppMaster appMaster =
       new TestMRApp(
           attemptId, mockAlloc, JobStateInternal.RUNNING, MRJobConfig.DEFAULT_MR_AM_MAX_ATTEMPTS);
   appMaster.init(conf);
   appMaster.start();
   appMaster.shutDownJob();
   // test whether notifyIsLastAMRetry called
   Assert.assertEquals(true, ((TestMRApp) appMaster).getTestIsLastAMRetry());
   verify(fs).delete(stagingJobPath, true);
 }
Пример #13
0
  @Override
  public RefreshQueuesResponse refreshQueues(RefreshQueuesRequest request)
      throws YarnException, StandbyException {
    String argName = "refreshQueues";
    UserGroupInformation user = checkAcls(argName);

    if (!isRMActive()) {
      RMAuditLogger.logFailure(
          user.getShortUserName(),
          argName,
          adminAcl.toString(),
          "AdminService",
          "ResourceManager is not active. Can not refresh queues.");
      throwStandbyException();
    }

    RefreshQueuesResponse response = recordFactory.newRecordInstance(RefreshQueuesResponse.class);
    try {
      rmContext.getScheduler().reinitialize(getConfig(), this.rmContext);
      RMAuditLogger.logSuccess(user.getShortUserName(), argName, "AdminService");
      return response;
    } catch (IOException ioe) {
      LOG.info("Exception refreshing queues ", ioe);
      RMAuditLogger.logFailure(
          user.getShortUserName(),
          argName,
          adminAcl.toString(),
          "AdminService",
          "Exception refreshing queues");
      throw RPCUtil.getRemoteException(ioe);
    }
  }
Пример #14
0
  @Before
  public void setUp() throws Exception {
    resourceMgrDelegate = mock(ResourceMgrDelegate.class);
    conf = new YarnConfiguration();
    conf.set(YarnConfiguration.RM_PRINCIPAL, "mapred/host@REALM");
    clientCache = new ClientCache(conf, resourceMgrDelegate);
    clientCache = spy(clientCache);
    yarnRunner = new YARNRunner(conf, resourceMgrDelegate, clientCache);
    yarnRunner = spy(yarnRunner);
    submissionContext = mock(ApplicationSubmissionContext.class);
    doAnswer(
            new Answer<ApplicationSubmissionContext>() {
              @Override
              public ApplicationSubmissionContext answer(InvocationOnMock invocation)
                  throws Throwable {
                return submissionContext;
              }
            })
        .when(yarnRunner)
        .createApplicationSubmissionContext(
            any(Configuration.class), any(String.class), any(Credentials.class));

    appId = recordFactory.newRecordInstance(ApplicationId.class);
    appId.setClusterTimestamp(System.currentTimeMillis());
    appId.setId(1);
    jobId = TypeConverter.fromYarn(appId);
    if (testWorkDir.exists()) {
      FileContext.getLocalFSFileContext().delete(new Path(testWorkDir.toString()), true);
    }
    testWorkDir.mkdirs();
  }
 public ApplicationReport getApplicationReport(ApplicationId appId) throws YarnRemoteException {
   GetApplicationReportRequest request =
       recordFactory.newRecordInstance(GetApplicationReportRequest.class);
   request.setApplicationId(appId);
   GetApplicationReportResponse response = applicationsManager.getApplicationReport(request);
   ApplicationReport applicationReport = response.getApplicationReport();
   return applicationReport;
 }
Пример #16
0
 public static ResourceRequest newResourceRequest(ResourceRequest r) {
   ResourceRequest request = recordFactory.newRecordInstance(ResourceRequest.class);
   request.setPriority(r.getPriority());
   request.setResourceName(r.getResourceName());
   request.setCapability(r.getCapability());
   request.setNumContainers(r.getNumContainers());
   return request;
 }
Пример #17
0
 public static URL newURL(String scheme, String host, int port, String file) {
   URL url = recordFactory.newRecordInstance(URL.class);
   url.setScheme(scheme);
   url.setHost(host);
   url.setPort(port);
   url.setFile(file);
   return url;
 }
Пример #18
0
 @Override
 public Priority getPriority() {
   // Right now per-app priorities are not passed to scheduler,
   // so everyone has the same priority.
   Priority p = recordFactory.newRecordInstance(Priority.class);
   p.setPriority(1);
   return p;
 }
Пример #19
0
 public static ContainerStatus newContainerStatus(
     ContainerId containerId, ContainerState containerState, String diagnostics, int exitStatus) {
   ContainerStatus containerStatus = recordFactory.newRecordInstance(ContainerStatus.class);
   containerStatus.setState(containerState);
   containerStatus.setContainerId(containerId);
   containerStatus.setDiagnostics(diagnostics);
   containerStatus.setExitStatus(exitStatus);
   return containerStatus;
 }
Пример #20
0
 public static <T extends Token> T newToken(
     Class<T> tokenClass, byte[] identifier, String kind, byte[] password, String service) {
   T token = recordFactory.newRecordInstance(tokenClass);
   token.setIdentifier(ByteBuffer.wrap(identifier));
   token.setKind(kind);
   token.setPassword(ByteBuffer.wrap(password));
   token.setService(service);
   return token;
 }
Пример #21
0
 public static ResourceRequest newResourceRequest(
     Priority priority, String hostName, Resource capability, int numContainers) {
   ResourceRequest request = recordFactory.newRecordInstance(ResourceRequest.class);
   request.setPriority(priority);
   request.setResourceName(hostName);
   request.setCapability(capability);
   request.setNumContainers(numContainers);
   return request;
 }
Пример #22
0
  @Test
  public void testOutOfOrder() throws Exception {
    LOG.info("STARTING testOutOfOrder");
    YarnRPC mockRpc = mock(YarnRPC.class);
    AppContext mockContext = mock(AppContext.class);
    @SuppressWarnings("rawtypes")
    EventHandler mockEventHandler = mock(EventHandler.class);
    when(mockContext.getEventHandler()).thenReturn(mockEventHandler);

    ContainerManager mockCM = mock(ContainerManager.class);
    when(mockRpc.getProxy(
            eq(ContainerManager.class), any(InetSocketAddress.class), any(Configuration.class)))
        .thenReturn(mockCM);

    ContainerLauncherImplUnderTest ut = new ContainerLauncherImplUnderTest(mockContext, mockRpc);

    Configuration conf = new Configuration();
    ut.init(conf);
    ut.start();
    try {
      ContainerId contId = makeContainerId(0l, 0, 0, 1);
      TaskAttemptId taskAttemptId = makeTaskAttemptId(0l, 0, 0, TaskType.MAP, 0);
      String cmAddress = "127.0.0.1:8000";
      StartContainerResponse startResp =
          recordFactory.newRecordInstance(StartContainerResponse.class);
      startResp.setServiceResponse(
          ShuffleHandler.MAPREDUCE_SHUFFLE_SERVICEID, ShuffleHandler.serializeMetaData(80));

      LOG.info("inserting cleanup event");
      ContainerLauncherEvent mockCleanupEvent = mock(ContainerLauncherEvent.class);
      when(mockCleanupEvent.getType()).thenReturn(EventType.CONTAINER_REMOTE_CLEANUP);
      when(mockCleanupEvent.getContainerID()).thenReturn(contId);
      when(mockCleanupEvent.getTaskAttemptID()).thenReturn(taskAttemptId);
      when(mockCleanupEvent.getContainerMgrAddress()).thenReturn(cmAddress);
      ut.handle(mockCleanupEvent);

      ut.waitForPoolToIdle();

      verify(mockCM, never()).stopContainer(any(StopContainerRequest.class));

      LOG.info("inserting launch event");
      ContainerRemoteLaunchEvent mockLaunchEvent = mock(ContainerRemoteLaunchEvent.class);
      when(mockLaunchEvent.getType()).thenReturn(EventType.CONTAINER_REMOTE_LAUNCH);
      when(mockLaunchEvent.getContainerID()).thenReturn(contId);
      when(mockLaunchEvent.getTaskAttemptID()).thenReturn(taskAttemptId);
      when(mockLaunchEvent.getContainerMgrAddress()).thenReturn(cmAddress);
      when(mockCM.startContainer(any(StartContainerRequest.class))).thenReturn(startResp);
      ut.handle(mockLaunchEvent);

      ut.waitForPoolToIdle();

      verify(mockCM, never()).startContainer(any(StartContainerRequest.class));
    } finally {
      ut.stop();
    }
  }
 public ApplicationId submitApplication(ApplicationSubmissionContext appContext)
     throws IOException {
   appContext.setApplicationId(applicationId);
   SubmitApplicationRequest request =
       recordFactory.newRecordInstance(SubmitApplicationRequest.class);
   request.setApplicationSubmissionContext(appContext);
   applicationsManager.submitApplication(request);
   LOG.info("Submitted application " + applicationId + " to ResourceManager" + " at " + rmAddress);
   return applicationId;
 }
 private GetQueueInfoRequest getQueueInfoRequest(
     String queueName,
     boolean includeApplications,
     boolean includeChildQueues,
     boolean recursive) {
   GetQueueInfoRequest request = recordFactory.newRecordInstance(GetQueueInfoRequest.class);
   request.setQueueName(queueName);
   request.setIncludeApplications(includeApplications);
   request.setIncludeChildQueues(includeChildQueues);
   request.setRecursive(recursive);
   return request;
 }
  @Test(timeout = 5000)
  public void testOutOfOrder() throws Exception {
    LOG.info("STARTING testOutOfOrder");
    AppContext mockContext = mock(AppContext.class);
    @SuppressWarnings("rawtypes")
    EventHandler mockEventHandler = mock(EventHandler.class);
    when(mockContext.getEventHandler()).thenReturn(mockEventHandler);

    ContainerManagementProtocol mockCM = mock(ContainerManagementProtocol.class);
    ContainerLauncherImplUnderTest ut = new ContainerLauncherImplUnderTest(mockContext, mockCM);

    Configuration conf = new Configuration();
    ut.init(conf);
    ut.start();
    try {
      ContainerId contId = makeContainerId(0l, 0, 0, 1);
      TaskAttemptId taskAttemptId = makeTaskAttemptId(0l, 0, 0, TaskType.MAP, 0);
      String cmAddress = "127.0.0.1:8000";
      StartContainersResponse startResp =
          recordFactory.newRecordInstance(StartContainersResponse.class);
      startResp.setAllServicesMetaData(serviceResponse);

      LOG.info("inserting cleanup event");
      ContainerLauncherEvent mockCleanupEvent = mock(ContainerLauncherEvent.class);
      when(mockCleanupEvent.getType()).thenReturn(EventType.CONTAINER_REMOTE_CLEANUP);
      when(mockCleanupEvent.getContainerID()).thenReturn(contId);
      when(mockCleanupEvent.getTaskAttemptID()).thenReturn(taskAttemptId);
      when(mockCleanupEvent.getContainerMgrAddress()).thenReturn(cmAddress);
      ut.handle(mockCleanupEvent);

      ut.waitForPoolToIdle();

      verify(mockCM, never()).stopContainers(any(StopContainersRequest.class));

      LOG.info("inserting launch event");
      ContainerRemoteLaunchEvent mockLaunchEvent = mock(ContainerRemoteLaunchEvent.class);
      when(mockLaunchEvent.getType()).thenReturn(EventType.CONTAINER_REMOTE_LAUNCH);
      when(mockLaunchEvent.getContainerID()).thenReturn(contId);
      when(mockLaunchEvent.getTaskAttemptID()).thenReturn(taskAttemptId);
      when(mockLaunchEvent.getContainerMgrAddress()).thenReturn(cmAddress);
      when(mockCM.startContainers(any(StartContainersRequest.class))).thenReturn(startResp);
      when(mockLaunchEvent.getContainerToken())
          .thenReturn(createNewContainerToken(contId, cmAddress));
      ut.handle(mockLaunchEvent);

      ut.waitForPoolToIdle();

      verify(mockCM, never()).startContainers(any(StartContainersRequest.class));
    } finally {
      ut.stop();
    }
  }
Пример #26
0
 public static LocalResource newLocalResource(
     URL url,
     LocalResourceType type,
     LocalResourceVisibility visibility,
     long size,
     long timestamp) {
   LocalResource resource = recordFactory.newRecordInstance(LocalResource.class);
   resource.setResource(url);
   resource.setType(type);
   resource.setVisibility(visibility);
   resource.setSize(size);
   resource.setTimestamp(timestamp);
   return resource;
 }
Пример #27
0
 public static ApplicationResourceUsageReport newApplicationResourceUsageReport(
     int numUsedContainers,
     int numReservedContainers,
     Resource usedResources,
     Resource reservedResources,
     Resource neededResources) {
   ApplicationResourceUsageReport report =
       recordFactory.newRecordInstance(ApplicationResourceUsageReport.class);
   report.setNumUsedContainers(numUsedContainers);
   report.setNumReservedContainers(numReservedContainers);
   report.setUsedResources(usedResources);
   report.setReservedResources(reservedResources);
   report.setNeededResources(neededResources);
   return report;
 }
 @Override
 public synchronized void init(Configuration conf) {
   this.rmAddress =
       conf.get(
           YarnConfiguration.RM_RESOURCE_TRACKER_ADDRESS,
           YarnConfiguration.DEFAULT_RM_RESOURCE_TRACKER_ADDRESS);
   this.heartBeatInterval =
       conf.getLong(
           YarnConfiguration.NM_TO_RM_HEARTBEAT_INTERVAL_MS,
           YarnConfiguration.DEFAULT_NM_TO_RM_HEARTBEAT_INTERVAL_MS);
   int memoryMb = conf.getInt(YarnConfiguration.NM_PMEM_MB, YarnConfiguration.DEFAULT_NM_PMEM_MB);
   this.totalResource = recordFactory.newRecordInstance(Resource.class);
   this.totalResource.setMemory(memoryMb);
   metrics.addResource(totalResource);
   super.init(conf);
 }
Пример #29
0
 public static Container newContainer(
     ContainerId containerId,
     NodeId nodeId,
     String nodeHttpAddress,
     Resource resource,
     Priority priority,
     Token containerToken) {
   Container container = recordFactory.newRecordInstance(Container.class);
   container.setId(containerId);
   container.setNodeId(nodeId);
   container.setNodeHttpAddress(nodeHttpAddress);
   container.setResource(resource);
   container.setPriority(priority);
   container.setContainerToken(containerToken);
   return container;
 }
Пример #30
0
 public static LocalResource newLocalResource(
     URL url,
     LocalResourceType type,
     LocalResourceVisibility visibility,
     long size,
     long timestamp,
     boolean shouldBeUploadedToSharedCache) {
   LocalResource resource = recordFactory.newRecordInstance(LocalResource.class);
   resource.setResource(url);
   resource.setType(type);
   resource.setVisibility(visibility);
   resource.setSize(size);
   resource.setTimestamp(timestamp);
   resource.setShouldBeUploadedToSharedCache(shouldBeUploadedToSharedCache);
   return resource;
 }