mirror of https://github.com/apache/druid.git
make defaultVersion configurable for non-jar testing
This commit is contained in:
parent
0ca23d7d0b
commit
d914afe1cd
|
@ -187,7 +187,7 @@ public class HadoopIndexTask extends AbstractTask
|
||||||
final List<URL> extensionURLs = Lists.newArrayList();
|
final List<URL> extensionURLs = Lists.newArrayList();
|
||||||
for (String coordinate : extensionsConfig.getCoordinates()) {
|
for (String coordinate : extensionsConfig.getCoordinates()) {
|
||||||
final ClassLoader coordinateLoader = Initialization.getClassLoaderForCoordinates(
|
final ClassLoader coordinateLoader = Initialization.getClassLoaderForCoordinates(
|
||||||
aetherClient, coordinate
|
aetherClient, coordinate, extensionsConfig.getDefaultVersion()
|
||||||
);
|
);
|
||||||
extensionURLs.addAll(Arrays.asList(((URLClassLoader) coordinateLoader).getURLs()));
|
extensionURLs.addAll(Arrays.asList(((URLClassLoader) coordinateLoader).getURLs()));
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ public class HadoopIndexTask extends AbstractTask
|
||||||
// put hadoop dependencies last to avoid jets3t & apache.httpcore version conflicts
|
// put hadoop dependencies last to avoid jets3t & apache.httpcore version conflicts
|
||||||
for (String hadoopDependencyCoordinate : finalHadoopDependencyCoordinates) {
|
for (String hadoopDependencyCoordinate : finalHadoopDependencyCoordinates) {
|
||||||
final ClassLoader hadoopLoader = Initialization.getClassLoaderForCoordinates(
|
final ClassLoader hadoopLoader = Initialization.getClassLoaderForCoordinates(
|
||||||
aetherClient, hadoopDependencyCoordinate
|
aetherClient, hadoopDependencyCoordinate, extensionsConfig.getDefaultVersion()
|
||||||
);
|
);
|
||||||
driverURLs.addAll(Arrays.asList(((URLClassLoader) hadoopLoader).getURLs()));
|
driverURLs.addAll(Arrays.asList(((URLClassLoader) hadoopLoader).getURLs()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public class ExtensionsConfig
|
public class ExtensionsConfig
|
||||||
{
|
{
|
||||||
|
public static final String PACKAGE_VERSION = ExtensionsConfig.class.getPackage().getImplementationVersion();
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@NotNull
|
@NotNull
|
||||||
private boolean searchCurrentClassloader = true;
|
private boolean searchCurrentClassloader = true;
|
||||||
|
@ -37,6 +39,10 @@ public class ExtensionsConfig
|
||||||
@NotNull
|
@NotNull
|
||||||
private List<String> coordinates = ImmutableList.of();
|
private List<String> coordinates = ImmutableList.of();
|
||||||
|
|
||||||
|
// default version to use for extensions without version info
|
||||||
|
@JsonProperty
|
||||||
|
private String defaultVersion;
|
||||||
|
|
||||||
@JsonProperty
|
@JsonProperty
|
||||||
@NotNull
|
@NotNull
|
||||||
private String localRepository = String.format("%s/%s", System.getProperty("user.home"), ".m2/repository");
|
private String localRepository = String.format("%s/%s", System.getProperty("user.home"), ".m2/repository");
|
||||||
|
@ -58,6 +64,11 @@ public class ExtensionsConfig
|
||||||
return coordinates;
|
return coordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getDefaultVersion()
|
||||||
|
{
|
||||||
|
return defaultVersion != null ? defaultVersion : PACKAGE_VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
public String getLocalRepository()
|
public String getLocalRepository()
|
||||||
{
|
{
|
||||||
return localRepository;
|
return localRepository;
|
||||||
|
@ -74,6 +85,7 @@ public class ExtensionsConfig
|
||||||
return "ExtensionsConfig{" +
|
return "ExtensionsConfig{" +
|
||||||
"searchCurrentClassloader=" + searchCurrentClassloader +
|
"searchCurrentClassloader=" + searchCurrentClassloader +
|
||||||
", coordinates=" + coordinates +
|
", coordinates=" + coordinates +
|
||||||
|
", defaultVersion='" + getDefaultVersion() + '\'' +
|
||||||
", localRepository='" + localRepository + '\'' +
|
", localRepository='" + localRepository + '\'' +
|
||||||
", remoteRepositories=" + remoteRepositories +
|
", remoteRepositories=" + remoteRepositories +
|
||||||
'}';
|
'}';
|
||||||
|
|
|
@ -93,9 +93,6 @@ import java.util.Set;
|
||||||
*/
|
*/
|
||||||
public class Initialization
|
public class Initialization
|
||||||
{
|
{
|
||||||
// default version to use for extensions without version info
|
|
||||||
private static final String DEFAULT_VERSION = Initialization.class.getPackage().getImplementationVersion();
|
|
||||||
|
|
||||||
private static final Logger log = new Logger(Initialization.class);
|
private static final Logger log = new Logger(Initialization.class);
|
||||||
private static final Map<String, URLClassLoader> loadersMap = Maps.newHashMap();
|
private static final Map<String, URLClassLoader> loadersMap = Maps.newHashMap();
|
||||||
|
|
||||||
|
@ -143,7 +140,7 @@ public class Initialization
|
||||||
for (String coordinate : config.getCoordinates()) {
|
for (String coordinate : config.getCoordinates()) {
|
||||||
log.info("Loading extension[%s] for class[%s]", coordinate, clazz.getName());
|
log.info("Loading extension[%s] for class[%s]", coordinate, clazz.getName());
|
||||||
try {
|
try {
|
||||||
URLClassLoader loader = getClassLoaderForCoordinates(aether, coordinate);
|
URLClassLoader loader = getClassLoaderForCoordinates(aether, coordinate, config.getDefaultVersion());
|
||||||
|
|
||||||
final ServiceLoader<T> serviceLoader = ServiceLoader.load(clazz, loader);
|
final ServiceLoader<T> serviceLoader = ServiceLoader.load(clazz, loader);
|
||||||
|
|
||||||
|
@ -163,7 +160,7 @@ public class Initialization
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static URLClassLoader getClassLoaderForCoordinates(TeslaAether aether, String coordinate)
|
public static URLClassLoader getClassLoaderForCoordinates(TeslaAether aether, String coordinate, String defaultVersion)
|
||||||
throws DependencyResolutionException, MalformedURLException
|
throws DependencyResolutionException, MalformedURLException
|
||||||
{
|
{
|
||||||
URLClassLoader loader = loadersMap.get(coordinate);
|
URLClassLoader loader = loadersMap.get(coordinate);
|
||||||
|
@ -177,8 +174,8 @@ public class Initialization
|
||||||
}
|
}
|
||||||
catch (IllegalArgumentException e) {
|
catch (IllegalArgumentException e) {
|
||||||
// try appending the default version so we can specify artifacts without versions
|
// try appending the default version so we can specify artifacts without versions
|
||||||
if (DEFAULT_VERSION != null) {
|
if (defaultVersion != null) {
|
||||||
versionedArtifact = new DefaultArtifact(coordinate + ":" + DEFAULT_VERSION);
|
versionedArtifact = new DefaultArtifact(coordinate + ":" + defaultVersion);
|
||||||
} else {
|
} else {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,7 +83,7 @@ public class CliHadoopIndexer implements Runnable
|
||||||
final List<URL> extensionURLs = Lists.newArrayList();
|
final List<URL> extensionURLs = Lists.newArrayList();
|
||||||
for (String coordinate : extensionsConfig.getCoordinates()) {
|
for (String coordinate : extensionsConfig.getCoordinates()) {
|
||||||
final ClassLoader coordinateLoader = Initialization.getClassLoaderForCoordinates(
|
final ClassLoader coordinateLoader = Initialization.getClassLoaderForCoordinates(
|
||||||
aetherClient, coordinate
|
aetherClient, coordinate, extensionsConfig.getDefaultVersion()
|
||||||
);
|
);
|
||||||
extensionURLs.addAll(Arrays.asList(((URLClassLoader) coordinateLoader).getURLs()));
|
extensionURLs.addAll(Arrays.asList(((URLClassLoader) coordinateLoader).getURLs()));
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ public class CliHadoopIndexer implements Runnable
|
||||||
// put hadoop dependencies last to avoid jets3t & apache.httpcore version conflicts
|
// put hadoop dependencies last to avoid jets3t & apache.httpcore version conflicts
|
||||||
for (String coordinate : allCoordinates) {
|
for (String coordinate : allCoordinates) {
|
||||||
final ClassLoader hadoopLoader = Initialization.getClassLoaderForCoordinates(
|
final ClassLoader hadoopLoader = Initialization.getClassLoaderForCoordinates(
|
||||||
aetherClient, coordinate
|
aetherClient, coordinate, extensionsConfig.getDefaultVersion()
|
||||||
);
|
);
|
||||||
driverURLs.addAll(Arrays.asList(((URLClassLoader) hadoopLoader).getURLs()));
|
driverURLs.addAll(Arrays.asList(((URLClassLoader) hadoopLoader).getURLs()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class PullDependencies implements Runnable
|
||||||
try {
|
try {
|
||||||
final DefaultTeslaAether aetherClient = Initialization.getAetherClient(extensionsConfig);
|
final DefaultTeslaAether aetherClient = Initialization.getAetherClient(extensionsConfig);
|
||||||
for (final String coordinate : allCoordinates) {
|
for (final String coordinate : allCoordinates) {
|
||||||
Initialization.getClassLoaderForCoordinates(aetherClient, coordinate);
|
Initialization.getClassLoaderForCoordinates(aetherClient, coordinate, extensionsConfig.getDefaultVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
|
Loading…
Reference in New Issue