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
\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
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;
}
@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"));
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();
}
@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
}
@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