Search in sources :

Example 1 with MutationType

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType in project hbase by apache.

the class ProtobufUtil method toGet.

/**
   * Convert a protocol buffer Mutate to a Get.
   * @param proto the protocol buffer Mutate to convert.
   * @param cellScanner
   * @return the converted client get.
   * @throws IOException
   */
public static Get toGet(final MutationProto proto, final CellScanner cellScanner) throws IOException {
    MutationType type = proto.getMutateType();
    assert type == MutationType.INCREMENT || type == MutationType.APPEND : type.name();
    byte[] row = proto.hasRow() ? proto.getRow().toByteArray() : null;
    Get get = null;
    int cellCount = proto.hasAssociatedCellCount() ? proto.getAssociatedCellCount() : 0;
    if (cellCount > 0) {
        // The proto has metadata only and the data is separate to be found in the cellScanner.
        if (cellScanner == null) {
            throw new DoNotRetryIOException("Cell count of " + cellCount + " but no cellScanner: " + TextFormat.shortDebugString(proto));
        }
        for (int i = 0; i < cellCount; i++) {
            if (!cellScanner.advance()) {
                throw new DoNotRetryIOException("Cell count of " + cellCount + " but at index " + i + " no cell returned: " + TextFormat.shortDebugString(proto));
            }
            Cell cell = cellScanner.current();
            if (get == null) {
                get = new Get(CellUtil.cloneRow(cell));
            }
            get.addColumn(CellUtil.cloneFamily(cell), CellUtil.cloneQualifier(cell));
        }
    } else {
        get = new Get(row);
        for (ColumnValue column : proto.getColumnValueList()) {
            byte[] family = column.getFamily().toByteArray();
            for (QualifierValue qv : column.getQualifierValueList()) {
                byte[] qualifier = qv.getQualifier().toByteArray();
                if (!qv.hasValue()) {
                    throw new DoNotRetryIOException("Missing required field: qualifier value");
                }
                get.addColumn(family, qualifier);
            }
        }
    }
    if (proto.hasTimeRange()) {
        TimeRange timeRange = protoToTimeRange(proto.getTimeRange());
        get.setTimeRange(timeRange);
    }
    for (NameBytesPair attribute : proto.getAttributeList()) {
        get.setAttribute(attribute.getName(), attribute.getValue().toByteArray());
    }
    return get;
}
Also used : TimeRange(org.apache.hadoop.hbase.io.TimeRange) MutationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType) NameBytesPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameBytesPair) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) Get(org.apache.hadoop.hbase.client.Get) QualifierValue(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue) ColumnValue(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue) Cell(org.apache.hadoop.hbase.Cell) ByteBufferCell(org.apache.hadoop.hbase.ByteBufferCell)

Example 2 with MutationType

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType in project hbase by apache.

the class RequestConverter method buildMutateRequest.

/**
   * Create a protocol buffer MutateRequest for conditioned row mutations
   *
   * @param regionName
   * @param row
   * @param family
   * @param qualifier
   * @param comparator
   * @param compareType
   * @param rowMutations
   * @return a mutate request
   * @throws IOException
   */
public static ClientProtos.MultiRequest buildMutateRequest(final byte[] regionName, final byte[] row, final byte[] family, final byte[] qualifier, final ByteArrayComparable comparator, final CompareType compareType, final RowMutations rowMutations) throws IOException {
    RegionAction.Builder builder = getRegionActionBuilderWithRegion(RegionAction.newBuilder(), regionName);
    builder.setAtomic(true);
    ClientProtos.Action.Builder actionBuilder = ClientProtos.Action.newBuilder();
    MutationProto.Builder mutationBuilder = MutationProto.newBuilder();
    Condition condition = buildCondition(row, family, qualifier, comparator, compareType);
    for (Mutation mutation : rowMutations.getMutations()) {
        MutationType mutateType = null;
        if (mutation instanceof Put) {
            mutateType = MutationType.PUT;
        } else if (mutation instanceof Delete) {
            mutateType = MutationType.DELETE;
        } else {
            throw new DoNotRetryIOException("RowMutations supports only put and delete, not " + mutation.getClass().getName());
        }
        mutationBuilder.clear();
        MutationProto mp = ProtobufUtil.toMutation(mutateType, mutation, mutationBuilder);
        actionBuilder.clear();
        actionBuilder.setMutation(mp);
        builder.addAction(actionBuilder.build());
    }
    ClientProtos.MultiRequest request = ClientProtos.MultiRequest.newBuilder().addRegionAction(builder.build()).setCondition(condition).build();
    return request;
}
Also used : Condition(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Condition) Delete(org.apache.hadoop.hbase.client.Delete) Action(org.apache.hadoop.hbase.client.Action) RegionAction(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionAction) MutationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) RegionAction(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionAction) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto) Put(org.apache.hadoop.hbase.client.Put) Mutation(org.apache.hadoop.hbase.client.Mutation) ClientProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos)

