Examples of IHostAttributes


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

    assertEquals(0, getValue(rackStatName("rackA")));
    assertEquals(0, getValue(rackStatName("rackB")));
  }

  private IExpectationSetters<?> expectGetHostRack(String host, String rackToReturn) {
    IHostAttributes attributes = IHostAttributes.build(new HostAttributes()
        .setHost(host)
        .setAttributes(ImmutableSet.of(
            new Attribute().setName("rack").setValues(ImmutableSet.of(rackToReturn)))));
    return expect(storageUtil.attributeStore.getHostAttributes(host))
        .andReturn(Optional.of(attributes));
View Full Code Here

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

  private IExpectationSetters<Optional<IHostAttributes>> expectGetHostAttributes(
      String host,
      Attribute... attributes) {

    IHostAttributes hostAttributes = IHostAttributes.build(new HostAttributes()
        .setHost(host)
        .setAttributes(ImmutableSet.<Attribute>builder().add(attributes).build()));
    return expect(attributeStore.getHostAttributes(host)).andReturn(Optional.of(hostAttributes));
  }
View Full Code Here

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

    return new Attribute(RACK_ATTRIBUTE, ImmutableSet.of(rack));
  }

  // Sets up a normal host, no dedicated hosts and no maintenance.
  private void setUpHost(String host, String rack) {
    IHostAttributes hostAttrs = IHostAttributes.build(
        new HostAttributes().setHost(host).setSlaveId(host + "_id")
            .setMode(NONE).setAttributes(ImmutableSet.of(rack(rack), host(host))));

    expect(this.storageUtil.attributeStore.getHostAttributes(host))
        .andReturn(Optional.of(hostAttrs)).anyTimes();
View Full Code Here

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

    insert(HOST_B_ATTRS);
    assertEquals(Optional.of(HOST_B_ATTRS), read(HOST_B));
    assertEquals(ImmutableSet.of(HOST_A_ATTRS, HOST_B_ATTRS), readAll());

    IHostAttributes updatedA = IHostAttributes.build(
        HOST_A_ATTRS.newBuilder().setAttributes(ImmutableSet.of(ATTR1, ATTR3)));
    insert(updatedA);
    assertEquals(Optional.of(updatedA), read(HOST_A));
    assertEquals(ImmutableSet.of(updatedA, HOST_B_ATTRS), readAll());
View Full Code Here

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

    assertEquals(ImmutableSet.<IHostAttributes>of(), readAll());
  }

  @Test(expected = IllegalArgumentException.class)
  public void testEmptyAttributeValues() {
    IHostAttributes attributes = IHostAttributes.build(HOST_A_ATTRS.newBuilder()
        .setAttributes(ImmutableSet.of(new Attribute("attr1", ImmutableSet.<String>of()))));
    insert(attributes);
  }
View Full Code Here

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

    insert(attributes);
  }

  @Test
  public void testNoAttributes() {
    IHostAttributes attributes = IHostAttributes.build(
        HOST_A_ATTRS.newBuilder().setAttributes(ImmutableSet.<Attribute>of()));
    insert(attributes);
    assertEquals(Optional.of(attributes), read(HOST_A));
  }
View Full Code Here

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

    insert(IHostAttributes.build(noMode));
    // Default mode NONE should be automatically applied.
    assertEquals(Optional.of(HOST_A_ATTRS), read(HOST_A));

    IHostAttributes updatedA = IHostAttributes.build(noMode.deepCopy().setMode(DRAINED));
    // Inserting the updated value should ignore the mode.
    insert(updatedA);
    assertEquals(Optional.of(HOST_A_ATTRS), read(HOST_A));

    // Instead, the mode must be explicitly set to be changed.
View Full Code Here

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

  }

  @Test
  public void testSlaveIdChanges() {
    insert(HOST_A_ATTRS);
    IHostAttributes updated = IHostAttributes.build(HOST_A_ATTRS.newBuilder().setSlaveId(SLAVE_B));
    insert(updated);
    assertEquals(Optional.of(updated), read(HOST_A));
  }
