Exemple #1
0
        public void Handle(DivideRequestMessage message)
        {
            var divider  = new Divider(message.Files, message.M, message.TaskId, message.Username);
            var result   = divider.divide();
            var response = new DivideResponseMessage(result, message.TaskId);

            Sender.Tell(response);
        }
        public void Handle(DivideResponseMessage message)
        {
            Task task = null;

            if (tasks.TryGetValue(message.TaskId, out task))
            {
                if (message.Files.Count == 0)
                {
                    abortTask(task, "No files to map");
                    return;
                }

                task.addDivideFiles(message.Files);

                NextCoordinatorInBulkGetter coordinatorGetter = null;
                try {
                    coordinatorGetter = new NextCoordinatorInBulkGetter(validMapCoordinator);
                } catch (Exception e) {
                    abortTask(task, "No coordinators");
                    return;
                }
                foreach (Dictionary <string, S3ObjectMetadata> files in message.Files)
                {
                    Dictionary <string, List <S3ObjectMetadata> > workConfigFiles = new Dictionary <string, List <S3ObjectMetadata> > ();

                    foreach (KeyValuePair <string, S3ObjectMetadata> pair in files)
                    {
                        workConfigFiles.Add(pair.Key, new List <S3ObjectMetadata> ()
                        {
                            pair.Value
                        });
                    }

                    WorkConfig workConfig = new WorkConfig(
                        task.Id,
                        task.Username,
                        workConfigFiles,
                        task.AssemblyMetadata
                        );

                    startNewMapWork(task, workConfig, coordinatorGetter.next());
                }
            }
            else
            {
                foreach (Dictionary <string, S3ObjectMetadata> dict in message.Files)
                {
                    foreach (S3ObjectMetadata file in dict.Values)
                    {
                        file.remove();
                    }
                }
            }
        }