Search in sources :

Example 1 with FamilyPath

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.BulkLoadHFileRequest.FamilyPath in project hbase by apache.

the class RSRpcServices method bulkLoadHFile.

/**
   * Atomically bulk load several HFiles into an open region
   * @return true if successful, false is failed but recoverably (no action)
   * @throws ServiceException if failed unrecoverably
   */
@Override
public BulkLoadHFileResponse bulkLoadHFile(final RpcController controller, final BulkLoadHFileRequest request) throws ServiceException {
    long start = EnvironmentEdgeManager.currentTime();
    try {
        checkOpen();
        requestCount.increment();
        Region region = getRegion(request.getRegion());
        boolean bypass = false;
        boolean loaded = false;
        Map<byte[], List<Path>> map = null;
        if (!request.hasBulkToken()) {
            // Old style bulk load. This will not be supported in future releases
            List<Pair<byte[], String>> familyPaths = new ArrayList<>(request.getFamilyPathCount());
            for (FamilyPath familyPath : request.getFamilyPathList()) {
                familyPaths.add(new Pair<>(familyPath.getFamily().toByteArray(), familyPath.getPath()));
            }
            if (region.getCoprocessorHost() != null) {
                bypass = region.getCoprocessorHost().preBulkLoadHFile(familyPaths);
            }
            try {
                if (!bypass) {
                    map = region.bulkLoadHFiles(familyPaths, request.getAssignSeqNum(), null, request.getCopyFile());
                    if (map != null) {
                        loaded = true;
                    }
                }
            } finally {
                if (region.getCoprocessorHost() != null) {
                    loaded = region.getCoprocessorHost().postBulkLoadHFile(familyPaths, map, loaded);
                }
            }
        } else {
            // secure bulk load
            map = regionServer.secureBulkLoadManager.secureBulkLoadHFiles(region, request);
        }
        BulkLoadHFileResponse.Builder builder = BulkLoadHFileResponse.newBuilder();
        if (map != null) {
            loaded = true;
        }
        builder.setLoaded(loaded);
        return builder.build();
    } catch (IOException ie) {
        throw new ServiceException(ie);
    } finally {
        if (regionServer.metricsRegionServer != null) {
            regionServer.metricsRegionServer.updateBulkLoad(EnvironmentEdgeManager.currentTime() - start);
        }
    }
}
Also used : FamilyPath(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.BulkLoadHFileRequest.FamilyPath) ArrayList(java.util.ArrayList) InterruptedIOException(java.io.InterruptedIOException) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) ServiceException(org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException) BulkLoadHFileResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.BulkLoadHFileResponse) ArrayList(java.util.ArrayList) List(java.util.List) Pair(org.apache.hadoop.hbase.util.Pair) NameInt64Pair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameInt64Pair) NameBytesPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameBytesPair)

Aggregations

IOException (java.io.IOException)1 InterruptedIOException (java.io.InterruptedIOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)1 ServiceException (org.apache.hadoop.hbase.shaded.com.google.protobuf.ServiceException)1 FamilyPath (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.BulkLoadHFileRequest.FamilyPath)1 BulkLoadHFileResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.BulkLoadHFileResponse)1 NameBytesPair (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameBytesPair)1 NameInt64Pair (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameInt64Pair)1 Pair (org.apache.hadoop.hbase.util.Pair)1