Java Code Examples for org.apache.hadoop.http.FilterContainer#addFilter()

The following examples show how to use org.apache.hadoop.http.FilterContainer#addFilter() . 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: Bats   File: StramWSFilterInitializer.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initFilter(FilterContainer container, Configuration conf)
{
  logger.debug("Conf {}", conf);
  Map<String, String> params = new HashMap<>();
  Collection<String> proxies = new ArrayList<>();
  if (ConfigUtils.isRMHAEnabled(conf)) {
    // HA is enabled get all
    for (String rmId : ConfigUtils.getRMHAIds(conf)) {
      proxies.add(getResolvedRMWebAppURLWithoutScheme(conf, rmId));
    }
    logger.info("HA proxy addresses {}", proxies);
  }
  if (proxies.isEmpty()) {
    proxies.add(getProxyHostAndPort(conf));
    logger.info("Proxy addresses {}", proxies);
  }
  StringBuilder proxyBr = new StringBuilder();
  for (String proxy : proxies) {
    if (proxyBr.length() != 0) {
      proxyBr.append(StramWSFilter.PROXY_DELIMITER);
    }
    String[] parts = proxy.split(":");
    proxyBr.append(parts[0]);
  }
  params.put(StramWSFilter.PROXY_HOST, proxyBr.toString());
  container.addFilter(FILTER_NAME, FILTER_CLASS, params);
}
 
Example 2
@Override
public void initFilter(FilterContainer container, Configuration conf) {

  Map<String, String> filterConfig = createFilterConfig(conf);
  container.addFilter("RMAuthenticationFilter",
    RMAuthenticationFilter.class.getName(), filterConfig);
}
 
Example 3
Source Project: hadoop   File: StaticUserWebFilter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initFilter(FilterContainer container, Configuration conf) {
  HashMap<String, String> options = new HashMap<String, String>();
  
  String username = getUsernameFromConf(conf);
  options.put(HADOOP_HTTP_STATIC_USER, username);

  container.addFilter("static_user_filter", 
                      StaticUserFilter.class.getName(), 
                      options);
}
 
Example 4
@Override
public void initFilter(FilterContainer container, Configuration conf) {

  Map<String, String> filterConfig = createFilterConfig(conf);
  container.addFilter("RMAuthenticationFilter",
    RMAuthenticationFilter.class.getName(), filterConfig);
}
 
Example 5
Source Project: big-c   File: StaticUserWebFilter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void initFilter(FilterContainer container, Configuration conf) {
  HashMap<String, String> options = new HashMap<String, String>();
  
  String username = getUsernameFromConf(conf);
  options.put(HADOOP_HTTP_STATIC_USER, username);

  container.addFilter("static_user_filter", 
                      StaticUserFilter.class.getName(), 
                      options);
}
 
Example 6
@Override
public void initFilter(FilterContainer container, Configuration conf)
{
  logger.debug("Conf {}", conf);
  Map<String, String> params = new HashMap<>();
  Collection<String> proxies = new ArrayList<>();
  if (ConfigUtils.isRMHAEnabled(conf)) {
    // HA is enabled get all
    for (String rmId : ConfigUtils.getRMHAIds(conf)) {
      proxies.add(getResolvedRMWebAppURLWithoutScheme(conf, rmId));
    }
    logger.info("HA proxy addresses {}", proxies);
  }
  if (proxies.isEmpty()) {
    proxies.add(getProxyHostAndPort(conf));
    logger.info("Proxy addresses {}", proxies);
  }
  StringBuilder proxyBr = new StringBuilder();
  for (String proxy : proxies) {
    if (proxyBr.length() != 0) {
      proxyBr.append(StramWSFilter.PROXY_DELIMITER);
    }
    String[] parts = proxy.split(":");
    proxyBr.append(parts[0]);
  }
  params.put(StramWSFilter.PROXY_HOST, proxyBr.toString());
  container.addFilter(FILTER_NAME, FILTER_CLASS, params);
}
 
Example 7
/**
 * Initializes hadoop-auth AuthenticationFilter.
 * <p/>
 * Propagates to hadoop-auth AuthenticationFilter configuration all Hadoop
 * configuration properties prefixed with "hadoop.http.authentication."
 *
 * @param container The filter container
 * @param conf Configuration for run-time parameters
 */
@Override
public void initFilter(FilterContainer container, Configuration conf) {
  Map<String, String> filterConfig = getFilterConfigMap(conf, PREFIX);

  container.addFilter("authentication",
                      AuthenticationFilter.class.getName(),
                      filterConfig);
}
 
Example 8
/**
 * Initializes hadoop-auth AuthenticationFilter.
 * <p/>
 * Propagates to hadoop-auth AuthenticationFilter configuration all Hadoop
 * configuration properties prefixed with "hadoop.http.authentication."
 *
 * @param container The filter container
 * @param conf Configuration for run-time parameters
 */
@Override
public void initFilter(FilterContainer container, Configuration conf) {
  Map<String, String> filterConfig = getFilterConfigMap(conf, PREFIX);

  container.addFilter("authentication",
                      AuthenticationFilter.class.getName(),
                      filterConfig);
}