Package org.apache.aurora.gen.storage

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


  }

  @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

    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))
View Full Code Here

      File backupFile = new File(backupDir, backupName);
      if (!backupFile.exists()) {
        throw new RecoveryException("Backup " + backupName + " does not exist.");
      }

      Snapshot snapshot;
      try {
        snapshot = ThriftBinaryCodec.decode(Snapshot.class, Files.toByteArray(backupFile));
      } catch (CodingException e) {
        throw new RecoveryException("Failed to decode backup " + e, e);
      } catch (IOException e) {
View Full Code Here

  @Override
  public Snapshot createSnapshot() {
    return storage.consistentRead(new Work.Quiet<Snapshot>() {
      @Override
      public Snapshot apply(StoreProvider storeProvider) {
        Snapshot snapshot = new Snapshot();

        // Capture timestamp to signify the beginning of a snapshot operation, apply after in case
        // one of the field closures is mean and tries to apply a timestamp.
        long timestamp = clock.nowMillis();
        for (SnapshotField field : SNAPSHOT_FIELDS) {
          field.saveToSnapshot(storeProvider, snapshot);
        }
        snapshot.setTimestamp(timestamp);
        return snapshot;
      }
    });
  }
View Full Code Here

      lastBackupMs = clock.nowMillis();
    }

    @Override
    public Snapshot createSnapshot() {
      Snapshot snapshot = delegate.createSnapshot();
      if (clock.nowMillis() >= (lastBackupMs + backupIntervalMs)) {
        save(snapshot);
      }
      return snapshot;
    }
View Full Code Here

  }

  void replay(final LogEntry logEntry) {
    switch (logEntry.getSetField()) {
      case SNAPSHOT:
        Snapshot snapshot = logEntry.getSnapshot();
        LOG.info("Applying snapshot taken on " + new Date(snapshot.getTimestamp()));
        snapshotStore.applySnapshot(snapshot);
        break;

      case TRANSACTION:
        write(new MutateWork.NoResult.Quiet() {
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

      lastBackupMs = clock.nowMillis();
    }

    @Override
    public Snapshot createSnapshot() {
      Snapshot snapshot = delegate.createSnapshot();
      if (clock.nowMillis() >= (lastBackupMs + backupIntervalMs)) {
        save(snapshot);
      }
      return snapshot;
    }
View Full Code Here

  @Override
  public Snapshot createSnapshot() {
    return storage.consistentRead(new Work.Quiet<Snapshot>() {
      @Override
      public Snapshot apply(StoreProvider storeProvider) {
        Snapshot snapshot = new Snapshot();

        // Capture timestamp to signify the beginning of a snapshot operation, apply after in case
        // one of the field closures is mean and tries to apply a timestamp.
        long timestamp = clock.nowMillis();
        for (SnapshotField field : SNAPSHOT_FIELDS) {
          field.saveToSnapshot(storeProvider, snapshot);
        }
        snapshot.setTimestamp(timestamp);
        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.