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

The following examples show how to use org.apache.hadoop.fs.FileSystem#listXAttrs() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: hadoop   File: BaseTestHttpFSWith.java    License: Apache License 2.0 5 votes vote down vote up
/** List xattrs */
private void testListXAttrs() throws Exception {
  if (!isLocalFS()) {
    FileSystem fs = FileSystem.get(getProxiedFSConf());
    fs.mkdirs(getProxiedFSTestDir());
    Path path = new Path(getProxiedFSTestDir(), "foo.txt");
    OutputStream os = fs.create(path);
    os.write(1);
    os.close();
    fs.close();

    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.close();

    fs = getHttpFSFileSystem();
    List<String> names = fs.listXAttrs(path);
    Assert.assertEquals(4, names.size());
    Assert.assertTrue(names.contains(name1));
    Assert.assertTrue(names.contains(name2));
    Assert.assertTrue(names.contains(name3));
    Assert.assertTrue(names.contains(name4));
  }
}
 
Example 2
Source Project: big-c   File: BaseTestHttpFSWith.java    License: Apache License 2.0 5 votes vote down vote up
/** List xattrs */
private void testListXAttrs() throws Exception {
  if (!isLocalFS()) {
    FileSystem fs = FileSystem.get(getProxiedFSConf());
    fs.mkdirs(getProxiedFSTestDir());
    Path path = new Path(getProxiedFSTestDir(), "foo.txt");
    OutputStream os = fs.create(path);
    os.write(1);
    os.close();
    fs.close();

    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.close();

    fs = getHttpFSFileSystem();
    List<String> names = fs.listXAttrs(path);
    Assert.assertEquals(4, names.size());
    Assert.assertTrue(names.contains(name1));
    Assert.assertTrue(names.contains(name2));
    Assert.assertTrue(names.contains(name3));
    Assert.assertTrue(names.contains(name4));
  }
}
 
Example 3
Source Project: hadoop   File: FSOperations.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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.
 */
@Override
public Map execute(FileSystem fs) throws IOException {
  List<String> names = fs.listXAttrs(path);
  return xAttrNamesToJSON(names);
}
 
Example 4
Source Project: big-c   File: FSOperations.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 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.
 */
@Override
public Map execute(FileSystem fs) throws IOException {
  List<String> names = fs.listXAttrs(path);
  return xAttrNamesToJSON(names);
}