@Override public void regionClose(final SnapshotRegionManifest.Builder region) throws IOException { // we should ensure the snapshot dir exist, maybe it has been deleted by master // see HBASE-16464 FileSystem workingDirFs = snapshotDir.getFileSystem(this.conf); if (workingDirFs.exists(snapshotDir)) { SnapshotRegionManifest manifest = region.build(); FSDataOutputStream stream = workingDirFs.create( getRegionManifestPath(snapshotDir, manifest)); try { manifest.writeTo(stream); } finally { stream.close(); } } else { LOG.warn("can't write manifest without parent dir, maybe it has been deleted by master?"); } }
private Path createRegionManifest() throws IOException { byte[] startKey = Bytes.toBytes("AAAAAA"); byte[] stopKey = Bytes.toBytes("BBBBBB"); HRegionInfo regionInfo = new HRegionInfo(TABLE_NAME, startKey, stopKey, false); SnapshotRegionManifest.Builder dataRegionManifestBuilder = SnapshotRegionManifest.newBuilder(); dataRegionManifestBuilder.setRegionInfo(HRegionInfo.convert(regionInfo)); for (ColumnFamilyDescriptor hcd: builder.getTableDescriptor().getColumnFamilies()) { SnapshotRegionManifest.FamilyFiles.Builder family = SnapshotRegionManifest.FamilyFiles.newBuilder(); family.setFamilyName(UnsafeByteOperations.unsafeWrap(hcd.getName())); for (int j = 0; j < TEST_NUM_REGIONFILES; ++j) { SnapshotRegionManifest.StoreFile.Builder sfManifest = SnapshotRegionManifest.StoreFile.newBuilder(); sfManifest.setName(String.format("%064d", j)); sfManifest.setFileSize(j * 1024); family.addStoreFiles(sfManifest.build()); } dataRegionManifestBuilder.addFamilyFiles(family.build()); } SnapshotRegionManifest manifest = dataRegionManifestBuilder.build(); Path regionPath = new Path(snapshotDir, SnapshotManifestV2.SNAPSHOT_MANIFEST_PREFIX + regionInfo.getEncodedName()); FSDataOutputStream stream = fs.create(regionPath); try { manifest.writeTo(stream); } finally { stream.close(); } return regionPath; }
private Path createRegionManifest() throws IOException { byte[] startKey = Bytes.toBytes("AAAAAA"); byte[] stopKey = Bytes.toBytes("BBBBBB"); HRegionInfo regionInfo = new HRegionInfo(TABLE_NAME, startKey, stopKey, false); SnapshotRegionManifest.Builder dataRegionManifestBuilder = SnapshotRegionManifest.newBuilder(); dataRegionManifestBuilder.setRegionInfo(HRegionInfo.convert(regionInfo)); for (ColumnFamilyDescriptor hcd: builder.getTableDescriptor().getColumnFamilies()) { SnapshotRegionManifest.FamilyFiles.Builder family = SnapshotRegionManifest.FamilyFiles.newBuilder(); family.setFamilyName(UnsafeByteOperations.unsafeWrap(hcd.getName())); for (int j = 0; j < TEST_NUM_REGIONFILES; ++j) { SnapshotRegionManifest.StoreFile.Builder sfManifest = SnapshotRegionManifest.StoreFile.newBuilder(); sfManifest.setName(String.format("%064d", j)); sfManifest.setFileSize(j * 1024); family.addStoreFiles(sfManifest.build()); } dataRegionManifestBuilder.addFamilyFiles(family.build()); } SnapshotRegionManifest manifest = dataRegionManifestBuilder.build(); Path regionPath = new Path(snapshotDir, SnapshotManifestV2.SNAPSHOT_MANIFEST_PREFIX + regionInfo.getEncodedName()); FSDataOutputStream stream = fs.create(regionPath); try { manifest.writeTo(stream); } finally { stream.close(); } return regionPath; }