コード例 #1
0
ファイル: Program.cs プロジェクト: kbochenina/Kraken
        static Dictionary<ExecutionService.TaskState, int> GetTaskStatesCount(ulong[] taskIds)
        {
            using (var service = new ExecutionService.ExecutionBrokerServiceClient())
            {
                var taskInfos = service.GetBriefTaskList();
                var statesCount = taskInfos
                    .Where(info => taskIds.Contains(info.TaskId))
                    .GroupBy(info => info.State)
                    .ToDictionary(group => group.Key, group => group.Count());

                return statesCount;
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: kbochenina/Kraken
        static void LaunchThemAll(object taskIdsAsObjects)
        {
            ulong[] taskIds = (ulong[]) taskIdsAsObjects;

            rnd = rnd ?? new System.Random();
            for (int i=0; i < taskIds.Length; i++)
            {
                using (var service = new ExecutionService.ExecutionBrokerServiceClient())
                {
                    ulong taskId = taskIds[i];
                    var taskToLaunch = TaskGenFunc(taskId);

                    service.DefineTask(taskToLaunch);
                    service.Execute(new ulong[] { taskId });

                    Thread.Sleep(rnd.Next(
                        (int) MIN_SLEEP_TIME_AFTER_LAUNCH.TotalMilliseconds,
                        (int) MAX_SLEEP_TIME_AFTER_LAUNCH.TotalMilliseconds
                    ));
                }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: kbochenina/Kraken
        static void Main(string[] args)
        {
            var service = new ExecutionService.ExecutionBrokerServiceClient();

            var timeStarted = DateTime.Now;
            Console.WriteLine("Started at {0}.", timeStarted);

            ulong[] taskIds = GetTaskIds();
            var launcherThread = new Thread(LaunchThemAll);
            launcherThread.Start(taskIds);

            int finishedTasksCount = 0;
            while (finishedTasksCount < LAUNCHES_COUNT)
            {
                var stateCounts = GetTaskStatesCount(taskIds);
                finishedTasksCount = stateCounts.Where(s =>
                    s.Key == ExecutionService.TaskState.Completed ||
                    s.Key == ExecutionService.TaskState.Failed ||
                    s.Key == ExecutionService.TaskState.Aborted
                ).Sum(s => s.Value);

                double avgSecondsOnTask =
                    (DateTime.Now - timeStarted).TotalSeconds / ((finishedTasksCount == 0)? 1: finishedTasksCount);

                Console.Write("{0}, ~{1} sec/task: ", DateTime.Now.ToString("HH:mm:ss"), avgSecondsOnTask);
                foreach (var state in stateCounts.Keys)
                    Console.Write("{0} = {1} ", state, stateCounts[state]);
                Console.WriteLine();

                Thread.Sleep(rnd.Next(
                    (int) MIN_SLEEP_TIME_AFTER_CHECK.TotalMilliseconds,
                    (int) MAX_SLEEP_TIME_AFTER_CHECK.TotalMilliseconds
                ));
            }

            Console.WriteLine("Press any key to continue...");
            Console.ReadKey();
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: kbochenina/Kraken
        const int WATCH_OUT = 10*1000; // maximum time to update in milliseconds

        #endregion Fields

        #region Methods

        static ExecutionService.TaskDescription[] GenerateTasks(System.Random rnd)
        {
            var resourcesService = new ResourceBaseService.ResourceBaseServiceClient();
            string[] names = resourcesService.GetResourceNames().Where(name => name == "b14").ToArray();

            List<string> allowedNames = new List<string>();
            foreach (string name in names)
            {
                var res = resourcesService.GetResourceByName(name);
                if (res.Nodes.Any(n => n.Packages.Any(p => p.Name.ToLowerInvariant() == PACK_NAME.ToLowerInvariant())))
                    allowedNames.Add(name);
            }

            int nameIndex = rnd.Next(allowedNames.Count);
            string resourceName = allowedNames[nameIndex];

            var executionService = new ExecutionService.ExecutionBrokerServiceClient();
            ulong generatedTaskId = executionService.GetNewTaskId();

            var tasks = new ExecutionService.TaskDescription[]
            {
                new ExecutionService.TaskDescription()
                {
                    WfId = "Watchina",
                    TaskId = generatedTaskId,
                    UserId = "sm",

                    LaunchMode = ExecutionService.TaskLaunchMode.Auto,

                    ExecParams = new Dictionary<string,string>()
                    {
                        {"Resource", resourceName},
                    },

                    Package  = "cnm",

                    Params = new Dictionary<string,string>()
                    {
                        {"in_format", "short"},
                    },

                    InputFiles = new ExecutionService.TaskFileDescription[]
                    {
                        new ExecutionService.TaskFileDescription
                        {
                            StorageId = "cnm_60k_p32",
                            FileName  = "cnm.in",
                            SlotName  = "inDataFile"
                        },
                    }
                },

                new ExecutionService.TaskDescription()
                {
                    WfId = "Watchina",
                    TaskId = generatedTaskId,
                    UserId = "sm",

                    LaunchMode = ExecutionService.TaskLaunchMode.Auto,

                    ExecParams = new Dictionary<string,string>()
                    {
                        {"Resource", resourceName},
                    },

                    Package  = "testp",
                    Method   = "arithm",

                    Params = new Dictionary<string,string>()
                    {
                        {"operation", "plus"},
                    },

                    InputFiles = new ExecutionService.TaskFileDescription[]
                    {
                        new ExecutionService.TaskFileDescription
                        {
                            StorageId = "number1",
                            FileName  = "my0.in",
                            SlotName  = "inf0"
                        },

                        new ExecutionService.TaskFileDescription
                        {
                            StorageId = "number25",
                            FileName  = "my1.in",
                            SlotName  = "inf1"
                        },
                    },

                    OutputFiles = new ExecutionService.TaskFileDescription[]
                    {
                        new ExecutionService.TaskFileDescription
                        {
                            StorageId = null,
                            FileName  = "out.txt",
                            SlotName  = "out_file"
                        }
                    }
                }
            };

            var packTasks = tasks.Where(t => t.Package.ToLowerInvariant() == PACK_NAME.ToLowerInvariant()).ToArray();
            return packTasks;
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: kbochenina/Kraken
        static void Main(string[] args)
        {
            var rnd = new System.Random();

            for (int iterNum = 0; MAX_LAUNCHES < 0 || iterNum < MAX_LAUNCHES; iterNum++)
            {
                try
                {
                    using (var service = new ExecutionService.ExecutionBrokerServiceClient())
                    {
                        while (true)
                        {
                            var tasks = GenerateTasks(rnd);
                            foreach (var task in tasks)
                                service.DefineTask(task);
                            service.Execute(tasks.Select(t => t.TaskId).ToArray());

                            Console.WriteLine(
                                DateTime.Now.ToString(TIME_FORMAT) +
                                String.Join(", ", tasks.Select(t => t.TaskId + " on " + t.ExecParams["Resource"]))
                            );

                            if (MAX_LAUNCHES < 0 && (iterNum % 10 == 0))
                                GetStatistics(CSV_PATH);

                            Thread.Sleep(rnd.Next(WATCH_IN, WATCH_OUT));
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Thread.Sleep(5000);
                }
            }

            GetStatistics(CSV_PATH);
        }