git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube...
authorvasary.daniel <TFS\vasary.daniel>
Mon, 16 Nov 2020 15:35:20 +0000 (15:35 +0000)
committervasary.daniel <TFS\vasary.daniel>
Mon, 16 Nov 2020 15:35:20 +0000 (15:35 +0000)
13 files changed:
client/Maestro/Configuration/configuration.json
client/MaestroShared/Commons/CustomFileCopier.cs
server/-configuration/log4j2.xml
server/-configuration/scheduledjobs.json
server/user.jobengine.executors/config/config-worker.xml
server/user.jobengine.executors/jobtemplates/cancelable.xml
server/user.jobengine.executors/jobtemplates/sync-subtitles.xml [new file with mode: 0644]
server/user.jobengine.executors/src/user/jobengine/server/steps/CancelableStep.java
server/user.jobengine.executors/src/user/jobengine/server/steps/DirMXFValidatorStep.java
server/user.jobengine.executors/src/user/jobengine/server/steps/SyncSubtitlesStep.java [new file with mode: 0644]
server/user.jobengine.osgi.commons/src/user/commons/MediaCubeFinishMarker.java
server/user.jobengine.osgi.commons/src/user/commons/mediatool/MediaInfo.java
server/user.jobengine.osgi.server/test/user/jobengine/server/IT/AMCTests.java

index 49934f32db169fc2922a1c545de9850fc78bc5bc..32edff1acd4bbf30bdebb83fb852aed36a61da3f 100644 (file)
   },\r
   "source": {\r
     "$type": "UNCSource",\r
-    "filter": "avi,wav,mxf,mts",\r
-    "useAlternateCopy": true,\r
+    "filter": "avi,wav,mxf,mts,mov",\r
+    "useAlternateCopy": false,\r
     "autoTarget": "AUTOTARGET",\r
     "autoTags": [ "AUTOTAG" ],\r
     "local": {\r
-      "address": "file://c:/_XDCAM/Clip",\r
+      "address": "file://c:/_video/x",\r
       "userName": "mediacube",\r
       "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
       "timeout": 1000\r
   },\r
   "metadatas": [\r
     {\r
-      "$type": "OctopusMetadata",\r
+      "$type": "MediaCubeMetadata",\r
       "server": {\r
-        "address": "http://10.10.1.27/services/rest/octopus",\r
-        "timeout": 5000\r
-      }\r
-    },\r
-    {\r
-      "$type": "TrafficMetadata",\r
-      "server": {\r
-        "address": "Data Source=10.10.1.45;Initial Catalog=PA_Echo;Persist Security Info=True;",\r
-        "userName": "MAM",\r
-        "password": "7RKZYBzumKjL40SJwuwiFCvX57xuCN8zay6OttUm2wbrgImyYZBHyZTUUYrXX31Ge2Uwew07HYsqh2uzdJeDBDwcVntxaHg3nIpv9Dyq/odVoiC4tUF/K+lgvKWANcrZ",\r
+        "address": "http://localhost:8888/services/rest/jobengine",\r
+        "userName": "mediacube",\r
+        "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
       },\r
-      "version": 0,\r
-      "redefineSegments": true\r
-    },\r
-  {\r
-    "$type": "MediaCubeMetadata",\r
-    "server": {\r
-      "address": "http://localhost:8888/services/rest/jobengine",\r
-      "userName": "mediacube",\r
-      "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
-      "timeout": 1000\r
-    },\r
-    "wsserver": {\r
-      "address": "ws://10.10.1.27/services/wsapi",\r
-      "timeout": 1000\r
-    },\r
-    "jobTemplate": "retrieve-material.xml",\r
-    "archiveFolder": "file://10.10.1.105/TESZT/TC/ARCHIVE",\r
-    "restoreFolder": "file://10.10.1.105/BRAAVOS/ARCHIVE_RESTORE",\r
-    "restoreNamePattern": "%s_%GUID%",\r
-    "serverRestoreFolder": "/mnt/ISILON/ARCHIVE_RESTORE",\r
-    "killDateDays": 1\r
-  }\r
+      "wsserver": {\r
+        "address": "ws://10.10.1.27/services/wsapi",\r
+        "timeout": 1000\r
+      },\r
+      "jobTemplate": "retrieve-material.xml",\r
+      "archiveFolder": "file://10.10.1.105/TESZT/TC/ARCHIVE",\r
+      "restoreFolder": "file://10.10.1.105/BRAAVOS/ARCHIVE_RESTORE",\r
+      "restoreNamePattern": "%s_%GUID%",\r
+      "serverRestoreFolder": "/mnt/ISILON/ARCHIVE_RESTORE",\r
+      "killDateDays": 1\r
+    }\r
   ],\r
   "targets": [\r
     {\r
       "killDateDays": 0,\r
       "saveArchiveMetadata": true,\r
       "remote": {\r
-        "address": "file://c:/opt1",\r
+        "address": "file://c:/_video/y",\r
         "userName": "mediacube",\r
         "password": "Dn8t4gfHcK98o8hyPgLDhr5SgSji4JCxsfpMJsODikUp3nXgrM0UNCi45lLAK8ZOnmEneO44P9qpJ4QDqhctN6MxZodjJgdZTyoZKmSa+ECzEzLr/wPYNgxVaXrVotEy",\r
         "timeout": 1000\r
index 45a0767f57924e38101f7f6bce9895bfe2c2f6d2..690159b53428e8629d83f7cf3d6738cfecf98701 100644 (file)
@@ -42,6 +42,9 @@ namespace MaestroShared.Commons {
                             break;\r
                         }\r
                     }\r
+\r
+                    //kell ?\r
+                    dest.Flush();\r
                 }\r
             }\r
 \r
