org.apache.hadoop.hbase.exceptions.DeserializationException Java Examples
The following examples show how to use
org.apache.hadoop.hbase.exceptions.DeserializationException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ColumnValueFilter.java From hbase with Apache License 2.0 | 6 votes |
/** * Parse protobuf bytes to a ColumnValueFilter * @param pbBytes pbBytes * @return a ColumnValueFilter * @throws DeserializationException deserialization exception */ public static ColumnValueFilter parseFrom(final byte[] pbBytes) throws DeserializationException { FilterProtos.ColumnValueFilter proto; try { proto = FilterProtos.ColumnValueFilter.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } final CompareOperator compareOp = CompareOperator.valueOf(proto.getCompareOp().name()); final ByteArrayComparable comparator; try { comparator = ProtobufUtil.toComparator(proto.getComparator()); } catch (IOException ioe) { throw new DeserializationException(ioe); } return new ColumnValueFilter(proto.getFamily().toByteArray(), proto.getQualifier().toByteArray(), compareOp, comparator); }
Example #2
Source File: FirstKeyValueMatchingQualifiersFilter.java From hbase with Apache License 2.0 | 6 votes |
/** * @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); }
Example #3
Source File: VisibilityLabelsCache.java From hbase with Apache License 2.0 | 6 votes |
public void refreshLabelsCache(byte[] data) throws IOException { List<VisibilityLabel> visibilityLabels = null; try { visibilityLabels = VisibilityUtils.readLabelsFromZKData(data); } catch (DeserializationException dse) { throw new IOException(dse); } this.lock.writeLock().lock(); try { labels.clear(); ordinalVsLabels.clear(); for (VisibilityLabel visLabel : visibilityLabels) { String label = Bytes.toString(visLabel.getLabel().toByteArray()); labels.put(label, visLabel.getOrdinal()); ordinalVsLabels.put(visLabel.getOrdinal(), label); } } finally { this.lock.writeLock().unlock(); } }
Example #4
Source File: SingleColumnValueExcludeFilter.java From hbase with Apache License 2.0 | 6 votes |
/** * @param pbBytes A pb serialized {@link SingleColumnValueExcludeFilter} instance * @return An instance of {@link SingleColumnValueExcludeFilter} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static SingleColumnValueExcludeFilter parseFrom(final byte [] pbBytes) throws DeserializationException { FilterProtos.SingleColumnValueExcludeFilter proto; try { proto = FilterProtos.SingleColumnValueExcludeFilter.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } FilterProtos.SingleColumnValueFilter parentProto = proto.getSingleColumnValueFilter(); final CompareOperator compareOp = CompareOperator.valueOf(parentProto.getCompareOp().name()); final ByteArrayComparable comparator; try { comparator = ProtobufUtil.toComparator(parentProto.getComparator()); } catch (IOException ioe) { throw new DeserializationException(ioe); } return new SingleColumnValueExcludeFilter(parentProto.hasColumnFamily() ? parentProto .getColumnFamily().toByteArray() : null, parentProto.hasColumnQualifier() ? parentProto .getColumnQualifier().toByteArray() : null, compareOp, comparator, parentProto .getFilterIfMissing(), parentProto.getLatestVersionOnly()); }
Example #5
Source File: ZKReplicationQueueStorage.java From hbase with Apache License 2.0 | 6 votes |
/** * Return the {lastPushedSequenceId, ZNodeDataVersion} pair. if ZNodeDataVersion is -1, it means * that the ZNode does not exist. */ @VisibleForTesting protected Pair<Long, Integer> getLastSequenceIdWithVersion(String encodedRegionName, String peerId) throws KeeperException { Stat stat = new Stat(); String path = getSerialReplicationRegionPeerNode(encodedRegionName, peerId); byte[] data = ZKUtil.getDataNoWatch(zookeeper, path, stat); if (data == null) { // ZNode does not exist, so just return version -1 to indicate that no node exist. return Pair.newPair(HConstants.NO_SEQNUM, -1); } try { return Pair.newPair(ZKUtil.parseWALPositionFrom(data), stat.getVersion()); } catch (DeserializationException de) { LOG.warn("Failed to parse log position (region=" + encodedRegionName + ", peerId=" + peerId + "), data=" + Bytes.toStringBinary(data)); } return Pair.newPair(HConstants.NO_SEQNUM, stat.getVersion()); }
Example #6
Source File: ClusterId.java From hbase with Apache License 2.0 | 6 votes |
/** * @param bytes A pb serialized {@link ClusterId} instance with pb magic prefix * @return An instance of {@link ClusterId} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray() */ public static ClusterId parseFrom(final byte [] bytes) throws DeserializationException { if (ProtobufUtil.isPBMagicPrefix(bytes)) { int pblen = ProtobufUtil.lengthOfPBMagic(); ClusterIdProtos.ClusterId.Builder builder = ClusterIdProtos.ClusterId.newBuilder(); ClusterIdProtos.ClusterId cid = null; try { ProtobufUtil.mergeFrom(builder, bytes, pblen, bytes.length - pblen); cid = builder.build(); } catch (IOException e) { throw new DeserializationException(e); } return convert(cid); } else { // Presume it was written out this way, the old way. return new ClusterId(Bytes.toString(bytes)); } }
Example #7
Source File: FuzzyRowFilter.java From hbase with Apache License 2.0 | 6 votes |
/** * @param pbBytes A pb serialized {@link FuzzyRowFilter} instance * @return An instance of {@link FuzzyRowFilter} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static FuzzyRowFilter parseFrom(final byte[] pbBytes) throws DeserializationException { FilterProtos.FuzzyRowFilter proto; try { proto = FilterProtos.FuzzyRowFilter.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } int count = proto.getFuzzyKeysDataCount(); ArrayList<Pair<byte[], byte[]>> fuzzyKeysData = new ArrayList<>(count); for (int i = 0; i < count; ++i) { BytesBytesPair current = proto.getFuzzyKeysData(i); byte[] keyBytes = current.getFirst().toByteArray(); byte[] keyMeta = current.getSecond().toByteArray(); fuzzyKeysData.add(new Pair<>(keyBytes, keyMeta)); } return new FuzzyRowFilter(fuzzyKeysData); }
Example #8
Source File: SingleColumnValueFilter.java From hbase with Apache License 2.0 | 6 votes |
/** * @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 CompareOperator compareOp = CompareOperator.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()); }
Example #9
Source File: TestHTableDescriptor.java From hbase with Apache License 2.0 | 6 votes |
@Test public void testPb() throws DeserializationException, IOException { HTableDescriptor htd = new HTableDescriptor(TableName.META_TABLE_NAME); final int v = 123; htd.setMaxFileSize(v); htd.setDurability(Durability.ASYNC_WAL); htd.setReadOnly(true); htd.setRegionReplication(2); byte [] bytes = htd.toByteArray(); HTableDescriptor deserializedHtd = HTableDescriptor.parseFrom(bytes); assertEquals(htd, deserializedHtd); assertEquals(v, deserializedHtd.getMaxFileSize()); assertTrue(deserializedHtd.isReadOnly()); assertEquals(Durability.ASYNC_WAL, deserializedHtd.getDurability()); assertEquals(2, deserializedHtd.getRegionReplication()); }
Example #10
Source File: QualifierFilter.java From hbase with Apache License 2.0 | 6 votes |
/** * @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 CompareOperator valueCompareOp = CompareOperator.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); }
Example #11
Source File: HBaseNumericIndexStrategyFilter.java From geowave with Apache License 2.0 | 6 votes |
public static HBaseNumericIndexStrategyFilter parseFrom(final byte[] pbBytes) throws DeserializationException { final ByteBuffer buf = ByteBuffer.wrap(pbBytes); NumericIndexStrategy indexStrategy; MultiDimensionalCoordinateRangesArray[] coordinateRanges; try { final int indexStrategyLength = VarintUtils.readUnsignedInt(buf); final byte[] indexStrategyBytes = new byte[indexStrategyLength]; buf.get(indexStrategyBytes); indexStrategy = (NumericIndexStrategy) URLClassloaderUtils.fromBinary(indexStrategyBytes); final byte[] coordRangeBytes = new byte[buf.remaining()]; buf.get(coordRangeBytes); final ArrayOfArrays arrays = new ArrayOfArrays(); arrays.fromBinary(coordRangeBytes); coordinateRanges = arrays.getCoordinateArrays(); } catch (final Exception e) { throw new DeserializationException("Unable to read parameters", e); } return new HBaseNumericIndexStrategyFilter(indexStrategy, coordinateRanges); }
Example #12
Source File: LoadBalancerTracker.java From hbase with Apache License 2.0 | 5 votes |
/** * Return true if the balance switch is on, false otherwise */ public boolean isBalancerOn() { byte [] upData = super.getData(false); try { // if data in ZK is null, use default of on. return upData == null || parseFrom(upData).getBalancerOn(); } catch (DeserializationException dex) { LOG.error("ZK state for LoadBalancer could not be parsed {}", Bytes.toStringBinary(upData)); // return false to be safe. return false; } }
Example #13
Source File: HTableDescriptor.java From hbase with Apache License 2.0 | 5 votes |
/** * @param bytes A pb serialized {@link HTableDescriptor} instance with pb magic prefix * @return An instance of {@link HTableDescriptor} made from <code>bytes</code> * @throws DeserializationException * @throws IOException * @see #toByteArray() */ public static HTableDescriptor parseFrom(final byte [] bytes) throws DeserializationException, IOException { TableDescriptor desc = TableDescriptorBuilder.parseFrom(bytes); if (desc instanceof ModifyableTableDescriptor) { return new HTableDescriptor((ModifyableTableDescriptor) desc); } else { return new HTableDescriptor(desc); } }
Example #14
Source File: TableState.java From hbase with Apache License 2.0 | 5 votes |
public static TableState parseFrom(TableName tableName, byte[] bytes) throws DeserializationException { try { return convert(tableName, HBaseProtos.TableState.parseFrom(bytes)); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } }
Example #15
Source File: ColumnCountGetFilter.java From hbase with Apache License 2.0 | 5 votes |
/** * @param pbBytes A pb serialized {@link ColumnCountGetFilter} instance * @return An instance of {@link ColumnCountGetFilter} made from <code>bytes</code> * @throws org.apache.hadoop.hbase.exceptions.DeserializationException * @see #toByteArray */ public static ColumnCountGetFilter parseFrom(final byte [] pbBytes) throws DeserializationException { FilterProtos.ColumnCountGetFilter proto; try { proto = FilterProtos.ColumnCountGetFilter.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } return new ColumnCountGetFilter(proto.getLimit()); }
Example #16
Source File: TableDescriptorBuilder.java From hbase with Apache License 2.0 | 5 votes |
/** * @param bytes A pb serialized {@link ModifyableTableDescriptor} instance * with pb magic prefix * @return An instance of {@link ModifyableTableDescriptor} made from * <code>bytes</code> * @throws DeserializationException * @see #toByteArray() */ private static TableDescriptor parseFrom(final byte[] bytes) throws DeserializationException { if (!ProtobufUtil.isPBMagicPrefix(bytes)) { throw new DeserializationException("Expected PB encoded ModifyableTableDescriptor"); } int pblen = ProtobufUtil.lengthOfPBMagic(); HBaseProtos.TableSchema.Builder builder = HBaseProtos.TableSchema.newBuilder(); try { ProtobufUtil.mergeFrom(builder, bytes, pblen, bytes.length - pblen); return ProtobufUtil.toTableDescriptor(builder.build()); } catch (IOException e) { throw new DeserializationException(e); } }
Example #17
Source File: BinaryComponentComparator.java From hbase with Apache License 2.0 | 5 votes |
/** * @param pbBytes A pb serialized {@link BinaryComponentComparator} instance * @return An instance of {@link BinaryComponentComparator} made from <code>bytes</code> * @throws DeserializationException DeserializationException * @see #toByteArray */ public static BinaryComponentComparator parseFrom(final byte[] pbBytes) throws DeserializationException { ComparatorProtos.BinaryComponentComparator proto; try { proto = ComparatorProtos.BinaryComponentComparator.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } return new BinaryComponentComparator(proto.getValue().toByteArray(), proto.getOffset()); }
Example #18
Source File: WhileMatchFilter.java From hbase with Apache License 2.0 | 5 votes |
/** * @param pbBytes A pb serialized {@link WhileMatchFilter} instance * @return An instance of {@link WhileMatchFilter} made from <code>bytes</code> * @throws org.apache.hadoop.hbase.exceptions.DeserializationException * @see #toByteArray */ public static WhileMatchFilter parseFrom(final byte [] pbBytes) throws DeserializationException { FilterProtos.WhileMatchFilter proto; try { proto = FilterProtos.WhileMatchFilter.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } try { return new WhileMatchFilter(ProtobufUtil.toFilter(proto.getFilter())); } catch (IOException ioe) { throw new DeserializationException(ioe); } }
Example #19
Source File: RawAsyncHBaseAdmin.java From hbase with Apache License 2.0 | 5 votes |
@Override public CompletableFuture<Void> mergeRegions(List<byte[]> nameOfRegionsToMerge, boolean forcible) { if (nameOfRegionsToMerge.size() < 2) { return failedFuture(new IllegalArgumentException( "Can not merge only " + nameOfRegionsToMerge.size() + " region")); } CompletableFuture<Void> future = new CompletableFuture<>(); byte[][] encodedNameOfRegionsToMerge = nameOfRegionsToMerge.stream().map(this::toEncodeRegionName).toArray(byte[][]::new); addListener(checkRegionsAndGetTableName(encodedNameOfRegionsToMerge), (tableName, err) -> { if (err != null) { future.completeExceptionally(err); return; } final MergeTableRegionsRequest request; try { request = RequestConverter.buildMergeTableRegionsRequest(encodedNameOfRegionsToMerge, forcible, ng.getNonceGroup(), ng.newNonce()); } catch (DeserializationException e) { future.completeExceptionally(e); return; } addListener( this.procedureCall(tableName, request, MasterService.Interface::mergeTableRegions, MergeTableRegionsResponse::getProcId, new MergeTableRegionProcedureBiConsumer(tableName)), (ret, err2) -> { if (err2 != null) { future.completeExceptionally(err2); } else { future.complete(ret); } }); }); return future; }
Example #20
Source File: BinaryComparator.java From hbase with Apache License 2.0 | 5 votes |
/** * @param pbBytes A pb serialized {@link BinaryComparator} instance * @return An instance of {@link BinaryComparator} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static BinaryComparator parseFrom(final byte [] pbBytes) throws DeserializationException { ComparatorProtos.BinaryComparator proto; try { proto = ComparatorProtos.BinaryComparator.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } return new BinaryComparator(proto.getComparable().getValue().toByteArray()); }
Example #21
Source File: RequestConverter.java From hbase with Apache License 2.0 | 5 votes |
public static MergeTableRegionsRequest buildMergeTableRegionsRequest( final byte[][] encodedNameOfdaughaterRegions, final boolean forcible, final long nonceGroup, final long nonce) throws DeserializationException { MergeTableRegionsRequest.Builder builder = MergeTableRegionsRequest.newBuilder(); for (int i = 0; i< encodedNameOfdaughaterRegions.length; i++) { builder.addRegion(buildRegionSpecifier( RegionSpecifierType.ENCODED_REGION_NAME, encodedNameOfdaughaterRegions[i])); } builder.setForcible(forcible); builder.setNonceGroup(nonceGroup); builder.setNonce(nonce); return builder.build(); }
Example #22
Source File: MasterAddressTracker.java From hbase with Apache License 2.0 | 5 votes |
/** * @param data zookeeper data. may be null * @return pb object of master, null if no active master * @throws DeserializationException if the parsing fails */ public static ZooKeeperProtos.Master parse(byte[] data) throws DeserializationException { if (data == null) { return null; } int prefixLen = ProtobufUtil.lengthOfPBMagic(); try { return ZooKeeperProtos.Master.PARSER.parseFrom(data, prefixLen, data.length - prefixLen); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } }
Example #23
Source File: EncodedQualifiersColumnProjectionFilter.java From phoenix with Apache License 2.0 | 5 votes |
public static EncodedQualifiersColumnProjectionFilter parseFrom(final byte [] pbBytes) throws DeserializationException { try { return (EncodedQualifiersColumnProjectionFilter)Writables.getWritable(pbBytes, new EncodedQualifiersColumnProjectionFilter()); } catch (IOException e) { throw new DeserializationException(e); } }
Example #24
Source File: TestRegionInfo.java From hbase with Apache License 2.0 | 5 votes |
@Test public void testPb() throws DeserializationException { RegionInfo hri = RegionInfoBuilder.FIRST_META_REGIONINFO; byte [] bytes = RegionInfo.toByteArray(hri); RegionInfo pbhri = RegionInfo.parseFrom(bytes); assertTrue(hri.equals(pbhri)); }
Example #25
Source File: ColumnRangeFilter.java From hbase with Apache License 2.0 | 5 votes |
/** * @param pbBytes A pb serialized {@link ColumnRangeFilter} instance * @return An instance of {@link ColumnRangeFilter} made from <code>bytes</code> * @throws DeserializationException * @see #toByteArray */ public static ColumnRangeFilter parseFrom(final byte [] pbBytes) throws DeserializationException { FilterProtos.ColumnRangeFilter proto; try { proto = FilterProtos.ColumnRangeFilter.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } return new ColumnRangeFilter(proto.hasMinColumn()?proto.getMinColumn().toByteArray():null, proto.getMinColumnInclusive(),proto.hasMaxColumn()?proto.getMaxColumn().toByteArray():null, proto.getMaxColumnInclusive()); }
Example #26
Source File: SkipScanFilter.java From phoenix with Apache License 2.0 | 5 votes |
public static SkipScanFilter parseFrom(final byte [] pbBytes) throws DeserializationException { try { return (SkipScanFilter)Writables.getWritable(pbBytes, new SkipScanFilter()); } catch (IOException e) { throw new DeserializationException(e); } }
Example #27
Source File: FSUtils.java From hbase with Apache License 2.0 | 5 votes |
/** * Parse the content of the ${HBASE_ROOTDIR}/hbase.version file. * @param bytes The byte content of the hbase.version file * @return The version found in the file as a String * @throws DeserializationException if the version data cannot be translated into a version */ static String parseVersionFrom(final byte [] bytes) throws DeserializationException { ProtobufUtil.expectPBMagicPrefix(bytes); int pblen = ProtobufUtil.lengthOfPBMagic(); FSProtos.HBaseVersionFileContent.Builder builder = FSProtos.HBaseVersionFileContent.newBuilder(); try { ProtobufUtil.mergeFrom(builder, bytes, pblen, bytes.length - pblen); return builder.getVersion(); } catch (IOException e) { // Convert throw new DeserializationException(e); } }
Example #28
Source File: FSUtils.java From hbase with Apache License 2.0 | 5 votes |
/** * Verifies current version of file system * * @param fs filesystem object * @param rootdir root hbase directory * @return null if no version file exists, version string otherwise * @throws IOException if the version file fails to open * @throws DeserializationException if the version data cannot be translated into a version */ public static String getVersion(FileSystem fs, Path rootdir) throws IOException, DeserializationException { final Path versionFile = new Path(rootdir, HConstants.VERSION_FILE_NAME); FileStatus[] status = null; try { // hadoop 2.0 throws FNFE if directory does not exist. // hadoop 1.0 returns null if directory does not exist. status = fs.listStatus(versionFile); } catch (FileNotFoundException fnfe) { return null; } if (ArrayUtils.getLength(status) == 0) { return null; } String version = null; byte [] content = new byte [(int)status[0].getLen()]; FSDataInputStream s = fs.open(versionFile); try { IOUtils.readFully(s, content, 0, content.length); if (ProtobufUtil.isPBMagicPrefix(content)) { version = parseVersionFrom(content); } else { // Presume it pre-pb format. try (DataInputStream dis = new DataInputStream(new ByteArrayInputStream(content))) { version = dis.readUTF(); } } } catch (EOFException eof) { LOG.warn("Version file was empty, odd, will try to set it."); } finally { s.close(); } return version; }
Example #29
Source File: RSGroupInfoManagerImpl.java From hbase with Apache License 2.0 | 5 votes |
private List<RSGroupInfo> retrieveGroupListFromZookeeper() throws IOException { String groupBasePath = ZNodePaths.joinZNode(watcher.getZNodePaths().baseZNode, RS_GROUP_ZNODE); List<RSGroupInfo> RSGroupInfoList = Lists.newArrayList(); // Overwrite any info stored by table, this takes precedence try { if (ZKUtil.checkExists(watcher, groupBasePath) != -1) { List<String> children = ZKUtil.listChildrenAndWatchForNewChildren(watcher, groupBasePath); if (children == null) { return RSGroupInfoList; } for (String znode : children) { byte[] data = ZKUtil.getData(watcher, ZNodePaths.joinZNode(groupBasePath, znode)); if (data.length > 0) { ProtobufUtil.expectPBMagicPrefix(data); ByteArrayInputStream bis = new ByteArrayInputStream(data, ProtobufUtil.lengthOfPBMagic(), data.length); RSGroupInfoList .add(ProtobufUtil.toGroupInfo(RSGroupProtos.RSGroupInfo.parseFrom(bis))); } } LOG.debug("Read ZK GroupInfo count:" + RSGroupInfoList.size()); } } catch (KeeperException | DeserializationException | InterruptedException e) { throw new IOException("Failed to read rsGroupZNode", e); } return RSGroupInfoList; }
Example #30
Source File: HBaseDoubleComparator.java From pxf with Apache License 2.0 | 5 votes |
public static ByteArrayComparable parseFrom(final byte[] pbBytes) throws DeserializationException { ComparatorProtos.ByteArrayComparable proto; try { proto = ComparatorProtos.ByteArrayComparable.parseFrom(pbBytes); } catch (InvalidProtocolBufferException e) { throw new DeserializationException(e); } return new HBaseDoubleComparator(Bytes.toDouble(proto.getValue().toByteArray())); }