List of usage examples for org.apache.hadoop.conf Configuration getStrings
public String[] getStrings(String name)
name
property as an array of String
s. From source file:org.apache.hive.hcatalog.templeton.tool.LaunchMapper.java
License:Apache License
/** * {@link #copyLocal(String, org.apache.hadoop.conf.Configuration)} should be called before this * See {@link org.apache.hive.hcatalog.templeton.SqoopDelegator#makeBasicArgs(String, String, String, String, boolean, String)} * for more comments//from w ww .j a v a 2 s. c om */ private static void handleSqoop(Configuration conf, Map<String, String> env) throws IOException { if (TempletonUtils.isset(conf.get(Sqoop.LIB_JARS))) { //LIB_JARS should only be set if Sqoop is auto-shipped LOG.debug(Sqoop.LIB_JARS + "=" + conf.get(Sqoop.LIB_JARS)); String[] files = conf.getStrings(Sqoop.LIB_JARS); StringBuilder jdbcJars = new StringBuilder(); for (String f : files) { jdbcJars.append(f).append(File.pathSeparator); } jdbcJars.setLength(jdbcJars.length() - 1); //this makes the jars available to Sqoop client prependPathToVariable(HADOOP_CLASSPATH, env, jdbcJars.toString()); } }
From source file:org.apache.hive.hcatalog.templeton.tool.LaunchMapper.java
License:Apache License
private static void handleHadoopClasspathExtras(Configuration conf, Map<String, String> env) throws IOException { if (!TempletonUtils.isset(conf.get(JobSubmissionConstants.HADOOP_CLASSPATH_EXTRAS))) { return;//from www .j av a 2 s . c o m } LOG.debug(HADOOP_CLASSPATH_EXTRAS + "=" + conf.get(HADOOP_CLASSPATH_EXTRAS)); String[] files = conf.getStrings(HADOOP_CLASSPATH_EXTRAS); StringBuilder paths = new StringBuilder(); FileSystem fs = FileSystem.getLocal(conf);//these have been localized already for (String f : files) { Path p = new Path(f); FileStatus fileStatus = fs.getFileStatus(p); paths.append(f); if (fileStatus.isDir()) { paths.append(File.separator).append("*"); } paths.append(File.pathSeparator); } paths.setLength(paths.length() - 1); prependPathToVariable(HADOOP_CLASSPATH, env, paths.toString()); }
From source file:org.apache.lens.cube.parse.StorageTableResolver.java
License:Apache License
private List<String> getSupportedStorages(Configuration conf) { String[] storages = conf.getStrings(CubeQueryConfUtil.DRIVER_SUPPORTED_STORAGES); if (storages != null) { return Arrays.asList(storages); }/*from www . j ava 2 s. com*/ return null; }
From source file:org.apache.lens.server.api.driver.hooks.ChainedDriverQueryHook.java
License:Apache License
public static ChainedDriverQueryHook from(Configuration conf, String key) throws LensException { String[] classNames = conf.getStrings(key); List<DriverQueryHook> hooks = Lists.newArrayList(); if (classNames != null) { for (String className : classNames) { Class<? extends DriverQueryHook> clazz; try { clazz = conf.getClassByName(className).asSubclass(DriverQueryHook.class); } catch (ClassNotFoundException e) { throw new LensException("Couldn't load class " + className, e); }/*from w w w .j a va 2 s .co m*/ DriverQueryHook instance; try { instance = clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new LensException("Couldn't create instance of class " + clazz.getName(), e); } if (instance instanceof Configurable) { ((Configurable) instance).setConf(conf); } hooks.add(instance); } } return new ChainedDriverQueryHook(hooks); }
From source file:org.apache.lens.server.api.retry.ChainedRetryPolicyDecider.java
License:Apache License
public static <FC extends FailureContext> ChainedRetryPolicyDecider<FC> from(Configuration conf, String key) throws LensException { String[] classNames = conf.getStrings(key); List<RetryPolicyDecider<FC>> retryPolicyDeciders = Lists.newArrayList(); if (classNames != null) { for (String className : classNames) { Class<? extends RetryPolicyDecider<FC>> clazz; try { clazz = (Class<? extends RetryPolicyDecider<FC>>) conf.getClassByName(className) .asSubclass(RetryPolicyDecider.class); } catch (ClassNotFoundException e) { throw new LensException("Couldn't load class " + className, e); }/*from www .j a v a2s .c o m*/ RetryPolicyDecider<FC> instance; try { instance = clazz.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new LensException("Couldn't create instance of class " + clazz.getName(), e); } if (instance instanceof Configurable) { ((Configurable) instance).setConf(conf); } retryPolicyDeciders.add(instance); } } return new ChainedRetryPolicyDecider<>(retryPolicyDeciders); }
From source file:org.apache.lens.server.api.util.LensUtil.java
License:Apache License
public static <T> Set<T> getImplementationsMutable(final String factoriesKey, final Configuration conf) { Set<T> implSet = Sets.newLinkedHashSet(); final String[] factoryNames = conf.getStrings(factoriesKey); if (factoryNames != null) { for (String factoryName : factoryNames) { if (StringUtils.isNotBlank(factoryName)) { final T implementation = getImplementation(factoryName.trim(), conf); implSet.add(implementation); }//from w ww. j a v a 2 s. c o m } } return implSet; }
From source file:org.apache.lens.server.query.RewriteUtil.java
License:Apache License
/** * Returns the rewriter chain implementations in the specified order in configuration and loads them through the * specified classloader./*from ww w . j a v a 2s . co m*/ * @param conf * the query conf * @param classLoader * @return */ public static Collection<QueryRewriter> getQueryRewriter(Configuration conf, ClassLoader classLoader) { String[] rewriterNames = conf.getStrings(LensConfConstants.QUERY_REWRITERS); if (rewriterNames == null || rewriterNames.length == 0) { return Collections.emptyList(); } List<QueryRewriter> rewriterInsts = new ArrayList<QueryRewriter>(rewriterNames.length); for (String rName : rewriterNames) { QueryRewriter rewriterInst = loadRewriterImpl(rName, conf, classLoader); if (rewriterInst != null) { rewriterInsts.add(rewriterInst); } } return rewriterInsts; }
From source file:org.apache.mahout.utils.ConcatenateVectorsReducer.java
License:Apache License
public void setup(Context context) throws java.io.IOException, InterruptedException { Configuration configuration = context.getConfiguration(); dimsA = Integer.valueOf(configuration.getStrings(ConcatenateVectorsJob.MATRIXA_DIMS)[0]); dimsB = Integer.valueOf(configuration.getStrings(ConcatenateVectorsJob.MATRIXB_DIMS)[0]); }
From source file:org.apache.mahout.utils.regex.RegexMapper.java
License:Apache License
@Override protected void setup(Context context) throws IOException, InterruptedException { groupsToKeep = Lists.newArrayList(); Configuration config = context.getConfiguration(); String regexStr = config.get(REGEX); regex = Pattern.compile(regexStr); String[] groups = config.getStrings(GROUP_MATCHERS); if (groups != null) { for (String group : groups) { groupsToKeep.add(Integer.parseInt(group)); }//from ww w . j a v a 2s .co m } transformer = ClassUtils.instantiateAs(config.get(TRANSFORMER_CLASS, IdentityTransformer.class.getName()), RegexTransformer.class); String analyzerName = config.get(ANALYZER_NAME); if (analyzerName != null && transformer instanceof AnalyzerTransformer) { Analyzer analyzer = ClassUtils.instantiateAs(analyzerName, Analyzer.class); ((AnalyzerTransformer) transformer).setAnalyzer(analyzer); } formatter = ClassUtils.instantiateAs(config.get(FORMATTER_CLASS, IdentityFormatter.class.getName()), RegexFormatter.class); }
From source file:org.apache.mnemonic.hadoop.MneConfigHelper.java
License:Apache License
public static Class<?>[] getEntityFactoryProxies(Configuration conf, String prefix) { List<Class<?>> ret = new ArrayList<>(); String[] vals = conf.getStrings(getConfigName(prefix, ENTITY_FACTORY_PROXIES)); String clsname = null;//from w ww.j a v a 2 s .c o m try { if (null != vals) { for (String itm : vals) { clsname = itm; ret.add(Class.forName(itm)); } } } catch (ClassNotFoundException | NoClassDefFoundError e) { throw new RuntimeException(String.format("Unable to find class '%s'", clsname), e); } return ret.toArray(new Class<?>[0]); }