Package org.apache.aurora.gen.storage

Examples of org.apache.aurora.gen.storage.Snapshot


    // NOOP LogEntry
    builder.add(LogEntry.noop(true));

    // Snapshot LogEntry
    Snapshot snapshot = new Snapshot();
    builder.add(LogEntry.snapshot(snapshot));
    snapshotStore.applySnapshot(snapshot);

    ImmutableSet.Builder<Entry> entryBuilder = ImmutableSet.builder();
    for (LogEntry logEntry : builder.build()) {
View Full Code Here


            .setTaskId(taskId)
            .setTask(config));
  }

  private Snapshot makeSnapshot() {
    Snapshot snapshot = new Snapshot()
        .setSchedulerMetadata(new SchedulerMetadata()
            .setFrameworkId("test"));

    for (Entry<String, TaskConfig> entry : taskIdToConfig.entrySet()) {
      snapshot.addToTasks(makeTask(entry.getKey(), entry.getValue()));
    }

    return snapshot;
  }
View Full Code Here

    return snapshot;
  }

  @Test
  public void testRoundTrip() throws Exception {
    Snapshot snapshot = makeSnapshot();

    assertEquals(
        snapshot,
        snapshotDeduplicator.reduplicate(snapshotDeduplicator.deduplicate(snapshot)));
  }
View Full Code Here

  }

  @Test(expected = CodingException.class)
  public void testReduplicateFailure() throws Exception {
    DeduplicatedSnapshot corrupt = new DeduplicatedSnapshot()
        .setPartialSnapshot(new Snapshot().setSchedulerMetadata(new SchedulerMetadata()))
        .setPartialTasks(ImmutableList.of(
            new DeduplicatedScheduledTask()
                .setPartialScheduledTask(new ScheduledTask())
                .setTaskConfigId(1)))
        .setTaskConfigs(ImmutableList.of(new TaskConfig()));
View Full Code Here

    snapshotDeduplicator.reduplicate(corrupt);
  }

  @Test
  public void testEmptyRoundTrip() throws Exception {
    Snapshot snapshot = new Snapshot();

    assertEquals(
        snapshot,
        snapshotDeduplicator.reduplicate(snapshotDeduplicator.deduplicate(snapshot)));
  }
View Full Code Here

    storageBackup = new StorageBackupImpl(delegate, clock, config);
  }

  @Test
  public void testBackup() throws Exception {
    Snapshot snapshot = makeSnapshot();
    expect(delegate.createSnapshot()).andReturn(snapshot).times(3);

    control.replay();

    assertEquals(snapshot, storageBackup.createSnapshot());
    assertBackupCount(0);
    clock.advance(Amount.of(INTERVAL.as(Time.MILLISECONDS) - 1, Time.MILLISECONDS));
    assertEquals(snapshot, storageBackup.createSnapshot());
    assertBackupCount(0);
    clock.advance(Amount.of(1L, Time.MILLISECONDS));
    assertEquals(snapshot, storageBackup.createSnapshot());
    assertBackupCount(1);
    assertEquals(1, storageBackup.getSuccesses().get());

    Snapshot restored = ThriftBinaryCodec.decode(
        Snapshot.class,
        Files.toByteArray(config.getDir().listFiles()[0]));
    assertEquals(snapshot, restored);
  }
View Full Code Here

    assertEquals(snapshot, restored);
  }

  @Test
  public void testDirectoryMissing() {
    Snapshot snapshot = makeSnapshot();
    expect(delegate.createSnapshot()).andReturn(snapshot).times(1);

    control.replay();

    clock.advance(INTERVAL);
View Full Code Here

    assertEquals(1, storageBackup.getFailures().get());
  }

  @Test
  public void testOldBackupsDeleted() {
    Snapshot snapshot = makeSnapshot();
    expect(delegate.createSnapshot()).andReturn(snapshot).times(MAX_BACKUPS + 1);

    control.replay();

    ImmutableList.Builder<String> nameBuilder = ImmutableList.builder();
View Full Code Here

  }

  @Test
  public void testInterval() {
    // Ensures that a long initial interval does not result in shortened subsequent intervals.
    Snapshot snapshot = makeSnapshot();
    expect(delegate.createSnapshot()).andReturn(snapshot).times(3);

    control.replay();

    assertEquals(snapshot, storageBackup.createSnapshot());
View Full Code Here

  private void assertBackupCount(int count) {
    assertEquals(count, config.getDir().list().length);
  }

  private Snapshot makeSnapshot() {
    Snapshot snapshot = new Snapshot();
    snapshot.setTimestamp(clock.nowMillis());
    snapshot.setHostAttributes(ImmutableSet.of(
        new HostAttributes(
            "hostA",
            ImmutableSet.of(new Attribute("attr", ImmutableSet.of("value"))))));
    snapshot.setJobs(ImmutableSet.of(
        new StoredJob(
            "jobManager",
            new JobConfiguration().setKey(new JobKey("owner", "env", "jobA")))));
    snapshot.setQuotaConfigurations(
        ImmutableSet.of(new QuotaConfiguration("roleA", new ResourceAggregate(10, 1024, 1024))));
    snapshot.setSchedulerMetadata(new SchedulerMetadata().setFrameworkId("frameworkId"));
    snapshot.setTasks(ImmutableSet.of(new ScheduledTask()));
    return snapshot;
  }
View Full Code Here

TOP

Related Classes of org.apache.aurora.gen.storage.Snapshot

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.