Package org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity

Examples of org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue$User


  @Before
  public void init() {
    UserGroup group = new UserGroup("main");
    groupId = getSession().save(group);

    User user1 = new User("User1");
    user1Id = getSession().save(user1);

    User user2 = new User("user2");
    user2Id = getSession().save(user2);

    group.addUser(user1);
    group.addUser(user2);
View Full Code Here


    getSession().clear();
  }

  @Test
  public void testMapUser() {
    User user1 = (User) getSession().load(User.class, user1Id);
    User user2 = (User) getSession().load(User.class, user2Id);
    assertNotNull(user1);
    for (int i = 0; i < 100; i++) {
      UserDto userDto1 = mapperFacade.map(user1, UserDto.class);
      assertEquals(userDto1.getName(), user1.getName());

      UserDto userDto2 = mapperFacade.map(user2, UserDto.class);
      assertEquals(userDto2.getName(), user2.getName());

      assertTrue(user1.getGroup().getUsers().contains(user2));
    }
  }
View Full Code Here

    getSession().clear();
    removeAuthority();
  }

  private void addAuthority() {
    User user1 = (User) getSession().load(User.class, user1Id);
    UserDto userDto1 = mapperFacade.map(user1, UserDto.class);

    log.debug("\n\n old userTO = " + userDto1);

    Authority authority = (Authority) getSession().load(Authority.class,
        adminAuthotityId);
    AuthorityDto authorityDto = mapperFacade.map(authority,
        AuthorityDto.class);
    assertFalse(userDto1.getAuthorities().contains(authorityDto));

    userDto1.getAuthorities().add(authorityDto);
    Assert.assertNotNull(user1);
    mapperFacade.map(userDto1, user1, TypeFactory.valueOf(UserDto.class),
        TypeFactory.valueOf(User.class));

    assertTrue(user1.getAuthorities().contains(authority));
  }
View Full Code Here

    assertTrue(user1.getAuthorities().contains(authority));
  }

  private void removeAuthority() {
    User user1 = (User) getSession().load(User.class, user1Id);
    UserDto userDto1 = mapperFacade.map(user1, UserDto.class);

    log.debug("\n\n old userTO = " + userDto1);

    Authority authority = (Authority) getSession().load(Authority.class,
        adminAuthotityId);
    AuthorityDto authorityDto = mapperFacade.map(authority,
        AuthorityDto.class);
    assertTrue(userDto1.getAuthorities().contains(authorityDto));

    userDto1.getAuthorities().remove(authorityDto);
    Assert.assertNotNull(user1);
    mapperFacade.map(userDto1, user1, TypeFactory.valueOf(UserDto.class),
        TypeFactory.valueOf(User.class));

    assertFalse(user1.getAuthorities().contains(authority));
  }
View Full Code Here

  private void removeGroup() {
    UserGroup group = (UserGroup) getSession().load(UserGroup.class,
        groupId);

    User user1 = (User) getSession().load(User.class, user1Id);

    assertTrue(group.getUsers().contains(user1));

    UserDto userDto1 = mapperFacade.map(user1, UserDto.class);
View Full Code Here

  private void revertGroup() {
    UserGroup group = (UserGroup) getSession().load(UserGroup.class,
        groupId);

    User user1 = (User) getSession().load(User.class, user1Id);

    assertFalse(group.getUsers().contains(user1));

    UserDto userDto1 = mapperFacade.map(user1, UserDto.class);
View Full Code Here

    return pq;
  }

  LeafQueue mockLeafQueue(ParentQueue p, float tot, int i, int[] abs,
      int[] used, int[] pending, int[] reserved, int[] apps, int[] gran) {
    LeafQueue lq = mock(LeafQueue.class);
    when(lq.getTotalResourcePending()).thenReturn(
        Resource.newInstance(pending[i], 0));
    // consider moving where CapacityScheduler::comparator accessible
    NavigableSet<FiCaSchedulerApp> qApps = new TreeSet<FiCaSchedulerApp>(
      new Comparator<FiCaSchedulerApp>() {
        @Override
        public int compare(FiCaSchedulerApp a1, FiCaSchedulerApp a2) {
          return a1.getApplicationAttemptId()
              .compareTo(a2.getApplicationAttemptId());
        }
      });
    // applications are added in global L->R order in queues
    if (apps[i] != 0) {
      int aUsed    = used[i] / apps[i];
      int aPending = pending[i] / apps[i];
      int aReserve = reserved[i] / apps[i];
      for (int a = 0; a < apps[i]; ++a) {
        qApps.add(mockApp(i, appAlloc, aUsed, aPending, aReserve, gran[i]));
        ++appAlloc;
      }
    }
    when(lq.getApplications()).thenReturn(qApps);
    if(setAMResourcePercent != 0.0f){
      when(lq.getMaxAMResourcePerQueuePercent()).thenReturn(setAMResourcePercent);
    }
    p.getChildQueues().add(lq);
    return lq;
  }
View Full Code Here

      int numContainers)
      throws Exception {
    checkCSLeafQueue(rm2, app, clusterResource, queueResource, usedResource,
      numContainers);

    LeafQueue queue = (LeafQueue) app.getQueue();
    Resource availableResources = Resources.subtract(queueResource, usedResource);
    // ************* check Queue metrics ************
    QueueMetrics queueMetrics = queue.getMetrics();
    asserteMetrics(queueMetrics, 1, 0, 1, 0, 2, availableResources.getMemory(),
      availableResources.getVirtualCores(), usedResource.getMemory(),
      usedResource.getVirtualCores());

    // ************ check user metrics ***********
 
View Full Code Here

  private void checkCSLeafQueue(MockRM rm,
      SchedulerApplication<SchedulerApplicationAttempt> app,
      Resource clusterResource, Resource queueResource, Resource usedResource,
      int numContainers) {
    LeafQueue leafQueue = (LeafQueue) app.getQueue();
    // assert queue used resources.
    assertEquals(usedResource, leafQueue.getUsedResources());
    assertEquals(numContainers, leafQueue.getNumContainers());

    ResourceCalculator calc =
        ((CapacityScheduler) rm.getResourceScheduler()).getResourceCalculator();
    float usedCapacity =
        Resources.divide(calc, clusterResource, usedResource, queueResource);
    // assert queue used capacity
    assertEquals(usedCapacity, leafQueue.getUsedCapacity(), 1e-8);
    float absoluteUsedCapacity =
        Resources.divide(calc, clusterResource, usedResource, clusterResource);
    // assert queue absolute capacity
    assertEquals(absoluteUsedCapacity, leafQueue.getAbsoluteUsedCapacity(),
      1e-8);
    // assert user consumed resources.
    assertEquals(usedResource, leafQueue.getUser(app.getUser())
      .getConsumedResources());
  }
View Full Code Here

    asserteMetrics(queue2Metrics, 1, 0, 1, 0, 2,
      q2availableResources.getMemory(), q2availableResources.getVirtualCores(),
      q2UsedResource.getMemory(), q2UsedResource.getVirtualCores());

    // assert parent queue state.
    LeafQueue leafQueue = (LeafQueue) schedulerApp2.getQueue();
    ParentQueue parentQueue = (ParentQueue) leafQueue.getParent();
    checkParentQueue(parentQueue, 6, totalUsedResource, (float) 6 / 16,
      (float) 6 / 16);
    asserteMetrics(parentQueue.getMetrics(), 3, 0, 3, 0, 6,
      totalAvailableResource.getMemory(),
      totalAvailableResource.getVirtualCores(), totalUsedResource.getMemory(),
View Full Code Here

TOP

Related Classes of org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.LeafQueue$User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.