當前位置: 首頁>>代碼示例>>Java>>正文


Java HConstants.SNAPSHOT_DIR_NAME屬性代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.HConstants.SNAPSHOT_DIR_NAME屬性的典型用法代碼示例。如果您正苦於以下問題:Java HConstants.SNAPSHOT_DIR_NAME屬性的具體用法?Java HConstants.SNAPSHOT_DIR_NAME怎麽用?Java HConstants.SNAPSHOT_DIR_NAME使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在org.apache.hadoop.hbase.HConstants的用法示例。


在下文中一共展示了HConstants.SNAPSHOT_DIR_NAME屬性的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testCompleteSnapshotWithNoSnapshotDirectoryFailure

/**
 * Test that we throw an exception if there is no working snapshot directory when we attempt to
 * 'complete' the snapshot
 * @throws Exception on failure
 */
@Test
public void testCompleteSnapshotWithNoSnapshotDirectoryFailure() throws Exception {
  Path snapshotDir = new Path(root, HConstants.SNAPSHOT_DIR_NAME);
  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());
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:20,代碼來源:TestSnapshotDescriptionUtils.java

示例2: migrateSnapshots

public void migrateSnapshots() throws IOException {
  //migrate snapshot dir
  Path oldSnapshotDir = new Path(rootDir, HConstants.OLD_SNAPSHOT_DIR_NAME);
  Path newSnapshotDir = new Path(rootDir, HConstants.SNAPSHOT_DIR_NAME);
  if (fs.exists(oldSnapshotDir)) {
    boolean foundOldSnapshotDir = false;
    // Logic to verify old snapshot dir culled from SnapshotManager
    // ignore all the snapshots in progress
    FileStatus[] snapshots = fs.listStatus(oldSnapshotDir,
      new SnapshotDescriptionUtils.CompletedSnaphotDirectoriesFilter(fs));
    // loop through all the completed snapshots
    for (FileStatus snapshot : snapshots) {
      Path info = new Path(snapshot.getPath(), SnapshotDescriptionUtils.SNAPSHOTINFO_FILE);
      // if the snapshot is bad
      if (fs.exists(info)) {
        foundOldSnapshotDir = true;
        break;
      }
    }
    if(foundOldSnapshotDir) {
      LOG.info("Migrating snapshot dir");
      if (!fs.rename(oldSnapshotDir, newSnapshotDir)) {
        throw new IOException("Failed to move old snapshot dir "+
            oldSnapshotDir+" to new "+newSnapshotDir);
      }
    }
  }
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:28,代碼來源:NamespaceUpgrade.java

示例3: testExportFileSystemState

/**
 * Test ExportSnapshot
 */
private void testExportFileSystemState(final TableName tableName, final byte[] snapshotName,
    final byte[] targetName, int filesExpected, Path copyDir, boolean overwrite)
    throws Exception {
  URI hdfsUri = FileSystem.get(TEST_UTIL.getConfiguration()).getUri();
  FileSystem fs = FileSystem.get(copyDir.toUri(), new Configuration());
  copyDir = copyDir.makeQualified(fs);

  List<String> opts = new ArrayList<String>();
  opts.add("-snapshot");
  opts.add(Bytes.toString(snapshotName));
  opts.add("-copy-to");
  opts.add(copyDir.toString());
  if (targetName != snapshotName) {
    opts.add("-target");
    opts.add(Bytes.toString(targetName));
  }
  if (overwrite) opts.add("-overwrite");

  // Export Snapshot
  int res = ExportSnapshot.innerMain(TEST_UTIL.getConfiguration(),
      opts.toArray(new String[opts.size()]));
  assertEquals(0, res);

  // Verify File-System state
  FileStatus[] rootFiles = fs.listStatus(copyDir);
  assertEquals(filesExpected > 0 ? 2 : 1, rootFiles.length);
  for (FileStatus fileStatus: rootFiles) {
    String name = fileStatus.getPath().getName();
    assertTrue(fileStatus.isDirectory());
    assertTrue(name.equals(HConstants.SNAPSHOT_DIR_NAME) ||
               name.equals(HConstants.HFILE_ARCHIVE_DIRECTORY));
  }

  // compare the snapshot metadata and verify the hfiles
  final FileSystem hdfs = FileSystem.get(hdfsUri, TEST_UTIL.getConfiguration());
  final Path snapshotDir = new Path(HConstants.SNAPSHOT_DIR_NAME, Bytes.toString(snapshotName));
  final Path targetDir = new Path(HConstants.SNAPSHOT_DIR_NAME, Bytes.toString(targetName));
  verifySnapshotDir(hdfs, new Path(TEST_UTIL.getDefaultRootDirPath(), snapshotDir),
      fs, new Path(copyDir, targetDir));
  Set<String> snapshotFiles = verifySnapshot(fs, copyDir, tableName, Bytes.toString(targetName));
  assertEquals(filesExpected, snapshotFiles.size());
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:45,代碼來源:TestExportSnapshot.java

示例4: getSnapshotRootDir

/**
 * Get the snapshot root directory. All the snapshots are kept under this directory, i.e.
 * ${hbase.rootdir}/.snapshot
 * @param rootDir hbase root directory
 * @return the base directory in which all snapshots are kept
 */
public static Path getSnapshotRootDir(final Path rootDir) {
  return new Path(rootDir, HConstants.SNAPSHOT_DIR_NAME);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:9,代碼來源:SnapshotDescriptionUtils.java

示例5: getSnapshotsDir

/**
 * @param rootDir hbase root directory
 * @return the directory for all completed snapshots;
 */
public static final Path getSnapshotsDir(Path rootDir) {
  return new Path(rootDir, HConstants.SNAPSHOT_DIR_NAME);
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:7,代碼來源:SnapshotDescriptionUtils.java


注:本文中的org.apache.hadoop.hbase.HConstants.SNAPSHOT_DIR_NAME屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。