Repository: incubator-atlas Updated Branches: refs/heads/master 08944c54d -> 0c1d599dd
ATLAS-1598: fix for NPE in Hive hook while processing create-table Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/0c1d599d Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/0c1d599d Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/0c1d599d Branch: refs/heads/master Commit: 0c1d599ddca7ad9e4c677c77908e96dd492a8f90 Parents: 08944c5 Author: Madhan Neethiraj <[email protected]> Authored: Sat Feb 25 15:23:29 2017 -0800 Committer: Madhan Neethiraj <[email protected]> Committed: Sun Feb 26 00:31:17 2017 -0800 ---------------------------------------------------------------------- .../org/apache/atlas/hive/hook/HiveHook.java | 4 +-- .../store/graph/v1/AtlasEntityStoreV1.java | 34 ++++++++++++-------- 2 files changed, 23 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/0c1d599d/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java ---------------------------------------------------------------------- diff --git a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java index 2b256d0..16835cf 100755 --- a/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java +++ b/addons/hive-bridge/src/main/java/org/apache/atlas/hive/hook/HiveHook.java @@ -248,7 +248,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { case CREATETABLE: LinkedHashMap<Type, Referenceable> tablesCreated = handleEventOutputs(dgiBridge, event, Type.TABLE); - if (tablesCreated.size() > 0) { + if (tablesCreated != null && tablesCreated.size() > 0) { handleExternalTables(dgiBridge, event, tablesCreated); } break; @@ -730,7 +730,7 @@ public class HiveHook extends AtlasHook implements ExecuteWithHookContext { final String location = lower(hiveTable.getDataLocation().toString()); final ReadEntity dfsEntity = new ReadEntity(); dfsEntity.setTyp(Type.DFS_DIR); - dfsEntity.setName(location); + dfsEntity.setD(new Path(location)); SortedMap<ReadEntity, Referenceable> hiveInputsMap = new TreeMap<ReadEntity, Referenceable>(entityComparator) {{ put(dfsEntity, dgiBridge.fillHDFSDataSet(location)); http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/0c1d599d/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java ---------------------------------------------------------------------- diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java index c0355d9..587f3c7 100644 --- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java +++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v1/AtlasEntityStoreV1.java @@ -21,7 +21,6 @@ package org.apache.atlas.repository.store.graph.v1; import com.google.inject.Inject; import com.google.inject.Singleton; import org.apache.atlas.AtlasErrorCode; -import org.apache.atlas.AtlasException; import org.apache.atlas.GraphTransaction; import org.apache.atlas.RequestContextV1; import org.apache.atlas.exception.AtlasBaseException; @@ -38,12 +37,10 @@ import org.apache.atlas.repository.store.graph.AtlasEntityStore; import org.apache.atlas.repository.store.graph.EntityGraphDiscovery; import org.apache.atlas.repository.store.graph.EntityGraphDiscoveryContext; import org.apache.atlas.type.AtlasEntityType; -import org.apache.atlas.type.AtlasStructType; import org.apache.atlas.type.AtlasStructType.AtlasAttribute; import org.apache.atlas.type.AtlasType; import org.apache.atlas.type.AtlasTypeRegistry; import org.apache.atlas.type.AtlasTypeUtil; -import org.apache.atlas.typesystem.persistence.Id; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -326,17 +323,18 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { // Retrieve vertices for requested guids. AtlasVertex vertex = AtlasGraphUtilsV1.findByGuid(guid); - if (LOG.isDebugEnabled()) { - if (vertex == null) { + Collection<AtlasVertex> deletionCandidates = new ArrayList<>(); + + if (vertex != null) { + deletionCandidates.add(vertex); + } else { + if (LOG.isDebugEnabled()) { // Entity does not exist - treat as non-error, since the caller // wanted to delete the entity and it's already gone. LOG.debug("Deletion request ignored for non-existent entity with guid " + guid); } } - Collection<AtlasVertex> deletionCandidates = new ArrayList<>(); - deletionCandidates.add(vertex); - EntityMutationResponse ret = deleteVertices(deletionCandidates); // Notify the change listeners @@ -357,15 +355,16 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { for (String guid : guids) { // Retrieve vertices for requested guids. AtlasVertex vertex = AtlasGraphUtilsV1.findByGuid(guid); - if (LOG.isDebugEnabled()) { - if (vertex == null) { + + if (vertex != null) { + deletionCandidates.add(vertex); + } else { + if (LOG.isDebugEnabled()) { // Entity does not exist - treat as non-error, since the caller // wanted to delete the entity and it's already gone. LOG.debug("Deletion request ignored for non-existent entity with guid " + guid); } } - deletionCandidates.add(vertex); - } if (deletionCandidates.isEmpty()) { @@ -391,7 +390,16 @@ public class AtlasEntityStoreV1 implements AtlasEntityStore { final AtlasVertex vertex = AtlasGraphUtilsV1.findByUniqueAttributes(entityType, uniqAttributes); Collection<AtlasVertex> deletionCandidates = new ArrayList<>(); - deletionCandidates.add(vertex); + + if (vertex != null) { + deletionCandidates.add(vertex); + } else { + if (LOG.isDebugEnabled()) { + // Entity does not exist - treat as non-error, since the caller + // wanted to delete the entity and it's already gone. + LOG.debug("Deletion request ignored for non-existent entity with uniqueAttributes " + uniqAttributes); + } + } EntityMutationResponse ret = deleteVertices(deletionCandidates);
