当前位置: 首页>>代码示例>>Java>>正文


Java DefaultResourceCalculator类代码示例

本文整理汇总了Java中org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator的典型用法代码示例。如果您正苦于以下问题:Java DefaultResourceCalculator类的具体用法?Java DefaultResourceCalculator怎么用?Java DefaultResourceCalculator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DefaultResourceCalculator类属于org.apache.hadoop.yarn.util.resource包,在下文中一共展示了DefaultResourceCalculator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUp

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Before
public void setUp() {
  clock = mock(Clock.class);
  plan = mock(Plan.class);
  rSystem = mock(ReservationSystem.class);
  plans.put(PLAN_NAME, plan);
  rrValidator = new ReservationInputValidator(clock);
  when(clock.getTime()).thenReturn(1L);
  ResourceCalculator rCalc = new DefaultResourceCalculator();
  Resource resource = Resource.newInstance(10240, 10, 10);
  when(plan.getResourceCalculator()).thenReturn(rCalc);
  when(plan.getTotalCapacity()).thenReturn(resource);
  when(rSystem.getQueueForReservation(any(ReservationId.class))).thenReturn(
      PLAN_NAME);
  when(rSystem.getPlan(PLAN_NAME)).thenReturn(plan);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:TestReservationInputValidator.java

示例2: setup

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Before
public void setup() throws Exception {

  // 1 sec step
  step = 1000L;

  initTime = System.currentTimeMillis();
  minAlloc = Resource.newInstance(1024, 1, 1);
  res = new DefaultResourceCalculator();
  maxAlloc = Resource.newInstance(1024 * 8, 8, 8);

  mAgent = mock(ReservationAgent.class);
  ReservationSystemTestUtil testUtil = new ReservationSystemTestUtil();
  String reservationQ = testUtil.getFullReservationQueueName();
  QueueMetrics rootQueueMetrics = mock(QueueMetrics.class);
  Resource clusterResource = testUtil.calculateClusterResource(totCont);
  ReservationSchedulerConfiguration conf = mock
      (ReservationSchedulerConfiguration.class);
  NoOverCommitPolicy policy = new NoOverCommitPolicy();
  policy.init(reservationQ, conf);

  plan =
      new InMemoryPlan(rootQueueMetrics, policy, mAgent,
          clusterResource, step, res, minAlloc, maxAlloc,
          "dedicated", null, true);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:27,代码来源:TestNoOverCommitPolicy.java

示例3: mockYarnScheduler

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
private static YarnScheduler mockYarnScheduler() {
  YarnScheduler yarnScheduler = mock(YarnScheduler.class);
  when(yarnScheduler.getMinimumResourceCapability()).thenReturn(
      Resources.createResource(
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB));
  when(yarnScheduler.getMaximumResourceCapability()).thenReturn(
      Resources.createResource(
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB));
  when(yarnScheduler.getAppsInQueue(QUEUE_1)).thenReturn(
      Arrays.asList(getApplicationAttemptId(101), getApplicationAttemptId(102)));
  when(yarnScheduler.getAppsInQueue(QUEUE_2)).thenReturn(
      Arrays.asList(getApplicationAttemptId(103)));
  ApplicationAttemptId attemptId = getApplicationAttemptId(1);
  when(yarnScheduler.getAppResourceUsageReport(attemptId)).thenReturn(null);
  ResourceCalculator rc = new DefaultResourceCalculator();
  when(yarnScheduler.getResourceCalculator()).thenReturn(rc);
  return yarnScheduler;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:19,代码来源:TestClientRMService.java

示例4: setUp

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Before
public void setUp() throws PlanningException {
  resCalc = new DefaultResourceCalculator();
  minAlloc = Resource.newInstance(1024, 1);
  maxAlloc = Resource.newInstance(64 * 1024, 20);
  totalCapacity = Resource.newInstance(100 * 1024, 100);

  clock = mock(Clock.class);
  queueMetrics = mock(QueueMetrics.class);
  policy = mock(SharingPolicy.class);
  replanner = mock(Planner.class);

  when(clock.getTime()).thenReturn(1L);

  context = ReservationSystemTestUtil.createMockRMContext();
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:17,代码来源:TestInMemoryPlan.java

示例5: testMergeAdd

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Test
public void testMergeAdd() throws PlanningException {

  TreeMap<Long, Resource> a = new TreeMap<>();
  TreeMap<Long, Resource> b = new TreeMap<>();

  setupArrays(a, b);

  RLESparseResourceAllocation rleA =
      new RLESparseResourceAllocation(a, new DefaultResourceCalculator());
  RLESparseResourceAllocation rleB =
      new RLESparseResourceAllocation(b, new DefaultResourceCalculator());

  RLESparseResourceAllocation out =
      RLESparseResourceAllocation.merge(new DefaultResourceCalculator(),
          Resource.newInstance(100 * 128 * 1024, 100 * 32), rleA, rleB,
          RLEOperator.add, 18, 45);

  System.out.println(out);

  long[] time = { 18, 20, 22, 30, 33, 40, 43, 45 };
  int[] alloc = { 10, 15, 20, 25, 30, 40, 30 };

  validate(out, time, alloc);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:26,代码来源:TestRLESparseResourceAllocation.java

示例6: testMergeMin

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Test
public void testMergeMin() throws PlanningException {

  TreeMap<Long, Resource> a = new TreeMap<>();
  TreeMap<Long, Resource> b = new TreeMap<>();

  setupArrays(a, b);

  RLESparseResourceAllocation rleA =
      new RLESparseResourceAllocation(a, new DefaultResourceCalculator());
  RLESparseResourceAllocation rleB =
      new RLESparseResourceAllocation(b, new DefaultResourceCalculator());

  RLESparseResourceAllocation out =
      RLESparseResourceAllocation.merge(new DefaultResourceCalculator(),
          Resource.newInstance(100 * 128 * 1024, 100 * 32), rleA, rleB,
          RLEOperator.min, 0, 60);

  System.out.println(out);

  long[] time = { 10, 22, 33, 40, 43, 50, 60 };
  int[] alloc = { 5, 10, 15, 20, 10, 0 };

  validate(out, time, alloc);

}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:TestRLESparseResourceAllocation.java

示例7: testMergeMax

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Test
public void testMergeMax() throws PlanningException {

  TreeMap<Long, Resource> a = new TreeMap<>();
  TreeMap<Long, Resource> b = new TreeMap<>();

  setupArrays(a, b);

  RLESparseResourceAllocation rleA =
      new RLESparseResourceAllocation(a, new DefaultResourceCalculator());
  RLESparseResourceAllocation rleB =
      new RLESparseResourceAllocation(b, new DefaultResourceCalculator());

  RLESparseResourceAllocation out =
      RLESparseResourceAllocation.merge(new DefaultResourceCalculator(),
          Resource.newInstance(100 * 128 * 1024, 100 * 32), rleA, rleB,
          RLEOperator.max, 0, 60);

  System.out.println(out);

  long[] time = { 10, 20, 30, 40, 50, 60 };
  int[] alloc = { 5, 10, 15, 20, 10 };

  validate(out, time, alloc);

}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:TestRLESparseResourceAllocation.java

示例8: testMergeSubtract

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Test
public void testMergeSubtract() throws PlanningException {

  TreeMap<Long, Resource> a = new TreeMap<>();
  TreeMap<Long, Resource> b = new TreeMap<>();

  setupArrays(a, b);

  RLESparseResourceAllocation rleA =
      new RLESparseResourceAllocation(a, new DefaultResourceCalculator());
  RLESparseResourceAllocation rleB =
      new RLESparseResourceAllocation(b, new DefaultResourceCalculator());

  RLESparseResourceAllocation out =
      RLESparseResourceAllocation.merge(new DefaultResourceCalculator(),
          Resource.newInstance(100 * 128 * 1024, 100 * 32), rleA, rleB,
          RLEOperator.subtract, 0, 60);

  System.out.println(out);

  long[] time = { 10, 11, 20, 22, 30, 33, 43, 50, 60 };
  int[] alloc = { 5, 0, 5, 0, 5, 0, 10, -10 };

  validate(out, time, alloc);

}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:27,代码来源:TestRLESparseResourceAllocation.java

示例9: setUp

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Before
public void setUp() {
  clock = mock(Clock.class);
  plan = mock(Plan.class);
  rSystem = mock(ReservationSystem.class);
  plans.put(PLAN_NAME, plan);
  rrValidator = new ReservationInputValidator(clock);
  when(clock.getTime()).thenReturn(1L);
  ResourceCalculator rCalc = new DefaultResourceCalculator();
  Resource resource = Resource.newInstance(10240, 10);
  when(plan.getResourceCalculator()).thenReturn(rCalc);
  when(plan.getTotalCapacity()).thenReturn(resource);
  when(rSystem.getQueueForReservation(any(ReservationId.class))).thenReturn(
      PLAN_NAME);
  when(rSystem.getPlan(PLAN_NAME)).thenReturn(plan);
}
 
开发者ID:aliyun-beta,项目名称:aliyun-oss-hadoop-fs,代码行数:17,代码来源:TestReservationInputValidator.java

示例10: setup

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Before
public void setup() throws Exception {

  // 1 sec step
  step = 1000L;

  initTime = System.currentTimeMillis();
  minAlloc = Resource.newInstance(1024, 1);
  res = new DefaultResourceCalculator();
  maxAlloc = Resource.newInstance(1024 * 8, 8);

  mAgent = mock(ReservationAgent.class);
  ReservationSystemTestUtil testUtil = new ReservationSystemTestUtil();
  String reservationQ = testUtil.getFullReservationQueueName();
  QueueMetrics rootQueueMetrics = mock(QueueMetrics.class);
  Resource clusterResource = testUtil.calculateClusterResource(totCont);
  ReservationSchedulerConfiguration conf = mock
      (ReservationSchedulerConfiguration.class);
  NoOverCommitPolicy policy = new NoOverCommitPolicy();
  policy.init(reservationQ, conf);

  plan =
      new InMemoryPlan(rootQueueMetrics, policy, mAgent,
          clusterResource, step, res, minAlloc, maxAlloc,
          "dedicated", null, true);
}
 
开发者ID:yncxcw,项目名称:big-c,代码行数:27,代码来源:TestNoOverCommitPolicy.java

示例11: setup

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Before
public void setup() throws Exception {

  // 1 sec step
  step = 1000L;

  initTime = System.currentTimeMillis();
  minAlloc = Resource.newInstance(1024, 1);
  res = new DefaultResourceCalculator();
  maxAlloc = Resource.newInstance(1024 * 8, 8);

  mAgent = mock(ReservationAgent.class);
  ReservationSystemTestUtil testUtil = new ReservationSystemTestUtil();
  CapacityScheduler scheduler = testUtil.mockCapacityScheduler(totCont);
  String reservationQ = testUtil.getFullReservationQueueName();
  CapacitySchedulerConfiguration capConf = scheduler.getConfiguration();
  NoOverCommitPolicy policy = new NoOverCommitPolicy();
  policy.init(reservationQ, capConf);

  plan =
      new InMemoryPlan(scheduler.getRootQueueMetrics(), policy, mAgent,
          scheduler.getClusterResource(), step, res, minAlloc, maxAlloc,
          "dedicated", null, true);
}
 
开发者ID:Nextzero,项目名称:hadoop-2.6.0-cdh5.4.3,代码行数:25,代码来源:TestNoOverCommitPolicy.java

示例12: testRangeOverlapping

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Test
public void testRangeOverlapping() {
  ResourceCalculator resCalc = new DefaultResourceCalculator();

  RLESparseResourceAllocation r =
      new RLESparseResourceAllocation(resCalc);
  int[] alloc = {10, 10, 10, 10, 10, 10};
  int start = 100;
  Set<Entry<ReservationInterval, Resource>> inputs =
      generateAllocation(start, alloc, false).entrySet();
  for (Entry<ReservationInterval, Resource> ip : inputs) {
    r.addInterval(ip.getKey(), ip.getValue());
  }
  long s = r.getEarliestStartTime();
  long d = r.getLatestNonNullTime();

  // tries to trigger "out-of-range" bug
  r =  r.getRangeOverlapping(s, d);
  r = r.getRangeOverlapping(s-1, d-1);
  r = r.getRangeOverlapping(s+1, d+1);
}
 
开发者ID:hopshadoop,项目名称:hops,代码行数:22,代码来源:TestRLESparseResourceAllocation.java

示例13: getSchedulingResourceTypes

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public EnumSet<SchedulerResourceTypes> getSchedulingResourceTypes() {
  if (calculator.getClass().getName()
    .equals(DefaultResourceCalculator.class.getName())) {
    return EnumSet.of(SchedulerResourceTypes.MEMORY);
  }
  return EnumSet
    .of(SchedulerResourceTypes.MEMORY, SchedulerResourceTypes.CPU, SchedulerResourceTypes.GPU);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:11,代码来源:CapacityScheduler.java

示例14: mockResourceScheduler

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
private static ResourceScheduler mockResourceScheduler() {
  ResourceScheduler scheduler = mock(ResourceScheduler.class);
  when(scheduler.getMinimumResourceCapability()).thenReturn(
      Resources.createResource(
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MINIMUM_ALLOCATION_MB));
  when(scheduler.getMaximumResourceCapability()).thenReturn(
      Resources.createResource(
          YarnConfiguration.DEFAULT_RM_SCHEDULER_MAXIMUM_ALLOCATION_MB));
  ResourceCalculator rc = new DefaultResourceCalculator();
  when(scheduler.getResourceCalculator()).thenReturn(rc);
  return scheduler;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:TestAppManager.java

示例15: setUp

import org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator; //导入依赖的package包/类
@Before
public void setUp() throws PlanningException {
  resCalc = new DefaultResourceCalculator();
  minAlloc = Resource.newInstance(1024, 1, 1);
  maxAlloc = Resource.newInstance(64 * 1024, 20, 20);
  totalCapacity = Resource.newInstance(100 * 1024, 100, 100);

  clock = mock(Clock.class);
  queueMetrics = mock(QueueMetrics.class);
  policy = mock(SharingPolicy.class);
  replanner = mock(Planner.class);

  when(clock.getTime()).thenReturn(1L);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:TestInMemoryPlan.java


注:本文中的org.apache.hadoop.yarn.util.resource.DefaultResourceCalculator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。