Search in sources :

Example 11 with RegionInfo

use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.

the class MasterRpcServices method assignRegion.

@Override
public AssignRegionResponse assignRegion(RpcController controller, AssignRegionRequest req) throws ServiceException {
    try {
        server.checkInitialized();
        final RegionSpecifierType type = req.getRegion().getType();
        if (type != RegionSpecifierType.REGION_NAME) {
            LOG.warn("assignRegion specifier type: expected: " + RegionSpecifierType.REGION_NAME + " actual: " + type);
        }
        final byte[] regionName = req.getRegion().getValue().toByteArray();
        final RegionInfo regionInfo = server.getAssignmentManager().getRegionInfo(regionName);
        if (regionInfo == null) {
            throw new UnknownRegionException(Bytes.toStringBinary(regionName));
        }
        final AssignRegionResponse arr = AssignRegionResponse.newBuilder().build();
        if (server.cpHost != null) {
            server.cpHost.preAssign(regionInfo);
        }
        LOG.info(server.getClientIdAuditPrefix() + " assign " + regionInfo.getRegionNameAsString());
        server.getAssignmentManager().assign(regionInfo);
        if (server.cpHost != null) {
            server.cpHost.postAssign(regionInfo);
        }
        return arr;
    } catch (IOException ioe) {
        throw new ServiceException(ioe);
    }
}
Also used : ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) RegionSpecifierType(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType) AssignRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.MasterProtos.AssignRegionResponse) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException)

Example 12 with RegionInfo

use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.

the class AssignmentManager method deleteTable.

/**
 * Delete the region states. This is called by "DeleteTable"
 */
public void deleteTable(final TableName tableName) throws IOException {
    final ArrayList<RegionInfo> regions = regionStates.getTableRegionsInfo(tableName);
    regionStateStore.deleteRegions(regions);
    for (int i = 0; i < regions.size(); ++i) {
        final RegionInfo regionInfo = regions.get(i);
        // we expect the region to be offline
        regionStates.removeFromOfflineRegions(regionInfo);
        regionStates.deleteRegion(regionInfo);
    }
}
Also used : RegionInfo(org.apache.hadoop.hbase.client.RegionInfo)

Example 13 with RegionInfo

use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.

the class AssignmentManager method markRegionAsMerged.

/**
 * When called here, the merge has happened. The merged regions have been
 * unassigned and the above markRegionClosed has been called on each so they have been
 * disassociated from a hosting Server. The merged region will be open after this call. The
 * merged regions are removed from hbase:meta below. Later they are deleted from the filesystem
 * by the catalog janitor running against hbase:meta. It notices when the merged region no
 * longer holds references to the old regions (References are deleted after a compaction
 * rewrites what the Reference points at but not until the archiver chore runs, are the
 * References removed).
 */
public void markRegionAsMerged(final RegionInfo child, final ServerName serverName, RegionInfo[] mergeParents) throws IOException {
    final RegionStateNode node = regionStates.getOrCreateRegionStateNode(child);
    node.setState(State.MERGED);
    for (RegionInfo ri : mergeParents) {
        regionStates.deleteRegion(ri);
    }
    TableDescriptor td = master.getTableDescriptors().get(child.getTable());
    regionStateStore.mergeRegions(child, mergeParents, serverName, td);
    if (shouldAssignFavoredNodes(child)) {
        getFavoredNodePromoter().generateFavoredNodesForMergedRegion(child, mergeParents);
    }
}
Also used : RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor)

Example 14 with RegionInfo

use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.

the class AssignmentManager method closeRegionSilently.

/**
 * Close <code>regionName</code> on <code>sn</code> silently and immediately without
 * using a Procedure or going via hbase:meta. For case where a RegionServer's hosting
 * of a Region is not aligned w/ the Master's accounting of Region state. This is for
 * cleaning up an error in accounting.
 */
private void closeRegionSilently(ServerName sn, byte[] regionName) {
    try {
        RegionInfo ri = CatalogFamilyFormat.parseRegionInfoFromRegionName(regionName);
        // Pass -1 for timeout. Means do not wait.
        ServerManager.closeRegionSilentlyAndWait(this.master.getAsyncClusterConnection(), sn, ri, -1);
    } catch (Exception e) {
        LOG.error("Failed trying to close {} on {}", Bytes.toStringBinary(regionName), sn, e);
    }
}
Also used : RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) PleaseHoldException(org.apache.hadoop.hbase.PleaseHoldException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) UnexpectedStateException(org.apache.hadoop.hbase.exceptions.UnexpectedStateException) UnknownRegionException(org.apache.hadoop.hbase.UnknownRegionException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) KeeperException(org.apache.zookeeper.KeeperException) IOException(java.io.IOException) DoNotRetryRegionException(org.apache.hadoop.hbase.client.DoNotRetryRegionException)

Example 15 with RegionInfo

use of org.apache.hadoop.hbase.client.RegionInfo in project hbase by apache.

the class AssignmentManager method regionClosing.

// should be called under the RegionStateNode lock
void regionClosing(RegionStateNode regionNode) throws IOException {
    transitStateAndUpdate(regionNode, State.CLOSING, STATES_EXPECTED_ON_CLOSING);
    RegionInfo hri = regionNode.getRegionInfo();
    // Set meta has not initialized early. so people trying to create/edit tables will wait
    if (isMetaRegion(hri)) {
        setMetaAssigned(hri, false);
    }
    regionStates.addRegionToServer(regionNode);
    // update the operation count metrics
    metrics.incrementOperationCounter();
}
Also used : RegionInfo(org.apache.hadoop.hbase.client.RegionInfo)

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