Examples of SnapshotDescription


Examples of org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription

      final String sourceTableName, final HTableDescriptor htdClone) throws IOException {
    CatalogTracker catalogTracker = Mockito.mock(CatalogTracker.class);
    HTableDescriptor tableDescriptor = Mockito.mock(HTableDescriptor.class);
    ForeignExceptionDispatcher monitor = Mockito.mock(ForeignExceptionDispatcher.class);

    SnapshotDescription sd = SnapshotDescription.newBuilder()
      .setName("snapshot").setTable(sourceTableName).build();

    return new RestoreSnapshotHelper(conf, fs, sd, snapshotDir,
      htdClone, HTableDescriptor.getTableDir(rootDir, htdClone.getName()), monitor);
  }
View Full Code Here

Examples of org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription

  }

  @Test(timeout = 15000)
  public void testAsyncFlushSnapshot() throws Exception {
    HBaseAdmin admin = UTIL.getHBaseAdmin();
    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("asyncSnapshot")
        .setTable(STRING_TABLE_NAME).setType(SnapshotDescription.Type.FLUSH).build();

    // take the snapshot async
    admin.takeSnapshotAsync(snapshot);

    // constantly loop, looking for the snapshot to complete
    HMaster master = UTIL.getMiniHBaseCluster().getMaster();
    SnapshotTestingUtils.waitForSnapshotToComplete(master, new HSnapshotDescription(snapshot), 200);
    LOG.info(" === Async Snapshot Completed ===");
    FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);
    // make sure we get the snapshot
    SnapshotTestingUtils.assertOneSnapshotThatMatches(admin, snapshot);

    // test that we can delete the snapshot
    admin.deleteSnapshot(snapshot.getName());
    LOG.info(" === Async Snapshot Deleted ===");
    FSUtils.logFileSystemState(UTIL.getTestFileSystem(),
      FSUtils.getRootDir(UTIL.getConfiguration()), LOG);
    // make sure we don't have any snapshots
    SnapshotTestingUtils.assertNoSnapshots(admin);
View Full Code Here

