Java Code Examples for org.apache.hadoop.fs.XAttr#Builder

The following examples show how to use org.apache.hadoop.fs.XAttr#Builder . 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: FSEditLogOp.java    From hadoop with Apache License 2.0 6 votes vote down vote up
private static List<XAttr> readXAttrsFromXml(Stanza st)
    throws InvalidXmlException {
  if (!st.hasChildren("XATTR")) {
    return null;
  }

  List<Stanza> stanzas = st.getChildren("XATTR");
  List<XAttr> xattrs = Lists.newArrayListWithCapacity(stanzas.size());
  for (Stanza a: stanzas) {
    XAttr.Builder builder = new XAttr.Builder();
    builder.setNameSpace(XAttr.NameSpace.valueOf(a.getValue("NAMESPACE"))).
        setName(a.getValue("NAME"));
    String v = a.getValueOrNull("VALUE");
    if (v != null) {
      try {
        builder.setValue(XAttrCodec.decodeValue(v));
      } catch (IOException e) {
        throw new InvalidXmlException(e.toString());
      }
    }
    xattrs.add(builder.build());
  }
  return xattrs;
}
 
Example 2
Source File: FSEditLogOp.java    From big-c with Apache License 2.0 6 votes vote down vote up
private static List<XAttr> readXAttrsFromXml(Stanza st)
    throws InvalidXmlException {
  if (!st.hasChildren("XATTR")) {
    return null;
  }

  List<Stanza> stanzas = st.getChildren("XATTR");
  List<XAttr> xattrs = Lists.newArrayListWithCapacity(stanzas.size());
  for (Stanza a: stanzas) {
    XAttr.Builder builder = new XAttr.Builder();
    builder.setNameSpace(XAttr.NameSpace.valueOf(a.getValue("NAMESPACE"))).
        setName(a.getValue("NAME"));
    String v = a.getValueOrNull("VALUE");
    if (v != null) {
      try {
        builder.setValue(XAttrCodec.decodeValue(v));
      } catch (IOException e) {
        throw new InvalidXmlException(e.toString());
      }
    }
    xattrs.add(builder.build());
  }
  return xattrs;
}
 
Example 3
Source File: PBHelper.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static XAttr convertXAttr(XAttrProto a) {
  XAttr.Builder builder = new XAttr.Builder();
  builder.setNameSpace(convert(a.getNamespace()));
  if (a.hasName()) {
    builder.setName(a.getName());
  }
  if (a.hasValue()) {
    builder.setValue(a.getValue().toByteArray());
  }
  return builder.build();
}
 
Example 4
Source File: PBHelper.java    From hadoop with Apache License 2.0 5 votes vote down vote up
public static List<XAttr> convertXAttrs(List<XAttrProto> xAttrSpec) {
  ArrayList<XAttr> xAttrs = Lists.newArrayListWithCapacity(xAttrSpec.size());
  for (XAttrProto a : xAttrSpec) {
    XAttr.Builder builder = new XAttr.Builder();
    builder.setNameSpace(convert(a.getNamespace()));
    if (a.hasName()) {
      builder.setName(a.getName());
    }
    if (a.hasValue()) {
      builder.setValue(a.getValue().toByteArray());
    }
    xAttrs.add(builder.build());
  }
  return xAttrs;
}
 
Example 5
Source File: PBHelper.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static XAttr convertXAttr(XAttrProto a) {
  XAttr.Builder builder = new XAttr.Builder();
  builder.setNameSpace(convert(a.getNamespace()));
  if (a.hasName()) {
    builder.setName(a.getName());
  }
  if (a.hasValue()) {
    builder.setValue(a.getValue().toByteArray());
  }
  return builder.build();
}
 
Example 6
Source File: PBHelper.java    From big-c with Apache License 2.0 5 votes vote down vote up
public static List<XAttr> convertXAttrs(List<XAttrProto> xAttrSpec) {
  ArrayList<XAttr> xAttrs = Lists.newArrayListWithCapacity(xAttrSpec.size());
  for (XAttrProto a : xAttrSpec) {
    XAttr.Builder builder = new XAttr.Builder();
    builder.setNameSpace(convert(a.getNamespace()));
    if (a.hasName()) {
      builder.setName(a.getName());
    }
    if (a.hasValue()) {
      builder.setValue(a.getValue().toByteArray());
    }
    xAttrs.add(builder.build());
  }
  return xAttrs;
}