zeppelin-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject zeppelin git commit: [ZEPPELIN-2815] Improve interpreter dependencies logging
Date Thu, 24 Aug 2017 16:13:37 GMT
Repository: zeppelin
Updated Branches:
  refs/heads/master f3e659f46 -> 26a39df08


[ZEPPELIN-2815] Improve interpreter dependencies logging

### What is this PR for?
As a developer, I want to be able to debug issues on dependency resolution "easier".
To achieve this, making available (in debug mode), existing listeners.
Also, exposing exceptions on dependency resolver.

### What type of PR is it?
Improvement

### What is the Jira issue?
* https://issues.apache.org/jira/browse/ZEPPELIN-2815

### How should this be tested?
Enable DEBUG logging mode. Import dependencies. Check detailed info. from dependency loading
being logged.

### Questions:
* Does the licenses files need update? N
* Is there breaking changes for older versions? N
* Does this needs documentation? N

Author: Nelson Costa <nelson.costa85@gmail.com>

Closes #2507 from necosta/zeppelin2815 and squashes the following commits:

ea353fa [Nelson Costa] [ZEPPELIN-2815] Improve interpreter dependencies logging
d381f3b [Nelson Costa] [ZEPPELIN-2815] Improve interpreter dependencies logging
b773d8a [Nelson Costa] [ZEPPELIN-2815] Improve interpreter dependencies logging


Project: http://git-wip-us.apache.org/repos/asf/zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/zeppelin/commit/26a39df0
Tree: http://git-wip-us.apache.org/repos/asf/zeppelin/tree/26a39df0
Diff: http://git-wip-us.apache.org/repos/asf/zeppelin/diff/26a39df0

Branch: refs/heads/master
Commit: 26a39df08567c46aebbcab6581fcad4daaa89079
Parents: f3e659f
Author: Nelson Costa <nelson.costa85@gmail.com>
Authored: Tue Aug 8 08:11:17 2017 +0100
Committer: Lee moon soo <moon@apache.org>
Committed: Thu Aug 24 09:13:34 2017 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/zeppelin/dep/Booter.java | 11 ++++++++---
 .../org/apache/zeppelin/dep/DependencyResolver.java   | 12 +++++-------
 .../org/apache/zeppelin/dep/TransferListener.java     | 14 ++++++--------
 3 files changed, 19 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/zeppelin/blob/26a39df0/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/Booter.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/Booter.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/Booter.java
index 5bc58ed..6339a4f 100644
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/Booter.java
+++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/Booter.java
@@ -19,6 +19,8 @@ package org.apache.zeppelin.dep;
 
 import org.apache.commons.lang.Validate;
 import org.apache.maven.repository.internal.MavenRepositorySystemSession;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.sonatype.aether.RepositorySystem;
 import org.sonatype.aether.RepositorySystemSession;
 import org.sonatype.aether.repository.LocalRepository;
