Search in sources :

Example 1 with MutationProto

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto 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 2 with MutationProto

use of org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto 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 3 with MutationProto

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

the class TestProtobufUtil method testAppendNoTimestamp.

/**
 * Older clients may not send along a timestamp in the MutationProto. Check that we
 * default correctly.
 */
@Test
public void testAppendNoTimestamp() throws IOException {
    MutationProto mutation = getAppendMutation(null);
    Append append = ProtobufUtil.toAppend(mutation, null);
    assertEquals(HConstants.LATEST_TIMESTAMP, append.getTimestamp());
    append.getFamilyCellMap().values().forEach(cells -> cells.forEach(cell -> assertEquals(HConstants.LATEST_TIMESTAMP, cell.getTimestamp())));
}
Also used : Any(org.apache.hbase.thirdparty.com.google.protobuf.Any) Increment(org.apache.hadoop.hbase.client.Increment) TimeRange(org.apache.hadoop.hbase.io.TimeRange) Column(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Column) ByteBuffer(java.nio.ByteBuffer) ArrayBackedTag(org.apache.hadoop.hbase.ArrayBackedTag) HConstants(org.apache.hadoop.hbase.HConstants) Delete(org.apache.hadoop.hbase.client.Delete) CellComparatorImpl(org.apache.hadoop.hbase.CellComparatorImpl) Tag(org.apache.hadoop.hbase.Tag) DeleteType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.DeleteType) ColumnValue(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue) LockServiceProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos) ClassRule(org.junit.ClassRule) ByteBufferKeyValue(org.apache.hadoop.hbase.ByteBufferKeyValue) ExtendedCellBuilderFactory(org.apache.hadoop.hbase.ExtendedCellBuilderFactory) Cell(org.apache.hadoop.hbase.Cell) KeyValue(org.apache.hadoop.hbase.KeyValue) Bytes(org.apache.hadoop.hbase.util.Bytes) NameBytesPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameBytesPair) Append(org.apache.hadoop.hbase.client.Append) ExtendedCellBuilder(org.apache.hadoop.hbase.ExtendedCellBuilder) CellBuilderType(org.apache.hadoop.hbase.CellBuilderType) Assert.assertNotNull(org.junit.Assert.assertNotNull) Put(org.apache.hadoop.hbase.client.Put) ClientProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos) ProcedureProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos) Get(org.apache.hadoop.hbase.client.Get) Assert.assertTrue(org.junit.Assert.assertTrue) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) IOException(java.io.IOException) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) CellProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.CellProtos) Lists(org.apache.hbase.thirdparty.com.google.common.collect.Lists) List(java.util.List) BytesValue(org.apache.hbase.thirdparty.com.google.protobuf.BytesValue) PrivateCellUtil(org.apache.hadoop.hbase.PrivateCellUtil) SmallTests(org.apache.hadoop.hbase.testclassification.SmallTests) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto) ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) MutationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType) Collections(java.util.Collections) QualifierValue(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue) Assert.assertEquals(org.junit.Assert.assertEquals) Append(org.apache.hadoop.hbase.client.Append) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto) Test(org.junit.Test)

Example 4 with MutationProto

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

the class TestProtobufUtil method testPut.

/**
 * Test Put Mutate conversions.
 *
 * @throws IOException if the conversion to a {@link Put} or a
 *                     {@link org.apache.hadoop.hbase.client.Mutation} fails
 */
@Test
public void testPut() throws IOException {
    MutationProto.Builder mutateBuilder = MutationProto.newBuilder();
    mutateBuilder.setRow(ByteString.copyFromUtf8("row"));
    mutateBuilder.setMutateType(MutationType.PUT);
    mutateBuilder.setTimestamp(111111);
    ColumnValue.Builder valueBuilder = ColumnValue.newBuilder();
    valueBuilder.setFamily(ByteString.copyFromUtf8("f1"));
    QualifierValue.Builder qualifierBuilder = QualifierValue.newBuilder();
    qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c1"));
    qualifierBuilder.setValue(ByteString.copyFromUtf8("v1"));
    valueBuilder.addQualifierValue(qualifierBuilder.build());
    qualifierBuilder.setQualifier(ByteString.copyFromUtf8("c2"));
    qualifierBuilder.setValue(ByteString.copyFromUtf8("v2"));
    qualifierBuilder.setTimestamp(222222);
    valueBuilder.addQualifierValue(qualifierBuilder.build());
    mutateBuilder.addColumnValue(valueBuilder.build());
    MutationProto proto = mutateBuilder.build();
    // default fields
    assertEquals(MutationProto.Durability.USE_DEFAULT, proto.getDurability());
    // set the default value for equal comparison
    mutateBuilder = MutationProto.newBuilder(proto);
    mutateBuilder.setDurability(MutationProto.Durability.USE_DEFAULT);
    Put put = ProtobufUtil.toPut(proto);
    // put value always use the default timestamp if no
    // value level timestamp specified,
    // add the timestamp to the original mutate
    long timestamp = put.getTimestamp();
    for (ColumnValue.Builder column : mutateBuilder.getColumnValueBuilderList()) {
        for (QualifierValue.Builder qualifier : column.getQualifierValueBuilderList()) {
            if (!qualifier.hasTimestamp()) {
                qualifier.setTimestamp(timestamp);
            }
        }
    }
    assertEquals(mutateBuilder.build(), ProtobufUtil.toMutation(MutationType.PUT, put));
}
Also used : QualifierValue(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue) ColumnValue(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto) Put(org.apache.hadoop.hbase.client.Put) Test(org.junit.Test)

