use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.
the class ExportSnapshot method getSnapshotFiles.
// ==========================================================================
// Input Format
// ==========================================================================
/**
* Extract the list of files (HFiles/WALs) to copy using Map-Reduce.
* @return list of files referenced by the snapshot (pair of path and size)
*/
private static List<Pair<SnapshotFileInfo, Long>> getSnapshotFiles(final Configuration conf, final FileSystem fs, final Path snapshotDir) throws IOException {
SnapshotDescription snapshotDesc = SnapshotDescriptionUtils.readSnapshotInfo(fs, snapshotDir);
final List<Pair<SnapshotFileInfo, Long>> files = new ArrayList<>();
final TableName table = TableName.valueOf(snapshotDesc.getTable());
// Get snapshot files
LOG.info("Loading Snapshot '" + snapshotDesc.getName() + "' hfile list");
SnapshotReferenceUtil.visitReferencedFiles(conf, fs, snapshotDir, snapshotDesc, new SnapshotReferenceUtil.SnapshotVisitor() {
@Override
public void storeFile(final RegionInfo regionInfo, final String family, final SnapshotRegionManifest.StoreFile storeFile) throws IOException {
Pair<SnapshotFileInfo, Long> snapshotFileAndSize = null;
if (!storeFile.hasReference()) {
String region = regionInfo.getEncodedName();
String hfile = storeFile.getName();
snapshotFileAndSize = getSnapshotFileAndSize(fs, conf, table, region, family, hfile, storeFile.hasFileSize() ? storeFile.getFileSize() : -1);
} else {
Pair<String, String> referredToRegionAndFile = StoreFileInfo.getReferredToRegionAndFile(storeFile.getName());
String referencedRegion = referredToRegionAndFile.getFirst();
String referencedHFile = referredToRegionAndFile.getSecond();
snapshotFileAndSize = getSnapshotFileAndSize(fs, conf, table, referencedRegion, family, referencedHFile, storeFile.hasFileSize() ? storeFile.getFileSize() : -1);
}
files.add(snapshotFileAndSize);
}
});
return files;
}
use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.
the class RSRpcServices method executeOpenRegionProcedures.
private void executeOpenRegionProcedures(OpenRegionRequest request, Map<TableName, TableDescriptor> tdCache) {
long masterSystemTime = request.hasMasterSystemTime() ? request.getMasterSystemTime() : -1;
for (RegionOpenInfo regionOpenInfo : request.getOpenInfoList()) {
RegionInfo regionInfo = ProtobufUtil.toRegionInfo(regionOpenInfo.getRegion());
TableName tableName = regionInfo.getTable();
TableDescriptor tableDesc = tdCache.get(tableName);
if (tableDesc == null) {
try {
tableDesc = server.getTableDescriptors().get(regionInfo.getTable());
} catch (IOException e) {
// Here we do not fail the whole method since we also need deal with other
// procedures, and we can not ignore this one, so we still schedule a
// AssignRegionHandler and it will report back to master if we still can not get the
// TableDescriptor.
LOG.warn("Failed to get TableDescriptor of {}, will try again in the handler", regionInfo.getTable(), e);
}
if (tableDesc != null) {
tdCache.put(tableName, tableDesc);
}
}
if (regionOpenInfo.getFavoredNodesCount() > 0) {
server.updateRegionFavoredNodesMapping(regionInfo.getEncodedName(), regionOpenInfo.getFavoredNodesList());
}
long procId = regionOpenInfo.getOpenProcId();
if (server.submitRegionProcedure(procId)) {
server.getExecutorService().submit(AssignRegionHandler.create(server, regionInfo, procId, tableDesc, masterSystemTime));
}
}
}
use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.
the class HRegionServer method skipReportingTransition.
/**
* Helper method for use in tests. Skip the region transition report when there's no master
* around to receive it.
*/
private boolean skipReportingTransition(final RegionStateTransitionContext context) {
final TransitionCode code = context.getCode();
final long openSeqNum = context.getOpenSeqNum();
long masterSystemTime = context.getMasterSystemTime();
final RegionInfo[] hris = context.getHris();
if (code == TransitionCode.OPENED) {
Preconditions.checkArgument(hris != null && hris.length == 1);
if (hris[0].isMetaRegion()) {
LOG.warn("meta table location is stored in master local store, so we can not skip reporting");
return false;
} else {
try {
MetaTableAccessor.updateRegionLocation(asyncClusterConnection.toConnection(), hris[0], serverName, openSeqNum, masterSystemTime);
} catch (IOException e) {
LOG.info("Failed to update meta", e);
return false;
}
}
}
return true;
}
use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.
the class HRegionServer method closeMetaTableRegions.
/**
* Close meta region if we carry it
* @param abort Whether we're running an abort.
*/
private void closeMetaTableRegions(final boolean abort) {
HRegion meta = null;
this.onlineRegionsLock.writeLock().lock();
try {
for (Map.Entry<String, HRegion> e : onlineRegions.entrySet()) {
RegionInfo hri = e.getValue().getRegionInfo();
if (hri.isMetaRegion()) {
meta = e.getValue();
}
if (meta != null) {
break;
}
}
} finally {
this.onlineRegionsLock.writeLock().unlock();
}
if (meta != null) {
closeRegionIgnoreErrors(meta.getRegionInfo(), abort);
}
}
use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.
the class HRegionServer method createReportRegionStateTransitionRequest.
private ReportRegionStateTransitionRequest createReportRegionStateTransitionRequest(final RegionStateTransitionContext context) {
final TransitionCode code = context.getCode();
final long openSeqNum = context.getOpenSeqNum();
final RegionInfo[] hris = context.getHris();
final long[] procIds = context.getProcIds();
ReportRegionStateTransitionRequest.Builder builder = ReportRegionStateTransitionRequest.newBuilder();
builder.setServer(ProtobufUtil.toServerName(serverName));
RegionStateTransition.Builder transition = builder.addTransitionBuilder();
transition.setTransitionCode(code);
if (code == TransitionCode.OPENED && openSeqNum >= 0) {
transition.setOpenSeqNum(openSeqNum);
}
for (RegionInfo hri : hris) {
transition.addRegionInfo(ProtobufUtil.toRegionInfo(hri));
}
for (long procId : procIds) {
transition.addProcId(procId);
}
return builder.build();
}
Aggregations