Java Code Examples for org.apache.hadoop.fs.FileSystem.listXAttrs()

The following are Jave code examples for showing how to use listXAttrs() of the org.apache.hadoop.fs.FileSystem class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: hadoop   File:   Source Code and License Vote up 5 votes
/** List xattrs */
private void testListXAttrs() throws Exception {
  if (!isLocalFS()) {
    FileSystem fs = FileSystem.get(getProxiedFSConf());
    Path path = new Path(getProxiedFSTestDir(), "foo.txt");
    OutputStream os = fs.create(path);

    final String name1 = "user.a1";
    final byte[] value1 = new byte[]{0x31, 0x32, 0x33};
    final String name2 = "user.a2";
    final byte[] value2 = new byte[]{0x41, 0x42, 0x43};
    final String name3 = "user.a3";
    final byte[] value3 = null;
    final String name4 = "trusted.a1";
    final byte[] value4 = new byte[]{0x31, 0x32, 0x33};
    fs = FileSystem.get(getProxiedFSConf());
    fs.setXAttr(path, name1, value1);
    fs.setXAttr(path, name2, value2);
    fs.setXAttr(path, name3, value3);
    fs.setXAttr(path, name4, value4);

    fs = getHttpFSFileSystem();
    List<String> names = fs.listXAttrs(path);
    Assert.assertEquals(4, names.size());
Example 2
Project: hadoop   File:   Source Code and License Vote up 2 votes
 * Executes the filesystem operation.
 * @param fs filesystem instance to use.
 * @return Map a map object (JSON friendly) with the xattr names.
 * @throws IOException thrown if an IO error occured.
public Map execute(FileSystem fs) throws IOException {
  List<String> names = fs.listXAttrs(path);
  return xAttrNamesToJSON(names);