use of io.tesla.aether.internal.DefaultTeslaAether in project druid by druid-io.
the class PullDependenciesTest method setUp.
@Before
public void setUp() throws Exception {
localRepo = temporaryFolder.newFolder();
extensionToJars = new HashMap<>();
extensionToJars.put(extension_A, ImmutableList.of("a.jar", "b.jar", "c.jar"));
extensionToJars.put(extension_B, ImmutableList.of("d.jar", "e.jar"));
extensionToJars.put(hadoop_client_2_3_0, ImmutableList.of("f.jar", "g.jar"));
extensionToJars.put(hadoop_client_2_4_0, ImmutableList.of("h.jar", "i.jar"));
rootExtensionsDir = new File(temporaryFolder.getRoot(), "extensions");
rootHadoopDependenciesDir = new File(temporaryFolder.getRoot(), "druid_hadoop_dependencies");
pullDependencies = new PullDependencies(new DefaultTeslaAether() {
@Override
public List<Artifact> resolveArtifacts(DependencyRequest request) throws DependencyResolutionException {
return getArtifactsForExtension(request.getCollectRequest().getRoot().getArtifact());
}
}, new ExtensionsConfig() {
@Override
public String getDirectory() {
return rootExtensionsDir.getAbsolutePath();
}
@Override
public String getHadoopDependenciesDir() {
return rootHadoopDependenciesDir.getAbsolutePath();
}
});
pullDependencies.coordinates = ImmutableList.of(EXTENSION_A_COORDINATE, EXTENSION_B_COORDINATE);
pullDependencies.hadoopCoordinates = ImmutableList.of(HADOOP_CLIENT_2_3_0_COORDINATE, HADOOP_CLIENT_2_4_0_COORDINATE);
}
use of io.tesla.aether.internal.DefaultTeslaAether in project druid by druid-io.
the class PullDependencies method getAetherClient.
private DefaultTeslaAether getAetherClient() {
/*
DefaultTeslaAether logs a bunch of stuff to System.out, which is annoying. We choose to disable that
unless debug logging is turned on. "Disabling" it, however, is kinda bass-ackwards. We copy out a reference
to the current System.out, and set System.out to a noop output stream. Then after DefaultTeslaAether has pulled
The reference we swap things back.
This has implications for other things that are running in parallel to this. Namely, if anything else also grabs
a reference to System.out or tries to log to it while we have things adjusted like this, then they will also log
to nothingness. Fortunately, the code that calls this is single-threaded and shouldn't hopefully be running
alongside anything else that's grabbing System.out. But who knows.
*/
final List<String> remoteUriList = Lists.newArrayList();
if (!noDefaultRemoteRepositories) {
remoteUriList.addAll(DEFAULT_REMOTE_REPOSITORIES);
}
remoteUriList.addAll(remoteRepositories);
List<Repository> remoteRepositories = Lists.newArrayList();
for (String uri : remoteUriList) {
try {
URI u = new URI(uri);
Repository r = new Repository(uri);
if (u.getUserInfo() != null) {
String[] auth = u.getUserInfo().split(":", 2);
if (auth.length == 2) {
r.setUsername(auth[0]);
r.setPassword(auth[1]);
} else {
log.warn("Invalid credentials in repository URI, expecting [<user>:<password>], got [%s] for [%s]", u.getUserInfo(), uri);
}
}
remoteRepositories.add(r);
} catch (URISyntaxException e) {
throw Throwables.propagate(e);
}
}
if (log.isTraceEnabled() || log.isDebugEnabled()) {
return new DefaultTeslaAether(localRepository, remoteRepositories.toArray(new Repository[remoteRepositories.size()]));
}
PrintStream oldOut = System.out;
try {
System.setOut(new PrintStream(new OutputStream() {
@Override
public void write(int b) throws IOException {
}
@Override
public void write(byte[] b) throws IOException {
}
@Override
public void write(byte[] b, int off, int len) throws IOException {
}
}, false, StringUtils.UTF8_STRING));
return new DefaultTeslaAether(localRepository, remoteRepositories.toArray(new Repository[remoteRepositories.size()]));
} catch (UnsupportedEncodingException e) {
// should never happen
throw new IllegalStateException(e);
} finally {
System.setOut(oldOut);
}
}
Aggregations