/** * Creates the labels data to be written to zookeeper. * @param existingLabels * @return Bytes form of labels and their ordinal details to be written to zookeeper. */ public static byte[] getDataToWriteToZooKeeper(Map<String, Integer> existingLabels) { VisibilityLabelsRequest.Builder visReqBuilder = VisibilityLabelsRequest.newBuilder(); for (Entry<String, Integer> entry : existingLabels.entrySet()) { VisibilityLabel.Builder visLabBuilder = VisibilityLabel.newBuilder(); visLabBuilder.setLabel(ByteString.copyFrom(Bytes.toBytes(entry.getKey()))); visLabBuilder.setOrdinal(entry.getValue()); visReqBuilder.addVisLabel(visLabBuilder.build()); } return ProtobufUtil.prependPBMagic(visReqBuilder.build().toByteArray()); }
/** * Creates the labels data to be written to zookeeper. * @param existingLabels * @return Bytes form of labels and their ordinal details to be written to zookeeper. */ public static byte[] getDataToWriteToZooKeeper(Map<String, Integer> existingLabels) { VisibilityLabelsRequest.Builder visReqBuilder = VisibilityLabelsRequest.newBuilder(); for (Entry<String, Integer> entry : existingLabels.entrySet()) { VisibilityLabel.Builder visLabBuilder = VisibilityLabel.newBuilder(); visLabBuilder.setLabel(ByteStringer.wrap(Bytes.toBytes(entry.getKey()))); visLabBuilder.setOrdinal(entry.getValue()); visReqBuilder.addVisLabel(visLabBuilder.build()); } return ProtobufUtil.prependPBMagic(visReqBuilder.build().toByteArray()); }
/** * Reads back from the zookeeper. The data read here is of the form written by * writeToZooKeeper(Map<byte[], Integer> entries). * * @param data * @return Labels and their ordinal details * @throws DeserializationException */ public static List<VisibilityLabel> readLabelsFromZKData(byte[] data) throws DeserializationException { if (ProtobufUtil.isPBMagicPrefix(data)) { int pblen = ProtobufUtil.lengthOfPBMagic(); try { VisibilityLabelsRequest.Builder builder = VisibilityLabelsRequest.newBuilder(); ProtobufUtil.mergeFrom(builder, data, pblen, data.length - pblen); return builder.getVisLabelList(); } catch (IOException e) { throw new DeserializationException(e); } } return null; }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsRequest prototype) {
public Builder toBuilder() { return newBuilder(this); }
public Builder toBuilder() { return newBuilder(this); }
public Builder toBuilder() { return newBuilder(this); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsRequest prototype) {
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsRequest prototype) {
public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsRequest prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsRequest prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsRequest prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }
/** * Reads back from the zookeeper. The data read here is of the form written by * writeToZooKeeper(Map<byte[], Integer> entries). * * @param data * @return Labels and their ordinal details * @throws DeserializationException */ public static List<VisibilityLabel> readLabelsFromZKData(byte[] data) throws DeserializationException { if (ProtobufUtil.isPBMagicPrefix(data)) { int pblen = ProtobufUtil.lengthOfPBMagic(); try { VisibilityLabelsRequest.Builder builder = VisibilityLabelsRequest.newBuilder(); ProtobufUtil.mergeFrom(builder, data, pblen, data.length - pblen); return builder.getVisLabelList(); } catch (IOException e) { throw new DeserializationException(e); } } return null; }
public Builder toBuilder() { return newBuilder(this); }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsRequest prototype) {
public static Builder newBuilder(org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabelsRequest prototype) { return newBuilder().mergeFrom(prototype); } public Builder toBuilder() { return newBuilder(this); }