Package org.apache.hadoop.hbase.protobuf.generated.HBaseProtos

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


  /**
   * Check that the snapshot description written in the filesystem matches the current snapshot
   * @param snapshotDir snapshot directory to check
   */
  private void verifySnapshotDescription(Path snapshotDir) throws CorruptedSnapshotException {
    SnapshotDescription found = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
    if (!this.snapshot.equals(found)) {
      throw new CorruptedSnapshotException("Snapshot read (" + found
          + ") doesn't equal snapshot we ran (" + snapshot + ").", snapshot);
    }
  }
View Full Code Here


    final byte[] tableWithRefsName = Bytes.toBytes("tableWithRefs");
    final String snapshotName = "tableWithRefs";
    final String TEST_FAMILY = Bytes.toString(FAMILY);
    final String TEST_HFILE = "abc";

    final SnapshotDescription sd = SnapshotDescription.newBuilder()
        .setName(snapshotName).setTable(Bytes.toString(tableWithRefsName)).build();

    FileSystem fs = TEST_UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getFileSystem();
    Path rootDir = TEST_UTIL.getHBaseCluster().getMaster().getMasterFileSystem().getRootDir();
    Path archiveDir = new Path(rootDir, HConstants.HFILE_ARCHIVE_DIRECTORY);
View Full Code Here

          assertTrue(path + " should not be empty", fs.getFileStatus(path).getLen() > 0);
        }
    });

    // Verify Snapshot description
    SnapshotDescription desc = SnapshotDescriptionUtils.readSnapshotInfo(fs, exportedSnapshot);
    assertTrue(desc.getName().equals(snapshotName));
    assertTrue(desc.getTable().equals(Bytes.toString(tableName)));
  }
View Full Code Here

    final MasterFileSystem mfs = util.getHBaseCluster().getMaster().getMasterFileSystem();
    final FileSystem fs = mfs.getFileSystem();

    Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName,
                                                                        mfs.getRootDir());
    SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
    final String table = snapshotDesc.getTable();

    final ArrayList corruptedFiles = new ArrayList();
    SnapshotReferenceUtil.visitTableStoreFiles(fs, snapshotDir, new FSVisitor.StoreFileVisitor() {
      public void storeFile (final String region, final String family, final String hfile)
          throws IOException {
View Full Code Here

    // check that we get an exception when looking up snapshot where one hasn't happened
    SnapshotTestingUtils.expectSnapshotDoneException(master, new HSnapshotDescription(),
      UnknownSnapshotException.class);

    // and that we get the same issue, even if we specify a name
    SnapshotDescription desc = SnapshotDescription.newBuilder()
      .setName(snapshotName).setTable(STRING_TABLE_NAME).build();
    SnapshotTestingUtils.expectSnapshotDoneException(master, new HSnapshotDescription(desc),
      UnknownSnapshotException.class);

    // set a mock handler to simulate a snapshot
    DisabledTableSnapshotHandler mockHandler = Mockito.mock(DisabledTableSnapshotHandler.class);
    Mockito.when(mockHandler.getException()).thenReturn(null);
    Mockito.when(mockHandler.getSnapshot()).thenReturn(desc);
    Mockito.when(mockHandler.isFinished()).thenReturn(new Boolean(true));
    Mockito.when(mockHandler.getCompletionTimestamp())
      .thenReturn(EnvironmentEdgeManager.currentTimeMillis());

    master.getSnapshotManagerForTesting()
        .setSnapshotHandlerForTesting(STRING_TABLE_NAME, mockHandler);

    // if we do a lookup without a snapshot name, we should fail - you should always know your name
    SnapshotTestingUtils.expectSnapshotDoneException(master, new HSnapshotDescription(),
      UnknownSnapshotException.class);

    // then do the lookup for the snapshot that it is done
    boolean isDone = master.isSnapshotDone(new HSnapshotDescription(desc));
    assertTrue("Snapshot didn't complete when it should have.", isDone);

    // now try the case where we are looking for a snapshot we didn't take
    desc = SnapshotDescription.newBuilder().setName("Not A Snapshot").build();
    SnapshotTestingUtils.expectSnapshotDoneException(master, new HSnapshotDescription(desc),
      UnknownSnapshotException.class);

    // then create a snapshot to the fs and make sure that we can find it when checking done
    snapshotName = "completed";
    Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
    desc = desc.toBuilder().setName(snapshotName).build();
    SnapshotDescriptionUtils.writeSnapshotInfo(desc, snapshotDir, fs);

    isDone = master.isSnapshotDone(new HSnapshotDescription(desc));
    assertTrue("Completed, on-disk snapshot not found", isDone);
  }
View Full Code Here

    assertEquals("Found unexpected number of snapshots", 0, snapshots.size());

    // write one snapshot to the fs
    String snapshotName = "completed";
    Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir);
    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName(snapshotName).build();
    SnapshotDescriptionUtils.writeSnapshotInfo(snapshot, snapshotDir, fs);

    // check that we get one snapshot
    snapshots = master.getCompletedSnapshots();
    assertEquals("Found unexpected number of snapshots", 1, snapshots.size());
View Full Code Here

  @Test
  public void testDeleteSnapshot() throws Exception {

    String snapshotName = "completed";
    SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName(snapshotName).build();

    try {
      master.deleteSnapshot(new HSnapshotDescription(snapshot));
      fail("Master didn't throw exception when attempting to delete snapshot that doesn't exist");
    } catch (IOException e) {
View Full Code Here

  }

  @Test(timeout = 60000)
  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

    CatalogTracker catalogTracker = Mockito.mock(CatalogTracker.class);
    HTableDescriptor tableDescriptor = Mockito.mock(HTableDescriptor.class);
    ForeignExceptionDispatcher monitor = Mockito.mock(ForeignExceptionDispatcher.class);
    MonitoredTask status = Mockito.mock(MonitoredTask.class);

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

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

    @Override
    public Subprocedure buildSubprocedure(String name, byte[] data) {
      try {
        // unwrap the snapshot information
        SnapshotDescription snapshot = SnapshotDescription.parseFrom(data);
        return RegionServerSnapshotManager.this.buildSubprocedure(snapshot);
      } catch (InvalidProtocolBufferException e) {
        throw new IllegalArgumentException("Could not read snapshot information from request.");
      }
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription

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.