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

The following examples show how to use org.apache.hadoop.fs.FileSystem#listXAttrs() . 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: BaseTestHttpFSWith.java    From hadoop with 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 File: BaseTestHttpFSWith.java    From big-c with 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 File: FSOperations.java    From hadoop with 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 File: FSOperations.java    From big-c with 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);
}