Java Code Examples for org.apache.commons.lang.time.DateUtils#MILLIS_PER_SECOND

The following examples show how to use org.apache.commons.lang.time.DateUtils#MILLIS_PER_SECOND . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RMContainerImpl.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private static void updateAttemptMetrics(RMContainerImpl container) {
  // If this is a preempted container, update preemption metrics
  Resource resource = container.getContainer().getResource();
  RMAppAttempt rmAttempt = container.rmContext.getRMApps()
      .get(container.getApplicationAttemptId().getApplicationId())
      .getCurrentAppAttempt();
  if (ContainerExitStatus.PREEMPTED == container.finishedStatus
    .getExitStatus()) {
    rmAttempt.getRMAppAttemptMetrics().updatePreemptionInfo(resource,
      container);
  }

  if (rmAttempt != null) {
    long usedMillis = container.finishTime - container.creationTime;
    long memorySeconds = resource.getMemory()
                          * usedMillis / DateUtils.MILLIS_PER_SECOND;
    long vcoreSeconds = resource.getVirtualCores()
                         * usedMillis / DateUtils.MILLIS_PER_SECOND;
    long gcoreSeconds = resource.getGpuCores()
                         * usedMillis / DateUtils.MILLIS_PER_SECOND;
    rmAttempt.getRMAppAttemptMetrics()
              .updateAggregateAppResourceUsage(memorySeconds,vcoreSeconds, gcoreSeconds);
  }
}
 
Example 2
Source File: SchedulerApplicationAttempt.java    From hadoop with Apache License 2.0 6 votes vote down vote up
synchronized AggregateAppResourceUsage getRunningAggregateAppResourceUsage() {
  long currentTimeMillis = System.currentTimeMillis();
  // Don't walk the whole container list if the resources were computed
  // recently.
  if ((currentTimeMillis - lastMemoryAggregateAllocationUpdateTime)
      > MEM_AGGREGATE_ALLOCATION_CACHE_MSECS) {
    long memorySeconds = 0;
    long vcoreSeconds = 0;
    long gcoreSeconds = 0;
    for (RMContainer rmContainer : this.liveContainers.values()) {
      long usedMillis = currentTimeMillis - rmContainer.getCreationTime();
      Resource resource = rmContainer.getContainer().getResource();
      memorySeconds += resource.getMemory() * usedMillis /  
          DateUtils.MILLIS_PER_SECOND;
      vcoreSeconds += resource.getVirtualCores() * usedMillis  
          / DateUtils.MILLIS_PER_SECOND;
      gcoreSeconds += resource.getGpuCores() * usedMillis / DateUtils.MILLIS_PER_SECOND;
    }

    lastMemoryAggregateAllocationUpdateTime = currentTimeMillis;
    lastMemorySeconds = memorySeconds;
    lastVcoreSeconds = vcoreSeconds;
    lastGcoreSeconds = gcoreSeconds;
  }
  return new AggregateAppResourceUsage(lastMemorySeconds, lastVcoreSeconds, lastGcoreSeconds);
}
 
Example 3
Source File: SchedulerApplicationAttempt.java    From big-c with Apache License 2.0 6 votes vote down vote up
synchronized AggregateAppResourceUsage getRunningAggregateAppResourceUsage() {
  long currentTimeMillis = System.currentTimeMillis();
  // Don't walk the whole container list if the resources were computed
  // recently.
  if ((currentTimeMillis - lastMemoryAggregateAllocationUpdateTime)
      > MEM_AGGREGATE_ALLOCATION_CACHE_MSECS) {
    long memorySeconds = 0;
    long vcoreSeconds = 0;
    for (RMContainer rmContainer : this.liveContainers.values()) {
      long usedMillis = currentTimeMillis - rmContainer.getCreationTime();
      Resource resource = rmContainer.getContainer().getResource();
      memorySeconds += resource.getMemory() * usedMillis /  
          DateUtils.MILLIS_PER_SECOND;
      vcoreSeconds += resource.getVirtualCores() * usedMillis  
          / DateUtils.MILLIS_PER_SECOND;
    }

    lastMemoryAggregateAllocationUpdateTime = currentTimeMillis;
    lastMemorySeconds = memorySeconds;
    lastVcoreSeconds = vcoreSeconds;
  }
  return new AggregateAppResourceUsage(lastMemorySeconds, lastVcoreSeconds);
}
 
Example 4
Source File: TestContainerResourceUsage.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private AggregateAppResourceUsage calculateContainerResourceMetrics(
    RMContainer rmContainer) {
  Resource resource = rmContainer.getContainer().getResource();
  long usedMillis =
      rmContainer.getFinishTime() - rmContainer.getCreationTime();
  long memorySeconds = resource.getMemory()
                        * usedMillis / DateUtils.MILLIS_PER_SECOND;
  long vcoreSeconds = resource.getVirtualCores()
                        * usedMillis / DateUtils.MILLIS_PER_SECOND;
  long gcoreSeconds = resource.getGpuCores()
                        * usedMillis / DateUtils.MILLIS_PER_SECOND;
  return new AggregateAppResourceUsage(memorySeconds, vcoreSeconds, gcoreSeconds);
}
 
Example 5
Source File: RMContainerImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
private static void updateAttemptMetrics(RMContainerImpl container) {
  // If this is a preempted container, update preemption metrics
  Resource resource = container.getContainer().getResource();
  RMAppAttempt rmAttempt = container.rmContext.getRMApps()
      .get(container.getApplicationAttemptId().getApplicationId())
      .getCurrentAppAttempt();
  if (ContainerExitStatus.PREEMPTED == container.finishedStatus
    .getExitStatus()) {
    rmAttempt.getRMAppAttemptMetrics().updatePreemptionInfo(resource,
      container);
  }
  
  if (rmAttempt != null) {
    long usedMillis = container.finishTime - container.creationTime;
    long memorySeconds = (long)(resource.getMemory()*container.utilization)
                          * usedMillis / DateUtils.MILLIS_PER_SECOND;
    long vcoreSeconds = (long)(resource.getVirtualCores()*container.utilization)
                         * usedMillis / DateUtils.MILLIS_PER_SECOND;
    
    if (container.suspendTime.size() >0 && container.resumeTime.size() >0 && container.suspendTime.size() == container.resumeTime.size()){
    	double acc=0;
    	for(int i=0; i < container.suspendTime.size();i++){
    		
    		acc = acc + (container.resumeTime.get(i) - container.suspendTime.get(i));
    	}
    	container.utilization = acc/usedMillis;  	
    }
    rmAttempt.getRMAppAttemptMetrics()
              .updateAggregateAppResourceUsage(memorySeconds,vcoreSeconds);
  }
}
 
Example 6
Source File: TestContainerResourceUsage.java    From big-c with Apache License 2.0 5 votes vote down vote up
private AggregateAppResourceUsage calculateContainerResourceMetrics(
    RMContainer rmContainer) {
  Resource resource = rmContainer.getContainer().getResource();
  long usedMillis =
      rmContainer.getFinishTime() - rmContainer.getCreationTime();
  long memorySeconds = resource.getMemory()
                        * usedMillis / DateUtils.MILLIS_PER_SECOND;
  long vcoreSeconds = resource.getVirtualCores()
                        * usedMillis / DateUtils.MILLIS_PER_SECOND;
  return new AggregateAppResourceUsage(memorySeconds, vcoreSeconds);
}