Examples of SnapshotDescription


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

    fs.createNewFile(file1);

    FileStatus[] completedFiles = FSUtils.listStatus(fs, family);

    // create an 'in progress' snapshot
    SnapshotDescription desc = SnapshotDescription.newBuilder().setName("working").build();
    snapshot = SnapshotDescriptionUtils.getWorkingSnapshotDir(desc, rootDir);
    region = new Path(snapshot, "7e91021");
    family = new Path(region, "fam");
    Path file2 = new Path(family, "file2");
    fs.createNewFile(file2);
View Full Code Here

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

    Path family = new Path(region, "fam");
    Path file1 = new Path(family, "file1");
    fs.createNewFile(file1);

    // create an 'in progress' snapshot
    SnapshotDescription desc = SnapshotDescription.newBuilder().setName("working").build();
    snapshot = SnapshotDescriptionUtils.getWorkingSnapshotDir(desc, rootDir);
    region = new Path(snapshot, "7e91021");
    family = new Path(region, "fam");
    Path file2 = new Path(family, "file2");
    fs.createNewFile(file2);
View Full Code Here

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

    } catch (UnsupportedOperationException e) {
      throw new IOException(e);
    }

    // get the snapshot information
    SnapshotDescription snapshot = SnapshotDescriptionUtils.validate(request.getProto(),
      this.conf);

    snapshotManager.takeSnapshot(snapshot);

    // 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 waitTime;
  }
View Full Code Here

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

   */
  public void deleteSnapshot(final byte[] snapshotName) throws IOException {
    // make sure the snapshot is possibly valid
    HTableDescriptor.isLegalTableName(snapshotName, true);
    // do the delete
    SnapshotDescription snapshot = SnapshotDescription.newBuilder()
      .setName(Bytes.toString(snapshotName)).build();
    try {
      getMaster().deleteSnapshot(new HSnapshotDescription(snapshot));
    } catch (RemoteException e) {
      throw RemoteExceptionHandler.decodeRemoteException(e);
View Full Code Here

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

   * Extract the list of files (HFiles/HLogs) to copy using Map-Reduce.
   * @return list of files referenced by the snapshot (pair of path and size)
   */
  private List<Pair<Path, Long>> getSnapshotFiles(final FileSystem fs, final Path snapshotDir)
      throws IOException {
    SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);

    final List<Pair<Path, Long>> files = new ArrayList<Pair<Path, Long>>();
    final TableName table =
        TableName.valueOf(snapshotDesc.getTable());
    final Configuration conf = getConf();

    // Get snapshot files
    SnapshotReferenceUtil.visitReferencedFiles(fs, snapshotDir,
      new SnapshotReferenceUtil.FileVisitor() {
View Full Code Here

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

   * @throws IllegalArgumentException if the restore request is formatted incorrectly
   */
  private void internalRestoreSnapshot(final String snapshotName, final TableName
      tableName)
      throws IOException, RestoreSnapshotException {
    SnapshotDescription snapshot = SnapshotDescription.newBuilder()
        .setName(snapshotName).setTable(tableName.getNameAsString()).build();

    // actually restore the snapshot
    internalRestoreSnapshotAsync(snapshot);

    final IsRestoreSnapshotDoneRequest request = IsRestoreSnapshotDoneRequest.newBuilder()
        .setSnapshot(snapshot).build();
    IsRestoreSnapshotDoneResponse done = IsRestoreSnapshotDoneResponse.newBuilder()
        .setDone(false).buildPartial();
    final long maxPauseTime = 5000;
    int tries = 0;
    while (!done.getDone()) {
      try {
        // sleep a backoff <= pauseTime amount
        long sleep = getPauseTime(tries++);
        sleep = sleep > maxPauseTime ? maxPauseTime : sleep;
        LOG.debug(tries + ") Sleeping: " + sleep + " ms while we wait for snapshot restore to complete.");
        Thread.sleep(sleep);
      } catch (InterruptedException e) {
        LOG.debug("Interrupted while waiting for snapshot " + snapshot + " restore to complete");
        Thread.currentThread().interrupt();
      }
      LOG.debug("Getting current status of snapshot restore from master...");
      done = executeCallable(new MasterCallable<IsRestoreSnapshotDoneResponse>(
          getConnection()) {
        @Override
        public IsRestoreSnapshotDoneResponse call() throws ServiceException {
          return master.isRestoreSnapshotDone(null, request);
        }
      });
    }
    if (!done.getDone()) {
      throw new RestoreSnapshotException("Snapshot '" + snapshot.getName() + "' wasn't restored.");
    }
  }
View Full Code Here

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

    // 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).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));

    master.getSnapshotManagerForTesting().setSnapshotHandlerForTesting(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

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

    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

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

  @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

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

    fs.createNewFile(log2_1);
    fs.createNewFile(log2_2);

    FSUtils.logFileSystemState(fs, testDir, LOG);
    FSUtils.setRootDir(conf, testDir);
    SnapshotDescription snapshot = SnapshotDescription.newBuilder()
        .setName("testWALReferenceSnapshot").build();
    ForeignExceptionDispatcher listener = Mockito.mock(ForeignExceptionDispatcher.class);

    // reference all the files in the first server directory
    ReferenceServerWALsTask task = new ReferenceServerWALsTask(snapshot, listener, server1Dir,
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.