Example 5 with MutationProto

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

the class TestProtobufUtil method testIncrementNoTimestamp.

/**
 * Older clients may not send along a timestamp in the MutationProto. Check that we
 * default correctly.
 */
@Test
public void testIncrementNoTimestamp() throws IOException {
    MutationProto mutation = getIncrementMutation(null);
    Increment increment = ProtobufUtil.toIncrement(mutation, null);
    assertEquals(HConstants.LATEST_TIMESTAMP, increment.getTimestamp());
    increment.getFamilyCellMap().values().forEach(cells -> cells.forEach(cell -> assertEquals(HConstants.LATEST_TIMESTAMP, cell.getTimestamp())));
}
Also used : Any(org.apache.hbase.thirdparty.com.google.protobuf.Any) Increment(org.apache.hadoop.hbase.client.Increment) TimeRange(org.apache.hadoop.hbase.io.TimeRange) Column(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.Column) ByteBuffer(java.nio.ByteBuffer) ArrayBackedTag(org.apache.hadoop.hbase.ArrayBackedTag) HConstants(org.apache.hadoop.hbase.HConstants) Delete(org.apache.hadoop.hbase.client.Delete) CellComparatorImpl(org.apache.hadoop.hbase.CellComparatorImpl) Tag(org.apache.hadoop.hbase.Tag) DeleteType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.DeleteType) ColumnValue(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue) LockServiceProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.LockServiceProtos) ClassRule(org.junit.ClassRule) ByteBufferKeyValue(org.apache.hadoop.hbase.ByteBufferKeyValue) ExtendedCellBuilderFactory(org.apache.hadoop.hbase.ExtendedCellBuilderFactory) Cell(org.apache.hadoop.hbase.Cell) KeyValue(org.apache.hadoop.hbase.KeyValue) Bytes(org.apache.hadoop.hbase.util.Bytes) NameBytesPair(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.NameBytesPair) Append(org.apache.hadoop.hbase.client.Append) ExtendedCellBuilder(org.apache.hadoop.hbase.ExtendedCellBuilder) CellBuilderType(org.apache.hadoop.hbase.CellBuilderType) Assert.assertNotNull(org.junit.Assert.assertNotNull) Put(org.apache.hadoop.hbase.client.Put) ClientProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos) ProcedureProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos) Get(org.apache.hadoop.hbase.client.Get) Assert.assertTrue(org.junit.Assert.assertTrue) HBaseClassTestRule(org.apache.hadoop.hbase.HBaseClassTestRule) IOException(java.io.IOException) Test(org.junit.Test) Category(org.junit.experimental.categories.Category) CellProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.CellProtos) Lists(org.apache.hbase.thirdparty.com.google.common.collect.Lists) List(java.util.List) BytesValue(org.apache.hbase.thirdparty.com.google.protobuf.BytesValue) PrivateCellUtil(org.apache.hadoop.hbase.PrivateCellUtil) SmallTests(org.apache.hadoop.hbase.testclassification.SmallTests) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto) ByteString(org.apache.hbase.thirdparty.com.google.protobuf.ByteString) MutationType(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType) Collections(java.util.Collections) QualifierValue(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue) Assert.assertEquals(org.junit.Assert.assertEquals) Increment(org.apache.hadoop.hbase.client.Increment) MutationProto(org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto) Test(org.junit.Test)

Aggregations

MutationProto (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto)27 Test (org.junit.Test)13 TableName (org.apache.hadoop.hbase.TableName)10 Mutation (org.apache.hadoop.hbase.client.Mutation)10 ClientProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos)10 IOException (java.io.IOException)9 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)8 Delete (org.apache.hadoop.hbase.client.Delete)8 Put (org.apache.hadoop.hbase.client.Put)8 MutationType (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.MutationType)8 Append (org.apache.hadoop.hbase.client.Append)7 Increment (org.apache.hadoop.hbase.client.Increment)7 Cell (org.apache.hadoop.hbase.Cell)6 CoprocessorRpcChannel (org.apache.hadoop.hbase.ipc.CoprocessorRpcChannel)6 ColumnValue (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue)6 RegionAction (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.RegionAction)6 MultiRowMutationService (org.apache.hadoop.hbase.shaded.protobuf.generated.MultiRowMutationProtos.MultiRowMutationService)6 MutateRowsRequest (org.apache.hadoop.hbase.shaded.protobuf.generated.MultiRowMutationProtos.MutateRowsRequest)6 MutateRowsResponse (org.apache.hadoop.hbase.shaded.protobuf.generated.MultiRowMutationProtos.MutateRowsResponse)6 QualifierValue (org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos.MutationProto.ColumnValue.QualifierValue)4