private SnapshotDescription toSnapshotDescription(ProcedureDescription desc) throws IOException { SnapshotDescription.Builder builder = SnapshotDescription.newBuilder(); if (!desc.hasInstance()) { throw new IOException("Snapshot name is not defined: " + desc.toString()); } String snapshotName = desc.getInstance(); List<NameStringPair> props = desc.getConfigurationList(); String table = null; for (NameStringPair prop : props) { if ("table".equalsIgnoreCase(prop.getName())) { table = prop.getValue(); } } if (table == null) { throw new IOException("Snapshot table is not defined: " + desc.toString()); } TableName tableName = TableName.valueOf(table); builder.setTable(tableName.getNameAsString()); builder.setName(snapshotName); builder.setType(SnapshotDescription.Type.FLUSH); return builder.build(); } }
SnapshotProtos.SnapshotDescription.newBuilder() .setTable(tableName.getNameAsString()) .setType(SnapshotProtos.SnapshotDescription.Type.FLUSH) .setName("test_table_snapshot") .setVersion(SnapshotManifestV2.DESCRIPTOR_VERSION)
@Test public void testAsyncFlushSnapshot() throws Exception { SnapshotProtos.SnapshotDescription snapshot = SnapshotProtos.SnapshotDescription.newBuilder() .setName("asyncSnapshot").setTable(TABLE_NAME.getNameAsString()) .setType(SnapshotProtos.SnapshotDescription.Type.FLUSH).build(); // take the snapshot async admin.takeSnapshotAsync( new SnapshotDescription("asyncSnapshot", TABLE_NAME, SnapshotType.FLUSH)); // constantly loop, looking for the snapshot to complete HMaster master = UTIL.getMiniHBaseCluster().getMaster(); SnapshotTestingUtils.waitForSnapshotToComplete(master, snapshot, 200); LOG.info(" === Async Snapshot Completed ==="); UTIL.getHBaseCluster().getMaster().getMasterFileSystem().logFileSystemState(LOG); // make sure we get the snapshot SnapshotTestingUtils.assertOneSnapshotThatMatches(admin, snapshot); }
SnapshotProtos.SnapshotDescription.newBuilder() .setTable(tableName.getNameAsString()) .setType(SnapshotProtos.SnapshotDescription.Type.FLUSH) .setName("test_table_snapshot") .setVersion(SnapshotManifestV2.DESCRIPTOR_VERSION)
setType(other.getType());
/** * Convert from {@link SnapshotDescription} to * {@link org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription} * @param snapshotDesc the POJO SnapshotDescription * @return the protobuf SnapshotDescription */ public static SnapshotProtos.SnapshotDescription createHBaseProtosSnapshotDesc(SnapshotDescription snapshotDesc) { SnapshotProtos.SnapshotDescription.Builder builder = SnapshotProtos.SnapshotDescription.newBuilder(); if (snapshotDesc.getTableName() != null) { builder.setTable(snapshotDesc.getTableNameAsString()); } if (snapshotDesc.getName() != null) { builder.setName(snapshotDesc.getName()); } if (snapshotDesc.getOwner() != null) { builder.setOwner(snapshotDesc.getOwner()); } if (snapshotDesc.getCreationTime() != -1L) { builder.setCreationTime(snapshotDesc.getCreationTime()); } if (snapshotDesc.getVersion() != -1) { builder.setVersion(snapshotDesc.getVersion()); } builder.setType(ProtobufUtil.createProtosSnapShotDescType(snapshotDesc.getType())); SnapshotProtos.SnapshotDescription snapshot = builder.build(); return snapshot; }
@Test public void testAsyncFlushSnapshot() throws Exception { SnapshotProtos.SnapshotDescription snapshot = SnapshotProtos.SnapshotDescription.newBuilder() .setName("asyncSnapshot").setTable(TABLE_NAME.getNameAsString()) .setType(SnapshotProtos.SnapshotDescription.Type.FLUSH).build(); // take the snapshot async admin.takeSnapshotAsync( new SnapshotDescription("asyncSnapshot", TABLE_NAME, SnapshotType.FLUSH)); // constantly loop, looking for the snapshot to complete HMaster master = UTIL.getMiniHBaseCluster().getMaster(); SnapshotTestingUtils.waitForSnapshotToComplete(master, snapshot, 200); LOG.info(" === Async Snapshot Completed ==="); UTIL.getHBaseCluster().getMaster().getMasterFileSystem().logFileSystemState(LOG); // make sure we get the snapshot SnapshotTestingUtils.assertOneSnapshotThatMatches(admin, snapshot); }
/** * Convert from {@link SnapshotDescription} to * {@link org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription} * @param snapshotDesc the POJO SnapshotDescription * @return the protobuf SnapshotDescription */ public static SnapshotProtos.SnapshotDescription createHBaseProtosSnapshotDesc(SnapshotDescription snapshotDesc) { SnapshotProtos.SnapshotDescription.Builder builder = SnapshotProtos.SnapshotDescription.newBuilder(); if (snapshotDesc.getTableName() != null) { builder.setTable(snapshotDesc.getTableNameAsString()); } if (snapshotDesc.getName() != null) { builder.setName(snapshotDesc.getName()); } if (snapshotDesc.getOwner() != null) { builder.setOwner(snapshotDesc.getOwner()); } if (snapshotDesc.getCreationTime() != -1L) { builder.setCreationTime(snapshotDesc.getCreationTime()); } if (snapshotDesc.getVersion() != -1) { builder.setVersion(snapshotDesc.getVersion()); } builder.setType(ProtobufUtil.createProtosSnapShotDescType(snapshotDesc.getType())); SnapshotProtos.SnapshotDescription snapshot = builder.build(); return snapshot; }
/** * Convert from {@link SnapshotDescription} to * {@link org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription} * @param snapshotDesc the POJO SnapshotDescription * @return the protobuf SnapshotDescription */ public static SnapshotProtos.SnapshotDescription createHBaseProtosSnapshotDesc(SnapshotDescription snapshotDesc) { SnapshotProtos.SnapshotDescription.Builder builder = SnapshotProtos.SnapshotDescription.newBuilder(); if (snapshotDesc.getTableName() != null) { builder.setTable(snapshotDesc.getTableNameAsString()); } if (snapshotDesc.getName() != null) { builder.setName(snapshotDesc.getName()); } if (snapshotDesc.getOwner() != null) { builder.setOwner(snapshotDesc.getOwner()); } if (snapshotDesc.getCreationTime() != -1L) { builder.setCreationTime(snapshotDesc.getCreationTime()); } if (snapshotDesc.getVersion() != -1) { builder.setVersion(snapshotDesc.getVersion()); } builder.setType(ProtobufUtil.createProtosSnapShotDescType(snapshotDesc.getType())); SnapshotProtos.SnapshotDescription snapshot = builder.build(); return snapshot; }
setType(other.getType());
/** * Take a snapshot of a disabled table. * @param snapshot description of the snapshot to take. Modified to be {@link Type#DISABLED}. * @throws IOException if the snapshot could not be started or filesystem for snapshot * temporary directory could not be determined */ private synchronized void snapshotDisabledTable(SnapshotDescription snapshot) throws IOException { // setup the snapshot prepareToTakeSnapshot(snapshot); // set the snapshot to be a disabled snapshot, since the client doesn't know about that snapshot = snapshot.toBuilder().setType(Type.DISABLED).build(); // Take the snapshot of the disabled table DisabledTableSnapshotHandler handler = new DisabledTableSnapshotHandler(snapshot, master, this); snapshotTable(snapshot, handler); }