private void openWithoutRestoringSnapshot() throws IOException { Path snapshotDir = SnapshotDescriptionUtils.getCompletedSnapshotDir(snapshotName, rootDir); SnapshotProtos.SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir); SnapshotManifest manifest = SnapshotManifest.open(conf, fs, snapshotDir, snapshotDesc); List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests(); if (regionManifests == null) { throw new IllegalArgumentException("Snapshot seems empty, snapshotName: " + snapshotName); } regions = new ArrayList<>(regionManifests.size()); regionManifests.stream().map(r -> HRegionInfo.convert(r.getRegionInfo())) .filter(this::isValidRegion).sorted().forEach(r -> regions.add(r)); htd = manifest.getTableDescriptor(); }
public void writeTo(org.apache.hbase.thirdparty.com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeInt32(1, version_); } if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeMessage(2, getRegionInfo()); } for (int i = 0; i < familyFiles_.size(); i++) { output.writeMessage(3, familyFiles_.get(i)); } unknownFields.writeTo(output); }
public static List<HRegionInfo> getRegionInfosFromManifest(SnapshotManifest manifest) { List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests(); if (regionManifests == null) { throw new IllegalArgumentException("Snapshot seems empty"); } List<HRegionInfo> regionInfos = Lists.newArrayListWithCapacity(regionManifests.size()); for (SnapshotRegionManifest regionManifest : regionManifests) { HRegionInfo hri = HRegionInfo.convert(regionManifest.getRegionInfo()); if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) { continue; } regionInfos.add(hri); } return regionInfos; }
/** * Get list of region locations from SnapshotManifest * BaseResultIterators assume that regions are sorted using RegionInfo.COMPARATOR */ private List<HRegionLocation> getRegionLocationsFromManifest(SnapshotManifest manifest) { List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests(); Preconditions.checkNotNull(regionManifests); List<RegionInfo> regionInfos = Lists.newArrayListWithCapacity(regionManifests.size()); List<HRegionLocation> hRegionLocations = Lists.newArrayListWithCapacity(regionManifests.size()); for (SnapshotRegionManifest regionManifest : regionManifests) { RegionInfo regionInfo = ProtobufUtil.toRegionInfo(regionManifest.getRegionInfo()); if (isValidRegion(regionInfo)) { regionInfos.add(regionInfo); } } regionInfos.sort(RegionInfo.COMPARATOR); for (RegionInfo regionInfo : regionInfos) { hRegionLocations.add(new HRegionLocation(regionInfo, null)); } return hRegionLocations; }
public static List<HRegionInfo> getRegionInfosFromManifest(SnapshotManifest manifest) { List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests(); if (regionManifests == null) { throw new IllegalArgumentException("Snapshot seems empty"); } List<HRegionInfo> regionInfos = Lists.newArrayListWithCapacity(regionManifests.size()); for (SnapshotRegionManifest regionManifest : regionManifests) { HRegionInfo hri = HRegionInfo.convert(regionManifest.getRegionInfo()); if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) { continue; } regionInfos.add(hri); } return regionInfos; }
public static List<HRegionInfo> getRegionInfosFromManifest(SnapshotManifest manifest) { List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests(); if (regionManifests == null) { throw new IllegalArgumentException("Snapshot seems empty"); } List<HRegionInfo> regionInfos = Lists.newArrayListWithCapacity(regionManifests.size()); for (SnapshotRegionManifest regionManifest : regionManifests) { HRegionInfo hri = HRegionInfo.convert(regionManifest.getRegionInfo()); if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) { continue; } regionInfos.add(hri); } return regionInfos; }
public void writeTo(org.apache.hbase.thirdparty.com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeInt32(1, version_); } if (((bitField0_ & 0x00000002) == 0x00000002)) { output.writeMessage(2, getRegionInfo()); } for (int i = 0; i < familyFiles_.size(); i++) { output.writeMessage(3, familyFiles_.get(i)); } unknownFields.writeTo(output); }
private List<HRegionLocation> getRegionLocationsFromManifest(SnapshotManifest manifest) { List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests(); Preconditions.checkNotNull(regionManifests); List<HRegionLocation> regionLocations = Lists.newArrayListWithCapacity(regionManifests.size()); for (SnapshotRegionManifest regionManifest : regionManifests) { regionLocations.add(new HRegionLocation( ProtobufUtil.toRegionInfo(regionManifest.getRegionInfo()), null)); } return regionLocations; }
/** * Get list of region locations from SnapshotManifest * BaseResultIterators assume that regions are sorted using RegionInfo.COMPARATOR */ private List<HRegionLocation> getRegionLocationsFromManifest(SnapshotManifest manifest) { List<SnapshotRegionManifest> regionManifests = manifest.getRegionManifests(); Preconditions.checkNotNull(regionManifests); List<RegionInfo> regionInfos = Lists.newArrayListWithCapacity(regionManifests.size()); List<HRegionLocation> hRegionLocations = Lists.newArrayListWithCapacity(regionManifests.size()); for (SnapshotRegionManifest regionManifest : regionManifests) { RegionInfo regionInfo = ProtobufUtil.toRegionInfo(regionManifest.getRegionInfo()); if (isValidRegion(regionInfo)) { regionInfos.add(regionInfo); } } regionInfos.sort(RegionInfo.COMPARATOR); for (RegionInfo regionInfo : regionInfos) { hRegionLocations.add(new HRegionLocation(regionInfo, null)); } return hRegionLocations; }
regionNames.remove(regionName); metaChanges.addRegionToRestore(ProtobufUtil.toRegionInfo(regionManifests.get(regionName) .getRegionInfo())); } else { LOG.info("region to remove: " + regionName); LOG.info("region to add: " + regionName); regionsToAdd.add(ProtobufUtil.toRegionInfo(regionManifests.get(regionName) .getRegionInfo()));
RegionInfo hri = ProtobufUtil.toRegionInfo(snapshotRegionManifest.getRegionInfo()); if (hri.isOffline() && (hri.isSplit() || hri.isSplitParent())) { continue;
mergeRegionInfo(other.getRegionInfo());
ProtobufUtil.toRegionInfo(rm.getRegionInfo()).getEncodedName());
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest)) { return super.equals(obj); } org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest other = (org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest) obj; boolean result = true; result = result && (hasVersion() == other.hasVersion()); if (hasVersion()) { result = result && (getVersion() == other.getVersion()); } result = result && (hasRegionInfo() == other.hasRegionInfo()); if (hasRegionInfo()) { result = result && getRegionInfo() .equals(other.getRegionInfo()); } result = result && getFamilyFilesList() .equals(other.getFamilyFilesList()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (hasVersion()) { hash = (37 * hash) + VERSION_FIELD_NUMBER; hash = (53 * hash) + getVersion(); } if (hasRegionInfo()) { hash = (37 * hash) + REGION_INFO_FIELD_NUMBER; hash = (53 * hash) + getRegionInfo().hashCode(); } if (getFamilyFilesCount() > 0) { hash = (37 * hash) + FAMILY_FILES_FIELD_NUMBER; hash = (53 * hash) + getFamilyFilesList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; if (isInitialized == 0) return false; if (!hasRegionInfo()) { memoizedIsInitialized = 0; return false; } if (!getRegionInfo().isInitialized()) { memoizedIsInitialized = 0; return false; } for (int i = 0; i < getFamilyFilesCount(); i++) { if (!getFamilyFiles(i).isInitialized()) { memoizedIsInitialized = 0; return false; } } memoizedIsInitialized = 1; return true; }
public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += org.apache.hbase.thirdparty.com.google.protobuf.CodedOutputStream .computeInt32Size(1, version_); } if (((bitField0_ & 0x00000002) == 0x00000002)) { size += org.apache.hbase.thirdparty.com.google.protobuf.CodedOutputStream .computeMessageSize(2, getRegionInfo()); } for (int i = 0; i < familyFiles_.size(); i++) { size += org.apache.hbase.thirdparty.com.google.protobuf.CodedOutputStream .computeMessageSize(3, familyFiles_.get(i)); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
/** * Iterate over the snapshot store files in the specified region * * @param manifest snapshot manifest to inspect * @param visitor callback object to get the store files * @throws IOException if an error occurred while scanning the directory */ static void visitRegionStoreFiles(final SnapshotRegionManifest manifest, final StoreFileVisitor visitor) throws IOException { RegionInfo regionInfo = ProtobufUtil.toRegionInfo(manifest.getRegionInfo()); for (SnapshotRegionManifest.FamilyFiles familyFiles: manifest.getFamilyFilesList()) { String familyName = familyFiles.getFamilyName().toStringUtf8(); for (SnapshotRegionManifest.StoreFile storeFile: familyFiles.getStoreFilesList()) { visitor.storeFile(regionInfo, familyName, storeFile); } } }
/** * Verify that the regionInfo is valid * @param region the region to check * @param manifest snapshot manifest to inspect */ private void verifyRegionInfo(final RegionInfo region, final SnapshotRegionManifest manifest) throws IOException { RegionInfo manifestRegionInfo = ProtobufUtil.toRegionInfo(manifest.getRegionInfo()); if (RegionInfo.COMPARATOR.compare(region, manifestRegionInfo) != 0) { String msg = "Manifest region info " + manifestRegionInfo + "doesn't match expected region:" + region; throw new CorruptedSnapshotException(msg, ProtobufUtil.createSnapshotDesc(snapshot)); } } }
/** * Extract the region encoded name from the region manifest */ static String getRegionNameFromManifest(final SnapshotRegionManifest manifest) { byte[] regionName = RegionInfo.createRegionName( ProtobufUtil.toTableName(manifest.getRegionInfo().getTableName()), manifest.getRegionInfo().getStartKey().toByteArray(), manifest.getRegionInfo().getRegionId(), true); return RegionInfo.encodeRegionName(regionName); }