Search in sources :

Example 1 with SnapshotDataManifest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDataManifest in project hbase by apache.

the class TestSnapshotManifest method createDataManifest.

private Path createDataManifest() throws IOException {
    SnapshotDataManifest.Builder dataManifestBuilder = SnapshotDataManifest.newBuilder();
    byte[] startKey = null;
    byte[] stopKey = null;
    for (int i = 1; i <= TEST_NUM_REGIONS; i++) {
        stopKey = Bytes.toBytes(String.format("%016d", i));
        HRegionInfo regionInfo = new HRegionInfo(TABLE_NAME, startKey, stopKey, false);
        SnapshotRegionManifest.Builder dataRegionManifestBuilder = SnapshotRegionManifest.newBuilder();
        for (HColumnDescriptor hcd : builder.getTableDescriptor().getFamilies()) {
            SnapshotRegionManifest.FamilyFiles.Builder family = SnapshotRegionManifest.FamilyFiles.newBuilder();
            family.setFamilyName(UnsafeByteOperations.unsafeWrap(hcd.getName()));
            for (int j = 0; j < 100; ++j) {
                SnapshotRegionManifest.StoreFile.Builder sfManifest = SnapshotRegionManifest.StoreFile.newBuilder();
                sfManifest.setName(String.format("%032d", i));
                sfManifest.setFileSize((1 + i) * (1 + i) * 1024);
                family.addStoreFiles(sfManifest.build());
            }
            dataRegionManifestBuilder.addFamilyFiles(family.build());
        }
        dataRegionManifestBuilder.setRegionInfo(HRegionInfo.convert(regionInfo));
        dataManifestBuilder.addRegionManifests(dataRegionManifestBuilder.build());
        startKey = stopKey;
    }
    dataManifestBuilder.setTableSchema(ProtobufUtil.convertToTableSchema(builder.getTableDescriptor()));
    SnapshotDataManifest dataManifest = dataManifestBuilder.build();
    return writeDataManifest(dataManifest);
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) HColumnDescriptor(org.apache.hadoop.hbase.HColumnDescriptor) SnapshotDataManifest(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDataManifest) SnapshotRegionManifest(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest)

Example 2 with SnapshotDataManifest

use of org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDataManifest in project hbase by apache.

the class SnapshotManifest method convertToV2SingleManifest.

/*
   * In case of rolling-upgrade, we try to read all the formats and build
   * the snapshot with the latest format.
   */
private void convertToV2SingleManifest() throws IOException {
    // Try to load v1 and v2 regions
    List<SnapshotRegionManifest> v1Regions, v2Regions;
    ThreadPoolExecutor tpool = createExecutor("SnapshotManifestLoader");
    try {
        v1Regions = SnapshotManifestV1.loadRegionManifests(conf, tpool, fs, workingDir, desc);
        v2Regions = SnapshotManifestV2.loadRegionManifests(conf, tpool, fs, workingDir, desc, manifestSizeLimit);
    } finally {
        tpool.shutdown();
    }
    SnapshotDataManifest.Builder dataManifestBuilder = SnapshotDataManifest.newBuilder();
    dataManifestBuilder.setTableSchema(ProtobufUtil.convertToTableSchema(htd));
    if (v1Regions != null && v1Regions.size() > 0) {
        dataManifestBuilder.addAllRegionManifests(v1Regions);
    }
    if (v2Regions != null && v2Regions.size() > 0) {
        dataManifestBuilder.addAllRegionManifests(v2Regions);
    }
    // Write the v2 Data Manifest.
    // Once the data-manifest is written, the snapshot can be considered complete.
    // Currently snapshots are written in a "temporary" directory and later
    // moved to the "complated" snapshot directory.
    SnapshotDataManifest dataManifest = dataManifestBuilder.build();
    writeDataManifest(dataManifest);
    this.regionManifests = dataManifest.getRegionManifestsList();
    // them we will get the same information.
    if (v1Regions != null && v1Regions.size() > 0) {
        for (SnapshotRegionManifest regionManifest : v1Regions) {
            SnapshotManifestV1.deleteRegionManifest(fs, workingDir, regionManifest);
        }
    }
    if (v2Regions != null && v2Regions.size() > 0) {
        for (SnapshotRegionManifest regionManifest : v2Regions) {
            SnapshotManifestV2.deleteRegionManifest(fs, workingDir, regionManifest);
        }
    }
}
Also used : SnapshotDataManifest(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDataManifest) SnapshotRegionManifest(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor)

Aggregations

SnapshotDataManifest (org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDataManifest)2 SnapshotRegionManifest (org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1 HColumnDescriptor (org.apache.hadoop.hbase.HColumnDescriptor)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1