Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 11BD9200CF9 for ; Sun, 17 Sep 2017 20:25:13 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 103F41609D8; Sun, 17 Sep 2017 18:25:13 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id D36771609CF for ; Sun, 17 Sep 2017 20:25:11 +0200 (CEST) Received: (qmail 75748 invoked by uid 500); 17 Sep 2017 18:25:11 -0000 Mailing-List: contact commits-help@atlas.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@atlas.apache.org Delivered-To: mailing list commits@atlas.apache.org Received: (qmail 75739 invoked by uid 99); 17 Sep 2017 18:25:11 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 17 Sep 2017 18:25:11 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 04B69F32C3; Sun, 17 Sep 2017 18:25:09 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: madhan@apache.org To: commits@atlas.apache.org Message-Id: <348bc549fda445ee81b1cb9f007e9d3f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: atlas git commit: ATLAS-2140: Throwing overly generic exceptions, or unnecessarily exceptions Date: Sun, 17 Sep 2017 18:25:09 +0000 (UTC) archived-at: Sun, 17 Sep 2017 18:25:13 -0000 Repository: atlas Updated Branches: refs/heads/master 45b84fa20 -> d67b0498e ATLAS-2140: Throwing overly generic exceptions, or unnecessarily exceptions Change-Id: I9df89ebca2e281768d3353bd691ea7eafca96f47 Signed-off-by: Madhan Neethiraj Project: http://git-wip-us.apache.org/repos/asf/atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/atlas/commit/d67b0498 Tree: http://git-wip-us.apache.org/repos/asf/atlas/tree/d67b0498 Diff: http://git-wip-us.apache.org/repos/asf/atlas/diff/d67b0498 Branch: refs/heads/master Commit: d67b0498edf907ea7370247447b7e86d46645c2a Parents: 45b84fa Author: Zsombor Gegesy Authored: Sat Sep 16 16:25:21 2017 +0200 Committer: Madhan Neethiraj Committed: Sun Sep 17 11:24:26 2017 -0700 ---------------------------------------------------------------------- .../atlas/falcon/bridge/FalconBridge.java | 25 +++++++++++--------- .../apache/atlas/falcon/hook/FalconHook.java | 12 ++++++---- .../falcon/publisher/FalconEventPublisher.java | 2 +- .../apache/atlas/storm/hook/StormAtlasHook.java | 25 ++++++++++---------- .../atlas/storm/hook/StormTopologyUtil.java | 8 +++---- .../classloader/AtlasPluginClassLoader.java | 19 ++++++++------- .../classloader/AtlasPluginClassLoaderUtil.java | 5 ++-- 7 files changed, 50 insertions(+), 46 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/atlas/blob/d67b0498/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/bridge/FalconBridge.java ---------------------------------------------------------------------- diff --git a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/bridge/FalconBridge.java b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/bridge/FalconBridge.java index 349da66..ff74559 100644 --- a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/bridge/FalconBridge.java +++ b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/bridge/FalconBridge.java @@ -27,6 +27,7 @@ import org.apache.atlas.hive.model.HiveDataTypes; import org.apache.atlas.typesystem.Referenceable; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; +import org.apache.falcon.FalconException; import org.apache.falcon.entity.CatalogStorage; import org.apache.falcon.entity.FeedHelper; import org.apache.falcon.entity.FileSystemStorage; @@ -47,6 +48,7 @@ import org.apache.hadoop.fs.Path; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -123,7 +125,7 @@ public class FalconBridge { return feedEntity; } - public static List createFeedCreationEntity(Feed feed, ConfigurationStore falconStore) throws Exception { + public static List createFeedCreationEntity(Feed feed, ConfigurationStore falconStore) throws FalconException, URISyntaxException { LOG.info("Creating feed : {}", feed.getName()); List entities = new ArrayList<>(); @@ -198,17 +200,18 @@ public class FalconBridge { } /** - * + * Creates process entity - * + * - * + * @param process process entity - * + * @param falconStore config store - * + * @param user falcon user - * + * @param timestamp timestamp of entity - * + * @return process instance reference - * + + * Creates process entity + * + * @param process process entity + * @param falconStore config store + * @param user falcon user + * @param timestamp timestamp of entity + * @return process instance reference + * + * @throws FalconException if retrieving from the configuration store fail */ public static List createProcessEntity(org.apache.falcon.entity.v0.process.Process process, - ConfigurationStore falconStore) throws Exception { + ConfigurationStore falconStore) throws FalconException { LOG.info("Creating process Entity : {}", process.getName()); // The requirement is for each cluster, create a process entity with name @@ -288,7 +291,7 @@ public class FalconBridge { } private static List getInputEntities(org.apache.falcon.entity.v0.cluster.Cluster cluster, - Feed feed) throws Exception { + Feed feed) throws URISyntaxException { org.apache.falcon.entity.v0.feed.Cluster feedCluster = FeedHelper.getCluster(feed, cluster.getName()); if(feedCluster != null) { http://git-wip-us.apache.org/repos/asf/atlas/blob/d67b0498/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java ---------------------------------------------------------------------- diff --git a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java index 3b384f8..188b754 100644 --- a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java +++ b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/hook/FalconHook.java @@ -27,6 +27,7 @@ import org.apache.atlas.hook.AtlasHook; import org.apache.atlas.kafka.NotificationProvider; import org.apache.atlas.notification.hook.HookNotification; import org.apache.atlas.typesystem.Referenceable; +import org.apache.falcon.FalconException; import org.apache.falcon.entity.store.ConfigurationStore; import org.apache.falcon.entity.v0.feed.Feed; import org.apache.falcon.entity.v0.process.Process; @@ -34,6 +35,7 @@ import org.apache.hadoop.util.ShutdownHookManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.net.URISyntaxException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; @@ -120,7 +122,7 @@ public class FalconHook extends AtlasHook implements FalconEventPublisher { } @Override - public void publish(final Data data) throws Exception { + public void publish(final Data data) { final FalconEvent event = data.getEvent(); try { if (sync) { @@ -147,7 +149,7 @@ public class FalconHook extends AtlasHook implements FalconEventPublisher { return HOOK_NUM_RETRIES; } - private void fireAndForget(FalconEvent event) throws Exception { + private void fireAndForget(FalconEvent event) throws FalconException, URISyntaxException { LOG.info("Entered Atlas hook for Falcon hook operation {}", event.getOperation()); List messages = new ArrayList<>(); @@ -163,7 +165,7 @@ public class FalconHook extends AtlasHook implements FalconEventPublisher { notifyEntities(messages); } - private List createEntities(FalconEvent event, String user) throws Exception { + private List createEntities(FalconEvent event, String user) throws FalconException, URISyntaxException { List entities = new ArrayList<>(); switch (event.getOperation()) { @@ -190,7 +192,7 @@ public class FalconHook extends AtlasHook implements FalconEventPublisher { return entities; } - private static Operation getOperation(final FalconEvent.OPERATION op) throws Exception { + private static Operation getOperation(final FalconEvent.OPERATION op) throws FalconException { switch (op) { case ADD_CLUSTER: case ADD_FEED: @@ -203,7 +205,7 @@ public class FalconHook extends AtlasHook implements FalconEventPublisher { return Operation.UPDATE; default: - throw new Exception("Falcon operation " + op + " is not valid or supported"); + throw new FalconException("Falcon operation " + op + " is not valid or supported"); } } } http://git-wip-us.apache.org/repos/asf/atlas/blob/d67b0498/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/publisher/FalconEventPublisher.java ---------------------------------------------------------------------- diff --git a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/publisher/FalconEventPublisher.java b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/publisher/FalconEventPublisher.java index ea81226..a01ec14 100644 --- a/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/publisher/FalconEventPublisher.java +++ b/addons/falcon-bridge/src/main/java/org/apache/atlas/falcon/publisher/FalconEventPublisher.java @@ -37,5 +37,5 @@ public interface FalconEventPublisher { } } - void publish(final Data data) throws Exception; + void publish(final Data data); } http://git-wip-us.apache.org/repos/asf/atlas/blob/d67b0498/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormAtlasHook.java ---------------------------------------------------------------------- diff --git a/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormAtlasHook.java b/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormAtlasHook.java index 5193832..c3df8fc 100644 --- a/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormAtlasHook.java +++ b/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormAtlasHook.java @@ -75,11 +75,10 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { * @param topologyInfo topology info * @param stormConf configuration * @param stormTopology a storm topology - * @throws IllegalAccessException */ @Override public void notify(TopologyInfo topologyInfo, Map stormConf, - StormTopology stormTopology) throws IllegalAccessException { + StormTopology stormTopology) { LOG.info("Collecting metadata for a new storm topology: {}", topologyInfo.get_name()); try { @@ -105,7 +104,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { } } - private Referenceable createTopologyInstance(TopologyInfo topologyInfo, Map stormConf) throws Exception { + private Referenceable createTopologyInstance(TopologyInfo topologyInfo, Map stormConf) { Referenceable topologyReferenceable = new Referenceable( StormDataTypes.STORM_TOPOLOGY.getName()); topologyReferenceable.set("id", topologyInfo.get_id()); @@ -125,7 +124,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { private List addTopologyDataSets(StormTopology stormTopology, Referenceable topologyReferenceable, String topologyOwner, - Map stormConf) throws Exception { + Map stormConf) { List dependentEntities = new ArrayList<>(); // add each spout as an input data set addTopologyInputs(topologyReferenceable, @@ -138,7 +137,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { private void addTopologyInputs(Referenceable topologyReferenceable, Map spouts, Map stormConf, - String topologyOwner, List dependentEntities) throws IllegalAccessException { + String topologyOwner, List dependentEntities) { final ArrayList inputDataSets = new ArrayList<>(); for (Map.Entry entry : spouts.entrySet()) { Serializable instance = Utils.javaDeserialize( @@ -156,7 +155,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { private void addTopologyOutputs(Referenceable topologyReferenceable, StormTopology stormTopology, String topologyOwner, - Map stormConf, List dependentEntities) throws Exception { + Map stormConf, List dependentEntities) { final ArrayList outputDataSets = new ArrayList<>(); Map bolts = stormTopology.get_bolts(); @@ -177,7 +176,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { private Referenceable createDataSet(String name, String topologyOwner, Serializable instance, - Map stormConf, List dependentEntities) throws IllegalAccessException { + Map stormConf, List dependentEntities) { Map config = StormTopologyUtil.getFieldValues(instance, true, null); String clusterName = null; @@ -265,7 +264,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { private ArrayList createTopologyGraph(StormTopology stormTopology, Map spouts, - Map bolts) throws Exception { + Map bolts) { // Add graph of nodes in the topology final Map nodeEntities = new HashMap<>(); addSpouts(spouts, nodeEntities); @@ -279,7 +278,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { } private void addSpouts(Map spouts, - Map nodeEntities) throws IllegalAccessException { + Map nodeEntities) { for (Map.Entry entry : spouts.entrySet()) { final String spoutName = entry.getKey(); Referenceable spoutReferenceable = createSpoutInstance( @@ -289,7 +288,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { } private Referenceable createSpoutInstance(String spoutName, - SpoutSpec stormSpout) throws IllegalAccessException { + SpoutSpec stormSpout) { Referenceable spoutReferenceable = new Referenceable(StormDataTypes.STORM_SPOUT.getName()); spoutReferenceable.set(AtlasClient.NAME, spoutName); @@ -304,7 +303,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { } private void addBolts(Map bolts, - Map nodeEntities) throws IllegalAccessException { + Map nodeEntities) { for (Map.Entry entry : bolts.entrySet()) { Referenceable boltInstance = createBoltInstance(entry.getKey(), entry.getValue()); nodeEntities.put(entry.getKey(), boltInstance); @@ -312,7 +311,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { } private Referenceable createBoltInstance(String boltName, - Bolt stormBolt) throws IllegalAccessException { + Bolt stormBolt) { Referenceable boltReferenceable = new Referenceable(StormDataTypes.STORM_BOLT.getName()); boltReferenceable.set(AtlasClient.NAME, boltName); @@ -328,7 +327,7 @@ public class StormAtlasHook extends AtlasHook implements ISubmitterHook { } private void addGraphConnections(StormTopology stormTopology, - Map nodeEntities) throws Exception { + Map nodeEntities) { // adds connections between spouts and bolts Map> adjacencyMap = StormTopologyUtil.getAdjacencyMap(stormTopology, true); http://git-wip-us.apache.org/repos/asf/atlas/blob/d67b0498/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormTopologyUtil.java ---------------------------------------------------------------------- diff --git a/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormTopologyUtil.java b/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormTopologyUtil.java index d999a6a..b903dbc 100644 --- a/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormTopologyUtil.java +++ b/addons/storm-bridge/src/main/java/org/apache/atlas/storm/hook/StormTopologyUtil.java @@ -69,8 +69,7 @@ public final class StormTopologyUtil { } public static Map> getAdjacencyMap(StormTopology topology, - boolean removeSystemComponent) - throws Exception { + boolean removeSystemComponent) { Map> adjacencyMap = new HashMap<>(); for (Map.Entry entry : topology.get_bolts().entrySet()) { @@ -129,8 +128,7 @@ public final class StormTopologyUtil { public static Map getFieldValues(Object instance, boolean prependClassName, - Set objectsToSkip) - throws IllegalAccessException { + Set objectsToSkip) { if (objectsToSkip == null) { objectsToSkip = new HashSet<>(); } @@ -213,7 +211,7 @@ public final class StormTopologyUtil { private static String getString(Object instance, boolean wrapWithQuote, - Set objectsToSkip) throws IllegalAccessException { + Set objectsToSkip) { if (instance == null) { return null; } else if (instance.getClass().isPrimitive() || isWrapperType(instance.getClass())) { http://git-wip-us.apache.org/repos/asf/atlas/blob/d67b0498/plugin-classloader/src/main/java/org/apache/atlas/plugin/classloader/AtlasPluginClassLoader.java ---------------------------------------------------------------------- diff --git a/plugin-classloader/src/main/java/org/apache/atlas/plugin/classloader/AtlasPluginClassLoader.java b/plugin-classloader/src/main/java/org/apache/atlas/plugin/classloader/AtlasPluginClassLoader.java index d7ec65d..4ed32c0 100644 --- a/plugin-classloader/src/main/java/org/apache/atlas/plugin/classloader/AtlasPluginClassLoader.java +++ b/plugin-classloader/src/main/java/org/apache/atlas/plugin/classloader/AtlasPluginClassLoader.java @@ -22,10 +22,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLClassLoader; import java.security.AccessController; import java.security.PrivilegedAction; +import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; import java.util.Enumeration; @@ -39,12 +41,12 @@ public final class AtlasPluginClassLoader extends URLClassLoader { private final MyClassLoader componentClassLoader; - private AtlasPluginClassLoader(String pluginType, Class pluginClass) throws Exception { + private AtlasPluginClassLoader(String pluginType, Class pluginClass) throws URISyntaxException { this(AtlasPluginClassLoaderUtil.getPluginImplLibPath(pluginType, pluginClass)); } //visible for testing - AtlasPluginClassLoader(String libraryPath) throws Exception { + AtlasPluginClassLoader(String libraryPath) { super(AtlasPluginClassLoaderUtil.getFilesInDirectories(new String[]{libraryPath}), null); componentClassLoader = AccessController.doPrivileged(new PrivilegedAction() { @@ -54,18 +56,17 @@ public final class AtlasPluginClassLoader extends URLClassLoader { }); } - public static AtlasPluginClassLoader getInstance(final String pluginType, final Class pluginClass) - throws Exception { + public static AtlasPluginClassLoader getInstance(final String pluginType, final Class pluginClass) throws PrivilegedActionException { AtlasPluginClassLoader ret = me; if (ret == null) { synchronized (AtlasPluginClassLoader.class) { ret = me; if (ret == null) { - me = AccessController.doPrivileged(new PrivilegedExceptionAction() { - public AtlasPluginClassLoader run() throws Exception { - return new AtlasPluginClassLoader(pluginType, pluginClass); - } - }); + me = AccessController.doPrivileged(new PrivilegedExceptionAction() { + public AtlasPluginClassLoader run() throws URISyntaxException { + return new AtlasPluginClassLoader(pluginType, pluginClass); + } + }); ret = me; } } http://git-wip-us.apache.org/repos/asf/atlas/blob/d67b0498/plugin-classloader/src/main/java/org/apache/atlas/plugin/classloader/AtlasPluginClassLoaderUtil.java ---------------------------------------------------------------------- diff --git a/plugin-classloader/src/main/java/org/apache/atlas/plugin/classloader/AtlasPluginClassLoaderUtil.java b/plugin-classloader/src/main/java/org/apache/atlas/plugin/classloader/AtlasPluginClassLoaderUtil.java index dfdad88..f44603b 100644 --- a/plugin-classloader/src/main/java/org/apache/atlas/plugin/classloader/AtlasPluginClassLoaderUtil.java +++ b/plugin-classloader/src/main/java/org/apache/atlas/plugin/classloader/AtlasPluginClassLoaderUtil.java @@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory; import java.io.File; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.nio.file.Path; import java.nio.file.Paths; @@ -40,7 +41,7 @@ final class AtlasPluginClassLoaderUtil { private AtlasPluginClassLoaderUtil(){ } - public static URL[] getFilesInDirectories(String[] libDirs) throws Exception { + public static URL[] getFilesInDirectories(String[] libDirs) { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasPluginClassLoaderUtil.getFilesInDirectories()"); } @@ -95,7 +96,7 @@ final class AtlasPluginClassLoaderUtil { } } - public static String getPluginImplLibPath(String pluginType, Class pluginClass) throws Exception { + public static String getPluginImplLibPath(String pluginType, Class pluginClass) throws URISyntaxException { if (LOG.isDebugEnabled()) { LOG.debug("==> AtlasPluginClassLoaderUtil.getPluginImplLibPath for Class ({})", pluginClass.getName()); }