From: Vásáry Dániel Date: Fri, 26 Jan 2018 16:21:16 +0000 (+0000) Subject: git-tfs-id: [http://tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube... X-Git-Url: http://git.useribm.hu/?a=commitdiff_plain;h=e77b45e96691a7c72d102dfad21faef7ccbfe080;p=mediacube.git git-tfs-id: [tfs.userrendszerhaz.hu:8080/tfs/DefaultCollection]$/MediaCube;C30853 --- diff --git a/client/Maestro/Configuration/-configuration-studio.json b/client/Maestro/Configuration/configuration-studio.json similarity index 100% rename from client/Maestro/Configuration/-configuration-studio.json rename to client/Maestro/Configuration/configuration-studio.json diff --git a/client/Maestro/Maestro.csproj b/client/Maestro/Maestro.csproj index edf46e53..2ec0bc5a 100644 --- a/client/Maestro/Maestro.csproj +++ b/client/Maestro/Maestro.csproj @@ -327,7 +327,7 @@ Always - + Always diff --git a/client/Maestro/Program.cs b/client/Maestro/Program.cs index b0e97ce9..b1913c4c 100644 --- a/client/Maestro/Program.cs +++ b/client/Maestro/Program.cs @@ -20,7 +20,7 @@ using System.Windows.Forms; namespace Maestro { static class Program { - private static Logger logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger logger = LogManager.GetCurrentClassLogger(); /// /// The main entry point for the application. @@ -76,7 +76,7 @@ namespace Maestro { } public class TrayApplicationContext : ApplicationContext { - private static Logger logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private const string GLOBAL_JSON = "global.json"; private const string AUDIORECORDER_JSON = "audiorecorder.json"; private const string JSON_WILDCARD = "*.json"; diff --git a/client/Maestro/Sources/FileSystemSource.cs b/client/Maestro/Sources/FileSystemSource.cs index 71a5cd9f..3a380fba 100644 --- a/client/Maestro/Sources/FileSystemSource.cs +++ b/client/Maestro/Sources/FileSystemSource.cs @@ -9,13 +9,12 @@ using Maestro.Sources.Messages; using System.Drawing; using NLog; using MaestroShared.Commons; -using System.Diagnostics; namespace Maestro.Sources { public delegate void ClearAndInitialize(); class FileSystemSource : BindingList, ISource, IBindingListView { - private readonly Logger logger = LogManager.GetCurrentClassLogger(); + private static readonly Logger logger = LogManager.GetCurrentClassLogger(); private IMessageBus messageBus; private List createdFileMonitors = new List(); private Control parent; @@ -23,7 +22,6 @@ namespace Maestro.Sources { private List acceptableExtensions = new List(); private List cache; private BackgroundWorker pathWatcherWorker = new BackgroundWorker(); - private string path; private string rootPath; FileSystemWatcher watcher; @@ -77,9 +75,11 @@ namespace Maestro.Sources { public bool IsSorted => true; public void ApplySort(PropertyDescriptor property, ListSortDirection direction) { + logger.Trace("Entry"); SortProperty = property; SortDirection = direction; Refresh(); + logger.Trace("Exit"); } public string Filter { @@ -97,6 +97,7 @@ namespace Maestro.Sources { public string Path { get; private set; } private void Refresh() { + logger.Trace("Entry"); if (cache == null) cache = new List(this); Clear(); @@ -114,6 +115,7 @@ namespace Maestro.Sources { filteredItems.OrderByDescending(i => getValue(i)).ToList().ForEach(i => Add(i)); break; } + logger.Trace("Exit"); } private object getValue(FileSourceItem i) { @@ -137,12 +139,14 @@ namespace Maestro.Sources { } public bool Reset(string path) { + logger.Trace("Entry"); if (Path.Equals(path)) return false; Path = path == null ? rootPath : path; Clear(); cache = null; Shutdown(); + logger.Trace("Exit"); return true; } @@ -169,15 +173,16 @@ namespace Maestro.Sources { } System.Threading.Thread.Sleep(100); } - } private void Shutdown() { + logger.Trace("Entry"); parent.SafeCall(() => Clear()); if (watcher != null) { watcher.Dispose(); watcher = null; - } + } + logger.Trace("Exit"); } private void SetAcceptableExtensions(string fileExtensionFilter) { @@ -186,14 +191,18 @@ namespace Maestro.Sources { } public void Startup(Uri address) { + logger.Trace("Entry"); Path = address.LocalPath; rootPath = Path; pathWatcherWorker.RunWorkerAsync(); + logger.Trace("Exit"); } private void InnerStartUp() { + logger.Trace("Entry"); createWatch(Path); initializeList(Path); + logger.Trace("Exit"); } private FileSourceItem CreateItem(FileInfo fi, bool highlight) { @@ -338,11 +347,13 @@ namespace Maestro.Sources { private void OnDeleted(object sender, FileSystemEventArgs e) { if (!String.IsNullOrEmpty(filter)) return; + logger.Trace("Entry"); logger.Debug("{0} {1}", e.ChangeType, e.Name); FileSourceItem item = this.Where(i => i.Name.Equals(e.Name)).FirstOrDefault(); if (item == null || !item.CanHandle(acceptableExtensions)) return; SafeDeleteItem(item); + logger.Trace("Exit"); } private void SafeCreateItem(FileSourceItem item) { diff --git a/client/Maestro/Sources/NexioRESTSource.cs b/client/Maestro/Sources/NexioRESTSource.cs index 1a2bec95..bca5dea7 100644 --- a/client/Maestro/Sources/NexioRESTSource.cs +++ b/client/Maestro/Sources/NexioRESTSource.cs @@ -224,15 +224,17 @@ namespace Maestro.Sources { item.ID = token[ID].ToString(); item.Name = token[LONGNAMEID].ToString() + MXFEXT; item.Agency = token[EXTAGENCY]?.ToString(); - item.Created = token.Value(RECORDDATE); - item.Modified = token.Value(MODIFIED); + DateTime? created = token.Value(RECORDDATE); + item.Created = created ?? DateTime.MinValue; + DateTime? modified = token.Value(MODIFIED); + item.Modified = modified ?? DateTime.MinValue; int d = token.Value(DURATION); item.Duration = new Timecode(d).ToString(); } catch (Exception e) { logger.Error(e.Message); } - + } diff --git a/client/Maestro/Sources/NexioSourceItem.cs b/client/Maestro/Sources/NexioSourceItem.cs index 80d0ce53..cbc0800f 100644 --- a/client/Maestro/Sources/NexioSourceItem.cs +++ b/client/Maestro/Sources/NexioSourceItem.cs @@ -1,6 +1,5 @@ using System; using System.ComponentModel; -using System.IO; using System.Runtime.CompilerServices; using System.Collections.Generic; namespace Maestro.Sources { diff --git a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java index b1cb4701..c548e980 100644 --- a/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java +++ b/server/user.jobengine.executors/src/user/jobengine/server/steps/TranscodeSELENIOStep.java @@ -187,8 +187,9 @@ public class TranscodeSELENIOStep extends JobStep { if (outFile.indexOf(".") > 2) { Path subdir = Paths.get(outFile.substring(0, 1), outFile.substring(1, 2), outFile.substring(2, 3)); manager.createMediaFile(Paths.get(subdir.toString(), outFile).toString(), fileType, store, mediaCubeMedia).add(); + EscortFiles.ensureUNCFolder(webPath, subdir.toString()); subdir = Paths.get(webPath, subdir.toString()); - subdir.toFile().mkdirs(); + //subdir.toFile().mkdirs(); Files.move(Paths.get(transcoderTargetPath, outFile), Paths.get(subdir.toString(), outFile), StandardCopyOption.REPLACE_EXISTING); } else { manager.createMediaFile(outFile, fileType, store, mediaCubeMedia).add(); diff --git a/server/user.jobengine.osgi.commons/src/user/commons/ffastrans/FFAStransAPI.java b/server/user.jobengine.osgi.commons/src/user/commons/ffastrans/FFAStransAPI.java new file mode 100644 index 00000000..99f420e0 --- /dev/null +++ b/server/user.jobengine.osgi.commons/src/user/commons/ffastrans/FFAStransAPI.java @@ -0,0 +1,134 @@ +package user.commons.ffastrans; + +import java.util.List; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder; +import org.jboss.resteasy.client.jaxrs.ResteasyWebTarget; + +import com.ibm.nosql.json.JSONUtil; +import com.ibm.nosql.json.api.BasicDBObject; + +import user.commons.nosql.NoSQLUtils; + +public class FFAStransAPI implements IFFAStransAPI { + + public static void main(String[] args) throws Exception { + + IFFAStransAPI api = new FFAStransAPI("http://10.10.1.74:65445/api/json/v1/"); + List workflows = api.getWorkflows(); + for (BasicDBObject workflow : workflows) { + //System.out.println(workflow.toPrettyString(null)); + if (!"MAM-Proxy".equals(workflow.getString("wf_name"))) + continue; + long wfID = workflow.getLong("wf_id"); + System.out.println("MAM-Proxy wf_id: " + wfID); + + String path = "\\\\PROXY-TRANSCODER-01\\MAM-Proxy_input\\test_09.mxf"; + String jobID = api.submit(wfID, path); + System.out.println("Submited: " + jobID); + + String jobStart = null; + while (true) { + Thread.sleep(1000); + BasicDBObject status = api.getStatus(jobID); + if (status != null) { + System.out.println("Status: " + status.toPrettyString(null)); + if (jobStart == null) + jobStart = status.getString("job_start"); + } else { + BasicDBObject history = api.getHistory(jobStart); + System.out.println("History: " + history.toPrettyString(null)); + break; + } + + } + } + } + + private ResteasyWebTarget webTarget; + + public FFAStransAPI(String apiAddress) { + webTarget = new ResteasyClientBuilder().build().target(apiAddress); + } + + @Override + public BasicDBObject getHistory(String jobStart) { + ResteasyWebTarget target = webTarget.path("history"); + BasicDBObject result = null; + try { + Response apiResponse = target.request().get(); + if (apiResponse.getStatus() != 200) + return null; + String json = apiResponse.readEntity(String.class); + BasicDBObject resultObject = (BasicDBObject) JSONUtil.jsonToDbObject(json); + List jobs = NoSQLUtils.asList(resultObject, "history"); + for (BasicDBObject job : jobs) { + if (job == null) + continue; + if (jobStart.equals(job.getString("job_start"))) { + result = job; + break; + } + } + } catch (Exception e) { + System.out.println(e.getMessage()); + } + + return result; + } + + @Override + public BasicDBObject getStatus(String jobID) { + ResteasyWebTarget target = webTarget.path("jobs"); + + BasicDBObject result = null; + try { + Response apiResponse = target.request().get(); + if (apiResponse.getStatus() != 200) + return null; + String json = apiResponse.readEntity(String.class); + BasicDBObject resultObject = (BasicDBObject) JSONUtil.jsonToDbObject(json); + List jobs = NoSQLUtils.asList(resultObject, "jobs"); + if (jobs == null) + return null; + for (BasicDBObject job : jobs) { + if (jobID.equals(job.getString("job_id"))) { + result = job; + break; + } + } + + } catch (Exception e) { + System.out.println(e.getClass() + " " + e.getMessage()); + } + + return result; + } + + @Override + public List getWorkflows() { + ResteasyWebTarget target = webTarget.path("workflows"); + Response apiResponse = target.request().get(); + if (apiResponse.getStatus() != 200) + return null; + String json = apiResponse.readEntity(String.class); + BasicDBObject resultObject = (BasicDBObject) JSONUtil.jsonToDbObject(json); + return NoSQLUtils.asList(resultObject, "workflows"); + } + + @Override + public String submit(long wfID, String path) { + BasicDBObject job = new BasicDBObject("wf_id", wfID).append("inputfile", path); + ResteasyWebTarget target = webTarget.path("jobs"); + Response apiResponse = target.request().post(Entity.entity(job.toString(), MediaType.APPLICATION_JSON)); + if (apiResponse.getStatus() != 202) + return null; + String json = apiResponse.readEntity(String.class); + BasicDBObject resultObject = (BasicDBObject) JSONUtil.jsonToDbObject(json); + return resultObject.getString("job_id"); + } +} diff --git a/server/user.jobengine.osgi.commons/src/user/commons/ffastrans/IFFAStransAPI.java b/server/user.jobengine.osgi.commons/src/user/commons/ffastrans/IFFAStransAPI.java new file mode 100644 index 00000000..1bb9ca10 --- /dev/null +++ b/server/user.jobengine.osgi.commons/src/user/commons/ffastrans/IFFAStransAPI.java @@ -0,0 +1,16 @@ +package user.commons.ffastrans; + +import java.util.List; + +import com.ibm.nosql.json.api.BasicDBObject; + +public interface IFFAStransAPI { + + BasicDBObject getHistory(String jobStart); + + BasicDBObject getStatus(String jobID); + + List getWorkflows(); + + String submit(long wfID, String path); +} diff --git a/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/EscortFiles.java b/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/EscortFiles.java index 57509664..fb73bd9a 100644 --- a/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/EscortFiles.java +++ b/server/user.jobengine.osgi.server/src/user/jobengine/server/steps/EscortFiles.java @@ -92,7 +92,7 @@ public class EscortFiles { } public static void createUNCKillDate(String filePath, String fileName, int days, Marker marker) throws IOException { - ensureUNCFolder(filePath, STATUSFOLDER, marker); + ensureUNCFolder(filePath, STATUSFOLDER); String killDateFileName = composeKillDateFileName(fileName, days); Path killDatePath = Paths.get(filePath, STATUSFOLDER, killDateFileName); if (Files.exists(killDatePath)) @@ -101,13 +101,13 @@ public class EscortFiles { Files.createFile(killDatePath); } - public static void ensureUNCFolder(String filePath, String folderName, Marker marker) throws IOException { + public static void ensureUNCFolder(String filePath, String folderName) throws IOException { Path statusPath = Paths.get(filePath, folderName); File statusFolder = statusPath.toFile(); if (!statusFolder.exists() || !statusFolder.isDirectory()) { Set perms = PosixFilePermissions.fromString("rwxrwxrwx"); FileAttribute> attr = PosixFilePermissions.asFileAttribute(perms); - Files.createDirectory(statusPath, attr); + Files.createDirectories(statusPath, attr); } } }