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 D55EB200B13 for ; Wed, 15 Jun 2016 20:21:22 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D3C91160A4D; Wed, 15 Jun 2016 18:21:22 +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 A627A160A19 for ; Wed, 15 Jun 2016 20:21:21 +0200 (CEST) Received: (qmail 20375 invoked by uid 500); 15 Jun 2016 18:21:20 -0000 Mailing-List: contact commits-help@atlas.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@atlas.incubator.apache.org Delivered-To: mailing list commits@atlas.incubator.apache.org Received: (qmail 20366 invoked by uid 99); 15 Jun 2016 18:21:20 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 15 Jun 2016 18:21:20 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 66B91C0034 for ; Wed, 15 Jun 2016 18:21:20 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.646 X-Spam-Level: X-Spam-Status: No, score=-4.646 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-1.426] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id Sm92CR82oim7 for ; Wed, 15 Jun 2016 18:21:18 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id C87AB5F19D for ; Wed, 15 Jun 2016 18:21:16 +0000 (UTC) Received: (qmail 20350 invoked by uid 99); 15 Jun 2016 18:21:16 -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; Wed, 15 Jun 2016 18:21:16 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id F13C5E03AF; Wed, 15 Jun 2016 18:21:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yhemanth@apache.org To: commits@atlas.incubator.apache.org Message-Id: <9ed7c5e730a64e1aac46ee573ade29a5@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: incubator-atlas git commit: ATLAS-890 Log received messages in case of error (sumasai via yhemanth) Date: Wed, 15 Jun 2016 18:21:15 +0000 (UTC) archived-at: Wed, 15 Jun 2016 18:21:23 -0000 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 Authored: Wed Jun 15 23:50:50 2016 +0530 Committer: Hemanth Yamijala 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 getEntities() throws JSONException { return entities; } + + @Override + public String toString() { + return entities.toString(); + } } /** @@ -210,6 +215,16 @@ public class HookNotification implements JsonDeserializer 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)); } }