Examples of IResourceAggregate


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

      if (!template.isProduction()) {
        return new QuotaCheckResult(SUFFICIENT_QUOTA);
      }

      QuotaInfo quotaInfo = getQuotaInfo(template.getJob().getRole());
      IResourceAggregate requestedTotal = add(
          quotaInfo.getProdConsumption(),
          ResourceAggregates.scale(fromTasks(ImmutableSet.of(template)), instances));

      return QuotaCheckResult.greaterOrEqual(quotaInfo.getQuota(), requestedTotal);
    }
View Full Code Here

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

          Map<IJobKey, IJobConfiguration> cronTemplates =
              FluentIterable.from(cronJobManager.getJobs())
                  .filter(Predicates.compose(Predicates.equalTo(role), JobKeys.CONFIG_TO_ROLE))
                  .uniqueIndex(JobKeys.FROM_CONFIG);

          IResourceAggregate prodConsumed = getConsumption(tasks, updates, cronTemplates, true);

          IResourceAggregate nonProdConsumed = getConsumption(tasks, updates, cronTemplates, false);

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

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

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

      Predicate<ITaskConfig> prodFilter = isProd ? IS_PRODUCTION : Predicates.not(IS_PRODUCTION);

      FluentIterable<IScheduledTask> filteredTasks =
          tasks.filter(Predicates.compose(prodFilter, SCHEDULED_TO_INFO));

      IResourceAggregate nonCronConsumption = getNonCronConsumption(
          updatesByKey,
          excludeCronTasks(filteredTasks, cronTemplatesByKey),
          isProd);

      IResourceAggregate cronConsumption =
          getCronConsumption(cronTemplatesByKey, filteredTasks, isProd);

      return add(nonCronConsumption, cronConsumption);
    }
View Full Code Here

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

      // 2. Calculate consumed resources from instances affected by the active job updates as
      //    "updateConsumption".
      //
      // 3. Add up the two to yield total consumption.

      IResourceAggregate nonUpdateConsumption = fromTasks(tasks
          .filter(buildNonUpdatingTasksFilter(updatesByKey))
          .transform(SCHEDULED_TO_INFO));

      IResourceAggregate updateConsumption = ResourceAggregates.EMPTY;
      for (IJobUpdate update : updatesByKey.values()) {
        updateConsumption =
            add(updateConsumption, instructionsToResources(update.getInstructions(), isProd));
      }
View Full Code Here

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

      // lack of enforcement on a cron job run duration).

      Multimap<IJobKey, ITaskConfig> taskConfigsByKey =
          tasks.transform(SCHEDULED_TO_INFO).index(INFO_TO_JOB_KEY);

      IResourceAggregate totalConsumption = ResourceAggregates.EMPTY;
      for (IJobConfiguration config : cronTemplates.values()) {
        if (isProd == config.getTaskConfig().isProduction()) {
          IResourceAggregate templateConsumption = ResourceAggregates.scale(
              fromTasks(ImmutableSet.of(config.getTaskConfig())), config.getInstanceCount());

          IResourceAggregate taskConsumption = fromTasks(taskConfigsByKey.get(config.getKey()));

          totalConsumption = add(totalConsumption, max(templateConsumption, taskConsumption));
        }
      }
      return totalConsumption;
View Full Code Here

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

    private static IResourceAggregate instructionsToResources(
        IJobUpdateInstructions instructions,
        final boolean isProd) {

      // Calculate initial state consumption.
      IResourceAggregate initial = ResourceAggregates.EMPTY;
      for (IInstanceTaskConfig group : instructions.getInitialState()) {
        ITaskConfig task = group.getTask();
        if (isProd == task.isProduction()) {
          for (IRange range : group.getInstances()) {
            initial = add(initial, ResourceAggregates.scale(
                fromTasks(ImmutableSet.of(task)),
                instanceCountFromRange(range)));
          }
        }
      }

      // Calculate desired state consumption.
      IResourceAggregate desired = Optional.fromNullable(instructions.getDesiredState())
          .transform(new Function<IInstanceTaskConfig, IResourceAggregate>() {
            @Override
            public IResourceAggregate apply(IInstanceTaskConfig input) {
              return isProd == input.getTask().isProduction()
                  ? ResourceAggregates.scale(
View Full Code Here

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

  public void testGetQuota() throws Exception {
    QuotaInfo infoMock = createMock(QuotaInfo.class);
    expect(quotaManager.getQuotaInfo(ROLE)).andReturn(infoMock);
    expect(infoMock.getQuota()).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

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

    });
  }

  @Test
  public void testWritesUnderTransaction() {
    final IResourceAggregate quota = IResourceAggregate
            .build(new ResourceAggregate().setDiskMb(100).setNumCpus(2.0).setRamMb(512));

    try {
      storage.write(new MutateWork.NoResult.Quiet() {
        @Override
View Full Code Here

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

  }

  @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

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

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

    expectQuota(quota);
    expectTasks(prodTask, nonProdTask);
    expectJobUpdates(taskConfig(1, 1, 1, true), taskConfig(1, 1, 1, true));
    expectCronJobs(
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.