[vlma-devel] commit: Decoupling of order checking and order giving. (Adrien Grand )

git version control git at videolan.org
Sun Nov 2 22:41:27 CET 2008


vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sat Nov  1 18:06:01 2008 +0100| [74f11ce2aecd73600f7f424528160014b5587d9a] | committer: Adrien Grand 

Decoupling of order checking and order giving.

> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=74f11ce2aecd73600f7f424528160014b5587d9a
---

 .../org/videolan/vlma/monitor/OrderMonitor.java    |   12 +++++++++---
 vlma-daemon/src/main/resources/config.properties   |    3 ++-
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
index 7f6fb78..803b8c0 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/monitor/OrderMonitor.java
@@ -25,6 +25,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.commons.configuration.Configuration;
 import org.apache.log4j.Logger;
@@ -58,6 +59,8 @@ public class OrderMonitor implements Monitor {
 
     private Thread orderMonitorDaemonThread;
 
+    private AtomicLong lastOrderGiving = new AtomicLong(0L);
+
     private AtomicBoolean shouldRun = new AtomicBoolean(true);
 
     private StreamWatcher streamWatcher;
@@ -152,7 +155,10 @@ public class OrderMonitor implements Monitor {
             /*
              * Something is wrong ! Ask for a new computation.
              */
-            if (shouldCompute) {
+            long currentTime = System.currentTimeMillis();
+            if (shouldCompute && currentTime > lastOrderGiving.get()
+                    + 1000L * configuration.getLong("vlma.monitor.order.give.interval")) {
+                lastOrderGiving.set(currentTime);
                 logger.info("Ask for programs reassignment.");
                 vlmaService.giveOrders();
             }
@@ -174,9 +180,9 @@ public class OrderMonitor implements Monitor {
             while (shouldRun.get()) {
                 // Wait before looping
                 try {
-                    Thread.sleep(1000L * configuration.getLong("vlma.monitor.order.interval"));
+                    Thread.sleep(1000L * configuration.getLong("vlma.monitor.order.check.interval"));
                 } catch (InterruptedException e) {
-
+                    continue;
                 }
                 if (shouldRun.get())
                     startOrderMonitoringThread();
diff --git a/vlma-daemon/src/main/resources/config.properties b/vlma-daemon/src/main/resources/config.properties
index 8cf1ffd..70a3bb6 100644
--- a/vlma-daemon/src/main/resources/config.properties
+++ b/vlma-daemon/src/main/resources/config.properties
@@ -25,7 +25,8 @@ vlma.announcement.sap.stream.group = Stream
 vlma.announcement.sap.satellite.group = Satellite
 vlma.announcement.sap.dtt.group = DTT
 vlma.encapsulation = TS
-vlma.monitor.order.interval = 600
+vlma.monitor.order.give.interval = 600
+vlma.monitor.order.check.interval = 30
 vlma.monitor.server.interval = 30
 vlma.notification.irc.host = irc.freenode.net
 vlma.notification.irc.nick = vlma



More information about the vlma-devel mailing list