Merge "Bug 3367 - StatManagerImpl scalable statPolling per stat type on device"
[openflowplugin.git] / openflowplugin / src / main / java / org / opendaylight / openflowplugin / openflow / md / core / ThreadPoolLoggingExecutor.java
index 448f5ece920c3a61e5ab2ecdc7123454192a221c..481e4585fba8fa3579ad263644559a4c7bd5ba41 100644 (file)
@@ -1,25 +1,25 @@
 /**
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- * 
+ *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 package org.opendaylight.openflowplugin.openflow.md.core;
 
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
 import java.util.concurrent.BlockingQueue;
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * 
+ * threadPoolExecutor implementation logging exceptions thrown by threads
  */
 public class ThreadPoolLoggingExecutor extends ThreadPoolExecutor {
-    
-    private static Logger LOG = LoggerFactory.getLogger(ThreadPoolLoggingExecutor.class);
+
+    private static final Logger LOG = LoggerFactory.getLogger(ThreadPoolLoggingExecutor.class);
 
     /**
      * @param corePoolSize
@@ -27,10 +27,13 @@ public class ThreadPoolLoggingExecutor extends ThreadPoolExecutor {
      * @param keepAliveTime
      * @param unit
      * @param workQueue
+     * @param poolName thread name prefix
      */
     public ThreadPoolLoggingExecutor(int corePoolSize, int maximumPoolSize,
-            long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue) {
-        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue);
+                                     long keepAliveTime, TimeUnit unit, BlockingQueue<Runnable> workQueue,
+            final String poolName) {
+        super(corePoolSize, maximumPoolSize, keepAliveTime, unit, workQueue,
+                new ThreadFactoryBuilder().setNameFormat(poolName+"-%d").build());
     }
 
     @Override