index 7153ef31362ec60c3ec714f0f8f6f2d8b0d4bcaa..6d1a786596045d476b81d230e80257c388d3de54 100644 (file)
@@ -20,7 +20,7 @@
                        <PatternLayout pattern="%d{HH:mm:ss.SSS} %-5level %logger{1}.%M - %marker - %msg (%F:%L) %n" />\r
                </Console>\r
                <HTMLMailAppender name="MarkeredMail" subject="[localhost] MediaCube rendszerüzenet" to="vasary@elgekko.net" from="mediacubeserver@gmail.com" smtpHost="smtp.gmail.com"\r
-                       smtpPort="465" smtpProtocol="smtps" smtpDebug="true" smtpUsername="mediacubeserver@gmail.com" smtpPassword="salabakter" ignoreExceptions="false" bufferSize="1">\r
+                       smtpPort="465" smtpProtocol="smtps" smtpDebug="false" smtpUsername="mediacubeserver@gmail.com" smtpPassword="salabakter" ignoreExceptions="false" bufferSize="1">\r
                        <Filters>\r
                                <MarkerFilter marker="MEDIACUBE" onMatch="ACCEPT" onMismatch="DENY" />\r
                        </Filters>\r
@@ -54,7 +54,7 @@
                        <AppenderRef ref="Console" />\r
                        <AppenderRef ref="MarkeredConsole" />\r
 <!--                   <AppenderRef ref="RollingFile" /> -->\r
-<!--                   <AppenderRef ref="MarkeredMail" /> -->\r
+                       <AppenderRef ref="MarkeredMail" />\r
 <!--                   <AppenderRef ref="MarkeredDB2" /> -->\r
                </Root>\r
                <Logger name="org.zkoss" level="trace" additivity="false" />\r
index 3f606aa91f967508f9048803172feca0c5232196..8a4caaa79516b3f7ed17188053230b099a012dd8 100644 (file)
@@ -22,6 +22,7 @@
       ]\r
        },      \r
        {\r
+         "name" : "Megszakítható teszt folyamat",\r
       "template": "cancelable.xml",\r
       "parameters": [ {"name": "param", "value": 1, "type": "java.lang.Integer"} ]\r
        },      \r
index 97f24d8790aad70a2879358a0a8fc1a0145233b3..438def00aec14749f4acfef589ac7eb233375ea8 100644 (file)
@@ -1,5 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
 <executors>\r
+       <executor className="user.jobengine.server.steps.SyncSubtitlesStep" maxConcurrent="1" isRemote="true" />\r
        <executor className="CancelableStep.java" maxConcurrent="1" isRemote="true" />\r
        <executor className="FakeStep.java" maxConcurrent="1" />\r
        <executor className="NEXIOArchiveCheckerStep.java" maxConcurrent="1" />\r
index fa29cc3fa4bd263bc9df9e0d5b94161d5431a76f..2be289b3fa73d9de54cd551fbe52519823ecd7af 100644 (file)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
-<jobtemplate multiInstance="true" useSessionLog="false">\r
+<jobtemplate multiInstance="true" useSessionLog="true">\r
        <declarations>\r
                <parameters>\r
                        <parameter name="param" type="java.lang.Integer" />\r
diff --git a/server/user.jobengine.executors/jobtemplates/sync-subtitles.xml b/server/user.jobengine.executors/jobtemplates/sync-subtitles.xml
new file mode 100644 (file)
index 0000000..37e2648
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<jobtemplate multiInstance="false" useSessionLog="false">\r
+       <declarations>\r
+               <parameters>\r
+                       <parameter name="sourceStoreName" type="java.lang.String" />\r
+                       <parameter name="targetStoreName" type="java.lang.String" />\r
+               </parameters>\r
+       </declarations>\r
+       <commands>\r
+               <calljobstep type="user.jobengine.server.steps.SyncSubtitlesStep" weight="1" >\r
+                       <inputs>\r
+                               <input>\r
+                                       <parameter name="sourceStoreName" />\r
+                               </input>\r
+                               <input>\r
+                                       <parameter name="targetStoreName" />\r
+                               </input>\r
+                       </inputs>\r
+               </calljobstep>\r
+       </commands>\r
+</jobtemplate>
\ No newline at end of file
index ea5d7bb9faf54b5984e290f0fc578c0dad279502..0f21e2ef812cc0d78bcf6564e824c456f29b3c49 100644 (file)
@@ -1,29 +1,46 @@
 package user.jobengine.server.steps;\r
 \r
+import java.nio.file.Paths;\r
+import java.util.Arrays;\r
+import java.util.List;\r
+\r
 import org.apache.commons.net.ftp.FTPClient;\r
 import org.apache.logging.log4j.LogManager;\r
 import org.apache.logging.log4j.Logger;\r
+import org.apache.logging.log4j.MarkerManager;\r
 \r
+import user.commons.MediaCubeMarker;\r
+import user.commons.RemoteFile;\r
 import user.commons.StoreUri;\r
+import user.commons.mediatool.MediaInfo;\r
 import user.commons.remotestore.FtpDirectoryLister;\r
+import user.commons.remotestore.IProgressEventListener;\r
+import user.commons.remotestore.IStatusEventListener;\r
+import user.commons.remotestore.ProgressEvent;\r
 import user.commons.remotestore.RemoteStoreProtocol;\r
