Java Code Examples for org.apache.hadoop.conf.Configuration.getStringCollection()

The following are Jave code examples for showing how to use getStringCollection() of the org.apache.hadoop.conf.Configuration 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-oss   File: CredentialProviderFactory.java   Source Code and License Vote up 6 votes
public static List<CredentialProvider> getProviders(Configuration conf
                                             ) throws IOException {
  List<CredentialProvider> result = new ArrayList<CredentialProvider>();
  for(String path: conf.getStringCollection(CREDENTIAL_PROVIDER_PATH)) {
    try {
      URI uri = new URI(path);
      boolean found = false;
      for(CredentialProviderFactory factory: serviceLoader) {
        CredentialProvider kp = factory.createProvider(uri, conf);
        if (kp != null) {
          result.add(kp);
          found = true;
          break;
        }
      }
      if (!found) {
        throw new IOException("No CredentialProviderFactory for " + uri + " in " +
            CREDENTIAL_PROVIDER_PATH);
      }
    } catch (URISyntaxException error) {
      throw new IOException("Bad configuration of " + CREDENTIAL_PROVIDER_PATH +
          " at " + path, error);
    }
  }
  return result;
}
 
Example 2
Project: hadoop-oss   File: KeyPairProviderFactory.java   Source Code and License Vote up 6 votes
public static List<KeyPairProvider> getProviders(Configuration conf
                                             ) throws IOException {
  List<KeyPairProvider> result = new ArrayList<>();
  for(String path: conf.getStringCollection(KEY_PROVIDER_PATH)) {
    try {
      URI uri = new URI(path);
      KeyPairProvider kp = get(uri, conf);
      if (kp != null) {
        result.add(kp);
      } else {
        throw new IOException("No KeyPairProviderFactory for " + uri + " in " +
            KEY_PROVIDER_PATH);
      }
    } catch (URISyntaxException error) {
      throw new IOException("Bad configuration of " + KEY_PROVIDER_PATH +
          " at " + path, error);
    }
  }
  return result;
}
 
Example 3
Project: hadoop-oss   File: KeyProviderFactory.java   Source Code and License Vote up 6 votes
public static List<KeyProvider> getProviders(Configuration conf
                                             ) throws IOException {
  List<KeyProvider> result = new ArrayList<KeyProvider>();
  for(String path: conf.getStringCollection(KEY_PROVIDER_PATH)) {
    try {
      URI uri = new URI(path);
      KeyProvider kp = get(uri, conf);
      if (kp != null) {
        result.add(kp);
      } else {
        throw new IOException("No KeyProviderFactory for " + uri + " in " +
            KEY_PROVIDER_PATH);
      }
    } catch (URISyntaxException error) {
      throw new IOException("Bad configuration of " + KEY_PROVIDER_PATH +
          " at " + path, error);
    }
  }
  return result;
}
 
Example 4
Project: hadoop-oss   File: ReEncryptionKeyProviderFactory.java   Source Code and License Vote up 6 votes
public static List<ReEncryptionKeyProviderInterface> getProviders(Configuration conf
                                             ) throws IOException {
  List<ReEncryptionKeyProviderInterface> result = new ArrayList<>();
  for(String path: conf.getStringCollection(KEY_PROVIDER_PATH)) {
    try {
      URI uri = new URI(path);
      ReEncryptionKeyProviderInterface kp = get(uri, conf);
      if (kp != null) {
        result.add(kp);
      } else {
        throw new IOException("No ReEncryptionKeyProviderFactory for " + uri + " in " +
            KEY_PROVIDER_PATH);
      }
    } catch (URISyntaxException error) {
      throw new IOException("Bad configuration of " + KEY_PROVIDER_PATH +
          " at " + path, error);
    }
  }
  return result;
}
 
Example 5
Project: hadoop   File: CredentialProviderFactory.java   Source Code and License Vote up 6 votes
public static List<CredentialProvider> getProviders(Configuration conf
                                             ) throws IOException {
  List<CredentialProvider> result = new ArrayList<CredentialProvider>();
  for(String path: conf.getStringCollection(CREDENTIAL_PROVIDER_PATH)) {
    try {
      URI uri = new URI(path);
      boolean found = false;
      for(CredentialProviderFactory factory: serviceLoader) {
        CredentialProvider kp = factory.createProvider(uri, conf);
        if (kp != null) {
          result.add(kp);
          found = true;
          break;
        }
      }
      if (!found) {
        throw new IOException("No CredentialProviderFactory for " + uri + " in " +
            CREDENTIAL_PROVIDER_PATH);
      }
    } catch (URISyntaxException error) {
      throw new IOException("Bad configuration of " + CREDENTIAL_PROVIDER_PATH +
          " at " + path, error);
    }
  }
  return result;
}
 
Example 6
Project: hadoop   File: KeyProviderFactory.java   Source Code and License Vote up 6 votes
public static List<KeyProvider> getProviders(Configuration conf
                                             ) throws IOException {
  List<KeyProvider> result = new ArrayList<KeyProvider>();
  for(String path: conf.getStringCollection(KEY_PROVIDER_PATH)) {
    try {
      URI uri = new URI(path);
      KeyProvider kp = get(uri, conf);
      if (kp != null) {
        result.add(kp);
      } else {
        throw new IOException("No KeyProviderFactory for " + uri + " in " +
            KEY_PROVIDER_PATH);
      }
    } catch (URISyntaxException error) {
      throw new IOException("Bad configuration of " + KEY_PROVIDER_PATH +
          " at " + path, error);
    }
  }
  return result;
}
 