@@ -30,6 +32,8 @@ import java.nio.file.Paths;
  * Manage mvn repository.
  */
 public class Booter {
+  private static Logger logger = LoggerFactory.getLogger(Booter.class);
+
   public static RepositorySystem newRepositorySystem() {
     return RepositorySystemFactory.newRepositorySystem();
   }
@@ -43,9 +47,10 @@ public class Booter {
     LocalRepository localRepo = new LocalRepository(resolveLocalRepoPath(localRepoPath));
     session.setLocalRepositoryManager(system.newLocalRepositoryManager(localRepo));
 
-    // session.setTransferListener(new ConsoleTransferListener());
-    // session.setRepositoryListener(new ConsoleRepositoryListener());
-
+    if (logger.isDebugEnabled()) {
+      session.setTransferListener(new TransferListener());
+      session.setRepositoryListener(new RepositoryListener());
+    }
     // uncomment to generate dirty trees
     // session.setDependencyGraphTransformer( null );
 

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/26a39df0/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/DependencyResolver.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/DependencyResolver.java
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/DependencyResolver.java
index 889101f..c3ecdee 100644
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/DependencyResolver.java
+++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/DependencyResolver.java
@@ -19,7 +19,6 @@ package org.apache.zeppelin.dep;
 
 import java.io.File;
 import java.io.IOException;
-import java.net.URL;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Iterator;
@@ -33,25 +32,23 @@ import org.slf4j.LoggerFactory;
 import org.sonatype.aether.RepositoryException;
 import org.sonatype.aether.artifact.Artifact;
 import org.sonatype.aether.collection.CollectRequest;
-import org.sonatype.aether.collection.DependencyCollectionException;
 import org.sonatype.aether.graph.Dependency;
 import org.sonatype.aether.graph.DependencyFilter;
 import org.sonatype.aether.repository.RemoteRepository;
 import org.sonatype.aether.resolution.ArtifactResult;
 import org.sonatype.aether.resolution.DependencyRequest;
+import org.sonatype.aether.resolution.DependencyResolutionException;
 import org.sonatype.aether.util.artifact.DefaultArtifact;
 import org.sonatype.aether.util.artifact.JavaScopes;
 import org.sonatype.aether.util.filter.DependencyFilterUtils;
 import org.sonatype.aether.util.filter.PatternExclusionsDependencyFilter;
-import org.sonatype.aether.util.graph.DefaultDependencyNode;
-
 
 /**
  * Deps resolver.
  * Add new dependencies from mvn repo (at runtime) to Zeppelin.
  */
 public class DependencyResolver extends AbstractDependencyResolver {
-  Logger logger = LoggerFactory.getLogger(DependencyResolver.class);
+  private Logger logger = LoggerFactory.getLogger(DependencyResolver.class);
 
   private final String[] exclusions = new String[] {"org.apache.zeppelin:zeppelin-zengine",
                                                     "org.apache.zeppelin:zeppelin-interpreter",
@@ -177,8 +174,9 @@ public class DependencyResolver extends AbstractDependencyResolver {
             DependencyFilterUtils.andFilter(exclusionFilter, classpathFilter));
     try {
       return system.resolveDependencies(session, dependencyRequest).getArtifactResults();
-    } catch (NullPointerException ex) {
-      throw new RepositoryException(String.format("Cannot fetch dependencies for %s", dependency));
+    } catch (NullPointerException | DependencyResolutionException ex) {
+      throw new RepositoryException(
+              String.format("Cannot fetch dependencies for %s", dependency), ex);
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/zeppelin/blob/26a39df0/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/TransferListener.java
----------------------------------------------------------------------
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/TransferListener.java
b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/TransferListener.java
index fd9029f..7f25e3b 100644
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/TransferListener.java
+++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/dep/TransferListener.java
@@ -17,7 +17,6 @@
 
 package org.apache.zeppelin.dep;
 
-import java.io.PrintStream;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.util.Locale;
@@ -34,8 +33,7 @@ import org.sonatype.aether.transfer.TransferResource;
  * Simple listener that show deps downloading progress.
  */
 public class TransferListener extends AbstractTransferListener {
-  Logger logger = LoggerFactory.getLogger(TransferListener.class);
-  private PrintStream out;
+  private Logger logger = LoggerFactory.getLogger(TransferListener.class);
 
   private Map<TransferResource, Long> downloads = new ConcurrentHashMap<>();
 
@@ -55,13 +53,13 @@ public class TransferListener extends AbstractTransferListener {
   @Override
   public void transferProgressed(TransferEvent event) {
     TransferResource resource = event.getResource();
-    downloads.put(resource, Long.valueOf(event.getTransferredBytes()));
+    downloads.put(resource, event.getTransferredBytes());
 
     StringBuilder buffer = new StringBuilder(64);
 
     for (Map.Entry<TransferResource, Long> entry : downloads.entrySet()) {
       long total = entry.getKey().getContentLength();
-      long complete = entry.getValue().longValue();
+      long complete = entry.getValue();
 
       buffer.append(getStatus(complete, total)).append("  ");
     }
@@ -122,7 +120,7 @@ public class TransferListener extends AbstractTransferListener {
   @Override
   public void transferFailed(TransferEvent event) {
     transferCompleted(event);
-    event.getException().printStackTrace(out);
+    logger.warn("Unsuccessful transfer", event.getException());
   }
 
   private void transferCompleted(TransferEvent event) {
@@ -135,10 +133,10 @@ public class TransferListener extends AbstractTransferListener {
 
   @Override
   public void transferCorrupted(TransferEvent event) {
-    event.getException().printStackTrace(out);
+    logger.error("Corrupted transfer", event.getException());
   }
 
-  protected long toKB(long bytes) {
+  private long toKB(long bytes) {
     return (bytes + 1023) / 1024;
   }
 


Mime
View raw message