+import user.commons.remotestore.StatusEvent;\r
 \r
 public class CancelableStep extends JobStep {\r
        private static final Logger logger = LogManager.getLogger();\r
        int count = 10;\r
 \r
        @StepEntry\r
-       public Object[] execute(int param) throws Exception {\r
+       public Object[] execute(int z) throws Exception {\r
                try {\r
+                       //                      retrieveTest();\r
                        //                      ftpTest();\r
+                       ((MediaCubeMarker) getJobRuntime().getFinishMarker()).setTo("hering.tamas70@gmail.com");\r
 \r
                        for (int i = 0; i < count; i++) {\r
                                if (getJobRuntime().isWaitingCancel())\r
                                        break;\r
-                               Thread.sleep(500);\r
+                               Thread.sleep(100);\r
                                int progress = (i + 1) * 100 / count;\r
                                setProgress(progress);\r
+                               logger.info(getSessionMarker(), "Current {}", i);\r
                        }\r
+\r
+                       logger.info(getSessionMarker(), "Finished");\r
                } catch (Exception e) {\r
                        e.printStackTrace();\r
                        throw e;\r
@@ -54,4 +71,48 @@ public class CancelableStep extends JobStep {
 \r
        }\r
 \r
+       void retrieveTest() {\r
+               String fn = null;\r
+               try {\r
+                       List<String> files = Arrays.asList("tLkaTXxW-M19-033419-1.MOV", "8RkqDrZF-M19-033418-1.MOV", "VnNflPem-M19-033415-1.MOV",\r
+                                       "OMMnXmXJ-M19-033416-1.MOV", "XKssDE0h-M19-033414-1-1.MOV", "o1PxGST2-M20-033486-3.MOV", "2aeKEvqG-M20-034175-1.MOV",\r
+                                       "eSlsY8zT-M20-034176-1.MOV", "sRhREmVR-M20-034177-1.MOV", "d3J3Tk21-M20-034177-1-1.MOV", "pTZDiXtO-M20-034178-1.MOV",\r
+                                       "7fdHizJG-M20-034179-1.MOV", "JGrkQ81d-M20-034156-1.MOV", "4K96kKNR-M20-034157-1.MOV", "MoTdzwAC-M20-034158-1.MOV",\r
+                                       "73uQdsE8-M20-034159-1.MOV", "TzcGEbpq-M20-034180-1.MOV", "G9mwxqMR-M20-034181-1.MOV", "C8UsIr45-M20-034182-1.MOV",\r
+                                       "n3bM1gns-M20-034161-1.MOV", "xYfCbTz4-M20-034160-1.MOV", "f0rkowuI-M20-034184-1.MOV", "HDAVOaZn-M20-034185-1.MOV",\r
+                                       "INxFHTy9-M20-034183-1.MOV", "cTiYIIa2-M20-035223-1.MOV", "YSiugJ2e-M20-035403-1.MOV", "Z4mhB0Hl-M20-035224-1.MOV",\r
+                                       "cBx8vwYP-M20-035402-1.MOV", "WNAunGsh-M20-035401-1.MOV", "4bJHH7dF-M20-035400-1.MOV", "whBVXEyl-M20-035217-1.MOV",\r
+                                       "pZJvUP4d-M20-035220-1.MOV", "fOp1jsww-M20-035407-1.MOV", "VIXrcyMD-M20-035406-1.MOV", "AkHIZveh-M20-035221-1.MOV",\r
+                                       "MEihdEMW-M20-035219-1.MOV", "H56Um2nU-M20-035405-1.MOV", "XZ7nysN8-M20-035222-1.MOV", "oCm9rtI2-M20-035218-1.MOV",\r
+                                       "fqkbYhxZ-M19-033363-1.mov", "aBaPHRqa-M19-033413-1.mov");\r
+\r
+                       for (String fileName : files) {\r
+                               StoreUri sourceUri = getManager().getStoreUri("TSM", RemoteStoreProtocol.TSM);\r
+                               StoreUri targetUri = getManager().getStoreUri("Low-res", RemoteStoreProtocol.LOCAL);\r
+                               targetUri.setRootPath("/mediacube/data");\r
+                               sourceUri.addProgressListener(new IProgressEventListener() {\r
+                                       @Override\r
+                                       public void progressChanged(ProgressEvent evt) {\r
+                                               //logger.info(evt.getProgress());\r
+                                       }\r
+                               });\r
+                               sourceUri.addStatusListener(new IStatusEventListener() {\r
+                                       @Override\r
+                                       public void statusChanged(StatusEvent evt) {\r
+                                               evt.setCancel(!canContinue());\r
+                                       }\r
+                               });\r
+                               fn = fileName.substring(9);\r
+                               RemoteFile result = sourceUri.transferFrom(targetUri, fileName, fn);\r
+\r
+                               MediaInfo mi = new MediaInfo(Paths.get(targetUri.toString(true), fn));\r
+                               mi.process();\r
+                               logger.info(MarkerManager.getMarker("MOVTEST"), "Az {} állomány viszatöltve, hossz {}, audio {}", fn, mi.getFrames(), mi.getAudioStreams());\r
+                       }\r
+               } catch (Exception e) {\r
+                       logger.info(MarkerManager.getMarker("MOVTEST"), "Az {} állomány viszatöltése sikertelen. {}", fn, e.getMessage());\r
+               }\r
+\r
+       }\r
+\r
 }\r
index 104806e4f67fe9eb5e39936fec8f62601c5c6508..bfb608c6e81876ff1814ed217129036a0ac32159 100644 (file)
@@ -8,7 +8,10 @@ import java.nio.file.Paths;
 import org.apache.logging.log4j.LogManager;\r
 import org.apache.logging.log4j.Logger;\r
 \r
+import user.commons.RemoteFile;\r
+import user.commons.StoreUri;\r
 import user.commons.mediatool.MediaInfo;\r
+import user.commons.remotestore.RemoteStoreProtocol;\r
 import user.jobengine.db.Media;\r
 \r
 public class DirMXFValidatorStep extends JobStep {\r
@@ -16,6 +19,14 @@ public class DirMXFValidatorStep extends JobStep {
 \r
        @StepEntry\r
        public Object[] execute(String source) throws Exception {\r
+\r
+               logger.info("get");\r
+               StoreUri storeUri = getManager().getStoreUri("NEXIO2", RemoteStoreProtocol.FTP);\r
+               RemoteFile f = storeUri.getRemoteFile("DANITESZT02.mxf");\r
+               logger.info("get done {}", f);\r
+               if (f != null)\r
+                       return null;\r
+\r
                Path path = Paths.get(source);\r
                DirectoryStream<Path> directoryStream = Files.newDirectoryStream(path);\r
                for (Path file : directoryStream) {\r
@@ -32,17 +43,16 @@ public class DirMXFValidatorStep extends JobStep {
                                fileName = fileName.substring(0, fileName.lastIndexOf("."));\r
 \r
                        if (file.toFile().length() == 0) {\r
-                               logger.error("Zero: {}", fileName);\r
+                               logger.error("Zero length: {}", fileName);\r
                                continue;\r
                        }\r
 \r
                        Media media = getManager().getMedia(fileName);\r
+                       long frames = 0;\r
                        if (media == null) {\r
-                               logger.error("Unchecked: {}", fileName);\r
-                               continue;\r
-                       }\r
-\r
-                       long frames = media.getLength();\r
+                               logger.warn("Unchecked yet: {}", fileName);\r
+                       } else\r
+                               frames = media.getLength();\r
 \r
                        MediaInfo mi = null;\r
 \r
@@ -54,14 +64,7 @@ public class DirMXFValidatorStep extends JobStep {
                                logger.error("Unreadable: {}", fileName);\r
                        }\r
 \r
-                       if (frames == 0) {\r
-                               logger.info("Ma valid: {}", fileName);\r
-                               continue;\r
-                       }\r
-\r
-                       if (Math.abs(frames - mi.getFrames()) < 4) {\r
-                               logger.info("Valid: {} {} {}", fileName, frames, mi.getFrames());\r
-                       }\r
+                       logger.info("{}: MC farmes {}, FF frames {}", fileName, frames, mi.getFrames());\r
                }\r
 \r
                return null;\r
diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/SyncSubtitlesStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/SyncSubtitlesStep.java
new file mode 100644 (file)
index 0000000..83b14db
--- /dev/null
@@ -0,0 +1,91 @@
+package user.jobengine.server.steps;\r
+\r
+import java.io.IOException;\r
+import java.io.RandomAccessFile;\r
+import java.nio.channels.FileLock;\r
+import java.nio.channels.OverlappingFileLockException;\r
+import java.nio.file.FileVisitResult;\r
+import java.nio.file.Files;\r
+import java.nio.file.Path;\r
+import java.nio.file.Paths;\r
+import java.nio.file.SimpleFileVisitor;\r
+import java.nio.file.attribute.BasicFileAttributes;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.apache.logging.log4j.LogManager;\r
+import org.apache.logging.log4j.Logger;\r
+\r
+import user.commons.StoreUri;\r
+import user.commons.remotestore.RemoteStoreProtocol;\r
+\r
+public class SyncSubtitlesStep extends JobStep {\r
+       private static final String EXT_STL = ".stl";\r
+       private static final Logger logger = LogManager.getLogger();\r
+       int count = 10;\r
+\r
+       @StepEntry\r
+       public Object[] execute(String sourceStoreName, String targetStoreName) throws Exception {\r
+               try {\r
+                       StoreUri sourceStoreUri = getManager().getStoreUri(sourceStoreName, RemoteStoreProtocol.LOCAL);\r
+                       StoreUri targetStoreUri = getManager().getStoreUri(targetStoreName, RemoteStoreProtocol.LOCAL);\r
+                       Path sourcePath = Paths.get(sourceStoreUri.toString(true));\r
+                       Path targetPath = Paths.get(targetStoreUri.toString(true));\r
+                       List<Path> files = new ArrayList<>();\r
+\r
+                       Files.walkFileTree(sourcePath, new SimpleFileVisitor<Path>() {\r
+                               @Override\r
+                               public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {\r
+                                       if (file.getFileName().toString().toLowerCase().endsWith(EXT_STL)) {\r
+                                               files.add(file);\r
+                                       }\r
+                                       if (getJobRuntime().isWaitingCancel())\r
+                                               return FileVisitResult.TERMINATE;\r
+                                       return super.visitFile(file, attrs);\r
+                               }\r
+                       });\r
+\r
+                       if (getJobRuntime().isWaitingCancel())\r
+                               return null;\r
+\r
+                       int currentCount = 0;\r
+                       for (Path file : files) {\r
+                               Path targetFile = Paths.get(targetPath.toString(), file.getFileName().toString());\r
+\r
+                               boolean delete = false;\r
+                               try (RandomAccessFile reader = new RandomAccessFile(file.toString(), "rw")) {\r
+                                       FileLock lock = reader.getChannel().lock();\r
+                                       byte[] content = new byte[(int) file.toFile().length()];\r
+                                       reader.read(content);\r
+                                       Files.write(targetFile, content);\r
+                                       lock.release();\r
+                                       delete = true;\r
+                               } catch (OverlappingFileLockException e) {\r
+                                       logger.warn(getSessionMarker(), "File is locked {}" + file);\r
+                               } catch (Exception e) {\r
+                                       logger.warn(getSessionMarker(), e.getMessage());\r
+                               }\r
+\r
+                               if (delete && file.toFile().length() == targetFile.toFile().length()) {\r
+                                       try {\r
+                                               Files.delete(file);\r
+                                       } catch (Exception e) {\r
+                                               logger.error(getSessionMarker(), e.getMessage());\r
+                                       }\r
+                               }\r
+\r
+                               currentCount++;\r
+                               int progress = currentCount * 100 / files.size();\r
+                               setProgress(progress);\r
+                               if (getJobRuntime().isWaitingCancel())\r
+                                       break;\r
+                       }\r
+\r
+               } catch (Exception e) {\r
+                       logger.error(getSessionMarker(), e.getMessage());\r
+                       throw e;\r
+               }\r
+               return null;\r
+       }\r
+\r
+}\r
index afe5f67733711823d3bfb0afd90b529306f9bc56..a0bee642777b29e0a9737afde903b8b93f88468b 100644 (file)
@@ -7,6 +7,7 @@ public class MediaCubeFinishMarker extends MediaCubeMarker {
                setSessionID(parent.getSessionID());\r
                setSessionName(parent.getSessionName());\r
                setTo(parent.getTo());\r
+               setUseSessionLog(parent.isUseSessionLog());\r
        }\r
 \r
        public MediaCubeFinishMarker(MediaCubeMarker parent, String to) {\r
index 2baef98525e5adb2e6c54277efc7e89d4702b3b3..7a60acfaa9db7a55f6ca0b308ddf48286e055b94 100644 (file)
@@ -61,6 +61,7 @@ public class MediaInfo {
                        demuxer.open(filePath.toString(), null, false, true, null, null);\r
 \r
                        bitRate = demuxer.getBitRate();\r
+\r
                        int numStreams = demuxer.getNumStreams();\r
                        frames = 0;\r
                        int videoStreamId = -1;\r
index b74a6555873037841907974875f70f57c6996a71..72726c4e82be31ba72efe17c3ea72b48b5cf9cb6 100644 (file)
@@ -4,7 +4,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import java.io.FileInputStream;
+import java.io.RandomAccessFile;
 import java.net.URL;
+import java.nio.channels.FileLock;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
@@ -61,111 +63,94 @@ public class AMCTests {
        }
 
        @Test
-       public void testNexioArchiveChecker() throws Exception {
-               //Tesztelni a HirTV-n lehet
+       public void testForkValidateAndArchive() throws Exception {
+               //Tesztelni egy helyi FTP-n lehet
+               Path statusPath = Paths.get(output, ".STATUS");
+               Files.createDirectories(statusPath);
 
-               jobEngine = new JobEngine();
-               jobEngine.startup();
-               jobEngine.bindItemManagerService(manager);
+               StoreUri sourceStoreUri = manager.ensureUri("Local FTP", "localhost", false, false, RemoteStoreProtocol.FTP);
+               StoreUri targetStoreUri = manager.ensureUri("TSM", "xxx", true, false, RemoteStoreProtocol.TSM);
+               DownloadableMedia downloadable = new DownloadableMedia();
+               String fileName = "HOSSZ_TEST.MXF";
+               long frames = 24;
+               Path escortFile = Paths.get(statusPath.toString(), "Local FTP.HOSSZ_TEST.MXF.json");
 
-               String sourceStoreName = "NEXIO";
-               manager.ensureUri(sourceStoreName, System.getProperty("nexio.host"), false, false, RemoteStoreProtocol.NEXIO);
+               downloadable.put("fileName", fileName);
+               downloadable.put("frames", frames);
+               downloadable.put("size", 0);
+               downloadable.put("storeUriId", sourceStoreUri.getId());
 
-               Files.createDirectories(Paths.get(output));
+               Files.write(escortFile, downloadable.toPrettyString("").getBytes());
 
-               Map<String, Object> jobParams = new HashMap<>();
-               jobParams.put("sourceStoreName", sourceStoreName);
-               jobParams.put("escortStoreName", "LOCAL");
-               jobParams.put("limit", 1);
+               String childTemplate = "validate-and-archive.xml";
 
                CountDownLatch finishLatch = new CountDownLatch(1);
-               IJobRuntime jobRuntime = jobEngine.submit(null, e -> {
-                       if (e.isRuntimeTerminated())
-                               finishLatch.countDown();
-               }, "nexio-archive-checker.xml", "NEXIO archive check", jobParams);
 
-               if (jobRuntime != null)
-                       finishLatch.await();
-
-               FileUtils.deleteDirectory(Paths.get(output).toFile());
-               jobEngine.shutdown();
-
-               assertNotNull(jobRuntime);
-               assertEquals(JobStatus.FINISHED, jobRuntime.getStatus());
-
-       }
-
-       @Test
-       public void testGenericArchiveChecker() throws Exception {
-               //Tesztelni egy helyi FTP-n lehet
+               jobEngine = new JobEngine() {
+                       @Override
+                       public IJobRuntime submit(String template, String name, Map<String, Object> parameters) throws JobEngineException {
+                               if (childTemplate.equals(template)) {
+                                       assertEquals(sourceStoreUri.getId(), ((StoreUri) parameters.get("sourceStoreUri")).getId());
+                                       assertEquals(tempUri.getId(), ((StoreUri) parameters.get("tempStoreUri")).getId());
+                                       assertEquals(targetStoreUri.getId(), ((StoreUri) parameters.get("targetStoreUri")).getId());
+                                       assertEquals(fileName, parameters.get("sourceFileName"));
+                                       assertEquals(frames, parameters.get("expectedFrameNumber"));
+                                       assertEquals(0L, parameters.get("expectedSize"));
+                                       assertEquals(escortFile.toAbsolutePath().toString(), parameters.get("escortFile"));
+                                       finishLatch.countDown();
+                                       return new JobRuntime();
+                               }
+                               return super.submit(template, name, parameters);
+                       }
 
-               jobEngine = new JobEngine();
+               };
                jobEngine.startup();
                jobEngine.bindItemManagerService(manager);
 
-               String sourceStoreName = "Local FTP";
-               StoreUri storeUri = manager.ensureUri(sourceStoreName, "localhost", false, false, RemoteStoreProtocol.FTP);
-               if (!"dani".equals(storeUri.getUserName())) {
-                       storeUri.setUserName("dani");
-                       storeUri.setPassword("dani");
-                       storeUri.modify();
-               }
-
-               Files.createDirectories(Paths.get(output));
-
                Map<String, Object> jobParams = new HashMap<>();
-               jobParams.put("sourceStoreName", sourceStoreName);
-               jobParams.put("protocol", "FTP");
-               jobParams.put("wildCard", ".mxf|.mov");
-               jobParams.put("escortStoreName", "LOCAL");
+               jobParams.put("sourceStoreName", "LOCAL");
+               jobParams.put("targetStoreName", "TSM");
+               jobParams.put("targetProtocol", "TSM");
+               jobParams.put("template", childTemplate);
                jobParams.put("limit", 1);
 
-               CountDownLatch finishLatch = new CountDownLatch(1);
                IJobRuntime jobRuntime = jobEngine.submit(null, e -> {
-                       if (e.isRuntimeTerminated())
-                               finishLatch.countDown();
-               }, "generic-archive-checker.xml", "Generic archive check", jobParams);
+               }, "fork-validate-and-archive.xml", "Fork validate and archive", jobParams);
 
                if (jobRuntime != null)
                        finishLatch.await();
 
                FileUtils.deleteDirectory(Paths.get(output).toFile());
                jobEngine.shutdown();
-
-               assertNotNull(jobRuntime);
-               assertEquals(JobStatus.FINISHED, jobRuntime.getStatus());
+               //assertEquals(jobRuntime.getStatus())
 
        }
 
        @Test
-       public void testForkValidateAndArchive() throws Exception {
-               //Tesztelni egy helyi FTP-n lehet
+       public void testForkValidateAndRestore() throws Exception {
                Path statusPath = Paths.get(output, ".STATUS");
                Files.createDirectories(statusPath);
 
-               StoreUri sourceStoreUri = manager.ensureUri("Local FTP", "localhost", false, false, RemoteStoreProtocol.FTP);
-               StoreUri targetStoreUri = manager.ensureUri("TSM", "xxx", true, false, RemoteStoreProtocol.TSM);
+               StoreUri videoStoreUri = manager.ensureUri("TEST SOURCE", "/_video", false, false, RemoteStoreProtocol.LOCAL);
+               StoreUri targetStoreUri = manager.ensureUri("TEST TARGET", output, false, false, RemoteStoreProtocol.LOCAL);
                DownloadableMedia downloadable = new DownloadableMedia();
                String fileName = "HOSSZ_TEST.MXF";
                long frames = 24;
-               Path escortFile = Paths.get(statusPath.toString(), "Local FTP.HOSSZ_TEST.MXF.json");
+               Path escortFile = Paths.get(statusPath.toString(), "NEXIO.HOSSZ_TEST.MXF.json");
 
                downloadable.put("fileName", fileName);
                downloadable.put("frames", frames);
                downloadable.put("size", 0);
-               downloadable.put("storeUriId", sourceStoreUri.getId());
-
+               downloadable.put("storeUriId", videoStoreUri.getId());
                Files.write(escortFile, downloadable.toPrettyString("").getBytes());
 
-               String childTemplate = "validate-and-archive.xml";
-
                CountDownLatch finishLatch = new CountDownLatch(1);
-
+               String childTemplate = "validate-and-restore.xml";
                jobEngine = new JobEngine() {
                        @Override
                        public IJobRuntime submit(String template, String name, Map<String, Object> parameters) throws JobEngineException {
                                if (childTemplate.equals(template)) {
-                                       assertEquals(sourceStoreUri.getId(), ((StoreUri) parameters.get("sourceStoreUri")).getId());
+                                       assertEquals(videoStoreUri.getId(), ((StoreUri) parameters.get("sourceStoreUri")).getId());
                                        assertEquals(tempUri.getId(), ((StoreUri) parameters.get("tempStoreUri")).getId());
                                        assertEquals(targetStoreUri.getId(), ((StoreUri) parameters.get("targetStoreUri")).getId());
                                        assertEquals(fileName, parameters.get("sourceFileName"));
@@ -184,13 +169,15 @@ public class AMCTests {
 
                Map<String, Object> jobParams = new HashMap<>();
                jobParams.put("sourceStoreName", "LOCAL");
-               jobParams.put("targetStoreName", "TSM");
-               jobParams.put("targetProtocol", "TSM");
+               jobParams.put("targetStoreName", "TEST TARGET");
+               jobParams.put("targetProtocol", "LOCAL");
                jobParams.put("template", childTemplate);
                jobParams.put("limit", 1);
 
                IJobRuntime jobRuntime = jobEngine.submit(null, e -> {
-               }, "fork-validate-and-archive.xml", "Fork validate and archive", jobParams);
+                       //                      if (e.isRuntimeTerminated())
+                       //                              finishLatch.countDown();
+               }, "fork-validate-and-restore.xml", "Fork validate and archive", jobParams);
 
                if (jobRuntime != null)
                        finishLatch.await();
@@ -202,55 +189,80 @@ public class AMCTests {
        }
 
        @Test
-       public void testValidateAndArchive() throws Exception {
-               Path statusPath = Paths.get(output, ".STATUS");
-               Files.createDirectories(statusPath);
-               String fileName = "HOSSZ_TEST.MXF";
-               Path escortFile = Paths.get(statusPath.toString(), "Local FTP." + fileName + ".json");
+       public void testGenericArchiveChecker() throws Exception {
+               //Tesztelni egy helyi FTP-n lehet
 
-               StoreUri storeUri = manager.ensureUri("Local FTP", "localhost", false, false, RemoteStoreProtocol.FTP);
+               jobEngine = new JobEngine();
+               jobEngine.startup();
+               jobEngine.bindItemManagerService(manager);
+
+               String sourceStoreName = "Local FTP";
+               StoreUri storeUri = manager.ensureUri(sourceStoreName, "localhost", false, false, RemoteStoreProtocol.FTP);
                if (!"dani".equals(storeUri.getUserName())) {
                        storeUri.setUserName("dani");
                        storeUri.setPassword("dani");
                        storeUri.modify();
                }
-               StoreUri tempUri = manager.ensureUri("LOCAL", output, false, false, RemoteStoreProtocol.LOCAL);
-               StoreUri targetStoreUri = manager.ensureUri("TEST TARGET", output + "/target", false, false, RemoteStoreProtocol.LOCAL);
-               DownloadableMedia downloadable = new DownloadableMedia();
 
-               long frames = 514;
-               downloadable.put("title", fileName);
-               downloadable.put("fileName", fileName);
-               downloadable.put("frames", frames);
-               downloadable.put("size", 0L);
-               downloadable.put("storeUriId", storeUri.getId());
-               Files.write(escortFile, downloadable.toPrettyString("").getBytes());
+               Files.createDirectories(Paths.get(output));
+
+               Map<String, Object> jobParams = new HashMap<>();
+               jobParams.put("sourceStoreName", sourceStoreName);
+               jobParams.put("protocol", "FTP");
+               jobParams.put("wildCard", ".mxf|.mov");
+               jobParams.put("escortStoreName", "LOCAL");
+               jobParams.put("limit", 1);
+
+               CountDownLatch finishLatch = new CountDownLatch(1);
+               IJobRuntime jobRuntime = jobEngine.submit(null, e -> {
+                       if (e.isRuntimeTerminated())
+                               finishLatch.countDown();
+               }, "generic-archive-checker.xml", "Generic archive check", jobParams);
+
+               if (jobRuntime != null)
+                       finishLatch.await();
+
+               FileUtils.deleteDirectory(Paths.get(output).toFile());
+               jobEngine.shutdown();
+
+               assertNotNull(jobRuntime);
+               assertEquals(JobStatus.FINISHED, jobRuntime.getStatus());
+
+       }
+
+       @Test
+       public void testNexioArchiveChecker() throws Exception {
+               //Tesztelni a HirTV-n lehet
 
                jobEngine = new JobEngine();
                jobEngine.startup();
                jobEngine.bindItemManagerService(manager);
 
+               String sourceStoreName = "NEXIO";
+               manager.ensureUri(sourceStoreName, System.getProperty("nexio.host"), false, false, RemoteStoreProtocol.NEXIO);
+
+               Files.createDirectories(Paths.get(output));
+
                Map<String, Object> jobParams = new HashMap<>();
-               jobParams.put("sourceStoreUri", storeUri);
-               jobParams.put("tempStoreUri", tempUri);
-               jobParams.put("targetStoreUri", targetStoreUri);
-               jobParams.put("fileName", fileName);
-               jobParams.put("expectedFrameNumber", frames);
-               jobParams.put("expectedSize", 0L);
-               //jobParams.put("expectedColorSpace", null);
-               jobParams.put("escortFile", escortFile.toAbsolutePath().toString());
-               CountDownLatch finishLatch = new CountDownLatch(1);
+               jobParams.put("sourceStoreName", sourceStoreName);
+               jobParams.put("escortStoreName", "LOCAL");
+               jobParams.put("limit", 1);
 
+               CountDownLatch finishLatch = new CountDownLatch(1);
                IJobRuntime jobRuntime = jobEngine.submit(null, e -> {
                        if (e.isRuntimeTerminated())
                                finishLatch.countDown();
-               }, "validate-and-archive.xml", "Validate and archive", jobParams);
+               }, "nexio-archive-checker.xml", "NEXIO archive check", jobParams);
 
                if (jobRuntime != null)
                        finishLatch.await();
 
                FileUtils.deleteDirectory(Paths.get(output).toFile());
                jobEngine.shutdown();
+
+               assertNotNull(jobRuntime);
+               assertEquals(JobStatus.FINISHED, jobRuntime.getStatus());
+
        }
 
        @Test
@@ -307,65 +319,91 @@ public class AMCTests {
        }
 
        @Test
-       public void testForkValidateAndRestore() throws Exception {
+       public void testSyncSubtitles() throws Exception {
+               jobEngine = new JobEngine();
+               jobEngine.startup();
+               jobEngine.bindItemManagerService(manager);
+
+               String sourceStoreName = "SUB-IN";
+               manager.ensureUri(sourceStoreName, "/SUB-IN", false, false, RemoteStoreProtocol.LOCAL);
+               String targetStoreName = "SUB-OUT";
+               manager.ensureUri(targetStoreName, "/SUB-OUT", false, false, RemoteStoreProtocol.LOCAL);
+
+               Map<String, Object> jobParams = new HashMap<>();
+               jobParams.put("sourceStoreName", sourceStoreName);
+               jobParams.put("targetStoreName", targetStoreName);
+
+               CountDownLatch finishLatch = new CountDownLatch(1);
+               IJobRuntime jobRuntime = null;
+
+               try (RandomAccessFile reader = new RandomAccessFile("/SUB-IN/BUL/CCEM100323-01.stl", "rw")) {
+                       FileLock lock = reader.getChannel().lock();
+
+                       jobRuntime = jobEngine.submit(null, e -> {
+                               if (e.isRuntimeTerminated())
+                                       finishLatch.countDown();
+                       }, "sync-subtitles.xml", "Sync subtitles", jobParams);
+
+                       if (jobRuntime != null)
+                               finishLatch.await();
+
+                       lock.release();
+               }
+
+               jobEngine.shutdown();
+               assertEquals(JobStatus.FINISHED, jobRuntime.getStatus());
+       }
+
+       @Test
+       public void testValidateAndArchive() throws Exception {
                Path statusPath = Paths.get(output, ".STATUS");
                Files.createDirectories(statusPath);
+               String fileName = "HOSSZ_TEST.MXF";
+               Path escortFile = Paths.get(statusPath.toString(), "Local FTP." + fileName + ".json");
 
-               StoreUri videoStoreUri = manager.ensureUri("TEST SOURCE", "/_video", false, false, RemoteStoreProtocol.LOCAL);
-               StoreUri targetStoreUri = manager.ensureUri("TEST TARGET", output, false, false, RemoteStoreProtocol.LOCAL);
+               StoreUri storeUri = manager.ensureUri("Local FTP", "localhost", false, false, RemoteStoreProtocol.FTP);
+               if (!"dani".equals(storeUri.getUserName())) {
+                       storeUri.setUserName("dani");
+                       storeUri.setPassword("dani");
+                       storeUri.modify();
+               }
+               StoreUri tempUri = manager.ensureUri("LOCAL", output, false, false, RemoteStoreProtocol.LOCAL);
+               StoreUri targetStoreUri = manager.ensureUri("TEST TARGET", output + "/target", false, false, RemoteStoreProtocol.LOCAL);
                DownloadableMedia downloadable = new DownloadableMedia();
-               String fileName = "HOSSZ_TEST.MXF";
-               long frames = 24;
-               Path escortFile = Paths.get(statusPath.toString(), "NEXIO.HOSSZ_TEST.MXF.json");
 
+               long frames = 514;
+               downloadable.put("title", fileName);
                downloadable.put("fileName", fileName);
                downloadable.put("frames", frames);
-               downloadable.put("size", 0);
-               downloadable.put("storeUriId", videoStoreUri.getId());
+               downloadable.put("size", 0L);
+               downloadable.put("storeUriId", storeUri.getId());
                Files.write(escortFile, downloadable.toPrettyString("").getBytes());
 
-               CountDownLatch finishLatch = new CountDownLatch(1);
-               String childTemplate = "validate-and-restore.xml";
-               jobEngine = new JobEngine() {
-                       @Override
-                       public IJobRuntime submit(String template, String name, Map<String, Object> parameters) throws JobEngineException {
-                               if (childTemplate.equals(template)) {
-                                       assertEquals(videoStoreUri.getId(), ((StoreUri) parameters.get("sourceStoreUri")).getId());
-                                       assertEquals(tempUri.getId(), ((StoreUri) parameters.get("tempStoreUri")).getId());
-                                       assertEquals(targetStoreUri.getId(), ((StoreUri) parameters.get("targetStoreUri")).getId());
-                                       assertEquals(fileName, parameters.get("sourceFileName"));
-                                       assertEquals(frames, parameters.get("expectedFrameNumber"));
-                                       assertEquals(0L, parameters.get("expectedSize"));
-                                       assertEquals(escortFile.toAbsolutePath().toString(), parameters.get("escortFile"));
-                                       finishLatch.countDown();
-                                       return new JobRuntime();
-                               }
-                               return super.submit(template, name, parameters);
-                       }
-
-               };
+               jobEngine = new JobEngine();
                jobEngine.startup();
                jobEngine.bindItemManagerService(manager);
 
                Map<String, Object> jobParams = new HashMap<>();
-               jobParams.put("sourceStoreName", "LOCAL");
-               jobParams.put("targetStoreName", "TEST TARGET");
-               jobParams.put("targetProtocol", "LOCAL");
-               jobParams.put("template", childTemplate);
-               jobParams.put("limit", 1);
+               jobParams.put("sourceStoreUri", storeUri);
+               jobParams.put("tempStoreUri", tempUri);
+               jobParams.put("targetStoreUri", targetStoreUri);
+               jobParams.put("fileName", fileName);
+               jobParams.put("expectedFrameNumber", frames);
+               jobParams.put("expectedSize", 0L);
+               //jobParams.put("expectedColorSpace", null);
+               jobParams.put("escortFile", escortFile.toAbsolutePath().toString());
+               CountDownLatch finishLatch = new CountDownLatch(1);
 
                IJobRuntime jobRuntime = jobEngine.submit(null, e -> {
-                       //                      if (e.isRuntimeTerminated())
-                       //                              finishLatch.countDown();
-               }, "fork-validate-and-restore.xml", "Fork validate and archive", jobParams);
+                       if (e.isRuntimeTerminated())
+                               finishLatch.countDown();
+               }, "validate-and-archive.xml", "Validate and archive", jobParams);
 
                if (jobRuntime != null)
                        finishLatch.await();
 
                FileUtils.deleteDirectory(Paths.get(output).toFile());
                jobEngine.shutdown();
-               //assertEquals(jobRuntime.getStatus())
-
        }
 
        @Test