Пример #1
0
        private void RunTask(IExecutorDriver driver, TaskInfo taskInfo)
        {
            driver.SendTaskRunningStatus(taskInfo.task_id);

            var url = Encoding.UTF8.GetString(taskInfo.data);
            var imageFileName = RunRendering(taskInfo.task_id, url);

            SendRenderResultMessage(driver, url, imageFileName);
            driver.SendTaskFinishedStatus(taskInfo.task_id);
        }
Пример #2
0
        public override void LaunchTask(IExecutorDriver driver, TaskInfo taskInfo)
        {
            Console.WriteLine($"Launching render task '{taskInfo.task_id.value}'...");

            Task.Factory.StartNew (() => {
                try {
                    RunTask (driver, taskInfo);
                } catch (Exception e) {
                    Console.WriteLine ($"Exception during render operation: {e}");
                    driver.SendTaskErrorStatus (taskInfo.task_id);
                }
            });
        }
Пример #3
0
        private static async Task RunTask(IExecutorDriver driver, TaskInfo taskInfo)
        {
            driver.SendTaskRunningStatus(taskInfo.task_id);

            var url = Encoding.UTF8.GetString(taskInfo.data);

            var htmlContent = await GetUrlContent(url);
            if (htmlContent != null)
            {
                var links = ExtractLinks(htmlContent);
                links = links
                    .Select(x => x.ToLower())
                    .Distinct(StringComparer.CurrentCultureIgnoreCase);

                if (links.Any())
                    SendCrawlResultMessage(driver, url, links.ToArray());
            }

            driver.SendTaskFinishedStatus(taskInfo.task_id);
        }
Пример #4
0
 public virtual void LaunchTask(IExecutorDriver driver, TaskInfo taskInfo)
 {
 }
Пример #5
0
        private TaskInfo GetRenderTaskInfo(Offer offer, int uniqueId, string url)
        {
            var result = new TaskInfo {
                name = "Rendler.Render_" + uniqueId,
                task_id = new TaskID { value = uniqueId.ToString () },
                slave_id = offer.slave_id,
                resources = {
                    new Resource {
                        name = "cpus",
                        type = Value.Type.SCALAR,
                        scalar = new Value.Scalar { value = RenderCpus }
                    },
                    new Resource {
                        name = "mem",
                        type = Value.Type.SCALAR,
                        scalar = new Value.Scalar { value = RenderMem }
                    }
                },
                executor = new ExecutorInfo {
                    executor_id = new ExecutorID { value = "RenderExecutor" },
                    command = new CommandInfo {
                        value = "mono rendler.exe -executor=render",
                        user = _runAsUser
                    },
                    data = Encoding.UTF8.GetBytes (_outputDir)
                },
                data = Encoding.UTF8.GetBytes (url)
            };

            result.executor.command.uris.Add (new CommandInfo.URI {
                cache = false,
                extract = true,
                value = "./rendler.tar.gz",  // relative to "frameworks_home" mesos-slave command argument
                executable = false
            });

            return result;
        }