Package org.apache.aurora.gen.storage

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


    expect(driverFactory.apply(null)).andReturn(driver).anyTimes();

    ScheduledTask snapshotTask = makeTask("snapshotTask", ScheduleStatus.ASSIGNED);
    ScheduledTask transactionTask = makeTask("transactionTask", ScheduleStatus.RUNNING);
    Iterable<Entry> recoveredEntries = toEntries(
        LogEntry.snapshot(new Snapshot().setTasks(ImmutableSet.of(snapshotTask))),
        LogEntry.transaction(new Transaction(
            ImmutableList.of(Op.saveTasks(new SaveTasks(ImmutableSet.of(transactionTask)))),
            storageConstants.CURRENT_SCHEMA_VERSION)));

    expect(log.open()).andReturn(logStream);
View Full Code Here


    assertEquals(position1, streamTransaction.commit());
  }

  @Test
  public void testTransactionSnapshot() throws CodingException {
    Snapshot snapshot = createSnapshot();
    expectAppend(position1, LogEntry.snapshot(snapshot));
    stream.truncateBefore(position1);

    control.replay();
View Full Code Here

    createStreamManager(message.chunkSize).readFromBeginning(reader);
  }

  @Test
  public void testWriteAndReadDeflatedEntry() throws Exception {
    Snapshot snapshot = createSnapshot();
    LogEntry snapshotLogEntry = LogEntry.snapshot(snapshot);
    LogEntry deflatedSnapshotEntry = Entries.deflate(snapshotLogEntry);

    Entry snapshotEntry = createMock(Entry.class);
    expect(stream.append(entryEq(deflatedSnapshotEntry))).andReturn(position1);
View Full Code Here

    streamManager.snapshot(snapshot);
    streamManager.readFromBeginning(reader);
  }

  private Snapshot createSnapshot() {
    return new Snapshot()
        .setTimestamp(1L)
        .setHostAttributes(ImmutableSet.of(new HostAttributes("host",
            ImmutableSet.of(new Attribute("hostname", ImmutableSet.of("abc"))))))
        .setTasks(ImmutableSet.of(
            new ScheduledTask().setStatus(ScheduleStatus.RUNNING)
View Full Code Here

        });

    // We should perform a snapshot when the snapshot thread runs.
    Capture<Runnable> snapshotAction = createCapture();
    schedulingService.doEvery(eq(SNAPSHOT_INTERVAL), capture(snapshotAction));
    Snapshot snapshotContents = new Snapshot()
        .setTimestamp(NOW)
        .setTasks(ImmutableSet.of(
            new ScheduledTask()
                .setStatus(ScheduleStatus.RUNNING)
                .setAssignedTask(new AssignedTask().setTaskId("task_id"))));
View Full Code Here

  }

  @Test
  public void testModifySnapshotBeforeCommit() throws Exception {
    expect(snapshotStore.createSnapshot()).andReturn(SNAPSHOT1);
    Snapshot modified = SNAPSHOT1.deepCopy().setTasks(ImmutableSet.of(TASK1));
    Capture<MutateWork<Object, Exception>> transaction = createCapture();
    expect(primaryStorage.write(capture(transaction))).andReturn(null);
    distributedStore.persist(modified);
    shutDownNow.execute();

    control.replay();

    clock.advance(INTERVAL);
    storageBackup.createSnapshot();
    String backup1 = storageBackup.createBackupName();
    recovery.stage(backup1);
    assertEquals(
        IScheduledTask.setFromBuilders(SNAPSHOT1.getTasks()),
        recovery.query(Query.unscoped()));
    recovery.deleteTasks(Query.taskScoped(Tasks.id(TASK2)));
    assertEquals(
        IScheduledTask.setFromBuilders(modified.getTasks()),
        recovery.query(Query.unscoped()));
    recovery.commit();
    transaction.getValue().apply(storeProvider);
  }
View Full Code Here

    control.replay();
    recovery.commit();
  }

  private static Snapshot makeSnapshot(ScheduledTask... tasks) {
    return new Snapshot()
        .setHostAttributes(ImmutableSet.<HostAttributes>of())
        .setJobs(ImmutableSet.<StoredJob>of())
        .setSchedulerMetadata(new SchedulerMetadata().setVersion(CURRENT_API_VERSION))
        .setQuotaConfigurations(ImmutableSet.<QuotaConfiguration>of())
        .setTasks(ImmutableSet.<ScheduledTask>builder().add(tasks).build())
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

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.