[vlma-devel] commit: Don't check the programmation state if orders are being given. ( Adrien Grand )
git version control
git at videolan.org
Sat Jun 28 01:46:07 CEST 2008
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sat Jun 28 00:27:53 2008 +0200| [25ca9ed7154f28be5130e56b140d9bb9f85ac0a5]
Don't check the programmation state if orders are being given.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=25ca9ed7154f28be5130e56b140d9bb9f85ac0a5
---
.../org/videolan/vlma/monitor/OrderMonitor.java | 115 ++++++++++----------
1 files changed, 57 insertions(+), 58 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 331faec..0a991bb 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
@@ -28,14 +28,9 @@ import org.apache.log4j.Logger;
import org.jrobin.core.Util;
import org.videolan.vlma.OrderGiver;
import org.videolan.vlma.VLMaService;
-import org.videolan.vlma.model.StreamingStrategy;
import org.videolan.vlma.model.media.Media;
import org.videolan.vlma.model.order.Order;
import org.videolan.vlma.model.program.Program;
-import org.videolan.vlma.model.watcher.DirectMulticastStreamWatcher;
-import org.videolan.vlma.model.watcher.HttpStreamWatcher;
-import org.videolan.vlma.model.watcher.StreamWatcher;
-import org.videolan.vlma.model.watcher.StreamWatcherMockImpl;
/**
* This class is an orders monitoring daemon. It connects to the router and
@@ -71,71 +66,75 @@ public class OrderMonitor implements Monitor {
private Runnable orderMonitor = new Runnable() {
public void run() {
- boolean shouldCompute = false;
- // Assigning programs state
- List<Media> medias = vlmaService.getMedias();
- for (Media media : medias) {
- Program program = media.getProgram();
- if (program != null) {
- /*
- * If the program must be played and is not then we have to
- * recompute.
- */
- if (program.isTimeToPlay()) {
- if (!program.isPlayed() && !orderGiver.isComputing()) {
- /*
- * If the OrderGiver is not computing then it can
- * modify the data.
- */
- program.setPlayer(null);
- program.setBroadcastState(false);
- shouldCompute = true;
- /* Remove the order of a non-diffused stream */
- Iterator<List<Order>> k = vlmaService.getOrders().values().iterator();
- while (k.hasNext()) {
- Iterator<Order> l = k.next().iterator();
- while (l.hasNext()) {
- Order o = l.next();
- if (o.getMedias().medias.contains(media)) {
- l.remove();
- break;
+ if (orderGiver.isComputing()) {
+ logger.info("Orders are already being given, computation delayed");
+ } else {
+ boolean shouldCompute = false;
+ // Assigning programs state
+ List<Media> medias = vlmaService.getMedias();
+ for (Media media : medias) {
+ Program program = media.getProgram();
+ if (program != null) {
+ /*
+ * If the program must be played and is not then we have to
+ * recompute.
+ */
+ if (program.isTimeToPlay()) {
+ if (!program.isPlayed()) {
+ logger.info("Program " + program.getSapName() + " is currently not played.");
+ /*
+ * If the OrderGiver is not computing then it can
+ * modify the data.
+ */
+ program.setPlayer(null);
+ program.setBroadcastState(false);
+ shouldCompute = true;
+ /* Remove the order of a non-diffused stream */
+ Iterator<List<Order>> k = vlmaService.getOrders().values().iterator();
+ while (k.hasNext()) {
+ Iterator<Order> l = k.next().iterator();
+ while (l.hasNext()) {
+ Order o = l.next();
+ if (o.getMedias().medias.contains(media)) {
+ l.remove();
+ break;
+ }
}
}
+ } else {
+ program.setBroadcastState(true);
}
}
- else {
- program.setBroadcastState(true);
- }
}
}
- }
- /*
- * Check if every media which belongs to a order has really a
- * program. If not, then it should compute.
- */
- for (List<Order> orderList : vlmaService.getOrders().values()) {
- for (Order order : orderList) {
- for (Media media : order.getMedias().medias) {
- if (media.getProgram() == null) {
- logger.log(Level.DEBUG, "The media " + media.getName()
- + " which belongs to an order has no more a program.");
- shouldCompute = true;
- break;
+ /*
+ * Check if every media which belongs to a order has really a
+ * program. If not, then it should compute.
+ */
+ for (List<Order> orderList : vlmaService.getOrders().values()) {
+ for (Order order : orderList) {
+ for (Media media : order.getMedias().medias) {
+ if (media.getProgram() == null) {
+ logger.log(Level.DEBUG, "The media " + media.getName()
+ + " which belongs to an order has no more a program.");
+ shouldCompute = true;
+ break;
+ }
}
+ if (shouldCompute == true)
+ break;
}
if (shouldCompute == true)
break;
}
- if (shouldCompute == true)
- break;
- }
- /*
- * Something is wrong ! Ask for a new computation.
- */
- if (shouldCompute) {
- logger.log(Level.DEBUG, "Ask for programs reassignment.");
- vlmaService.giveOrders();
+ /*
+ * Something is wrong ! Ask for a new computation.
+ */
+ if (shouldCompute) {
+ logger.log(Level.DEBUG, "Ask for programs reassignment.");
+ vlmaService.giveOrders();
+ }
}
}
};
More information about the vlma-devel
mailing list