예제 #1
0
        public void Handle(Terminated message)
        {
            WorkerConfig workerConfig;

            if (workers.TryGetValue(message.ActorRef, out workerConfig))
            {
                LocalFilesDirectory dir = new LocalFilesDirectory(workerConfig);
                dir.removeDirectory();

                Console.WriteLine("Restarting worker...");

                startNewWorker(workerConfig);
            }
        }
예제 #2
0
        public void Handle(NewWorkerMessage message)
        {
            WorkerConfig     = message.WorkerConfig;
            TaskId           = WorkerConfig.WorkConfig.TaskId;
            CoordinatorId    = WorkerConfig.CoordinatorId;
            WorkerId         = WorkerConfig.WorkerId;
            Coordinator      = Sender;
            self             = Self;
            AssemblyMetaData = WorkerConfig.WorkConfig.AssemblyMetaData;

            LocalFileUtils = new LocalFilesDirectory(WorkerConfig);

            WorkerThread = new Thread(() => {
                try{
                    LocalFileUtils.createDirectory();


                    workProcessing();

                    if (Monitor.TryEnter(uploadLock))
                    {
                        uploadResult();

                        Monitor.Exit(uploadLock);
                    }
                }
                catch (ThreadAbortException e) {
                }
                catch (Exception e) {
                    Coordinator.Tell(new WorkerFailureMessage(WorkerId, TaskId, e.Message), self);
                }
                finally{
                    this.LocalFileUtils.removeDirectory();
                }
            });

            WorkerThread.Start();
        }