Revision: 00b69af0c015
Author:   emmartins <[email protected]>
Date:     Wed Jun 25 18:31:34 2014 UTC
Log:      allowing fault tolerant timer to use a custom thread factory

http://code.google.com/p/commscale/source/detail?r=00b69af0c015&repo=cluster

Modified:
 /timers/src/main/java/org/mobicents/timers/FaultTolerantScheduler.java

=======================================
--- /timers/src/main/java/org/mobicents/timers/FaultTolerantScheduler.java Tue Dec 27 16:57:13 2011 UTC +++ /timers/src/main/java/org/mobicents/timers/FaultTolerantScheduler.java Wed Jun 25 18:31:34 2014 UTC
@@ -1,23 +1,22 @@
 /*
- * JBoss, Home of Professional Open Source
- * Copyright 2011, Red Hat, Inc. and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
+ * TeleStax, Open Source Cloud Communications
+ * Copyright 2011-2014, Telestax Inc and individual contributors
+ * by the @authors tag.
  *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
+ * This program is free software: you can redistribute it and/or modify
+ * under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of
  * the License, or (at your option) any later version.
  *
- * This software is distributed in the hope that it will be useful,
+ * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>
+ *
+ * This file incorporates work covered by the following copyright contributed under the GNU LGPL : Copyright 2007-2011 Red Hat.
  */

 package org.mobicents.timers;
@@ -26,7 +25,9 @@
 import java.util.HashSet;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
+import java.util.concurrent.ThreadFactory;
 import java.util.concurrent.TimeUnit;

 import javax.transaction.Transaction;
@@ -104,49 +105,78 @@
         * @param txManager
         * @param timerTaskFactory
         */
- public FaultTolerantScheduler(String name, int corePoolSize, MobicentsCluster cluster, byte priority, TransactionManager txManager,TimerTaskFactory timerTaskFactory) { - this(name, corePoolSize, cluster, priority, txManager, timerTaskFactory, 0); + public FaultTolerantScheduler(String name, int corePoolSize, MobicentsCluster cluster, byte priority, TransactionManager txManager, TimerTaskFactory timerTaskFactory) { + this(name, corePoolSize, cluster, priority, txManager, timerTaskFactory, 0, Executors.defaultThreadFactory());
        }
-
-       /**
-        *
-        * @param name
-        * @param corePoolSize
-        * @param cluster
-        * @param priority
-        * @param txManager
-        * @param timerTaskFactory
-        * @param purgePeriod
-        */
+
+    /**
+     *
+     * @param name
+     * @param corePoolSize
+     * @param cluster
+     * @param priority
+     * @param txManager
+     * @param timerTaskFactory
+     * @param threadFactory
+     */
+ public FaultTolerantScheduler(String name, int corePoolSize, MobicentsCluster cluster, byte priority, TransactionManager txManager, TimerTaskFactory timerTaskFactory, ThreadFactory threadFactory) { + this(name, corePoolSize, cluster, priority, txManager, timerTaskFactory, 0, threadFactory);
+    }
+
+    /**
+     *
+     * @param name
+     * @param corePoolSize
+     * @param cluster
+     * @param priority
+     * @param txManager
+     * @param timerTaskFactory
+     * @param purgePeriod
+     */
public FaultTolerantScheduler(String name, int corePoolSize, MobicentsCluster cluster, byte priority, TransactionManager txManager,TimerTaskFactory timerTaskFactory, int purgePeriod) {
-               this.name = name;
-               this.executor = new ScheduledThreadPoolExecutor(corePoolSize);
-               if(purgePeriod > 0) {
-                       Runnable r = new Runnable() {
-                               @Override
-                               public void run() {
-                                       try {
-                                               executor.purge();
-                                       }
-                                       catch (Exception e) {
-                                               logger.error("failed to execute 
purge",e);
-                                       }
-                               }
-                       };
- this.executor.scheduleWithFixedDelay(r, purgePeriod, purgePeriod, TimeUnit.MINUTES);
-               }
-               this.baseFqn = Fqn.fromElements(name);
-               this.cluster = cluster;
-               this.timerTaskFactory = timerTaskFactory;
-               this.txManager = txManager;
-               cacheData = new 
FaultTolerantSchedulerCacheData(baseFqn,cluster);
-               if (cluster.isStarted()) {
-                       cacheData.create();
-               }
-               clusterClientLocalListener = new ClientLocalListener(priority);
-               cluster.addFailOverListener(clusterClientLocalListener);
-               cluster.addDataRemovalListener(clusterClientLocalListener);
+ this(name, corePoolSize, cluster, priority, txManager, timerTaskFactory, purgePeriod, Executors.defaultThreadFactory());
        }
+
+    /**
+     *
+     * @param name
+     * @param corePoolSize
+     * @param cluster
+     * @param priority
+     * @param txManager
+     * @param timerTaskFactory
+     * @param purgePeriod
+     * @param threadFactory
+     */
+ public FaultTolerantScheduler(String name, int corePoolSize, MobicentsCluster cluster, byte priority, TransactionManager txManager,TimerTaskFactory timerTaskFactory, int purgePeriod, ThreadFactory threadFactory) {
+        this.name = name;
+ this.executor = new ScheduledThreadPoolExecutor(corePoolSize, threadFactory);
+        if(purgePeriod > 0) {
+            Runnable r = new Runnable() {
+                @Override
+                public void run() {
+                    try {
+                        executor.purge();
+                    }
+                    catch (Exception e) {
+                        logger.error("failed to execute purge",e);
+                    }
+                }
+            };
+ this.executor.scheduleWithFixedDelay(r, purgePeriod, purgePeriod, TimeUnit.MINUTES);
+        }
+        this.baseFqn = Fqn.fromElements(name);
+        this.cluster = cluster;
+        this.timerTaskFactory = timerTaskFactory;
+        this.txManager = txManager;
+        cacheData = new FaultTolerantSchedulerCacheData(baseFqn,cluster);
+        if (cluster.isStarted()) {
+            cacheData.create();
+        }
+        clusterClientLocalListener = new ClientLocalListener(priority);
+        cluster.addFailOverListener(clusterClientLocalListener);
+        cluster.addDataRemovalListener(clusterClientLocalListener);
+    }

        /**
* Retrieves the {@link TimerTaskData} associated with the specified taskID.

--

--- You received this message because you are subscribed to the Google Groups "mobicents-commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to