1 /*********************************************************************** 2 * Copyright (c) 2013-2024 Commonwealth Computer Research, Inc. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Apache License, Version 2.0 5 * which accompanies this distribution and is available at 6 * http://www.opensource.org/licenses/apache2.0.php. 7 ***********************************************************************/ 8 9 package org.locationtech.geomesa.jobs 10 11 import com.typesafe.scalalogging.LazyLogging 12 import org.apache.hadoop.conf.Configuration 13 import org.locationtech.geomesa.utils.classpath.ClassPathUtils 14 15 import java.io.File 16 17 object JobUtils extends LazyLogging { 18 19 /** 20 * Sets the libjars into a Hadoop configuration. Will search the environment first, then the 21 * classpath, until all required jars have been found. 22 * 23 * @param conf job configuration 24 * @param libJars jar prefixes to load 25 */ 26 def setLibJars(conf: Configuration, libJars: Seq[String], searchPath: Iterator[() => Seq[File]]): Unit = { 27 val extra = ClassPathUtils.loadClassPathFromEnv("GEOMESA_EXTRA_CLASSPATHS") 28 val found = ClassPathUtils.findJars(libJars, searchPath) 29 // always prepend GEOMESA_EXTRA_CLASSPATHS first 30 val paths = (extra ++ found).map(f => "file://" + f.getAbsolutePath) 31 // tmpjars is the hadoop config that corresponds to libjars 32 if (paths.nonEmpty) { 33 conf.setStrings("tmpjars", paths: _*) 34 } 35 logger.debug(s"Job will use the following libjars:${paths.mkString("\n\t", "\n\t", "")}") 36 } 37 }
| Line | Stmt Id | Pos | Tree | Symbol | Tests | Code |
|---|---|---|---|---|---|---|
| 27 | 166 | 1087 - 1150 | Apply | org.locationtech.geomesa.utils.classpath.ClassPathUtils.loadClassPathFromEnv | org.locationtech.geomesa.utils.classpath.ClassPathUtils.loadClassPathFromEnv("GEOMESA_EXTRA_CLASSPATHS") | |
| 28 | 167 | 1167 - 1211 | Apply | org.locationtech.geomesa.utils.classpath.ClassPathUtils.findJars | org.locationtech.geomesa.utils.classpath.ClassPathUtils.findJars(libJars, searchPath) | |
| 30 | 168 | 1288 - 1288 | TypeApply | scala.collection.Seq.canBuildFrom | collection.this.Seq.canBuildFrom[java.io.File] | |
| 30 | 169 | 1307 - 1316 | Literal | <nosymbol> | "file://" | |
| 30 | 170 | 1319 - 1336 | Apply | java.io.File.getAbsolutePath | f.getAbsolutePath() | |
| 30 | 171 | 1307 - 1336 | Apply | java.lang.String.+ | "file://".+(f.getAbsolutePath()) | |
| 30 | 172 | 1301 - 1301 | TypeApply | scala.collection.Seq.canBuildFrom | collection.this.Seq.canBuildFrom[String] | |
| 30 | 173 | 1281 - 1337 | ApplyToImplicitArgs | scala.collection.TraversableLike.map | extra.++[java.io.File, Seq[java.io.File]](found)(collection.this.Seq.canBuildFrom[java.io.File]).map[String, Seq[String]](((f: java.io.File) => "file://".+(f.getAbsolutePath())))(collection.this.Seq.canBuildFrom[String]) | |
| 32 | 174 | 1410 - 1424 | Select | scala.collection.TraversableOnce.nonEmpty | paths.nonEmpty | |
| 32 | 178 | 1406 - 1406 | Literal | <nosymbol> | () | |
| 32 | 179 | 1406 - 1406 | Block | <nosymbol> | () | |
| 33 | 175 | 1450 - 1459 | Literal | <nosymbol> | "tmpjars" | |
| 33 | 176 | 1434 - 1471 | Apply | org.apache.hadoop.conf.Configuration.setStrings | conf.setStrings("tmpjars", (paths: _*)) | |
| 33 | 177 | 1434 - 1471 | Block | org.apache.hadoop.conf.Configuration.setStrings | conf.setStrings("tmpjars", (paths: _*)) |