Search in sources :

Example 31 with DeserializationException

use of org.apache.hadoop.hbase.exceptions.DeserializationException in project hbase by apache.

the class MasterAddressTracker method deleteIfEquals.

/**
 * delete the master znode if its content is same as the parameter
 * @param zkw must not be null
 * @param content must not be null
 */
public static boolean deleteIfEquals(ZKWatcher zkw, final String content) {
    if (content == null) {
        throw new IllegalArgumentException("Content must not be null");
    }
    try {
        Stat stat = new Stat();
        byte[] data = ZKUtil.getDataNoWatch(zkw, zkw.getZNodePaths().masterAddressZNode, stat);
        ServerName sn = ProtobufUtil.parseServerNameFrom(data);
        if (sn != null && content.equals(sn.toString())) {
            return (ZKUtil.deleteNode(zkw, zkw.getZNodePaths().masterAddressZNode, stat.getVersion()));
        }
    } catch (KeeperException e) {
        LOG.warn("Can't get or delete the master znode", e);
    } catch (DeserializationException e) {
        LOG.warn("Can't get or delete the master znode", e);
    }
    return false;
}
Also used : Stat(org.apache.zookeeper.data.Stat) ServerName(org.apache.hadoop.hbase.ServerName) KeeperException(org.apache.zookeeper.KeeperException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 32 with DeserializationException

use of org.apache.hadoop.hbase.exceptions.DeserializationException in project hbase by apache.

the class MetaTableLocator method getMetaRegionState.

/**
 * Load the meta region state from the meta region server ZNode.
 *
 * @param zkw reference to the {@link ZKWatcher} which also contains configuration and operation
 * @param replicaId the ID of the replica
 * @return regionstate
 * @throws KeeperException if a ZooKeeper operation fails
 */
public static RegionState getMetaRegionState(ZKWatcher zkw, int replicaId) throws KeeperException {
    RegionState regionState = null;
    try {
        byte[] data = ZKUtil.getData(zkw, zkw.getZNodePaths().getZNodeForReplica(replicaId));
        regionState = ProtobufUtil.parseMetaRegionStateFrom(data, replicaId);
    } catch (DeserializationException e) {
        throw ZKUtil.convert(e);
    } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
    }
    return regionState;
}
Also used : RegionState(org.apache.hadoop.hbase.master.RegionState) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 33 with DeserializationException

use of org.apache.hadoop.hbase.exceptions.DeserializationException in project hbase by apache.

the class RegionNormalizerTracker method parseFrom.

private RegionNormalizerProtos.RegionNormalizerState parseFrom(byte[] pbBytes) throws DeserializationException {
    ProtobufUtil.expectPBMagicPrefix(pbBytes);
    RegionNormalizerProtos.RegionNormalizerState.Builder builder = RegionNormalizerProtos.RegionNormalizerState.newBuilder();
    try {
        int magicLen = ProtobufUtil.lengthOfPBMagic();
        ProtobufUtil.mergeFrom(builder, pbBytes, magicLen, pbBytes.length - magicLen);
    } catch (IOException e) {
        throw new DeserializationException(e);
    }
    return builder.build();
}
Also used : IOException(java.io.IOException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 34 with DeserializationException

use of org.apache.hadoop.hbase.exceptions.DeserializationException in project hbase by apache.

the class LoadBalancerTracker method parseFrom.

private LoadBalancerProtos.LoadBalancerState parseFrom(byte[] pbBytes) throws DeserializationException {
    ProtobufUtil.expectPBMagicPrefix(pbBytes);
    LoadBalancerProtos.LoadBalancerState.Builder builder = LoadBalancerProtos.LoadBalancerState.newBuilder();
    try {
        int magicLen = ProtobufUtil.lengthOfPBMagic();
        ProtobufUtil.mergeFrom(builder, pbBytes, magicLen, pbBytes.length - magicLen);
    } catch (IOException e) {
        throw new DeserializationException(e);
    }
    return builder.build();
}
Also used : IOException(java.io.IOException) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException)

Example 35 with DeserializationException

use of org.apache.hadoop.hbase.exceptions.DeserializationException in project hbase by apache.

the class ThriftUtilities method appendFromHBase.

public static TAppend appendFromHBase(Append in) throws IOException {
    TAppend out = new TAppend();
    out.setRow(in.getRow());
    if (in.getDurability() != Durability.USE_DEFAULT) {
        out.setDurability(durabilityFromHBase(in.getDurability()));
    }
    for (Map.Entry<byte[], List<Cell>> entry : in.getFamilyCellMap().entrySet()) {
        byte[] family = entry.getKey();
        for (Cell cell : entry.getValue()) {
            TColumnValue columnValue = new TColumnValue();
            columnValue.setFamily(family).setQualifier(CellUtil.cloneQualifier(cell)).setType(cell.getType().getCode()).setTimestamp(cell.getTimestamp()).setValue(CellUtil.cloneValue(cell));
            if (cell.getTagsLength() != 0) {
                columnValue.setTags(PrivateCellUtil.cloneTags(cell));
            }
            out.addToColumns(columnValue);
        }
    }
    for (Map.Entry<String, byte[]> attribute : in.getAttributesMap().entrySet()) {
        out.putToAttributes(ByteBuffer.wrap(Bytes.toBytes(attribute.getKey())), ByteBuffer.wrap(attribute.getValue()));
    }
    try {
        CellVisibility cellVisibility = in.getCellVisibility();
        if (cellVisibility != null) {
            TCellVisibility tCellVisibility = new TCellVisibility();
            tCellVisibility.setExpression(cellVisibility.getExpression());
            out.setCellVisibility(tCellVisibility);
        }
    } catch (DeserializationException e) {
        throw new RuntimeException(e);
    }
    out.setReturnResults(in.isReturnResults());
    return out;
}
Also used : TCellVisibility(org.apache.hadoop.hbase.thrift2.generated.TCellVisibility) CellVisibility(org.apache.hadoop.hbase.security.visibility.CellVisibility) TColumnValue(org.apache.hadoop.hbase.thrift2.generated.TColumnValue) DeserializationException(org.apache.hadoop.hbase.exceptions.DeserializationException) TCellVisibility(org.apache.hadoop.hbase.thrift2.generated.TCellVisibility) List(java.util.List) ArrayList(java.util.ArrayList) TAppend(org.apache.hadoop.hbase.thrift2.generated.TAppend) Map(java.util.Map) Cell(org.apache.hadoop.hbase.Cell)

Aggregations

DeserializationException (org.apache.hadoop.hbase.exceptions.DeserializationException)83 IOException (java.io.IOException)57 InvalidProtocolBufferException (org.apache.hbase.thirdparty.com.google.protobuf.InvalidProtocolBufferException)15 FilterProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.FilterProtos)13 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)12 KeeperException (org.apache.zookeeper.KeeperException)12 ArrayList (java.util.ArrayList)11 ServerName (org.apache.hadoop.hbase.ServerName)9 Cell (org.apache.hadoop.hbase.Cell)8 CompareOperator (org.apache.hadoop.hbase.CompareOperator)8 InterruptedIOException (java.io.InterruptedIOException)7 CellVisibility (org.apache.hadoop.hbase.security.visibility.CellVisibility)7 ByteArrayInputStream (java.io.ByteArrayInputStream)6 Tag (org.apache.hadoop.hbase.Tag)6 HBaseProtos (org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos)6 Map (java.util.Map)5 HBaseIOException (org.apache.hadoop.hbase.HBaseIOException)5 TableName (org.apache.hadoop.hbase.TableName)5 FilterList (org.apache.hadoop.hbase.filter.FilterList)5 List (java.util.List)4