Repository: incubator-atlas Updated Branches: refs/heads/master aad34ae00 -> 39eb9f1ee
ATLAS-890 Log received messages in case of error (sumasai via yhemanth) Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/39eb9f1e Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/39eb9f1e Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/39eb9f1e Branch: refs/heads/master Commit: 39eb9f1eea636c0cf823570aed5f7dc5e8141bc5 Parents: aad34ae Author: Hemanth Yamijala <[email protected]> Authored: Wed Jun 15 23:50:50 2016 +0530 Committer: Hemanth Yamijala <[email protected]> Committed: Wed Jun 15 23:50:50 2016 +0530 ---------------------------------------------------------------------- .../notification/hook/HookNotification.java | 24 ++++++ release-log.txt | 1 + .../atlas/web/resources/EntityResource.java | 89 +++++++++++--------- 3 files changed, 76 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/39eb9f1e/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java ---------------------------------------------------------------------- diff --git a/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java b/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java index 80c96fa..88a0322 100644 --- a/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java +++ b/notification/src/main/java/org/apache/atlas/notification/hook/HookNotification.java @@ -159,6 +159,11 @@ public class HookNotification implements JsonDeserializer<HookNotification.HookN public List<Referenceable> getEntities() throws JSONException { return entities; } + + @Override + public String toString() { + return entities.toString(); + } } /** @@ -210,6 +215,16 @@ public class HookNotification implements JsonDeserializer<HookNotification.HookN public String getAttributeValue() { return attributeValue; } + + @Override + public String toString() { + return "{" + + "entityType='" + typeName + '\'' + + ", attribute=" + attribute + + ", value=" + attributeValue + + ", entity=" + entity + + '}'; + } } /** @@ -247,5 +262,14 @@ public class HookNotification implements JsonDeserializer<HookNotification.HookN public String getAttributeValue() { return attributeValue; } + + @Override + public String toString() { + return "{" + + "entityType='" + typeName + '\'' + + ", attribute=" + attribute + + ", value=" + attributeValue + + '}'; + } } } http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/39eb9f1e/release-log.txt ---------------------------------------------------------------------- diff --git a/release-log.txt b/release-log.txt index 0f384d2..57525d7 100644 --- a/release-log.txt +++ b/release-log.txt @@ -23,6 +23,7 @@ ATLAS-409 Atlas will not import avro tables with schema read from a file (dosset ATLAS-379 Create sqoop and falcon metadata addons (venkatnrangan,bvellanki,sowmyaramesh via shwethags) ALL CHANGES: +ATLAS-890 Log received messages in case of error (sumasai via yhemanth) ATLAS-888 NPE in NotificationHookConsumer (sumasai via shwethags) ATLAS-884 Process registration should call Entity update instead of create (sumasai) ATLAS-515 Ability to initialize Kafka topics with more than 1 replica (yhemanth) http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/39eb9f1e/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java ---------------------------------------------------------------------- diff --git a/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java b/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java index 364f17a..0713d30 100755 --- a/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java +++ b/webapp/src/main/java/org/apache/atlas/web/resources/EntityResource.java @@ -105,6 +105,8 @@ public class EntityResource { @Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON}) @Produces(Servlets.JSON_MEDIA_TYPE) public Response submit(@Context HttpServletRequest request) { + + String entityJson = null; try { String entities = Servlets.getRequestPayload(request); @@ -118,7 +120,8 @@ public class EntityResource { }}.toString(); } - LOG.debug("submitting entities {} ", AtlasClient.toString(new JSONArray(entities))); + entityJson = AtlasClient.toString(new JSONArray(entities)); + LOG.debug("submitting entities {} ", entityJson); final List<String> guids = metadataService.createEntities(entities); JSONObject response = getResponse(new AtlasClient.EntityResult(guids, null, null)); @@ -128,16 +131,16 @@ public class EntityResource { return Response.created(locationURI).entity(response).build(); } catch(EntityExistsException e) { - LOG.error("Unique constraint violation", e); + LOG.error("Unique constraint violation for entity entityDef={}", entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.CONFLICT)); } catch (ValueConversionException ve) { - LOG.error("Unable to persist entity instance due to a deserialization error ", ve); + LOG.error("Unable to persist entity instance due to a deserialization error entityDef={}", entityJson, ve); throw new WebApplicationException(Servlets.getErrorResponse(ve.getCause(), Response.Status.BAD_REQUEST)); } catch (AtlasException | IllegalArgumentException e) { - LOG.error("Unable to persist entity instance", e); + LOG.error("Unable to persist entity instance entityDef={}", entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (Throwable e) { - LOG.error("Unable to persist entity instance", e); + LOG.error("Unable to persist entity instance entityDef={}", entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -180,24 +183,28 @@ public class EntityResource { @Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON}) @Produces(Servlets.JSON_MEDIA_TYPE) public Response updateEntities(@Context HttpServletRequest request) { + + String entityJson = null; try { final String entities = Servlets.getRequestPayload(request); - LOG.debug("updating entities {} ", AtlasClient.toString(new JSONArray(entities))); + + entityJson = AtlasClient.toString(new JSONArray(entities)); + LOG.debug("updating entities {} ", entityJson); AtlasClient.EntityResult entityResult = metadataService.updateEntities(entities); JSONObject response = getResponse(entityResult); return Response.ok(response).build(); } catch(EntityExistsException e) { - LOG.error("Unique constraint violation", e); + LOG.error("Unique constraint violation for entityDef={}", entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.CONFLICT)); } catch (ValueConversionException ve) { - LOG.error("Unable to persist entity instance due to a deserialization error ", ve); + LOG.error("Unable to persist entity instance due to a deserialization error entityDef={}", entityJson, ve); throw new WebApplicationException(Servlets.getErrorResponse(ve.getCause(), Response.Status.BAD_REQUEST)); } catch (AtlasException | IllegalArgumentException e) { - LOG.error("Unable to persist entity instance", e); + LOG.error("Unable to persist entity instance entityDef={}", entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (Throwable e) { - LOG.error("Unable to persist entity instance", e); + LOG.error("Unable to persist entity instance entityDef={}", entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -241,32 +248,35 @@ public class EntityResource { public Response updateByUniqueAttribute(@QueryParam("type") String entityType, @QueryParam("property") String attribute, @QueryParam("value") String value, @Context HttpServletRequest request) { + + String entityJson = null; try { - String entities = Servlets.getRequestPayload(request); + entityJson = Servlets.getRequestPayload(request); - LOG.debug("Partially updating entity by unique attribute {} {} {} {} ", entityType, attribute, value, entities); + LOG.debug("Partially updating entity by unique attribute {} {} {} {} ", entityType, attribute, value, entityJson); Referenceable updatedEntity = - InstanceSerialization.fromJsonReferenceable(entities, true); + InstanceSerialization.fromJsonReferenceable(entityJson, true); + AtlasClient.EntityResult entityResult = metadataService.updateEntityByUniqueAttribute(entityType, attribute, value, updatedEntity); JSONObject response = getResponse(entityResult); return Response.ok(response).build(); } catch (ValueConversionException ve) { - LOG.error("Unable to persist entity instance due to a deserialization error ", ve); + LOG.error("Unable to persist entity instance due to a deserialization error {} ", entityJson, ve); throw new WebApplicationException(Servlets.getErrorResponse(ve.getCause(), Response.Status.BAD_REQUEST)); } catch(EntityExistsException e) { - LOG.error("Unique constraint violation", e); + LOG.error("Unique constraint violation for entity {} ", entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.CONFLICT)); } catch (EntityNotFoundException e) { - LOG.error("An entity with type={} and qualifiedName={} does not exist", entityType, value, e); + LOG.error("An entity with type={} and qualifiedName={} does not exist {} ", entityType, value, entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND)); } catch (AtlasException | IllegalArgumentException e) { - LOG.error("Unable to create/update entity {}" + entityType + ":" + attribute + "." + value, e); + LOG.error("Unable to partially update entity {} {} " + entityType + ":" + attribute + "." + value, entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (Throwable e) { - LOG.error("Unable to update entity {}" + entityType + ":" + attribute + "." + value, e); + LOG.error("Unable to partially update entity {} {} " + entityType + ":" + attribute + "." + value, entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -294,9 +304,10 @@ public class EntityResource { } private Response updateEntityPartialByGuid(String guid, HttpServletRequest request) { + String entityJson = null; try { ParamChecker.notEmpty(guid, "Guid property cannot be null"); - final String entityJson = Servlets.getRequestPayload(request); + entityJson = Servlets.getRequestPayload(request); LOG.debug("partially updating entity for guid {} : {} ", guid, entityJson); Referenceable updatedEntity = @@ -305,13 +316,13 @@ public class EntityResource { JSONObject response = getResponse(entityResult); return Response.ok(response).build(); } catch (EntityNotFoundException e) { - LOG.error("An entity with GUID={} does not exist", guid, e); + LOG.error("An entity with GUID={} does not exist {} ", guid, entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND)); } catch (AtlasException | IllegalArgumentException e) { - LOG.error("Unable to update entity {}", guid, e); + LOG.error("Unable to update entity by GUID {} {}", guid, entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (Throwable e) { - LOG.error("Unable to update entity {}", guid, e); + LOG.error("Unable to update entity by GUID {} {} ", guid, entityJson, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -327,22 +338,23 @@ public class EntityResource { * @return response payload as json */ private Response updateEntityAttributeByGuid(String guid, String property, HttpServletRequest request) { + String value = null; try { Preconditions.checkNotNull(property, "Entity property cannot be null"); - String value = Servlets.getRequestPayload(request); + value = Servlets.getRequestPayload(request); Preconditions.checkNotNull(value, "Entity value cannot be null"); AtlasClient.EntityResult entityResult = metadataService.updateEntityAttributeByGuid(guid, property, value); JSONObject response = getResponse(entityResult); return Response.ok(response).build(); } catch (EntityNotFoundException e) { - LOG.error("An entity with GUID={} does not exist", guid, e); + LOG.error("An entity with GUID={} does not exist {} ", guid, value, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND)); } catch (AtlasException | IllegalArgumentException e) { - LOG.error("Unable to add property {} to entity id {}", property, guid, e); + LOG.error("Unable to add property {} to entity id {} {} ", property, guid, value, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (Throwable e) { - LOG.error("Unable to add property {} to entity id {}", property, guid, e); + LOG.error("Unable to add property {} to entity id {} {} ", property, guid, value, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -377,16 +389,16 @@ public class EntityResource { return Response.ok(response).build(); } catch (EntityNotFoundException e) { if(guids != null || !guids.isEmpty()) { - LOG.error("An entity with GUID={} does not exist", guids, e); + LOG.error("An entity with GUID={} does not exist ", guids, e); } else { LOG.error("An entity with qualifiedName {}-{}-{} does not exist", entityType, attribute, value, e); } throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND)); } catch (AtlasException | IllegalArgumentException e) { - LOG.error("Unable to delete entities {}", guids, e); + LOG.error("Unable to delete entities {} {} {} {} ", guids, entityType, attribute, value, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (Throwable e) { - LOG.error("Unable to delete entities {}", guids, e); + LOG.error("Unable to delete entities {} {} {} {} ", guids, entityType, attribute, value, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -420,10 +432,10 @@ public class EntityResource { return Response.status(status).entity(response).build(); } catch (EntityNotFoundException e) { - LOG.error("An entity with GUID={} does not exist", guid, e); + LOG.error("An entity with GUID={} does not exist ", guid, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND)); } catch (AtlasException | IllegalArgumentException e) { - LOG.error("Bad GUID={}", guid, e); + LOG.error("Bad GUID={} ", guid, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (Throwable e) { LOG.error("Unable to get instance definition for GUID {}", guid, e); @@ -564,8 +576,9 @@ public class EntityResource { @Consumes({Servlets.JSON_MEDIA_TYPE, MediaType.APPLICATION_JSON}) @Produces(Servlets.JSON_MEDIA_TYPE) public Response addTrait(@Context HttpServletRequest request, @PathParam("guid") final String guid) { + String traitDefinition = null; try { - final String traitDefinition = Servlets.getRequestPayload(request); + traitDefinition = Servlets.getRequestPayload(request); LOG.debug("Adding trait={} for entity={} ", traitDefinition, guid); metadataService.addTrait(guid, traitDefinition); @@ -578,13 +591,13 @@ public class EntityResource { return Response.created(locationURI).entity(response).build(); } catch (EntityNotFoundException | TypeNotFoundException e) { - LOG.error("An entity with GUID={} does not exist", guid, e); + LOG.error("An entity with GUID={} does not exist traitDef={} ", guid, traitDefinition, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND)); } catch (AtlasException | IllegalArgumentException e) { - LOG.error("Unable to add trait for entity={}", guid, e); + LOG.error("Unable to add trait for entity={} traitDef={}", guid, traitDefinition, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (Throwable e) { - LOG.error("Unable to add trait for entity={}", guid, e); + LOG.error("Unable to add trait for entity={} traitDef={}", guid, traitDefinition, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } } @@ -611,7 +624,7 @@ public class EntityResource { return Response.ok(response).build(); } catch (EntityNotFoundException | TypeNotFoundException e) { - LOG.error("An entity with GUID={} does not exist", guid, e); + LOG.error("An entity with GUID={} does not exist traitName={} ", guid, traitName, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND)); } catch (TraitNotFoundException e) { LOG.error("The trait name={} for entity={} does not exist.", traitName, guid, e); @@ -650,10 +663,10 @@ public class EntityResource { response.put(AtlasClient.EVENTS, getJSONArray(events)); return Response.ok(response).build(); } catch (AtlasException | IllegalArgumentException e) { - LOG.error("Unable to get audit events for entity {}", guid, e); + LOG.error("Unable to get audit events for entity guid={} startKey={}", guid, startKey, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } catch (Throwable e) { - LOG.error("Unable to get audit events for entity {}", guid, e); + LOG.error("Unable to get audit events for entity guid={} startKey={}", guid, startKey, e); throw new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.INTERNAL_SERVER_ERROR)); } }