Examples of org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription

  private static final HBaseTestingUtility UTIL = new HBaseTestingUtility();

  @Test
  public void testCopyFiles() throws Exception {

    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("snapshot").build();
    ForeignExceptionDispatcher monitor = Mockito.mock(ForeignExceptionDispatcher.class);
    FileSystem fs = UTIL.getTestFileSystem();
    Path root = UTIL.getDataTestDir();
    String regionName = "regionA";
    Path regionDir = new Path(root, regionName);
View Full Code Here

Examples of org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription

   * Check that we don't get an exception if there is no recovered edits directory to copy
   * @throws Exception on failure
   */
  @Test
  public void testNoEditsDir() throws Exception {
    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("snapshot").build();
    ForeignExceptionDispatcher monitor = Mockito.mock(ForeignExceptionDispatcher.class);
    FileSystem fs = UTIL.getTestFileSystem();
    Path root = UTIL.getDataTestDir();
    String regionName = "regionA";
    Path regionDir = new Path(root, regionName);
View Full Code Here

Examples of org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription

    // create the snapshot directory
    Path snapshotRegionDir = new Path(testdir, HConstants.SNAPSHOT_DIR_NAME);
    fs.mkdirs(snapshotRegionDir);

    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("name")
        .setTable("table").build();
    ForeignExceptionDispatcher monitor = Mockito.mock(ForeignExceptionDispatcher.class);
    ReferenceRegionHFilesTask task = new ReferenceRegionHFilesTask(snapshot, monitor, regionDir,
        fs, snapshotRegionDir);
    ReferenceRegionHFilesTask taskSpy = Mockito.spy(task);
View Full Code Here

Examples of org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription

   * Check that errors from running the task get propagated back to the error listener.
   */
  @Test
  public void testErrorPropagation() throws Exception {
    ForeignExceptionDispatcher error = mock(ForeignExceptionDispatcher.class);
    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("snapshot")
        .setTable("table").build();
    final Exception thrown = new Exception("Failed!");
    SnapshotTask fail = new SnapshotTask(snapshot, error) {
      @Override
      public Void call() {
View Full Code Here

Examples of org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription

    Path snapshotDir = new Path(root, ".snapshot");
    Path tmpDir = new Path(snapshotDir, ".tmp");
    Path workingDir = new Path(tmpDir, "not_a_snapshot");
    assertFalse("Already have working snapshot dir: " + workingDir
        + " but shouldn't. Test file leak?", fs.exists(workingDir));
    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName("snapshot").build();
    try {
      SnapshotDescriptionUtils.completeSnapshot(snapshot, root, workingDir, fs);
      fail("Shouldn't successfully complete move of a non-existent directory.");
    } catch (IOException e) {
      LOG.info("Correctly failed to move non-existant directory: " + e.getMessage());
View Full Code Here

Examples of org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription

        continue;
      }
      FSDataInputStream in = null;
      try {
        in = fs.open(info);
        SnapshotDescription desc = SnapshotDescription.parseFrom(in);
        snapshotDescs.add(desc);
      } catch (IOException e) {
        LOG.warn("Found a corrupted snapshot " + snapshot.getPath(), e);
      } finally {
        if (in != null) {
View Full Code Here

Examples of org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription

      LOG.error("A Snapshot named '" + reqSnapshot.getName() + "' does not exist.");
      throw new SnapshotDoesNotExistException(reqSnapshot);
    }

    // read snapshot information
    SnapshotDescription fsSnapshot = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
    HTableDescriptor snapshotTableDesc =
        FSTableDescriptors.getTableDescriptorFromFs(fs, snapshotDir);
    TableName tableName = TableName.valueOf(reqSnapshot.getTable());

    // stop tracking "abandoned" handlers
    cleanupSentinels();

    // Verify snapshot validity
    SnapshotReferenceUtil.verifySnapshot(master.getConfiguration(), fs, snapshotDir, fsSnapshot);

    // Execute the restore/clone operation
    if (MetaReader.tableExists(master.getCatalogTracker(), tableName)) {
      if (master.getAssignmentManager().getZKTable().isEnabledTable(
          TableName.valueOf(fsSnapshot.getTable()))) {
        throw new UnsupportedOperationException("Table '" +
            TableName.valueOf(fsSnapshot.getTable()) + "' must be disabled in order to " +
            "perform a restore operation" +
            ".");
      }

      // call coproc pre hook
      if (cpHost != null) {
        cpHost.preRestoreSnapshot(reqSnapshot, snapshotTableDesc);
      }
      restoreSnapshot(fsSnapshot, snapshotTableDesc);
      LOG.info("Restore snapshot=" + fsSnapshot.getName() + " as table=" + tableName);

      if (cpHost != null) {
        cpHost.postRestoreSnapshot(reqSnapshot, snapshotTableDesc);
      }
    } else {
      HTableDescriptor htd = RestoreSnapshotHelper.cloneTableSchema(snapshotTableDesc, tableName);
      if (cpHost != null) {
        cpHost.preCloneSnapshot(reqSnapshot, htd);
      }
      cloneSnapshot(fsSnapshot, htd);
      LOG.info("Clone snapshot=" + fsSnapshot.getName() + " as table=" + tableName);

      if (cpHost != null) {
        cpHost.postCloneSnapshot(reqSnapshot, htd);
      }
    }
View Full Code Here

Examples of org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription

    }

    LOG.info(getClientIdAuditPrefix() + " snapshot request for:" +
        ClientSnapshotDescriptionUtils.toString(request.getSnapshot()));
    // get the snapshot information
    SnapshotDescription snapshot = SnapshotDescriptionUtils.validate(request.getSnapshot(),
      this.conf);
    try {
      snapshotManager.takeSnapshot(snapshot);
    } catch (IOException e) {
      throw new ServiceException(e);
    }

    // send back the max amount of time the client should wait for the snapshot to complete
    long waitTime = SnapshotDescriptionUtils.getMaxMasterTimeout(conf, snapshot.getType(),
      SnapshotDescriptionUtils.DEFAULT_MAX_WAIT_TIME);
    return SnapshotResponse.newBuilder().setExpectedTimeout(waitTime).build();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.