@InterfaceAudience.Private public final class ProtobufUtil extends Object
ProtobufUtil
public static byte[] prependPBMagic(byte[] bytes)
ProtobufMagic.PB_MAGIC
, to flag what
follows as a protobuf in hbase. Prepend these bytes to all content written to znodes, etc.bytes
- Bytes to decoratebytes
with magic prepended (Creates a new byte array that is
bytes.length
plus ProtobufMagic.PB_MAGIC
.length.public static boolean isPBMagicPrefix(byte[] bytes)
ProtobufMagic.PB_MAGIC
bytes
- Bytes to check.bytes
has ProtobufMagic.PB_MAGIC
for a prefix.public static boolean isPBMagicPrefix(byte[] bytes, int offset, int len)
ProtobufMagic.PB_MAGIC
bytes
- Bytes to check.offset
- offset to start atlen
- length to usebytes
has ProtobufMagic.PB_MAGIC
for a prefix.public static void expectPBMagicPrefix(byte[] bytes) throws DeserializationException
ProtobufMagic.PB_MAGIC
bytes
- bytes to checkDeserializationException
- if we are missing the pb magic prefixpublic static int lengthOfPBMagic()
ProtobufMagic.lengthOfPBMagic()
public static IOException getRemoteException(com.google.protobuf.ServiceException se)
se
- ServiceException that wraps IO exception thrown by the serverpublic static IOException getServiceException(org.apache.hbase.thirdparty.com.google.protobuf.ServiceException e)
e
- ServiceException that wraps IO exception thrown by the serverpublic static IOException handleRemoteException(Exception e)
getRemoteException(ServiceException)
but more generic, able to handle more than
just ServiceException
. Prefer this method to
getRemoteException(ServiceException)
because trying to contain direct protobuf
references. npublic static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ServerName toServerName(ServerName serverName)
serverName
- the ServerName to converttoServerName(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ServerName)
public static ServerName toServerName(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.ServerName proto)
proto
- the protocol buffer ServerName to convertpublic static Durability toDurability(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.Durability proto)
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.Durability toDurability(Durability d)
public static Get toGet(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Get proto) throws IOException
proto
- the protocol buffer Get to convertIOException
public static Consistency toConsistency(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Consistency consistency)
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Consistency toConsistency(Consistency consistency)
public static Put toPut(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto proto) throws IOException
proto
- The protocol buffer MutationProto to convertIOException
public static Put toPut(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto proto, CellScanner cellScanner) throws IOException
proto
- The protocol buffer MutationProto to convertcellScanner
- If non-null, the Cell data that goes with this proto.IOException
public static Delete toDelete(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto proto) throws IOException
proto
- the protocol buffer Mutate to convertIOException
public static Delete toDelete(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto proto, CellScanner cellScanner) throws IOException
proto
- the protocol buffer Mutate to convertcellScanner
- if non-null, the data that goes with this delete.IOException
public static Append toAppend(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto proto, CellScanner cellScanner) throws IOException
IOException
public static Increment toIncrement(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto proto, CellScanner cellScanner) throws IOException
IOException
public static Mutation toMutation(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto proto) throws IOException
proto
- the protocol buffer Mutate to convertIOException
public static Get toGet(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto proto, CellScanner cellScanner) throws IOException
proto
- the protocol buffer Mutate to convert. n * @return the converted client get. nIOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Scan.ReadType toReadType(Scan.ReadType readType)
public static Scan.ReadType toReadType(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Scan.ReadType readType)
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Scan toScan(Scan scan) throws IOException
scan
- the client Scan to convertIOException
public static Scan toScan(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Scan proto) throws IOException
proto
- the protocol buffer Scan to convertIOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Get toGet(Get get) throws IOException
get
- the client GetIOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto toMutation(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType type, Mutation mutation) throws IOException
IOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto toMutation(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType type, Mutation mutation, long nonce) throws IOException
IOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto toMutation(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType type, Mutation mutation, org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.Builder builder) throws IOException
IOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto toMutation(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType type, Mutation mutation, org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.Builder builder, long nonce) throws IOException
IOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto toMutationNoData(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType type, Mutation mutation, org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.Builder builder) throws IOException
IOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto toMutationNoData(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType type, Mutation mutation) throws IOException
IOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto toMutationNoData(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.MutationType type, Mutation mutation, org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.Builder builder, long nonce) throws IOException
IOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Result toResult(Result result)
result
- the client Result to convertpublic static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Result toResult(boolean existence, boolean stale)
existence
- the client existence to sendpublic static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Result toResultNoData(Result result)
result
- the client Result to convertpublic static Result toResult(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Result proto)
proto
- the protocol buffer Result to convertpublic static Result toResult(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Result proto, CellScanner scanner) throws IOException
proto
- the protocol buffer Result to convertscanner
- Optional cell scanner.IOException
public static org.apache.hadoop.hbase.protobuf.generated.ComparatorProtos.Comparator toComparator(ByteArrayComparable comparator)
comparator
- the ByteArrayComparable to convertpublic static ByteArrayComparable toComparator(org.apache.hadoop.hbase.protobuf.generated.ComparatorProtos.Comparator proto) throws IOException
proto
- the protocol buffer Comparator to convertIOException
public static Filter toFilter(org.apache.hadoop.hbase.protobuf.generated.FilterProtos.Filter proto) throws IOException
proto
- the protocol buffer Filter to convertIOException
public static org.apache.hadoop.hbase.protobuf.generated.FilterProtos.Filter toFilter(Filter filter) throws IOException
filter
- the Filter to convertIOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.DeleteType toDeleteType(KeyValue.Type type) throws IOException
IOException
public static KeyValue.Type fromDeleteType(org.apache.hadoop.hbase.protobuf.generated.ClientProtos.MutationProto.DeleteType type) throws IOException
type
- The DeleteTypeIOException
public static Throwable toException(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.NameBytesPair parameter) throws IOException
parameter
- the protocol buffer Parameter to convertIOException
- if failed to deserialize the parameterpublic static <T extends com.google.protobuf.Service> T newServiceStub(Class<T> service, com.google.protobuf.RpcChannel channel) throws Exception
Exception
public static org.apache.hadoop.hbase.protobuf.generated.AdminProtos.ServerInfo getServerInfo(com.google.protobuf.RpcController controller, org.apache.hadoop.hbase.protobuf.generated.AdminProtos.AdminService.BlockingInterface admin) throws IOException
IOException
public static org.apache.hadoop.hbase.protobuf.generated.AdminProtos.GetServerInfoRequest buildGetServerInfoRequest()
public static ScanMetrics toScanMetrics(byte[] bytes)
public static void toIOException(com.google.protobuf.ServiceException se) throws IOException
se
- the ServiceException
instance to convert into an IOException
IOException
public static org.apache.hadoop.hbase.protobuf.generated.CellProtos.Cell toCell(Cell kv)
public static Cell toCell(ExtendedCellBuilder cellBuilder, org.apache.hadoop.hbase.protobuf.generated.CellProtos.Cell cell)
public static TableName toTableName(org.apache.hadoop.hbase.protobuf.generated.TableProtos.TableName tableNamePB)
public static org.apache.hadoop.hbase.protobuf.generated.TableProtos.TableName toProtoTableName(TableName tableName)
public static void mergeFrom(com.google.protobuf.Message.Builder builder, byte[] b) throws IOException
builder
- current message builderb
- byte array nIOException
public static void mergeFrom(com.google.protobuf.Message.Builder builder, byte[] b, int offset, int length) throws IOException
builder
- current message builderb
- byte array nnnIOException
public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription.Type createProtosSnapShotDescType(SnapshotType type)
HBaseProtos.SnapshotDescription.Type
from SnapshotType
type
- the SnapshotDescription typepublic static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier buildRegionSpecifier(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.RegionSpecifier.RegionSpecifierType type, byte[] value)
type
- the region specifier typevalue
- the region specifier byte array valuepublic static ServerName toServerName(byte[] data) throws DeserializationException
data
- Data with a serialize server name in it; can handle the old style servername where
servername was host and port. Works too with data that begins w/ the pb 'PBUF'
magic and that is then followed by a protobuf that has a serialized
ServerName
in it.data
is null else converts passed data to a ServerName
instance. nDeserializationException
public static RSGroupInfo toGroupInfo(org.apache.hadoop.hbase.protobuf.generated.RSGroupProtos.RSGroupInfo proto)
public static org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TimeRange toTimeRange(TimeRange timeRange)
public static TimeRange toTimeRange(org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.TimeRange timeRange)
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Condition toCondition(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, Filter filter, TimeRange timeRange) throws IOException
IOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Condition toCondition(byte[] row, Filter filter, TimeRange timeRange) throws IOException
IOException
public static org.apache.hadoop.hbase.protobuf.generated.ClientProtos.Condition toCondition(byte[] row, byte[] family, byte[] qualifier, CompareOperator op, byte[] value, TimeRange timeRange) throws IOException
IOException
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.