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

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


        //                offers when the host attributes cannot be found. (AURORA-137)
        storage.write(new MutateWork.NoResult.Quiet() {
          @Override
          protected void execute(MutableStoreProvider storeProvider) {
            for (Offer offer : offers) {
              IHostAttributes attributes =
                  AttributeStore.Util.mergeOffer(storeProvider.getAttributeStore(), offer);
              storeProvider.getAttributeStore().saveHostAttributes(attributes);
              if (LOG.isLoggable(Level.FINE)) {
                LOG.log(Level.FINE, String.format("Received offer: %s", offer));
              }
View Full Code Here


     * @param store Store to fetch the existing maintenance mode for this host.
     * @param offer Offer to merge.
     * @return attributes from {@code offer} and the existing (or default) maintenance mode.
     */
    public static IHostAttributes mergeOffer(AttributeStore store, Protos.Offer offer) {
      IHostAttributes fromOffer = Conversions.getAttributes(offer);
      MaintenanceMode mode =
          store.getHostAttributes(fromOffer.getHost()).transform(GET_MODE).or(MaintenanceMode.NONE);
      return IHostAttributes.build(fromOffer.newBuilder().setMode(mode));
    }
View Full Code Here

    assertEquals(0, getValue(rackStatName("rackB")));
    assertEquals(1, getValue(jobStatName(failedTask, FAILED)));
  }

  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

    assertEquals(mutated, storage.mutateTasks(query, mutator));
  }

  @Test
  public void testSaveHostAttributes() {
    IHostAttributes attributes = IHostAttributes.build(
        new HostAttributes()
            .setHost("a")
            .setMode(MaintenanceMode.DRAINING)
            .setAttributes(ImmutableSet.of(
                new Attribute().setName("b").setValues(ImmutableSet.of("1", "2")))));

    expect(attributeStore.saveHostAttributes(attributes)).andReturn(true);
    expectOp(Op.saveHostAttributes(
        new SaveHostAttributes().setHostAttributes(attributes.newBuilder())));
    eventSink.post(new PubsubEvent.HostAttributesChanged(attributes));

    expect(attributeStore.saveHostAttributes(attributes)).andReturn(false);

    control.replay();
View Full Code Here

    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"))))
            .setSlaveId("slave id"));
    // A legacy attribute that has a maintenance mode set, but nothing else.  These should be
    // dropped.
    IHostAttributes legacyAttribute = IHostAttributes.build(
        new HostAttributes("host", ImmutableSet.<Attribute>of()));
    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);
    final String updateId1 = "updateId1";
    final String updateId2 = "updateId2";
    IJobUpdateDetails updateDetails1 = IJobUpdateDetails.build(new JobUpdateDetails()
        .setUpdate(new JobUpdate().setSummary(new JobUpdateSummary().setUpdateId(updateId1)))
        .setUpdateEvents(ImmutableList.of(new JobUpdateEvent().setStatus(JobUpdateStatus.ERROR)))
        .setInstanceEvents(ImmutableList.of(new JobInstanceUpdateEvent().setTimestampMs(123L))));

    IJobUpdateDetails updateDetails2 = IJobUpdateDetails.build(new JobUpdateDetails()
        .setUpdate(new JobUpdate().setSummary(new JobUpdateSummary().setUpdateId(updateId2))));

    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, legacyAttribute));
    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));
    String lockToken = "token";
    expect(storageUtil.jobUpdateStore.fetchAllJobUpdateDetails())
        .andReturn(ImmutableSet.of(
            new StoredJobUpdateDetails(updateDetails1.newBuilder(), lockToken),
            new StoredJobUpdateDetails(updateDetails2.newBuilder(), null)));

    expectDataWipe();
    storageUtil.taskStore.saveTasks(tasks);
    storageUtil.quotaStore.saveQuota("steve", ResourceAggregates.none());
    expect(storageUtil.attributeStore.saveHostAttributes(attribute)).andReturn(true);
    storageUtil.jobStore.saveAcceptedJob(
        job.getJobManagerId(),
        IJobConfiguration.build(job.getJobConfiguration()));
    storageUtil.schedulerStore.saveFrameworkId(frameworkId);
    storageUtil.lockStore.saveLock(lock);
    storageUtil.jobUpdateStore.saveJobUpdate(
        updateDetails1.getUpdate(), Optional.fromNullable(lockToken));
    storageUtil.jobUpdateStore.saveJobUpdateEvent(
        Iterables.getOnlyElement(updateDetails1.getUpdateEvents()),
        updateId1);
    storageUtil.jobUpdateStore.saveJobInstanceUpdateEvent(
        Iterables.getOnlyElement(updateDetails1.getInstanceEvents()),
        updateId1);
    storageUtil.jobUpdateStore.saveJobUpdate(
        updateDetails2.getUpdate(), Optional.<String>absent());

    control.replay();

    Snapshot expected = new Snapshot()
        .setTimestamp(NOW)
        .setTasks(IScheduledTask.toBuildersSet(tasks))
        .setQuotaConfigurations(quotas)
        .setHostAttributes(ImmutableSet.of(attribute.newBuilder(), legacyAttribute.newBuilder()))
        .setJobs(ImmutableSet.of(job))
        .setSchedulerMetadata(metadata)
        .setLocks(ImmutableSet.of(lock.newBuilder()))
        .setJobUpdateDetails(ImmutableSet.of(
            new StoredJobUpdateDetails(updateDetails1.newBuilder(), lockToken),
View Full Code Here

    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

  @Test
  public void testAttributesModePreserved() throws Exception {
    new OfferFixture() {
      @Override
      void respondToOffer() throws Exception {
        IHostAttributes draining =
            IHostAttributes.build(OFFER.getAttributes().newBuilder().setMode(DRAINING));
        expect(storageUtil.attributeStore.getHostAttributes(OFFER.getOffer().getHostname()))
            .andReturn(Optional.of(draining));
        IHostAttributes saved = IHostAttributes.build(
            Conversions.getAttributes(OFFER.getOffer()).newBuilder().setMode(DRAINING));
        expect(storageUtil.attributeStore.saveHostAttributes(saved)).andReturn(true);

        HostOffer offer = new HostOffer(OFFER.getOffer(), draining);
        expect(systemLauncher.willUse(offer)).andReturn(false);
View Full Code Here

  }

  private void expectOfferAttributesSaved(HostOffer offer) {
    expect(storageUtil.attributeStore.getHostAttributes(offer.getOffer().getHostname()))
        .andReturn(Optional.<IHostAttributes>absent());
    IHostAttributes defaultMode = IHostAttributes.build(
        Conversions.getAttributes(offer.getOffer()).newBuilder().setMode(MaintenanceMode.NONE));
    expect(storageUtil.attributeStore.saveHostAttributes(defaultMode)).andReturn(true);
  }
View Full Code Here

  @Test
  public void testMultiValuedAttributes() {
    control.replay();

    IHostAttributes hostA = hostAttributes(HOST_A, valueAttribute("jvm", "1.0", "2.0", "3.0"));
    checkConstraint(hostA, "jvm", true, "1.0");
    checkConstraint(hostA, "jvm", false, "4.0");

    checkConstraint(hostA, "jvm", true, "1.0", "2.0");
    IHostAttributes hostB = hostAttributes(HOST_A, valueAttribute("jvm", "1.0"));
    checkConstraint(hostB, "jvm", false, "2.0", "3.0");
  }
View Full Code Here

        makeScheduledTask(OWNER_B, JOB_A, HOST_B))),
        attributeStore);

    control.replay();

    IHostAttributes hostA = hostAttributes(HOST_A, host(HOST_A), rack(RACK_A));
    IHostAttributes hostB = hostAttributes(HOST_B, host(HOST_B), rack(RACK_A));
    IHostAttributes hostC = hostAttributes(HOST_C, host(HOST_C), rack(RACK_B));
    assertNoVetoes(hostLimitTask(OWNER_A, JOB_A, 2), hostA, stateA);
    assertVetoes(
        hostLimitTask(OWNER_A, JOB_A, 1),
        hostB,
        stateA,
View Full Code Here

TOP

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

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.