Author: andre
Date: 2010-06-09 11:29:58 +0200 (Wed, 09 Jun 2010)
New Revision: 42483

Modified:
   
mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/SegmenterAnalyzer.java
Log:
added time-out to wait for filesystem to be ready


Modified: 
mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/SegmenterAnalyzer.java
===================================================================
--- 
mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/SegmenterAnalyzer.java
 2010-06-09 09:29:32 UTC (rev 42482)
+++ 
mmbase/branches/MMBase-1_9/applications/streams/src/main/java/org/mmbase/streams/transcoders/SegmenterAnalyzer.java
 2010-06-09 09:29:58 UTC (rev 42483)
@@ -33,7 +33,8 @@
 
 /**
  * Analyzes <code>segmenter</code> output during its job, changes url field to 
m3u8 index file when 
- * ready and rewrites m3u8 to removed full paths.
+ * ready and rewrites m3u8 to removed full paths. It can wait two minutes for 
the filesystem to be
+ * ready before starting to rewrite.
  * 
  * @author Andr&eacute; van Toly
  * @version $Id: SegmenterAnalyzer.java 40036 2009-11-30 20:27:39Z andre $
@@ -103,7 +104,7 @@
             String url = destNode.getStringValue("url");
             url = url.substring(0, url.lastIndexOf('.')) + ".m3u8";
             destNode.setStringValue("url", url);
-            
+
             if (FileServlet.getInstance() != null) {
                 
                 String filesDirectory = FileServlet.getDirectory().toString();
@@ -112,6 +113,18 @@
                 }
                 File index = new File(filesDirectory + url);
                 File temp  = new File(filesDirectory + url + ".tmp");
+
+                int count = 0;
+                while ((!index.exists() || index.length() < 1) && count < 12) {
+                    LOG.service("Result ready, but file " + index + 
(index.exists() ? " is too small" : " doesn't exist") + ". Waiting 10 sec. to 
be sure filesystem is ready (" + count + ")");
+                    try {
+                        Thread.currentThread().sleep(10000);
+                        count++;
+                    } catch (InterruptedException ie) {
+                        LOG.info("Interrupted");
+                        return;
+                    }
+                }
                 
                 try {
                     BufferedReader in = new BufferedReader(new 
FileReader(index));

_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to