Search in sources :

Example 61 with RegionInfo

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;
}
Also used : ArrayList(java.util.ArrayList) SnapshotRegionManifest(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotRegionManifest) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) SnapshotDescription(org.apache.hadoop.hbase.shaded.protobuf.generated.SnapshotProtos.SnapshotDescription) IOException(java.io.IOException) TableName(org.apache.hadoop.hbase.TableName) Pair(org.apache.hadoop.hbase.util.Pair)

Example 62 with RegionInfo

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));
        }
    }
}
Also used : TableName(org.apache.hadoop.hbase.TableName) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) UncheckedIOException(java.io.UncheckedIOException) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) RegionOpenInfo(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.OpenRegionRequest.RegionOpenInfo)

Example 63 with RegionInfo

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;
}
Also used : TransitionCode(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Example 64 with RegionInfo

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);
    }
}
Also used : RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) Map(java.util.Map) TreeMap(java.util.TreeMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SortedMap(java.util.SortedMap) ConcurrentMap(java.util.concurrent.ConcurrentMap) ConcurrentSkipListMap(java.util.concurrent.ConcurrentSkipListMap)

Example 65 with RegionInfo

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();
}
Also used : TransitionCode(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition.TransitionCode) ReportRegionStateTransitionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.ReportRegionStateTransitionRequest) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) RegionStateTransition(org.apache.hadoop.hbase.shaded.protobuf.generated.RegionServerStatusProtos.RegionStateTransition)

Aggregations

RegionInfo (org.apache.hadoop.hbase.client.RegionInfo)824 Test (org.junit.Test)416 TableName (org.apache.hadoop.hbase.TableName)311 ServerName (org.apache.hadoop.hbase.ServerName)191 ArrayList (java.util.ArrayList)175 IOException (java.io.IOException)174 TableDescriptor (org.apache.hadoop.hbase.client.TableDescriptor)174 Path (org.apache.hadoop.fs.Path)141 List (java.util.List)118 HashMap (java.util.HashMap)90 Table (org.apache.hadoop.hbase.client.Table)90 Map (java.util.Map)81 Put (org.apache.hadoop.hbase.client.Put)81 Configuration (org.apache.hadoop.conf.Configuration)80 HRegion (org.apache.hadoop.hbase.regionserver.HRegion)67 TreeMap (java.util.TreeMap)66 Result (org.apache.hadoop.hbase.client.Result)59 FileSystem (org.apache.hadoop.fs.FileSystem)58 Cell (org.apache.hadoop.hbase.Cell)50 Scan (org.apache.hadoop.hbase.client.Scan)46