Java Code Examples for org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#createHBaseProtosSnapshotDesc()

The following examples show how to use org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil#createHBaseProtosSnapshotDesc() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestCloneSnapshotProcedure.java    From hbase with Apache License 2.0 6 votes vote down vote up
private SnapshotProtos.SnapshotDescription getSnapshot() throws Exception {
  if (snapshot == null) {
    final TableName snapshotTableName = TableName.valueOf("testCloneSnapshot");
    long tid = System.currentTimeMillis();
    final String snapshotName = "snapshot-" + tid;

    Admin admin = UTIL.getAdmin();
    // create Table
    SnapshotTestingUtils.createTable(UTIL, snapshotTableName, getNumReplicas(), CF);
    // Load data
    SnapshotTestingUtils.loadData(UTIL, snapshotTableName, 500, CF);
    admin.disableTable(snapshotTableName);
    // take a snapshot
    admin.snapshot(snapshotName, snapshotTableName);
    admin.enableTable(snapshotTableName);

    List<SnapshotDescription> snapshotList = admin.listSnapshots();
    snapshot = ProtobufUtil.createHBaseProtosSnapshotDesc(snapshotList.get(0));
  }
  return snapshot;
}
 
Example 2
Source File: SnapshotInfo.java    From hbase with Apache License 2.0 5 votes vote down vote up
SnapshotStats(final Configuration conf, final FileSystem fs,
    final SnapshotDescription snapshot)
{
  this.snapshot = ProtobufUtil.createHBaseProtosSnapshotDesc(snapshot);
  this.snapshotTable = snapshot.getTableName();
  this.conf = conf;
  this.fs = fs;
}
 
Example 3
Source File: SnapshotInfo.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the snapshot stats
 * @param conf the {@link Configuration} to use
 * @param snapshot {@link SnapshotDescription} to get stats from
 * @return the snapshot stats
 */
public static SnapshotStats getSnapshotStats(final Configuration conf,
    final SnapshotDescription snapshot) throws IOException {
  SnapshotProtos.SnapshotDescription snapshotDesc =
    ProtobufUtil.createHBaseProtosSnapshotDesc(snapshot);
  return getSnapshotStats(conf, snapshotDesc, null);
}
 
Example 4
Source File: TestRestoreSnapshotProcedure.java    From hbase with Apache License 2.0 4 votes vote down vote up
private void setupSnapshotAndUpdateTable() throws Exception {
  long tid = System.currentTimeMillis();
  final String snapshotName = "snapshot-" + tid;
  Admin admin = UTIL.getAdmin();
  // create Table
  SnapshotTestingUtils.createTable(UTIL, snapshotTableName, getNumReplicas(), CF1, CF2);
  // Load data
  SnapshotTestingUtils.loadData(UTIL, snapshotTableName, rowCountCF1, CF1);
  SnapshotTestingUtils.loadData(UTIL, snapshotTableName, rowCountCF2, CF2);
  SnapshotTestingUtils.verifyRowCount(UTIL, snapshotTableName, rowCountCF1 + rowCountCF2);

  snapshotHTD = admin.getDescriptor(snapshotTableName);

  admin.disableTable(snapshotTableName);
  // take a snapshot
  admin.snapshot(snapshotName, snapshotTableName);

  List<SnapshotDescription> snapshotList = admin.listSnapshots();
  snapshot = ProtobufUtil.createHBaseProtosSnapshotDesc(snapshotList.get(0));

  // modify the table
  ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor columnFamilyDescriptor3 =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(CF3);
  ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor columnFamilyDescriptor4 =
    new ColumnFamilyDescriptorBuilder.ModifyableColumnFamilyDescriptor(CF4);
  admin.addColumnFamily(snapshotTableName, columnFamilyDescriptor3);
  admin.addColumnFamily(snapshotTableName, columnFamilyDescriptor4);
  admin.deleteColumnFamily(snapshotTableName, CF2);
  // enable table and insert data
  admin.enableTable(snapshotTableName);
  SnapshotTestingUtils.loadData(UTIL, snapshotTableName, rowCountCF3, CF3);
  SnapshotTestingUtils.loadData(UTIL, snapshotTableName, rowCountCF4, CF4);
  SnapshotTestingUtils.loadData(UTIL, snapshotTableName, rowCountCF1addition, CF1);
  HTableDescriptor currentHTD = new HTableDescriptor(admin.getDescriptor(snapshotTableName));
  assertTrue(currentHTD.hasFamily(CF1));
  assertFalse(currentHTD.hasFamily(CF2));
  assertTrue(currentHTD.hasFamily(CF3));
  assertTrue(currentHTD.hasFamily(CF4));
  assertNotEquals(currentHTD.getFamiliesKeys().size(), snapshotHTD.getColumnFamilies().length);
  SnapshotTestingUtils.verifyRowCount(
    UTIL, snapshotTableName, rowCountCF1 + rowCountCF3 + rowCountCF4 + rowCountCF1addition);
  admin.disableTable(snapshotTableName);
}