Java 类org.apache.hadoop.hbase.protobuf.generated.VisibilityLabelsProtos.VisibilityLabel 实例源码

项目:ditb    文件:VisibilityLabelsCache.java   
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();
  }
}
项目:pbase    文件:VisibilityLabelsCache.java   
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();
  }
}
项目:HIndex    文件:VisibilityLabelsManager.java   
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 {
    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();
  }
}
项目:hbase    文件:VisibilityLabelsCache.java   
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();
  }
}
项目:PyroDB    文件:VisibilityLabelsManager.java   
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 {
    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();
  }
}
项目:ditb    文件:VisibilityUtils.java   
/**
 * 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());
}
项目:ditb    文件:VisibilityUtils.java   
/**
 * Reads back from the zookeeper. The data read here is of the form written by
 * writeToZooKeeper(Map&lt;byte[], Integer&gt; 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;
}
项目:pbase    文件:VisibilityUtils.java   
/**
 * 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());
}
项目:pbase    文件:VisibilityUtils.java   
/**
 * 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 request = VisibilityLabelsRequest.newBuilder()
          .mergeFrom(data, pblen, data.length - pblen).build();
      return request.getVisLabelList();
    } catch (InvalidProtocolBufferException e) {
      throw new DeserializationException(e);
    }
  }
  return null;
}
项目:HIndex    文件:VisibilityUtils.java   
/**
 * 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(HBaseZeroCopyByteString.wrap(Bytes.toBytes(entry.getKey())));
    visLabBuilder.setOrdinal(entry.getValue());
    visReqBuilder.addVisLabel(visLabBuilder.build());
  }
  return ProtobufUtil.prependPBMagic(visReqBuilder.build().toByteArray());
}
项目:HIndex    文件:VisibilityUtils.java   
/**
 * 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 request = VisibilityLabelsRequest.newBuilder()
          .mergeFrom(data, pblen, data.length - pblen).build();
      return request.getVisLabelList();
    } catch (InvalidProtocolBufferException e) {
      throw new DeserializationException(e);
    }
  }
  return null;
}
项目:hbase    文件:VisibilityUtils.java   
/**
 * 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());
}
项目:hbase    文件:VisibilityUtils.java   
/**
 * Reads back from the zookeeper. The data read here is of the form written by
 * writeToZooKeeper(Map&lt;byte[], Integer&gt; 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;
}
项目:PyroDB    文件:VisibilityUtils.java   
/**
 * 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(HBaseZeroCopyByteString.wrap(Bytes.toBytes(entry.getKey())));
    visLabBuilder.setOrdinal(entry.getValue());
    visReqBuilder.addVisLabel(visLabBuilder.build());
  }
  return ProtobufUtil.prependPBMagic(visReqBuilder.build().toByteArray());
}
项目:PyroDB    文件:VisibilityUtils.java   
/**
 * 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 request = VisibilityLabelsRequest.newBuilder()
          .mergeFrom(data, pblen, data.length - pblen).build();
      return request.getVisLabelList();
    } catch (InvalidProtocolBufferException e) {
      throw new DeserializationException(e);
    }
  }
  return null;
}