You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sn...@apache.org on 2013/12/03 14:59:50 UTC

git commit: Reduce repetitive logging in three specific locations that are noisy and repetitive during testing. The first exception of any given type is logged at ERROR level with a stack trace and subsequent instances of the same exception are logged wi

Updated Branches:
  refs/heads/master 970f36e2a -> 96a3a6d85


Reduce repetitive logging in three specific locations that are noisy and repetitive during testing. The first exception of any given type is logged at ERROR level with a stack trace and subsequent instances of the same exception are logged without a stack trace (unless debug is turned on).

Change that was made to apigee/usergrid but did not make it into usergrid/usergrid in time for the Apache import.
See also: https://github.com/apigee/usergrid-stack/pull/257


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

Branch: refs/heads/master
Commit: 96a3a6d850f5f9e3f30a66000b7fb4c3cb3fa22d
Parents: 970f36e
Author: Dave Johnson <dm...@apigee.com>
Authored: Tue Dec 3 08:59:47 2013 -0500
Committer: Dave Johnson <dm...@apigee.com>
Committed: Tue Dec 3 08:59:47 2013 -0500

----------------------------------------------------------------------
 .../batch/service/JobSchedulerService.java      | 24 +++++++++++++++--
 .../usergrid/count/CassandraCounterStore.java   | 27 +++++++++++++++-----
 .../mq/cassandra/io/ConsumerTransaction.java    |  8 +++---
 3 files changed, 46 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/96a3a6d8/stack/core/src/main/java/org/usergrid/batch/service/JobSchedulerService.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/batch/service/JobSchedulerService.java b/stack/core/src/main/java/org/usergrid/batch/service/JobSchedulerService.java
index d0b9821..9cb07ba 100644
--- a/stack/core/src/main/java/org/usergrid/batch/service/JobSchedulerService.java
+++ b/stack/core/src/main/java/org/usergrid/batch/service/JobSchedulerService.java
@@ -32,6 +32,8 @@ import com.google.common.util.concurrent.ListeningScheduledExecutorService;
 import com.google.common.util.concurrent.MoreExecutors;
 import com.yammer.metrics.annotation.ExceptionMetered;
 import com.yammer.metrics.annotation.Timed;
+import java.util.HashMap;
+import java.util.Map;
 
 import org.usergrid.batch.Job;
 import org.usergrid.batch.JobExecution;
@@ -54,6 +56,9 @@ public class JobSchedulerService extends AbstractScheduledService {
 
     private static final Logger LOG = LoggerFactory.getLogger( JobSchedulerService.class );
 
+    // keep track of exceptions thrown in scheduler so we can reduce noise in logs
+    private Map<String, Integer> schedulerRunFailures = new HashMap<String, Integer>();
+
     private long interval = DEFAULT_DELAY;
     private int workerSize = 1;
     private int maxFailCount = 10;
@@ -112,7 +117,22 @@ public class JobSchedulerService extends AbstractScheduledService {
             }
         }
         catch ( Throwable t ) {
-            LOG.error( "Something really bad happened!  Scheduler run failed", t );
+
+            // errors here happen a lot on shutdown, don't fill the logs with them
+            String error = t.getClass().getCanonicalName();
+            if (schedulerRunFailures.get( error ) == null) {
+                LOG.error( "Scheduler run failed, first instance of this exception", t );
+                schedulerRunFailures.put( error, 1);
+
+            } else {
+                int count = schedulerRunFailures.get(error) + 1; 
+                schedulerRunFailures.put(error, count);
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug( error + " caused scheduler run failure, count =  " + count, t );
+                } else {
+                    LOG.error( error + " caused scheduler run failure, count =  " + count );
+                }
+            }
         }
     }
 