Example 3 with MutationType

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType in project hbase by apache.

the class RSRpcServices method doNonAtomicRegionMutation.

/**
 * Run through the regionMutation <code>rm</code> and per Mutation, do the work, and then when
 * done, add an instance of a {@link ResultOrException} that corresponds to each Mutation.
 * @param cellsToReturn  Could be null. May be allocated in this method.  This is what this
 * method returns as a 'result'.
 * @param closeCallBack the callback to be used with multigets
 * @param context the current RpcCallContext
 * @return Return the <code>cellScanner</code> passed
 */
private List<CellScannable> doNonAtomicRegionMutation(final HRegion region, final OperationQuota quota, final RegionAction actions, final CellScanner cellScanner, final RegionActionResult.Builder builder, List<CellScannable> cellsToReturn, long nonceGroup, final RegionScannersCloseCallBack closeCallBack, RpcCallContext context, ActivePolicyEnforcement spaceQuotaEnforcement) {
    // Gather up CONTIGUOUS Puts and Deletes in this mutations List.  Idea is that rather than do
    // one at a time, we instead pass them in batch.  Be aware that the corresponding
    // ResultOrException instance that matches each Put or Delete is then added down in the
    // doNonAtomicBatchOp call.  We should be staying aligned though the Put and Delete are
    // deferred/batched
    List<ClientProtos.Action> mutations = null;
    long maxQuotaResultSize = Math.min(maxScannerResultSize, quota.getReadAvailable());
    IOException sizeIOE = null;
    Object lastBlock = null;
    ClientProtos.ResultOrException.Builder resultOrExceptionBuilder = ResultOrException.newBuilder();
    boolean hasResultOrException = false;
    for (ClientProtos.Action action : actions.getActionList()) {
        hasResultOrException = false;
        resultOrExceptionBuilder.clear();
        try {
            Result r = null;
            if (context != null && context.isRetryImmediatelySupported() && (context.getResponseCellSize() > maxQuotaResultSize || context.getResponseBlockSize() + context.getResponseExceptionSize() > maxQuotaResultSize)) {
                // change after the response size limit is reached.
                if (sizeIOE == null) {
                    // We don't need the stack un-winding do don't throw the exception.
                    // Throwing will kill the JVM's JIT.
                    // 
                    // Instead just create the exception and then store it.
                    sizeIOE = new MultiActionResultTooLarge("Max size exceeded" + " CellSize: " + context.getResponseCellSize() + " BlockSize: " + context.getResponseBlockSize());
                    // Only report the exception once since there's only one request that
                    // caused the exception. Otherwise this number will dominate the exceptions count.
                    rpcServer.getMetrics().exception(sizeIOE);
                }
                // Now that there's an exception is known to be created
                // use it for the response.
                // 
                // This will create a copy in the builder.
                NameBytesPair pair = ResponseConverter.buildException(sizeIOE);
                resultOrExceptionBuilder.setException(pair);
                context.incrementResponseExceptionSize(pair.getSerializedSize());
                resultOrExceptionBuilder.setIndex(action.getIndex());
                builder.addResultOrException(resultOrExceptionBuilder.build());
                skipCellsForMutation(action, cellScanner);
                continue;
            }
            if (action.hasGet()) {
                long before = EnvironmentEdgeManager.currentTime();
                ClientProtos.Get pbGet = action.getGet();
                // they are; its a problem for non-native clients like asynchbase. HBASE-20225.
                if (pbGet.hasClosestRowBefore() && pbGet.getClosestRowBefore()) {
                    throw new UnknownProtocolException("Is this a pre-hbase-1.0.0 or asynchbase client? " + "Client is invoking getClosestRowBefore removed in hbase-2.0.0 replaced by " + "reverse Scan.");
                }
                try {
                    Get get = ProtobufUtil.toGet(pbGet);
                    if (context != null) {
                        r = get(get, (region), closeCallBack, context);
                    } else {
                        r = region.get(get);
                    }
                } finally {
                    final MetricsRegionServer metricsRegionServer = server.getMetrics();
                    if (metricsRegionServer != null) {
                        metricsRegionServer.updateGet(region.getTableDescriptor().getTableName(), EnvironmentEdgeManager.currentTime() - before);
                    }
                }
            } else if (action.hasServiceCall()) {
                hasResultOrException = true;
                Message result = execServiceOnRegion(region, action.getServiceCall());
                ClientProtos.CoprocessorServiceResult.Builder serviceResultBuilder = ClientProtos.CoprocessorServiceResult.newBuilder();
                resultOrExceptionBuilder.setServiceResult(serviceResultBuilder.setValue(serviceResultBuilder.getValueBuilder().setName(result.getClass().getName()).setValue(UnsafeByteOperations.unsafeWrap(result.toByteArray()))));
            } else if (action.hasMutation()) {
                MutationType type = action.getMutation().getMutateType();
                if (type != MutationType.PUT && type != MutationType.DELETE && mutations != null && !mutations.isEmpty()) {
                    // Flush out any Puts or Deletes already collected.
                    doNonAtomicBatchOp(builder, region, quota, mutations, cellScanner, spaceQuotaEnforcement);
                    mutations.clear();
                }
                switch(type) {
                    case APPEND:
                        r = append(region, quota, action.getMutation(), cellScanner, nonceGroup, spaceQuotaEnforcement);
                        break;
                    case INCREMENT:
                        r = increment(region, quota, action.getMutation(), cellScanner, nonceGroup, spaceQuotaEnforcement);
                        break;
                    case PUT:
                    case DELETE:
                        // Collect the individual mutations and apply in a batch
                        if (mutations == null) {
                            mutations = new ArrayList<>(actions.getActionCount());
                        }
                        mutations.add(action);
                        break;
                    default:
                        throw new DoNotRetryIOException("Unsupported mutate type: " + type.name());
                }
            } else {
                throw new HBaseIOException("Unexpected Action type");
            }
            if (r != null) {
                ClientProtos.Result pbResult = null;
                if (isClientCellBlockSupport(context)) {
                    pbResult = ProtobufUtil.toResultNoData(r);
                    // Hard to guess the size here.  Just make a rough guess.
                    if (cellsToReturn == null) {
                        cellsToReturn = new ArrayList<>();
                    }
                    cellsToReturn.add(r);
                } else {
                    pbResult = ProtobufUtil.toResult(r);
                }
                lastBlock = addSize(context, r, lastBlock);
                hasResultOrException = true;
                resultOrExceptionBuilder.setResult(pbResult);
            }
        // Could get to here and there was no result and no exception.  Presumes we added
        // a Put or Delete to the collecting Mutations List for adding later.  In this
        // case the corresponding ResultOrException instance for the Put or Delete will be added
        // down in the doNonAtomicBatchOp method call rather than up here.
        } catch (IOException ie) {
            rpcServer.getMetrics().exception(ie);
            hasResultOrException = true;
            NameBytesPair pair = ResponseConverter.buildException(ie);
            resultOrExceptionBuilder.setException(pair);
            context.incrementResponseExceptionSize(pair.getSerializedSize());
        }
        if (hasResultOrException) {
            // Propagate index.
            resultOrExceptionBuilder.setIndex(action.getIndex());
            builder.addResultOrException(resultOrExceptionBuilder.build());
        }
    }
    // Finish up any outstanding mutations
    if (!CollectionUtils.isEmpty(mutations)) {
        doNonAtomicBatchOp(builder, region, quota, mutations, cellScanner, spaceQuotaEnforcement);
    }
    return cellsToReturn;
}
Also used : MultiActionResultTooLarge(org.apache.hadoop.hbase.MultiActionResultTooLarge) RegionAction(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionAction) Action(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Action) MutationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType) Message(org.apache.hbase.thirdparty.com.google.protobuf.Message) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) CacheBuilder(org.apache.hbase.thirdparty.com.google.common.cache.CacheBuilder) CacheEvictionStatsBuilder(org.apache.hadoop.hbase.CacheEvictionStatsBuilder) Action(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Action) IOException(java.io.IOException) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) UncheckedIOException(java.io.UncheckedIOException) RegionActionResult(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionActionResult) Result(org.apache.hadoop.hbase.client.Result) CheckAndMutateResult(org.apache.hadoop.hbase.client.CheckAndMutateResult) NameBytesPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameBytesPair) Get(org.apache.hadoop.hbase.client.Get) MutableObject(org.apache.commons.lang3.mutable.MutableObject) UnknownProtocolException(org.apache.hadoop.hbase.exceptions.UnknownProtocolException) ResultOrException(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ResultOrException) ClientProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos)