Example 7
Project: ditb   File: TableMapReduceUtil.java   Source Code and License Vote up 6 votes
/**
 * Returns a classpath string built from the content of the "tmpjars" value in {@code conf}.
 * Also exposed to shell scripts via `bin/hbase mapredcp`.
 */
public static String buildDependencyClasspath(Configuration conf) {
  if (conf == null) {
    throw new IllegalArgumentException("Must provide a configuration object.");
  }
  Set<String> paths = new HashSet<String>(conf.getStringCollection("tmpjars"));
  if (paths.size() == 0) {
    throw new IllegalArgumentException("Configuration contains no tmpjars.");
  }
  StringBuilder sb = new StringBuilder();
  for (String s : paths) {
    // entries can take the form 'file:/path/to/file.jar'.
    int idx = s.indexOf(":");
    if (idx != -1) s = s.substring(idx + 1);
    if (sb.length() > 0) sb.append(File.pathSeparator);
    sb.append(s);
  }
  return sb.toString();
}
 
Example 8
Project: hadoop   File: FSNamesystem.java   Source Code and License Vote up 5 votes
private List<AuditLogger> initAuditLoggers(Configuration conf) {
  // Initialize the custom access loggers if configured.
  Collection<String> alClasses = conf.getStringCollection(DFS_NAMENODE_AUDIT_LOGGERS_KEY);
  List<AuditLogger> auditLoggers = Lists.newArrayList();
  if (alClasses != null && !alClasses.isEmpty()) {
    for (String className : alClasses) {
      try {
        AuditLogger logger;
        if (DFS_NAMENODE_DEFAULT_AUDIT_LOGGER_NAME.equals(className)) {
          logger = new DefaultAuditLogger();
        } else {
          logger = (AuditLogger) Class.forName(className).newInstance();
        }
        logger.initialize(conf);
        auditLoggers.add(logger);
      } catch (RuntimeException re) {
        throw re;
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
  }

  // Make sure there is at least one logger installed.
  if (auditLoggers.isEmpty()) {
    auditLoggers.add(new DefaultAuditLogger());
  }

  // Add audit logger to calculate top users
  if (topConf.isEnabled) {
    topMetrics = new TopMetrics(conf, topConf.nntopReportingPeriodsMs);
    auditLoggers.add(new TopAuditLogger(topMetrics));
  }

  return Collections.unmodifiableList(auditLoggers);
}
 
Example 9
Project: ditb   File: IOTestProvider.java   Source Code and License Vote up 5 votes
@Override
public void init(FileSystem fs, Path path, Configuration conf, boolean overwritable) throws IOException {
  Collection<String> operations = conf.getStringCollection(ALLOWED_OPERATIONS);
  if (operations.isEmpty() || operations.contains(AllowedOperations.all.name())) {
    doAppends = doSyncs = true;
  } else if (operations.contains(AllowedOperations.none.name())) {
    doAppends = doSyncs = false;
  } else {
    doAppends = operations.contains(AllowedOperations.append.name());
    doSyncs = operations.contains(AllowedOperations.sync.name());
  }
  LOG.info("IOTestWriter initialized with appends " + (doAppends ? "enabled" : "disabled") +
      " and syncs " + (doSyncs ? "enabled" : "disabled"));
  super.init(fs, path, conf, overwritable);
}
 
Example 10
Project: ditb   File: IOTestProvider.java   Source Code and License Vote up 3 votes
/**
 * Create an edit log at the given <code>dir</code> location.
 *
 * You should never have to load an existing log. If there is a log at
 * startup, it should have already been processed and deleted by the time the
 * WAL object is started up.
 *
 * @param fs filesystem handle
 * @param rootDir path to where logs and oldlogs
 * @param logDir dir where wals are stored
 * @param archiveDir dir where wals are archived
 * @param conf configuration to use
 * @param listeners Listeners on WAL events. Listeners passed here will
 * be registered before we do anything else; e.g. the
 * Constructor {@link #rollWriter()}.
 * @param failIfWALExists If true IOException will be thrown if files related to this wal
 *        already exist.
 * @param prefix should always be hostname and port in distributed env and
 *        it will be URL encoded before being used.
 *        If prefix is null, "wal" will be used
 * @param suffix will be url encoded. null is treated as empty. non-empty must start with
 *        {@link DefaultWALProvider#WAL_FILE_NAME_DELIMITER}
 * @throws IOException
 */
public IOTestWAL(final FileSystem fs, final Path rootDir, final String logDir,
    final String archiveDir, final Configuration conf,
    final List<WALActionsListener> listeners,
    final boolean failIfWALExists, final String prefix, final String suffix)
    throws IOException {
  super(fs, rootDir, logDir, archiveDir, conf, listeners, failIfWALExists, prefix, suffix);
  Collection<String> operations = conf.getStringCollection(ALLOWED_OPERATIONS);
  doFileRolls = operations.isEmpty() || operations.contains(AllowedOperations.all.name()) ||
      operations.contains(AllowedOperations.fileroll.name());
  initialized = true;
  LOG.info("Initialized with file rolling " + (doFileRolls ? "enabled" : "disabled"));
}
 
Example 11
Project: hadoop   File: HAUtil.java   Source Code and License Vote up 2 votes
/**
 * @param conf Configuration. Please use getRMHAIds to check.
 * @return RM Ids on success
 */
public static Collection<String> getRMHAIds(Configuration conf) {
  return  conf.getStringCollection(YarnConfiguration.RM_HA_IDS);
}