Search in sources :

Example 1 with InvalidProtocolBufferException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.

the class MetaTableLocator method getMetaRegionState.

/**
   * Load the meta region state from the meta server ZNode.
   * @param zkw
   * @param replicaId
   * @return regionstate
   * @throws KeeperException
   */
public static RegionState getMetaRegionState(ZooKeeperWatcher zkw, int replicaId) throws KeeperException {
    RegionState.State state = RegionState.State.OPEN;
    ServerName serverName = null;
    try {
        byte[] data = ZKUtil.getData(zkw, zkw.znodePaths.getZNodeForReplica(replicaId));
        if (data != null && data.length > 0 && ProtobufUtil.isPBMagicPrefix(data)) {
            try {
                int prefixLen = ProtobufUtil.lengthOfPBMagic();
                ZooKeeperProtos.MetaRegionServer rl = ZooKeeperProtos.MetaRegionServer.PARSER.parseFrom(data, prefixLen, data.length - prefixLen);
                if (rl.hasState()) {
                    state = RegionState.State.convert(rl.getState());
                }
                HBaseProtos.ServerName sn = rl.getServer();
                serverName = ServerName.valueOf(sn.getHostName(), sn.getPort(), sn.getStartCode());
            } catch (InvalidProtocolBufferException e) {
                throw new DeserializationException("Unable to parse meta region location");
            }
        } else {
            // old style of meta region location?
            serverName = ProtobufUtil.parseServerNameFrom(data);
        }
    } catch (DeserializationException e) {
        throw ZKUtil.convert(e);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    if (serverName == null) {
        state = RegionState.State.OFFLINE;
    }
    return new RegionState(RegionReplicaUtil.getRegionInfoForReplica(HRegionInfo.FIRST_META_REGIONINFO, replicaId), state, serverName);
}
Also used : MetaRegionServer(org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos.MetaRegionServer) RegionState(org.apache.hadoop.hbase.master.RegionState) ServerName(org.apache.hadoop.hbase.ServerName) InvalidProtocolBufferException(org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException) ZooKeeperProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ZooKeeperProtos) HBaseProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 2 with InvalidProtocolBufferException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.

the class ProtobufUtil method toScanMetrics.

public static ScanMetrics toScanMetrics(final byte[] bytes) {
    MapReduceProtos.ScanMetrics pScanMetrics = null;
    try {
        pScanMetrics = MapReduceProtos.ScanMetrics.parseFrom(bytes);
    } catch (InvalidProtocolBufferException e) {
    // Ignored there are just no key values to add.
    }
    ScanMetrics scanMetrics = new ScanMetrics();
    if (pScanMetrics != null) {
        for (HBaseProtos.NameInt64Pair pair : pScanMetrics.getMetricsList()) {
            if (pair.hasName() && pair.hasValue()) {
                scanMetrics.setCounter(pair.getName(), pair.getValue());
            }
        }
    }
    return scanMetrics;
}
Also used : MapReduceProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.MapReduceProtos) InvalidProtocolBufferException(org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException) ScanMetrics(org.apache.hadoop.hbase.client.metrics.ScanMetrics) HBaseProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)

Example 3 with InvalidProtocolBufferException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.

the class BitComparator method parseFrom.

/**
   * @param pbBytes A pb serialized {@link BitComparator} instance
   * @return An instance of {@link BitComparator} made from <code>bytes</code>
   * @throws DeserializationException
   * @see #toByteArray
   */
public static BitComparator parseFrom(final byte[] pbBytes) throws DeserializationException {
    ComparatorProtos.BitComparator proto;
    try {
        proto = ComparatorProtos.BitComparator.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    BitwiseOp bitwiseOp = BitwiseOp.valueOf(proto.getBitwiseOp().name());
    return new BitComparator(proto.getComparable().getValue().toByteArray(), bitwiseOp);
}
Also used : ComparatorProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.ComparatorProtos) InvalidProtocolBufferException(org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 4 with InvalidProtocolBufferException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.

the class DependentColumnFilter method parseFrom.

/**
   * @param pbBytes A pb serialized {@link DependentColumnFilter} instance
   * @return An instance of {@link DependentColumnFilter} made from <code>bytes</code>
   * @throws DeserializationException
   * @see #toByteArray
   */
public static DependentColumnFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.DependentColumnFilter proto;
    try {
        proto = FilterProtos.DependentColumnFilter.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    final CompareOp valueCompareOp = CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
    ByteArrayComparable valueComparator = null;
    try {
        if (proto.getCompareFilter().hasComparator()) {
            valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
        }
    } catch (IOException ioe) {
        throw new DeserializationException(ioe);
    }
    return new DependentColumnFilter(proto.hasColumnFamily() ? proto.getColumnFamily().toByteArray() : null, proto.hasColumnQualifier() ? proto.getColumnQualifier().toByteArray() : null, proto.getDropDependentColumn(), valueCompareOp, valueComparator);
}
Also used : InvalidProtocolBufferException(org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException) FilterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos) IOException(java.io.IOException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 5 with InvalidProtocolBufferException

use of org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException in project hbase by apache.

the class FamilyFilter method parseFrom.

/**
   * @param pbBytes A pb serialized {@link FamilyFilter} instance
   * @return An instance of {@link FamilyFilter} made from <code>bytes</code>
   * @throws DeserializationException
   * @see #toByteArray
   */
public static FamilyFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.FamilyFilter proto;
    try {
        proto = FilterProtos.FamilyFilter.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    final CompareOp valueCompareOp = CompareOp.valueOf(proto.getCompareFilter().getCompareOp().name());
    ByteArrayComparable valueComparator = null;
    try {
        if (proto.getCompareFilter().hasComparator()) {
            valueComparator = ProtobufUtil.toComparator(proto.getCompareFilter().getComparator());
        }
    } catch (IOException ioe) {
        throw new DeserializationException(ioe);
    }
    return new FamilyFilter(valueCompareOp, valueComparator);
}
Also used : InvalidProtocolBufferException(org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException) FilterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos) IOException(java.io.IOException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Aggregations

InvalidProtocolBufferException (org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException)19 DeserializationException (org.apache.hadoop.hbase.exceptions.DeserializationException)15 FilterProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos)12 IOException (java.io.IOException)9 ArrayList (java.util.ArrayList)4 FSDataInputStream (org.apache.hadoop.fs.FSDataInputStream)3 Path (org.apache.hadoop.fs.Path)2 CompareOp (org.apache.hadoop.hbase.filter.CompareFilter.CompareOp)2 CodedInputStream (org.apache.hadoop.hbase.shaded.com.google.protobuf.CodedInputStream)2 ComparatorProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.ComparatorProtos)2 HBaseProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)2 FileNotFoundException (java.io.FileNotFoundException)1 InterruptedIOException (java.io.InterruptedIOException)1 IllegalCharsetNameException (java.nio.charset.IllegalCharsetNameException)1 TreeSet (java.util.TreeSet)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorCompletionService (java.util.concurrent.ExecutorCompletionService)1 FileStatus (org.apache.hadoop.fs.FileStatus)1 PathFilter (org.apache.hadoop.fs.PathFilter)1 ServerName (org.apache.hadoop.hbase.ServerName)1