Example 4 with MutationType

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType in project hbase by apache.

the class RSRpcServices method isReplicationRequest.

private boolean isReplicationRequest(Action action) {
    // replication request can only be put or delete.
    if (!action.hasMutation()) {
        return false;
    }
    MutationProto mutation = action.getMutation();
    MutationType type = mutation.getMutateType();
    if (type != MutationType.PUT && type != MutationType.DELETE) {
        return false;
    }
    // is for replication.
    return mutation.getAttributeList().stream().map(p -> p.getName()).filter(n -> n.equals(ReplicationUtils.REPLICATION_ATTR_NAME)).findAny().isPresent();
}
Also used : FileSystem(org.apache.hadoop.fs.FileSystem) GetRegionInfoResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoResponse) Delete(org.apache.hadoop.hbase.client.Delete) CompactionSwitchRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CompactionSwitchRequest) Map(java.util.Map) Configuration(org.apache.hadoop.conf.Configuration) Lease(org.apache.hadoop.hbase.regionserver.LeaseManager.Lease) FailedSanityCheckException(org.apache.hadoop.hbase.exceptions.FailedSanityCheckException) Pair(org.apache.hadoop.hbase.util.Pair) Append(org.apache.hadoop.hbase.client.Append) TextFormat(org.apache.hbase.thirdparty.com.google.protobuf.TextFormat) Address(org.apache.hadoop.hbase.net.Address) CompactRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CompactRegionRequest) CacheEvictionStats(org.apache.hadoop.hbase.CacheEvictionStats) RSProcedureCallable(org.apache.hadoop.hbase.procedure2.RSProcedureCallable) RpcServerInterface(org.apache.hadoop.hbase.ipc.RpcServerInterface) RegionSpecifierType(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType) ResultOrException(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ResultOrException) OpenRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.OpenRegionResponse) OpenRegionHandler(org.apache.hadoop.hbase.regionserver.handler.OpenRegionHandler) ScanResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanResponse) ScannerResetException(org.apache.hadoop.hbase.exceptions.ScannerResetException) OutOfOrderScannerNextException(org.apache.hadoop.hbase.exceptions.OutOfOrderScannerNextException) MultiRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiRequest) ByteBuffAllocator(org.apache.hadoop.hbase.io.ByteBuffAllocator) RegionTooBusyException(org.apache.hadoop.hbase.RegionTooBusyException) RegionSpecifier(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.RegionSpecifier) MultiRegionLoadStats(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiRegionLoadStats) ServerType(org.apache.hadoop.hbase.util.DNS.ServerType) LimitScope(org.apache.hadoop.hbase.regionserver.ScannerContext.LimitScope) ClearRegionBlockCacheRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearRegionBlockCacheRequest) StopServerResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.StopServerResponse) Server(org.apache.hadoop.hbase.Server) Cache(org.apache.hbase.thirdparty.com.google.common.cache.Cache) RegionLoad(org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos.RegionLoad) CellScannable(org.apache.hadoop.hbase.CellScannable) CheckAndMutate(org.apache.hadoop.hbase.client.CheckAndMutate) TableName(org.apache.hadoop.hbase.TableName) VersionInfoUtil(org.apache.hadoop.hbase.client.VersionInfoUtil) AdminService(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.AdminService) IOException(java.io.IOException) RegionServerSpaceQuotaManager(org.apache.hadoop.hbase.quotas.RegionServerSpaceQuotaManager) AssignRegionHandler(org.apache.hadoop.hbase.regionserver.handler.AssignRegionHandler) RpcServerFactory(org.apache.hadoop.hbase.ipc.RpcServerFactory) RegionActionResult(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionActionResult) CompactRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CompactRegionResponse) AtomicLong(java.util.concurrent.atomic.AtomicLong) BlockingServiceAndInterface(org.apache.hadoop.hbase.ipc.RpcServer.BlockingServiceAndInterface) ActivePolicyEnforcement(org.apache.hadoop.hbase.quotas.ActivePolicyEnforcement) CompactionDescriptor(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.CompactionDescriptor) LeaseStillHeldException(org.apache.hadoop.hbase.regionserver.LeaseManager.LeaseStillHeldException) MutateRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateRequest) WALKey(org.apache.hadoop.hbase.wal.WALKey) RegionEventDescriptor(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.RegionEventDescriptor) WarmupRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WarmupRegionResponse) FlushDescriptor(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.FlushDescriptor) Result(org.apache.hadoop.hbase.client.Result) OpenMetaHandler(org.apache.hadoop.hbase.regionserver.handler.OpenMetaHandler) ScanRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ScanRequest) UpdateFavoredNodesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesRequest) Message(org.apache.hbase.thirdparty.com.google.protobuf.Message) NotServingRegionException(org.apache.hadoop.hbase.NotServingRegionException) GetServerInfoResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetServerInfoResponse) MutableObject(org.apache.commons.lang3.mutable.MutableObject) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) RollWALWriterRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.RollWALWriterRequest) ProtobufUtil(org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil) GetRegionLoadResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionLoadResponse) RegionAction(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionAction) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) UnassignRegionHandler(org.apache.hadoop.hbase.regionserver.handler.UnassignRegionHandler) ZKWatcher(org.apache.hadoop.hbase.zookeeper.ZKWatcher) NavigableMap(java.util.NavigableMap) Row(org.apache.hadoop.hbase.client.Row) CollectionUtils(org.apache.hbase.thirdparty.org.apache.commons.collections4.CollectionUtils) WarmupRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WarmupRegionRequest) Entry(java.util.Map.Entry) MultiResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MultiResponse) MutationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType) HBaseIOException(org.apache.hadoop.hbase.HBaseIOException) BulkLoadHFileResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.BulkLoadHFileResponse) Increment(org.apache.hadoop.hbase.client.Increment) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) RpcController(org.apache.hbase.thirdparty.com.google.protobuf.RpcController) GetResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetResponse) ConcurrentMap(java.util.concurrent.ConcurrentMap) ServerRegionReplicaUtil(org.apache.hadoop.hbase.util.ServerRegionReplicaUtil) HConstants(org.apache.hadoop.hbase.HConstants) CompactionLifeCycleTracker(org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker) ClearCompactionQueuesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearCompactionQueuesRequest) GetSpaceQuotaSnapshotsRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaSnapshotsRequest) ExecuteProceduresResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ExecuteProceduresResponse) RpcCallback(org.apache.hadoop.hbase.ipc.RpcCallback) QuotaUtil(org.apache.hadoop.hbase.quotas.QuotaUtil) GetStoreFileRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetStoreFileRequest) Bytes(org.apache.hadoop.hbase.util.Bytes) Logger(org.slf4j.Logger) OpenRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.OpenRegionRequest) ServerNotRunningYetException(org.apache.hadoop.hbase.ipc.ServerNotRunningYetException) ClientMetaService(org.apache.hadoop.hbase.shaded.protobuf.generated.RegistryProtos.ClientMetaService) Lists(org.apache.hbase.thirdparty.com.google.common.collect.Lists) UnknownProtocolException(org.apache.hadoop.hbase.exceptions.UnknownProtocolException) RequestConverter(org.apache.hadoop.hbase.shaded.protobuf.RequestConverter) CellUtil(org.apache.hadoop.hbase.CellUtil) InterfaceAudience(org.apache.yetus.audience.InterfaceAudience) CloseRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionResponse) Action(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Action) ClientService(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ClientService) CompactionSwitchResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CompactionSwitchResponse) Mutation(org.apache.hadoop.hbase.client.Mutation) Arrays(java.util.Arrays) RemoteProcedureRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.RemoteProcedureRequest) WALSplitUtil(org.apache.hadoop.hbase.wal.WALSplitUtil) ReplicateWALEntryResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ReplicateWALEntryResponse) InetAddress(java.net.InetAddress) ServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException) Condition(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Condition) BootstrapNodeService(org.apache.hadoop.hbase.shaded.protobuf.generated.BootstrapNodeProtos.BootstrapNodeService) WAL(org.apache.hadoop.hbase.wal.WAL) GetServerInfoRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetServerInfoRequest) Cell(org.apache.hadoop.hbase.Cell) SpaceQuotaSnapshot(org.apache.hadoop.hbase.quotas.SpaceQuotaSnapshot) GetOnlineRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetOnlineRegionRequest) FlushRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.FlushRegionRequest) Get(org.apache.hadoop.hbase.client.Get) CloseRegionRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.CloseRegionRequest) Set(java.util.Set) StopServerRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.StopServerRequest) UncheckedIOException(java.io.UncheckedIOException) CellScanner(org.apache.hadoop.hbase.CellScanner) UnknownScannerException(org.apache.hadoop.hbase.UnknownScannerException) Superusers(org.apache.hadoop.hbase.security.Superusers) PrivateCellUtil(org.apache.hadoop.hbase.PrivateCellUtil) ClusterStatusProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ClusterStatusProtos) ByteBufferExtendedCell(org.apache.hadoop.hbase.ByteBufferExtendedCell) BulkLoadDescriptor(org.apache.hadoop.hbase.shaded.protobuf.generated.WALProtos.BulkLoadDescriptor) CoprocessorServiceRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceRequest) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) ServerRpcController(org.apache.hadoop.hbase.ipc.ServerRpcController) RollWALWriterResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.RollWALWriterResponse) NameInt64Pair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameInt64Pair) ClearRegionBlockCacheResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearRegionBlockCacheResponse) WALEdit(org.apache.hadoop.hbase.wal.WALEdit) UpdateFavoredNodesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.UpdateFavoredNodesResponse) ServerName(org.apache.hadoop.hbase.ServerName) MultiActionResultTooLarge(org.apache.hadoop.hbase.MultiActionResultTooLarge) NameBytesPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameBytesPair) ExecuteProceduresRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ExecuteProceduresRequest) CleanupBulkLoadRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CleanupBulkLoadRequest) ClientProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos) CheckAndMutateResult(org.apache.hadoop.hbase.client.CheckAndMutateResult) FlushRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.FlushRegionResponse) Scan(org.apache.hadoop.hbase.client.Scan) QosPriority(org.apache.hadoop.hbase.ipc.QosPriority) CacheBuilder(org.apache.hbase.thirdparty.com.google.common.cache.CacheBuilder) PrepareBulkLoadRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.PrepareBulkLoadRequest) UnsafeByteOperations(org.apache.hbase.thirdparty.com.google.protobuf.UnsafeByteOperations) RegionOpenInfo(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.OpenRegionRequest.RegionOpenInfo) GetRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.GetRequest) GetRegionLoadRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionLoadRequest) LoggerFactory(org.slf4j.LoggerFactory) ResponseConverter(org.apache.hadoop.hbase.shaded.protobuf.ResponseConverter) SpaceViolationPolicyEnforcement(org.apache.hadoop.hbase.quotas.SpaceViolationPolicyEnforcement) OpenPriorityRegionHandler(org.apache.hadoop.hbase.regionserver.handler.OpenPriorityRegionHandler) GetSpaceQuotaSnapshotsResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaSnapshotsResponse) ByteBuffer(java.nio.ByteBuffer) OperationQuota(org.apache.hadoop.hbase.quotas.OperationQuota) BlockCache(org.apache.hadoop.hbase.io.hfile.BlockCache) BulkLoadHFileRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.BulkLoadHFileRequest) Path(org.apache.hadoop.fs.Path) PriorityFunction(org.apache.hadoop.hbase.ipc.PriorityFunction) HBaseRpcServicesBase(org.apache.hadoop.hbase.HBaseRpcServicesBase) Durability(org.apache.hadoop.hbase.client.Durability) GetStoreFileResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetStoreFileResponse) FamilyPath(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.BulkLoadHFileRequest.FamilyPath) RestrictedApi(com.google.errorprone.annotations.RestrictedApi) Operation(org.apache.hadoop.hbase.regionserver.Region.Operation) GetAllBootstrapNodesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.BootstrapNodeProtos.GetAllBootstrapNodesResponse) HBaseRpcController(org.apache.hadoop.hbase.ipc.HBaseRpcController) InetSocketAddress(java.net.InetSocketAddress) ClearCompactionQueuesResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ClearCompactionQueuesResponse) ReplicateWALEntryRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.ReplicateWALEntryRequest) FileNotFoundException(java.io.FileNotFoundException) GetRegionInfoRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetRegionInfoRequest) List(java.util.List) WALEntry(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.WALEntry) EnvironmentEdgeManager(org.apache.hadoop.hbase.util.EnvironmentEdgeManager) CleanupBulkLoadResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CleanupBulkLoadResponse) CoprocessorServiceResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.CoprocessorServiceResponse) MutateResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutateResponse) TableDescriptor(org.apache.hadoop.hbase.client.TableDescriptor) RegionOpeningState(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.OpenRegionResponse.RegionOpeningState) Permission(org.apache.hadoop.hbase.security.access.Permission) DNS(org.apache.hadoop.hbase.util.DNS) LongAdder(java.util.concurrent.atomic.LongAdder) HashMap(java.util.HashMap) ScanMetrics(org.apache.hadoop.hbase.shaded.protobuf.generated.MapReduceProtos.ScanMetrics) BindException(java.net.BindException) RejectReplicationRequestStateChecker(org.apache.hadoop.hbase.replication.regionserver.RejectReplicationRequestStateChecker) RejectRequestsFromClientStateChecker(org.apache.hadoop.hbase.replication.regionserver.RejectRequestsFromClientStateChecker) DroppedSnapshotException(org.apache.hadoop.hbase.DroppedSnapshotException) PrepareBulkLoadResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.PrepareBulkLoadResponse) MutationReplay(org.apache.hadoop.hbase.wal.WALSplitUtil.MutationReplay) OperationWithAttributes(org.apache.hadoop.hbase.client.OperationWithAttributes) RpcServer(org.apache.hadoop.hbase.ipc.RpcServer) ReplicationUtils(org.apache.hadoop.hbase.replication.ReplicationUtils) Iterator(java.util.Iterator) Put(org.apache.hadoop.hbase.client.Put) RegionReplicaUtil(org.apache.hadoop.hbase.client.RegionReplicaUtil) TableQuotaSnapshot(org.apache.hadoop.hbase.shaded.protobuf.generated.QuotaProtos.GetSpaceQuotaSnapshotsResponse.TableQuotaSnapshot) GetAllBootstrapNodesRequest(org.apache.hadoop.hbase.shaded.protobuf.generated.BootstrapNodeProtos.GetAllBootstrapNodesRequest) TimeUnit(java.util.concurrent.TimeUnit) RegionServerRpcQuotaManager(org.apache.hadoop.hbase.quotas.RegionServerRpcQuotaManager) GetOnlineRegionResponse(org.apache.hadoop.hbase.shaded.protobuf.generated.AdminProtos.GetOnlineRegionResponse) RpcCall(org.apache.hadoop.hbase.ipc.RpcCall) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto) RpcCallContext(org.apache.hadoop.hbase.ipc.RpcCallContext) ImmutableList(org.apache.hbase.thirdparty.com.google.common.collect.ImmutableList) ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) Collections(java.util.Collections) CacheEvictionStatsBuilder(org.apache.hadoop.hbase.CacheEvictionStatsBuilder) RegionInfo(org.apache.hadoop.hbase.client.RegionInfo) MutationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto)

