Package org.apache.aurora.gen.storage

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


    return ImmutableMap.<LogEntry._Fields, Closure<LogEntry>>builder()
        .put(LogEntry._Fields.SNAPSHOT, new Closure<LogEntry>() {
          @Override
          public void execute(LogEntry logEntry) throws RuntimeException {
            Snapshot snapshot = logEntry.getSnapshot();
            LOG.info("Applying snapshot taken on " + new Date(snapshot.getTimestamp()));
            snapshotStore.applySnapshot(snapshot);
          }
        })
        .put(LogEntry._Fields.TRANSACTION, new Closure<LogEntry>() {
          @Override
View Full Code Here


      @Override
      protected void execute(MutableStoreProvider unused)
          throws CodingException, InvalidPositionException, StreamAccessException {

        LOG.info("Creating snapshot.");
        Snapshot snapshot = snapshotStore.createSnapshot();
        persist(snapshot);
        LOG.info("Snapshot complete."
                 + " host attrs: " + snapshot.getHostAttributesSize()
                 + ", jobs: " + snapshot.getJobsSize()
                 + ", locks: " + snapshot.getLocksSize()
                 + ", quota confs: " + snapshot.getQuotaConfigurationsSize()
                 + ", tasks: " + snapshot.getTasksSize());
      }
    });
  }
View Full Code Here

        .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

    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))
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

    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

    streamManager.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

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.