Search in sources :

Example 6 with InvalidProtocolBufferException

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

the class FilterList method parseFrom.

/**
   * @param pbBytes A pb serialized {@link FilterList} instance
   * @return An instance of {@link FilterList} made from <code>bytes</code>
   * @throws DeserializationException
   * @see #toByteArray
   */
public static FilterList parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.FilterList proto;
    try {
        proto = FilterProtos.FilterList.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    List<Filter> rowFilters = new ArrayList<>(proto.getFiltersCount());
    try {
        List<FilterProtos.Filter> filtersList = proto.getFiltersList();
        int listSize = filtersList.size();
        for (int i = 0; i < listSize; i++) {
            rowFilters.add(ProtobufUtil.toFilter(filtersList.get(i)));
        }
    } catch (IOException ioe) {
        throw new DeserializationException(ioe);
    }
    return new FilterList(Operator.valueOf(proto.getOperator().name()), rowFilters);
}
Also used : InvalidProtocolBufferException(org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException) ArrayList(java.util.ArrayList) FilterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos) IOException(java.io.IOException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 7 with InvalidProtocolBufferException

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

the class FirstKeyValueMatchingQualifiersFilter method parseFrom.

/**
   * @param pbBytes A pb serialized {@link FirstKeyValueMatchingQualifiersFilter} instance
   * @return An instance of {@link FirstKeyValueMatchingQualifiersFilter} made from <code>bytes</code>
   * @throws DeserializationException
   * @see #toByteArray
   */
public static FirstKeyValueMatchingQualifiersFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.FirstKeyValueMatchingQualifiersFilter proto;
    try {
        proto = FilterProtos.FirstKeyValueMatchingQualifiersFilter.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    TreeSet<byte[]> qualifiers = new TreeSet<>(Bytes.BYTES_COMPARATOR);
    for (ByteString qualifier : proto.getQualifiersList()) {
        qualifiers.add(qualifier.toByteArray());
    }
    return new FirstKeyValueMatchingQualifiersFilter(qualifiers);
}
Also used : TreeSet(java.util.TreeSet) ByteString(org.apache.hadoop.hbase.shaded.com.google.protobuf.ByteString) InvalidProtocolBufferException(org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException) FilterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 8 with InvalidProtocolBufferException

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

the class QualifierFilter method parseFrom.

/**
   * @param pbBytes A pb serialized {@link QualifierFilter} instance
   * @return An instance of {@link QualifierFilter} made from <code>bytes</code>
   * @throws org.apache.hadoop.hbase.exceptions.DeserializationException
   * @see #toByteArray
   */
public static QualifierFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.QualifierFilter proto;
    try {
        proto = FilterProtos.QualifierFilter.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 QualifierFilter(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 9 with InvalidProtocolBufferException

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

the class ProcedureWALFormatReader method read.

public void read(final ProcedureWALFile log) throws IOException {
    localTracker = log.getTracker().isPartial() ? log.getTracker() : null;
    if (localTracker != null) {
        LOG.info("Rebuilding tracker for log - " + log);
    }
    FSDataInputStream stream = log.getStream();
    try {
        boolean hasMore = true;
        while (hasMore) {
            ProcedureWALEntry entry = ProcedureWALFormat.readEntry(stream);
            if (entry == null) {
                LOG.warn("nothing left to decode. exiting with missing EOF");
                break;
            }
            switch(entry.getType()) {
                case PROCEDURE_WAL_INIT:
                    readInitEntry(entry);
                    break;
                case PROCEDURE_WAL_INSERT:
                    readInsertEntry(entry);
                    break;
                case PROCEDURE_WAL_UPDATE:
                case PROCEDURE_WAL_COMPACT:
                    readUpdateEntry(entry);
                    break;
                case PROCEDURE_WAL_DELETE:
                    readDeleteEntry(entry);
                    break;
                case PROCEDURE_WAL_EOF:
                    hasMore = false;
                    break;
                default:
                    throw new CorruptedWALProcedureStoreException("Invalid entry: " + entry);
            }
        }
    } catch (InvalidProtocolBufferException e) {
        LOG.error("got an exception while reading the procedure WAL: " + log, e);
        loader.markCorruptedWAL(log, e);
    }
    if (localTracker != null) {
        localTracker.setPartialFlag(false);
    }
    if (!localProcedureMap.isEmpty()) {
        log.setProcIds(localProcedureMap.getMinProcId(), localProcedureMap.getMaxProcId());
        procedureMap.mergeTail(localProcedureMap);
    //if (hasFastStartSupport) {
    // TODO: Some procedure may be already runnables (see readInitEntry())
    //       (we can also check the "update map" in the log trackers)
    // --------------------------------------------------
    //EntryIterator iter = procedureMap.fetchReady();
    //if (iter != null) loader.load(iter);
    // --------------------------------------------------
    //}
    }
}
Also used : InvalidProtocolBufferException(org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException) FSDataInputStream(org.apache.hadoop.fs.FSDataInputStream) ProcedureWALEntry(org.apache.hadoop.hbase.shaded.protobuf.generated.ProcedureProtos.ProcedureWALEntry)

Example 10 with InvalidProtocolBufferException

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

the class SingleColumnValueFilter method parseFrom.

/**
   * @param pbBytes A pb serialized {@link SingleColumnValueFilter} instance
   * @return An instance of {@link SingleColumnValueFilter} made from <code>bytes</code>
   * @throws org.apache.hadoop.hbase.exceptions.DeserializationException
   * @see #toByteArray
   */
public static SingleColumnValueFilter parseFrom(final byte[] pbBytes) throws DeserializationException {
    FilterProtos.SingleColumnValueFilter proto;
    try {
        proto = FilterProtos.SingleColumnValueFilter.parseFrom(pbBytes);
    } catch (InvalidProtocolBufferException e) {
        throw new DeserializationException(e);
    }
    final CompareOp compareOp = CompareOp.valueOf(proto.getCompareOp().name());
    final org.apache.hadoop.hbase.filter.ByteArrayComparable comparator;
    try {
        comparator = ProtobufUtil.toComparator(proto.getComparator());
    } catch (IOException ioe) {
        throw new DeserializationException(ioe);
    }
    return new SingleColumnValueFilter(proto.hasColumnFamily() ? proto.getColumnFamily().toByteArray() : null, proto.hasColumnQualifier() ? proto.getColumnQualifier().toByteArray() : null, compareOp, comparator, proto.getFilterIfMissing(), proto.getLatestVersionOnly());
}
Also used : InvalidProtocolBufferException(org.apache.hadoop.hbase.shaded.com.google.protobuf.InvalidProtocolBufferException) FilterProtos(org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos) CompareOp(org.apache.hadoop.hbase.filter.CompareFilter.CompareOp) 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