usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mru...@apache.org
Subject [09/11] usergrid git commit: Add additional logging around batch entity creation.
Date Thu, 23 Jun 2016 22:26:14 GMT
Add additional logging around batch entity creation.


Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/20ae3824
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/20ae3824
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/20ae3824

Branch: refs/heads/release-2.1.1
Commit: 20ae3824b67f291b9b4dd065bf83c8eefc3bb408
Parents: b6b0132
Author: Michael Russo <mrusso@apigee.com>
Authored: Thu Jun 23 11:25:00 2016 -0700
Committer: Michael Russo <mrusso@apigee.com>
Committed: Thu Jun 23 11:25:00 2016 -0700

----------------------------------------------------------------------
 .../graph/impl/GraphManagerImpl.java            |  4 ++
 .../services/AbstractCollectionService.java     | 41 ++++++++++++--------
 2 files changed, 28 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/20ae3824/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
index e8761f8..5fcdcb4 100644
--- a/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
+++ b/stack/corepersistence/graph/src/main/java/org/apache/usergrid/persistence/graph/impl/GraphManagerImpl.java
@@ -483,6 +483,10 @@ public class GraphManagerImpl implements GraphManager {
                         return true;
                     }
 
+                    if(logger.isTraceEnabled()){
+                        logger.trace("Filtering edge {}", simpleMarkedEdge);
+                    }
+
                     //if any one of these is true, we filter it
                     return !simpleMarkedEdge.isDeleted() &&  !simpleMarkedEdge.isSourceNodeDelete()
&& !simpleMarkedEdge.isTargetNodeDeleted();
                 });

http://git-wip-us.apache.org/repos/asf/usergrid/blob/20ae3824/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
b/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
index 7b9e230..cbea659 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/AbstractCollectionService.java
@@ -17,11 +17,7 @@
 package org.apache.usergrid.services;
 
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.UUID;
+import java.util.*;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -389,37 +385,48 @@ public class AbstractCollectionService extends AbstractService {
                         batch.size(), context.getCollectionName());
             }
 
-            int i = 1;
+
+            final Map<String, Boolean> nameValues = new HashMap<>(batch.size());
 
             for ( Map<String, Object> p : batch ) {
+
+                // track unique name value in the batch to identify if duplicates are trying
to be created
+                String name = p.get("name").toString();
+                if( name !=null && nameValues.get(name) !=null ){
+                    logger.warn("Batch contains more than 1 entity with the same name: {}",
name);
+                }else{
+                    nameValues.put(name, true);
+                }
+
+
                 if (logger.isTraceEnabled()) {
-                    logger.trace("Creating entity {} in collection {}", i, context.getCollectionName());
+                    logger.trace("Creating entity [{}] in collection [{}]", p, context.getCollectionName());
                 }
 
-                Entity item = null;
 
+                Entity item = null;
                 try {
                     item = em.createItemInCollection( context.getOwner(), context.getCollectionName(),
getEntityType(),
                             p );
                 }
                 catch ( Exception e ) {
-                    // TODO should we not log this as error?
-                    if (logger.isDebugEnabled()) {
-                        logger.debug("Entity {} unable to be created in collection {}", i,
context.getCollectionName(),
-                            e);
-                    }
 
-                    i++;
+                    logger.error("Entity [{}] unable to be created in collection [{}] due
to [{} - {}]", p, context.getCollectionName(),
+                            e.getClass().getSimpleName(), e.getMessage());
+
+                    // move on as we can't block the whole batch if only 1 failed
                     continue;
                 }
+
+
                 if (logger.isTraceEnabled()) {
-                    logger.trace(
-                        "Entity {} created in collection {} with UUID {}", i, context.getCollectionName(),
item.getUuid());
+                    logger.trace("Successfully created entity [{}] in collection [{}]", p,
context.getCollectionName());
                 }
 
+
                 item = importEntity( context, item );
                 entities.add( item );
-                i++;
+
             }
             return new ServiceResults( this, context, Type.COLLECTION, Results.fromEntities(
entities ), null, null );
         }


Mime
View raw message