Package org.apache.aurora.scheduler.storage.entities

Examples of org.apache.aurora.scheduler.storage.entities.IResourceAggregate


  @Test
  public void testGetQuotaInfo() {
    IScheduledTask prodTask = createTask("foo", "id1", 3, 3, 3, true);
    IScheduledTask nonProdTask = createTask("bar", "id1", 2, 2, 2, false);
    IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate(4, 4, 4));

    expectQuota(quota);
    expectTasks(prodTask, nonProdTask);
    storageUtil.expectOperations();
View Full Code Here


        quotaInfo.getNonProdConsumption());
  }

  @Test
  public void testGetQuotaInfoNoTasks() {
    IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate(4, 4, 4));

    expectQuota(quota);
    expectNoTasks();
    storageUtil.expectOperations();
View Full Code Here

public class QuotaCheckResultTest {

  @Test
  public void testGreaterOrEqualPass() {
    IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate()
        .setNumCpus(1.0)
        .setRamMb(256L)
        .setDiskMb(512L));
    IResourceAggregate request = IResourceAggregate.build(new ResourceAggregate()
        .setNumCpus(1.0)
        .setRamMb(256L)
        .setDiskMb(512L));
    assertEquals(SUFFICIENT_QUOTA, QuotaCheckResult.greaterOrEqual(quota, request).getResult());
  }
View Full Code Here

    assertEquals(SUFFICIENT_QUOTA, QuotaCheckResult.greaterOrEqual(quota, request).getResult());
  }

  @Test
  public void testGreaterOrEqualFailsCpu() {
    IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate()
        .setNumCpus(1.0)
        .setRamMb(256L)
        .setDiskMb(512L));
    IResourceAggregate request = IResourceAggregate.build(new ResourceAggregate()
        .setNumCpus(2.0)
        .setRamMb(256L)
        .setDiskMb(512L));
    QuotaCheckResult result = QuotaCheckResult.greaterOrEqual(quota, request);
    assertEquals(INSUFFICIENT_QUOTA, result.getResult());
View Full Code Here

    assertTrue(result.getDetails().get().contains("CPU"));
  }

  @Test
  public void testGreaterOrEqualFailsRam() {
    IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate()
        .setNumCpus(1.0)
        .setRamMb(256L)
        .setDiskMb(512L));
    IResourceAggregate request = IResourceAggregate.build(new ResourceAggregate()
        .setNumCpus(1.0)
        .setRamMb(512L)
        .setDiskMb(512L));
    QuotaCheckResult result = QuotaCheckResult.greaterOrEqual(quota, request);
    assertEquals(INSUFFICIENT_QUOTA, result.getResult());
View Full Code Here

    assertTrue(result.getDetails().get().contains("RAM"));
  }

  @Test
  public void testGreaterOrEqualFailsDisk() {
    IResourceAggregate quota = IResourceAggregate.build(new ResourceAggregate()
        .setNumCpus(1.0)
        .setRamMb(256L)
        .setDiskMb(512L));
    IResourceAggregate request = IResourceAggregate.build(new ResourceAggregate()
        .setNumCpus(1.0)
        .setRamMb(256L)
        .setDiskMb(1024L));
    QuotaCheckResult result = QuotaCheckResult.greaterOrEqual(quota, request);
    assertEquals(INSUFFICIENT_QUOTA, result.getResult());
View Full Code Here

  }

  @Test
  public void testSaveQuota() throws Exception {
    final String role = "role";
    final IResourceAggregate quota =
        IResourceAggregate.build(new ResourceAggregate(1.0, 128L, 1024L));

    new MutationFixture() {
      @Override
      protected void setupExpectations() throws Exception {
        storageUtil.expectWriteOperation();
        storageUtil.quotaStore.saveQuota(role, quota);
        streamMatcher.expectTransaction(Op.saveQuota(new SaveQuota(role, quota.newBuilder())))
            .andReturn(position);
      }

      @Override
      protected void performMutations(MutableStoreProvider storeProvider) {
View Full Code Here

  public void testGetQuota() throws Exception {
    QuotaInfo infoMock = createMock(QuotaInfo.class);
    expect(quotaManager.getQuotaInfo(ROLE)).andReturn(infoMock);
    expect(infoMock.guota()).andReturn(QUOTA);
    expect(infoMock.getProdConsumption()).andReturn(CONSUMED);
    IResourceAggregate nonProdConsumed = IResourceAggregate.build(new ResourceAggregate(1, 0, 0));
    expect(infoMock.getNonProdConsumption()).andReturn(nonProdConsumed);
    control.replay();

    Response response = assertOkResponse(thrift.getQuota(ROLE));
    assertEquals(QUOTA.newBuilder(), response.getResult().getGetQuotaResult().getQuota());
    assertEquals(
        CONSUMED.newBuilder(),
        response.getResult().getGetQuotaResult().getProdConsumption());
    assertEquals(
        nonProdConsumed.newBuilder(),
        response.getResult().getGetQuotaResult().getNonProdConsumption());
  }
View Full Code Here

        public QuotaInfo apply(StoreProvider storeProvider) {
          FluentIterable<ITaskConfig> tasks = FluentIterable
              .from(storeProvider.getTaskStore().fetchTasks(Query.roleScoped(role).active()))
              .transform(Tasks.SCHEDULED_TO_INFO);

          IResourceAggregate prodConsumed = fromTasks(tasks.filter(Tasks.IS_PRODUCTION));
          IResourceAggregate nonProdConsumed =
              fromTasks(tasks.filter(Predicates.not(Tasks.IS_PRODUCTION)));

          IResourceAggregate quota =
              storeProvider.getQuotaStore().fetchQuota(role).or(ResourceAggregates.none());

          return new QuotaInfo(quota, prodConsumed, nonProdConsumed);
        }
      });
View Full Code Here

        return new QuotaCheckResult(SUFFICIENT_QUOTA);
      }

      QuotaInfo quotaInfo = getQuotaInfo(JobKeys.from(template).getRole());

      IResourceAggregate additionalRequested =
          ResourceAggregates.scale(fromTasks(ImmutableSet.of(template)), instances);

      return QuotaCheckResult.greaterOrEqual(
          quotaInfo.guota(),
          add(quotaInfo.getProdConsumption(), additionalRequested));
View Full Code Here

TOP

Related Classes of org.apache.aurora.scheduler.storage.entities.IResourceAggregate

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.