View Full Code Here

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

    ImmutableSet<IScheduledTask> tasks = ImmutableSet.of(
        IScheduledTask.build(new ScheduledTask().setStatus(ScheduleStatus.PENDING)));
    Set<QuotaConfiguration> quotas =
        ImmutableSet.of(
            new QuotaConfiguration("steve", ResourceAggregates.none().newBuilder()));
    IHostAttributes attribute = IHostAttributes.build(new HostAttributes("host",
        ImmutableSet.of(new Attribute("attr", ImmutableSet.of("value")))));
    StoredJob job = new StoredJob(
        "jobManager",
        new JobConfiguration().setKey(new JobKey("owner", "env", "name")));
    String frameworkId = "framework_id";
    ILock lock = ILock.build(new Lock()
        .setKey(LockKey.job(JobKeys.from("testRole", "testEnv", "testJob").newBuilder()))
        .setToken("lockId")
        .setUser("testUser")
        .setTimestampMs(12345L));
    SchedulerMetadata metadata = new SchedulerMetadata()
        .setFrameworkId(frameworkId)
        .setVersion(CURRENT_API_VERSION);

    storageUtil.expectOperations();
    expect(storageUtil.taskStore.fetchTasks(Query.unscoped())).andReturn(tasks);
    expect(storageUtil.quotaStore.fetchQuotas())
        .andReturn(ImmutableMap.of("steve", ResourceAggregates.none()));
    expect(storageUtil.attributeStore.getHostAttributes()).andReturn(ImmutableSet.of(attribute));
    expect(storageUtil.jobStore.fetchManagerIds()).andReturn(ImmutableSet.of("jobManager"));
    expect(storageUtil.jobStore.fetchJobs("jobManager"))
        .andReturn(ImmutableSet.of(IJobConfiguration.build(job.getJobConfiguration())));
    expect(storageUtil.schedulerStore.fetchFrameworkId()).andReturn(Optional.of(frameworkId));
    expect(storageUtil.lockStore.fetchLocks()).andReturn(ImmutableSet.of(lock));

    expectDataWipe();
    storageUtil.taskStore.saveTasks(tasks);
    storageUtil.quotaStore.saveQuota("steve", ResourceAggregates.none());
    storageUtil.attributeStore.saveHostAttributes(attribute);
    storageUtil.jobStore.saveAcceptedJob(
        job.getJobManagerId(),
        IJobConfiguration.build(job.getJobConfiguration()));
    storageUtil.schedulerStore.saveFrameworkId(frameworkId);
    storageUtil.lockStore.saveLock(lock);

    control.replay();

    Snapshot expected = new Snapshot()
        .setTimestamp(NOW)
        .setTasks(IScheduledTask.toBuildersSet(tasks))
        .setQuotaConfigurations(quotas)
        .setHostAttributes(ImmutableSet.of(attribute.newBuilder()))
        .setJobs(ImmutableSet.of(job))
        .setSchedulerMetadata(metadata)
        .setLocks(ILock.toBuildersSet(ImmutableSet.of(lock)));

    assertEquals(expected, snapshotStore.createSnapshot());
View Full Code Here

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

          // There are multiple offers for the same host. Since both have maintenance information
          // we don't preempt with this information and wait for mesos to merge the two offers for
          // us.
          return Optional.absent();
        }
        IHostAttributes attributes = Iterables.getOnlyElement(
            FluentIterable.from(offers).transform(OFFER_TO_ATTRIBUTES).toSet());

        Set<SchedulingFilter.Veto> vetoes = schedulingFilter.filter(
            slackResources,
            attributes,
            pendingTask.getTask(),
            pendingTask.getTaskId(),
            attributeAggregate);

        if (vetoes.isEmpty()) {
          return Optional.<Set<IAssignedTask>>of(ImmutableSet.<IAssignedTask>of());
        }
      }

      FluentIterable<IAssignedTask> preemptableTasks =
          FluentIterable.from(possibleVictims).filter(canPreempt(pendingTask));

      if (preemptableTasks.isEmpty()) {
        return Optional.absent();
      }

      List<IAssignedTask> toPreemptTasks = Lists.newArrayList();

      Iterable<IAssignedTask> sortedVictims = RESOURCE_ORDER.immutableSortedCopy(preemptableTasks);

      for (IAssignedTask victim : sortedVictims) {
        toPreemptTasks.add(victim);

        ResourceSlot totalResource = ResourceSlot.sum(
            ResourceSlot.sum(Iterables.transform(toPreemptTasks, TASK_TO_RESOURCES)),
            slackResources);

        Optional<IHostAttributes> attributes = getHostAttributes(host);
        if (!attributes.isPresent()) {
          missingAttributes.incrementAndGet();
          continue;
        }

        Set<SchedulingFilter.Veto> vetoes = schedulingFilter.filter(
            totalResource,
            attributes.get(),
            pendingTask.getTask(),
            pendingTask.getTaskId(),
            attributeAggregate);

        if (vetoes.isEmpty()) {
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.