Java Code Examples for org.apache.hadoop.hdfs.web.SWebHdfsFileSystem

The following examples show how to use org.apache.hadoop.hdfs.web.SWebHdfsFileSystem. 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 check out the related API usage on the sidebar.
Example 1
Source Project: hadoop   Source File: DFSUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns list of InetSocketAddress corresponding to HA NN HTTP addresses from
 * the configuration.
 *
 * @return list of InetSocketAddresses
 */
public static Map<String, Map<String, InetSocketAddress>> getHaNnWebHdfsAddresses(
    Configuration conf, String scheme) {
  if (WebHdfsFileSystem.SCHEME.equals(scheme)) {
    return getAddresses(conf, null,
        DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY);
  } else if (SWebHdfsFileSystem.SCHEME.equals(scheme)) {
    return getAddresses(conf, null,
        DFSConfigKeys.DFS_NAMENODE_HTTPS_ADDRESS_KEY);
  } else {
    throw new IllegalArgumentException("Unsupported scheme: " + scheme);
  }
}
 
Example 2
Source Project: hadoop   Source File: NamenodeWebHdfsMethods.java    License: Apache License 2.0 5 votes vote down vote up
private Token<? extends TokenIdentifier> generateDelegationToken(
    final NameNode namenode, final UserGroupInformation ugi,
    final String renewer) throws IOException {
  final Credentials c = DelegationTokenSecretManager.createCredentials(
      namenode, ugi, renewer != null? renewer: ugi.getShortUserName());
  if (c == null) {
    return null;
  }
  final Token<? extends TokenIdentifier> t = c.getAllTokens().iterator().next();
  Text kind = request.getScheme().equals("http") ? WebHdfsFileSystem.TOKEN_KIND
      : SWebHdfsFileSystem.TOKEN_KIND;
  t.setKind(kind);
  return t;
}
 
Example 3
Source Project: hadoop   Source File: TestHttpFSPorts.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSWebHdfsCustomDefaultPorts() throws IOException {
  URI uri = URI.create("swebhdfs://localhost");
  SWebHdfsFileSystem fs = (SWebHdfsFileSystem) FileSystem.get(uri, conf);

  assertEquals(456, fs.getDefaultPort());
  assertEquals(uri, fs.getUri());
  assertEquals("127.0.0.1:456", fs.getCanonicalServiceName());
}
 
Example 4
Source Project: hadoop   Source File: TestHttpFSPorts.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSwebHdfsCustomUriPortWithCustomDefaultPorts() throws IOException {
  URI uri = URI.create("swebhdfs://localhost:789");
  SWebHdfsFileSystem fs = (SWebHdfsFileSystem) FileSystem.get(uri, conf);

  assertEquals(456, fs.getDefaultPort());
  assertEquals(uri, fs.getUri());
  assertEquals("127.0.0.1:789", fs.getCanonicalServiceName());
}
 
Example 5
Source Project: big-c   Source File: DFSUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns list of InetSocketAddress corresponding to HA NN HTTP addresses from
 * the configuration.
 *
 * @return list of InetSocketAddresses
 */
public static Map<String, Map<String, InetSocketAddress>> getHaNnWebHdfsAddresses(
    Configuration conf, String scheme) {
  if (WebHdfsFileSystem.SCHEME.equals(scheme)) {
    return getAddresses(conf, null,
        DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY);
  } else if (SWebHdfsFileSystem.SCHEME.equals(scheme)) {
    return getAddresses(conf, null,
        DFSConfigKeys.DFS_NAMENODE_HTTPS_ADDRESS_KEY);
  } else {
    throw new IllegalArgumentException("Unsupported scheme: " + scheme);
  }
}
 
Example 6
Source Project: big-c   Source File: NamenodeWebHdfsMethods.java    License: Apache License 2.0 5 votes vote down vote up
private Token<? extends TokenIdentifier> generateDelegationToken(
    final NameNode namenode, final UserGroupInformation ugi,
    final String renewer) throws IOException {
  final Credentials c = DelegationTokenSecretManager.createCredentials(
      namenode, ugi, renewer != null? renewer: ugi.getShortUserName());
  if (c == null) {
    return null;
  }
  final Token<? extends TokenIdentifier> t = c.getAllTokens().iterator().next();
  Text kind = request.getScheme().equals("http") ? WebHdfsFileSystem.TOKEN_KIND
      : SWebHdfsFileSystem.TOKEN_KIND;
  t.setKind(kind);
  return t;
}
 
Example 7
Source Project: big-c   Source File: TestHttpFSPorts.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSWebHdfsCustomDefaultPorts() throws IOException {
  URI uri = URI.create("swebhdfs://localhost");
  SWebHdfsFileSystem fs = (SWebHdfsFileSystem) FileSystem.get(uri, conf);

  assertEquals(456, fs.getDefaultPort());
  assertEquals(uri, fs.getUri());
  assertEquals("127.0.0.1:456", fs.getCanonicalServiceName());
}
 
Example 8
Source Project: big-c   Source File: TestHttpFSPorts.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testSwebHdfsCustomUriPortWithCustomDefaultPorts() throws IOException {
  URI uri = URI.create("swebhdfs://localhost:789");
  SWebHdfsFileSystem fs = (SWebHdfsFileSystem) FileSystem.get(uri, conf);

  assertEquals(456, fs.getDefaultPort());
  assertEquals(uri, fs.getUri());
  assertEquals("127.0.0.1:789", fs.getCanonicalServiceName());
}
 
Example 9
Source Project: hadoop   Source File: TestHttpFSFWithSWebhdfsFileSystem.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected Class getFileSystemClass() {
  return SWebHdfsFileSystem.class;
}
 
Example 10
Source Project: hadoop   Source File: DelegationTokenIdentifier.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Text getKind() {
  return SWebHdfsFileSystem.TOKEN_KIND;
}
 
Example 11
Source Project: big-c   Source File: TestHttpFSFWithSWebhdfsFileSystem.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected Class getFileSystemClass() {
  return SWebHdfsFileSystem.class;
}
 
Example 12
Source Project: big-c   Source File: DelegationTokenIdentifier.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Text getKind() {
  return SWebHdfsFileSystem.TOKEN_KIND;
}