Example 5 with MutationType

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType in project hbase by apache.

the class RSRpcServices method checkAndMutate.

private CheckAndMutateResult checkAndMutate(HRegion region, OperationQuota quota, MutationProto mutation, CellScanner cellScanner, Condition condition, long nonceGroup, ActivePolicyEnforcement spaceQuota) throws IOException {
    long before = EnvironmentEdgeManager.currentTime();
    CheckAndMutate checkAndMutate = ProtobufUtil.toCheckAndMutate(condition, mutation, cellScanner);
    long nonce = mutation.hasNonce() ? mutation.getNonce() : HConstants.NO_NONCE;
    checkCellSizeLimit(region, (Mutation) checkAndMutate.getAction());
    spaceQuota.getPolicyEnforcement(region).check((Mutation) checkAndMutate.getAction());
    quota.addMutation((Mutation) checkAndMutate.getAction());
    CheckAndMutateResult result = null;
    if (region.getCoprocessorHost() != null) {
        result = region.getCoprocessorHost().preCheckAndMutate(checkAndMutate);
    }
    if (result == null) {
        result = region.checkAndMutate(checkAndMutate, nonceGroup, nonce);
        if (region.getCoprocessorHost() != null) {
            result = region.getCoprocessorHost().postCheckAndMutate(checkAndMutate, result);
        }
    }
    MetricsRegionServer metricsRegionServer = server.getMetrics();
    if (metricsRegionServer != null) {
        long after = EnvironmentEdgeManager.currentTime();
        metricsRegionServer.updateCheckAndMutate(region.getRegionInfo().getTable(), after - before);
        MutationType type = mutation.getMutateType();
        switch(type) {
            case PUT:
                metricsRegionServer.updateCheckAndPut(region.getRegionInfo().getTable(), after - before);
                break;
            case DELETE:
                metricsRegionServer.updateCheckAndDelete(region.getRegionInfo().getTable(), after - before);
                break;
            default:
                break;
        }
    }
    return result;
}
Also used : MutationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType) CheckAndMutateResult(org.apache.hadoop.hbase.client.CheckAndMutateResult) CheckAndMutate(org.apache.hadoop.hbase.client.CheckAndMutate)

Aggregations

MutationType (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType)20 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)14 ClientProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos)7 Delete (org.apache.hadoop.hbase.client.Delete)6 Put (org.apache.hadoop.hbase.client.Put)6 Action (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Action)6 MutationProto (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto)6 NameBytesPair (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameBytesPair)6 CheckAndMutateResult (org.apache.hadoop.hbase.client.CheckAndMutateResult)5 Mutation (org.apache.hadoop.hbase.client.Mutation)5 RegionAction (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionAction)5 ResultOrException (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.ResultOrException)5 IOException (java.io.IOException)4 Cell (org.apache.hadoop.hbase.Cell)4 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)4 CheckAndMutate (org.apache.hadoop.hbase.client.CheckAndMutate)4 Get (org.apache.hadoop.hbase.client.Get)4 Result (org.apache.hadoop.hbase.client.Result)4 TimeRange (org.apache.hadoop.hbase.io.TimeRange)4 RegionActionResult (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionActionResult)4