From ed9773ea977c3b3ab0a83ea1e0f6da26da636f5a Mon Sep 17 00:00:00 2001 From: Sweidan Omar Date: Mon, 2 May 2022 10:08:37 +0000 Subject: [PATCH] git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C33277 --- .../src/user/commons/FFAStransAPI.java | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/server/user.jobengine.osgi.commons/src/user/commons/FFAStransAPI.java b/server/user.jobengine.osgi.commons/src/user/commons/FFAStransAPI.java index e857b2e7..0a4fbf66 100644 --- a/server/user.jobengine.osgi.commons/src/user/commons/FFAStransAPI.java +++ b/server/user.jobengine.osgi.commons/src/user/commons/FFAStransAPI.java @@ -38,7 +38,7 @@ public class FFAStransAPI implements IFFAStransAPI { for (int i = 0; i < inputs.length; i++) { final String inputi = inDir + inputs[i]; final String outputi = outDir + FilenameUtils.removeExtension(inputs[i]) + ".MP4"; - //Task task = new Task(inDir + input, outDir + output); + // Task task = new Task(inDir + input, outDir + output); Runnable task = new Runnable() { private String input = inputi; @@ -48,7 +48,7 @@ public class FFAStransAPI implements IFFAStransAPI { public void run() { try { IFFAStransAPI api = new FFAStransAPI("http://10.11.1.111:65445/api/json/v1/", p -> { - //System.out.println(output + " progress: " + p); + // System.out.println(output + " progress: " + p); }); api.submit("MP4", input); @@ -64,17 +64,18 @@ public class FFAStransAPI implements IFFAStransAPI { }; executor.execute(task); - // try { + // try { // - // String outputFile = "\\\\10.10.1.74\\MAM-Proxy_output\\20180201-0700_hirado_TEST-_CS.mp4"; - // Path outputFilePath = Paths.get(outputFile); - // File file = outputFilePath.toFile(); - // if (!file.exists()) - // Thread.sleep(2000); - // Files.delete(outputFilePath); - // } catch (Exception e) { - // System.out.println(e.getMessage()); - // } + // String outputFile = + // "\\\\10.10.1.74\\MAM-Proxy_output\\20180201-0700_hirado_TEST-_CS.mp4"; + // Path outputFilePath = Paths.get(outputFile); + // File file = outputFilePath.toFile(); + // if (!file.exists()) + // Thread.sleep(2000); + // Files.delete(outputFilePath); + // } catch (Exception e) { + // System.out.println(e.getMessage()); + // } } executor.shutdown(); executor.awaitTermination(1, TimeUnit.HOURS); @@ -98,7 +99,7 @@ public class FFAStransAPI implements IFFAStransAPI { if (apiResponse.getStatus() != 202) throw new Exception("Can not submit, response status is: " + apiResponse.getStatus()); String json = apiResponse.readEntity(String.class); - //logger.info("Transoder response: {}", json); + // logger.info("Transoder response: {}", json); if (StringUtils.isBlank(json)) throw new Exception("Can not submit, response JSON is empty"); BasicDBObject resultObject = (BasicDBObject) JSONUtil.jsonToDbObject(json); @@ -142,12 +143,12 @@ public class FFAStransAPI implements IFFAStransAPI { continue; if (file.equals(f.getName())) { - //logger.info("Found success history {}", f.getName()); + // logger.info("Found success history {}", f.getName()); result = job; break; } if (file.equals(inputFile)) { - //logger.info("Found error history {}", inputFile); + // logger.info("Found error history {}", inputFile); result = job; break; } @@ -166,15 +167,15 @@ public class FFAStransAPI implements IFFAStransAPI { BasicDBObject result = null; try { Response apiResponse = target.request().get(); - //logger.info("Transoder response code: {}", apiResponse.getStatus()); + // logger.info("Transoder response code: {}", apiResponse.getStatus()); if (apiResponse.getStatus() != 200) { logger.info("{} | Invalid response {}", inputFileName, apiResponse.getStatus()); return null; } String json = apiResponse.readEntity(String.class); - //logger.info("Transoder response: {}", json); - //System.out.println(json); + // logger.info("Transoder response: {}", json); + // System.out.println(json); BasicDBObject resultObject = (BasicDBObject) JSONUtil.jsonToDbObject(json); List jobs = NoSQLUtils.asList(resultObject, "jobs"); @@ -184,7 +185,7 @@ public class FFAStransAPI implements IFFAStransAPI { } for (BasicDBObject job : jobs) { if (jobID.equals(job.getString("job_id"))) { - //logger.info("Found job {}", jobID); + // logger.info("Found job {}", jobID); result = job; break; } @@ -223,16 +224,16 @@ public class FFAStransAPI implements IFFAStransAPI { long started = System.currentTimeMillis(); - // BasicDBObject status = getStatus(jobId); + // BasicDBObject status = getStatus(jobId); // - // while (true) { - // status = getStatus(jobId); - // long current = System.currentTimeMillis(); - // if (status != null || current - started > 15 * 60 * 1000) - // break; + // while (true) { + // status = getStatus(jobId); + // long current = System.currentTimeMillis(); + // if (status != null || current - started > 15 * 60 * 1000) + // break; // - // Thread.sleep(pollIntervall); - // } + // Thread.sleep(pollIntervall); + // } BasicDBObject status = null; boolean hasAnyResponse = false; @@ -259,7 +260,7 @@ public class FFAStransAPI implements IFFAStransAPI { } } else { - logger.info("{} status not exists, checking history", inputFileName); + logger.info("{} status does not exist, checking history", inputFileName); listener.onProgressChanged(100); BasicDBObject history = getHistory(); if (history != null) { @@ -279,7 +280,7 @@ public class FFAStransAPI implements IFFAStransAPI { } } - //5 percig nincs valasz + // 5 percig nincs valasz if (!hasAnyResponse && (queryTime - started > 10 * 60 * 1000)) throw new Exception("Transcoder timeout"); Thread.sleep(pollIntervall); @@ -298,7 +299,7 @@ public class FFAStransAPI implements IFFAStransAPI { long wfID = -1; wfID = getWorkflowId(workflowName, workflows, wfID); if (wfID < 0) - throw new Exception("Workflow not exists: " + workflowName); + throw new Exception("Workflow does not exist: " + workflowName); BasicDBObject jobToSubmit = new BasicDBObject("wf_id", wfID).append("inputfile", inputFile); doSubmit(jobToSubmit); -- 2.54.0