for (SnapshotDescription snapshotDesc : snapshots) { out.write("\n <tr>\n <td><a href=\"/snapshot.jsp?name="); out.print( snapshotDesc.getName() ); out.write("\">\n "); out.print( snapshotDesc.getName() ); out.write("</a></td>\n "); TableName snapshotTable = TableName.valueOf(snapshotDesc.getTable()); SnapshotInfo.SnapshotStats stats = SnapshotInfo.getSnapshotStats(master.getConfiguration(), snapshotDesc, filesMap); out.print( snapshotTable.getNameAsString() ); out.write("</a></td>\n <td>"); out.print( new Date(snapshotDesc.getCreationTime()) ); out.write("</td>\n <td>"); out.print( StringUtils.humanReadableInt(stats.getSharedStoreFilesSize()) );
SnapshotProtos.SnapshotDescription.newBuilder() .setTable(tableName.getNameAsString()) .setType(SnapshotProtos.SnapshotDescription.Type.FLUSH) .setVersion(SnapshotManifestV2.DESCRIPTOR_VERSION) .build(); ForeignExceptionDispatcher monitor = new ForeignExceptionDispatcher(snapshot.getName());
SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(inputFs, snapshotDir) .toBuilder() .setName(targetName) .build();
SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(inputFs, snapshotDir) .toBuilder() .setName(targetName) .build();
SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(inputFs, snapshotDir) .toBuilder() .setName(targetName) .build();
result = result && (hasName() == other.hasName()); if (hasName()) { result = result && getName() .equals(other.getName()); result = result && (hasTable() == other.hasTable()); if (hasTable()) { result = result && getTable() .equals(other.getTable()); result = result && (hasCreationTime() == other.hasCreationTime()); if (hasCreationTime()) { result = result && (getCreationTime() == other.getCreationTime()); result = result && (hasType() == other.hasType()); if (hasType()) { result = result && type_ == other.type_; result = result && (hasVersion() == other.hasVersion()); if (hasVersion()) { result = result && (getVersion() == other.getVersion()); result = result && (hasOwner() == other.hasOwner()); if (hasOwner()) { result = result && getOwner() .equals(other.getOwner());
hash = (19 * hash) + getDescriptor().hashCode(); if (hasName()) { hash = (37 * hash) + NAME_FIELD_NUMBER; hash = (53 * hash) + getName().hashCode(); if (hasTable()) { hash = (37 * hash) + TABLE_FIELD_NUMBER; hash = (53 * hash) + getTable().hashCode(); if (hasCreationTime()) { hash = (37 * hash) + CREATION_TIME_FIELD_NUMBER; hash = (53 * hash) + org.apache.hbase.thirdparty.com.google.protobuf.Internal.hashLong( getCreationTime()); if (hasType()) { hash = (37 * hash) + TYPE_FIELD_NUMBER; hash = (53 * hash) + type_; if (hasVersion()) { hash = (37 * hash) + VERSION_FIELD_NUMBER; hash = (53 * hash) + getVersion(); if (hasOwner()) { hash = (37 * hash) + OWNER_FIELD_NUMBER; hash = (53 * hash) + getOwner().hashCode(); if (hasUsersAndPermissions()) { hash = (37 * hash) + USERS_AND_PERMISSIONS_FIELD_NUMBER; hash = (53 * hash) + getUsersAndPermissions().hashCode();
public Builder mergeFrom(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription other) { if (other == org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription.getDefaultInstance()) return this; if (other.hasName()) { bitField0_ |= 0x00000001; name_ = other.name_; onChanged(); if (other.hasTable()) { bitField0_ |= 0x00000002; table_ = other.table_; onChanged(); if (other.hasCreationTime()) { setCreationTime(other.getCreationTime()); if (other.hasType()) { setType(other.getType()); if (other.hasVersion()) { setVersion(other.getVersion()); if (other.hasOwner()) { bitField0_ |= 0x00000020; owner_ = other.owner_; onChanged(); if (other.hasUsersAndPermissions()) { mergeUsersAndPermissions(other.getUsersAndPermissions());
@Test public void testDeleteSnapshot() throws Exception { String snapshotName = "completed"; SnapshotDescription snapshot = SnapshotDescription.newBuilder().setName(snapshotName).build(); DeleteSnapshotRequest request = DeleteSnapshotRequest.newBuilder().setSnapshot(snapshot) .build(); try { master.getMasterRpcServices().deleteSnapshot(null, request); fail("Master didn't throw exception when attempting to delete snapshot that doesn't exist"); } catch (org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e) { // Expected } // write one snapshot to the fs createSnapshot(snapshotName); // then delete the existing snapshot,which shouldn't cause an exception to be thrown master.getMasterRpcServices().deleteSnapshot(null, request); }
/** * Check to make sure that the description of the snapshot requested is valid * @param snapshot description of the snapshot * @throws IllegalArgumentException if the name of the snapshot or the name of the table to * snapshot are not valid names. */ public static void assertSnapshotRequestIsValid(SnapshotProtos.SnapshotDescription snapshot) throws IllegalArgumentException { // make sure the snapshot name is valid TableName.isLegalTableQualifierName(Bytes.toBytes(snapshot.getName()), true); if(snapshot.hasTable()) { // make sure the table name is valid, this will implicitly check validity TableName tableName = TableName.valueOf(snapshot.getTable()); if (tableName.isSystemTable()) { throw new IllegalArgumentException("System table snapshots are not allowed"); } } }
/** * Returns a single line (no \n) representation of snapshot metadata. Use this instead of * {@link org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription#toString()}. We don't replace SnapshotDescrpition's toString * because it is auto-generated by protoc. * @param ssd * @return Single line string with a summary of the snapshot parameters */ public static String toString(SnapshotProtos.SnapshotDescription ssd) { if (ssd == null) { return null; } return "{ ss=" + ssd.getName() + " table=" + (ssd.hasTable()?TableName.valueOf(ssd.getTable()):"") + " type=" + ssd.getType() + " }"; } }
private CompletableFuture<Void> internalRestoreSnapshot(String snapshotName, TableName tableName) { SnapshotProtos.SnapshotDescription snapshot = SnapshotProtos.SnapshotDescription.newBuilder() .setName(snapshotName).setTable(tableName.getNameAsString()).build(); try { ClientSnapshotDescriptionUtils.assertSnapshotRequestIsValid(snapshot); } catch (IllegalArgumentException e) { return failedFuture(e); } return waitProcedureResult(this .<Long> newMasterCaller() .action( (controller, stub) -> this.<RestoreSnapshotRequest, RestoreSnapshotResponse, Long> call( controller, stub, RestoreSnapshotRequest.newBuilder().setSnapshot(snapshot) .setNonceGroup(ng.getNonceGroup()).setNonce(ng.newNonce()).build(), (s, c, req, done) -> s.restoreSnapshot(c, req, done), (resp) -> resp.getProcId())).call()); }
@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); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
public static Builder newBuilder(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } public Builder toBuilder() {
public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); } public static Builder newBuilder(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription prototype) {
private SnapshotBuilder createSnapshot(final String snapshotName, final String tableName, final int numRegions, final int version) throws IOException { TableDescriptor htd = createHtd(tableName); RegionData[] regions = createTable(htd, numRegions); SnapshotProtos.SnapshotDescription desc = SnapshotProtos.SnapshotDescription.newBuilder() .setTable(htd.getTableName().getNameAsString()) .setName(snapshotName) .setVersion(version) .build(); Path workingDir = SnapshotDescriptionUtils.getWorkingSnapshotDir(desc, rootDir); SnapshotDescriptionUtils.writeSnapshotInfo(desc, workingDir, fs); return new SnapshotBuilder(conf, fs, rootDir, htd, desc, regions); }
/** * <code>optional string owner = 6;</code> */ public Builder clearOwner() { bitField0_ = (bitField0_ & ~0x00000020); owner_ = getDefaultInstance().getOwner(); onChanged(); return this; } /**
/** * Convert from * {@link org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription} to * {@link SnapshotDescription} * @param snapshotDesc the protobuf SnapshotDescription * @return the POJO SnapshotDescription */ public static SnapshotDescription createSnapshotDesc(SnapshotProtos.SnapshotDescription snapshotDesc) { return new SnapshotDescription(snapshotDesc.getName(), snapshotDesc.hasTable() ? TableName.valueOf(snapshotDesc.getTable()) : null, createSnapshotType(snapshotDesc.getType()), snapshotDesc.getOwner(), snapshotDesc.getCreationTime(), snapshotDesc.getVersion()); }
public Path[] addRegionV2() throws IOException { return addRegion(desc.toBuilder() .setVersion(SnapshotManifestV2.DESCRIPTOR_VERSION) .build()); }