@@ -292,4 +312,4 @@ public class JobSchedulerService extends AbstractScheduledService {
     public JobListener getJobListener() {
         return jobListener;
     }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/96a3a6d8/stack/core/src/main/java/org/usergrid/count/CassandraCounterStore.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/count/CassandraCounterStore.java b/stack/core/src/main/java/org/usergrid/count/CassandraCounterStore.java
index b82262c..3eda1d2 100644
--- a/stack/core/src/main/java/org/usergrid/count/CassandraCounterStore.java
+++ b/stack/core/src/main/java/org/usergrid/count/CassandraCounterStore.java
@@ -30,19 +30,19 @@ import org.usergrid.count.common.Count;
 import me.prettyprint.cassandra.model.HCounterColumnImpl;
 import me.prettyprint.cassandra.serializers.ByteBufferSerializer;
 import me.prettyprint.hector.api.Keyspace;
-import me.prettyprint.hector.api.exceptions.HectorException;
 import me.prettyprint.hector.api.factory.HFactory;
 import me.prettyprint.hector.api.mutation.Mutator;
 
 
 /**
  * Encapsulate counter writes to Cassandra
- *
- * @author zznate
  */
 public class CassandraCounterStore implements CounterStore {
     private Logger log = LoggerFactory.getLogger( CassandraCounterStore.class );
 
+    // keep track of exceptions thrown in scheduler so we can reduce noise in logs
+    private Map<String, Integer> counterInsertFailures = new HashMap<String, Integer>();
+
     private final Keyspace keyspace;
 
 
@@ -76,8 +76,23 @@ public class CassandraCounterStore implements CounterStore {
         try {
             mutator.execute();
         }
-        catch ( HectorException he ) {
-            log.error( "Insert failed. Reason: ", he );
+        catch ( Exception e ) {
+
+            // errors here happen a lot on shutdown, don't fill the logs with them
+            String error = e.getClass().getCanonicalName();
+            if (counterInsertFailures.get( error ) == null) {
+                log.error( "CounterStore insert failed, first instance", e);
+                counterInsertFailures.put( error, 1);
+
+            } else {
+                int count = counterInsertFailures.get(error) + 1; 
+                counterInsertFailures.put(error, count);
+                if (log.isDebugEnabled()) {
+                    log.debug( error + " caused CounterStore insert failure, count =  " + count, e );
+                } else {
+                    log.error( error + " caused CounterStore insert failure, count =  " + count );
+                }
+            }
         }
     }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/96a3a6d8/stack/core/src/main/java/org/usergrid/mq/cassandra/io/ConsumerTransaction.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/usergrid/mq/cassandra/io/ConsumerTransaction.java b/stack/core/src/main/java/org/usergrid/mq/cassandra/io/ConsumerTransaction.java
index 10d8343..cda99aa 100644
--- a/stack/core/src/main/java/org/usergrid/mq/cassandra/io/ConsumerTransaction.java
+++ b/stack/core/src/main/java/org/usergrid/mq/cassandra/io/ConsumerTransaction.java
@@ -51,8 +51,6 @@ import static org.usergrid.mq.cassandra.QueuesCF.CONSUMER_QUEUE_TIMEOUTS;
 
 /**
  * Reads from the queue and starts a transaction
- *
- * @author tnine
  */
 public class ConsumerTransaction extends NoTransactionSearch
 {
@@ -278,7 +276,7 @@ public class ConsumerTransaction extends NoTransactionSearch
         }
         catch ( UGLockException e )
         {
-            logger.error( "Unable to acquire lock", e );
+            logger.debug( "Unable to acquire lock", e );
             throw new QueueException( "Unable to acquire lock", e );
         }
         finally
@@ -289,7 +287,7 @@ public class ConsumerTransaction extends NoTransactionSearch
             }
             catch ( UGLockException e )
             {
-                logger.error( "Unable to release lock", e );
+                logger.debug( "Unable to release lock", e );
                 throw new QueueException( "Unable to release lock", e );
             }
         }
@@ -458,4 +456,4 @@ public class ConsumerTransaction extends NoTransactionSearch
             return "TransactionPointer [expiration=" + expiration + ", targetMessage=" + targetMessage + "]";
         }
     }
-}
+}
\ No newline at end of file