public StatusMessage Start(string config, IDictionary<string, string> parameters) { var statuslocal = new StatusMessage(); if (string.IsNullOrEmpty(config)) { statuslocal.Type = StatusType.Error; statuslocal.Message = "Invalid config name"; } else if (worker != null) { statuslocal.Type = StatusType.Error; statuslocal.Message = "A MapReduce is already running"; } else { driver = new MapReduceDriver(Path.Combine("configs",config)); SetParameters(driver.Tasks, parameters); worker = new Thread(new ThreadStart(MapReduceThread)); worker.Start(); status.ResultSetId = statuslocal.ResultSetId = Guid.NewGuid(); } return statuslocal; }
protected void Page_Load(object sender, EventArgs e) { worker = Session[WorkerThreadKey] as Thread; status = Session[StatusKey] as StatusMessage; string rootDir = HostingEnvironment.MapPath("/App_Data/"); Environment.CurrentDirectory = rootDir; string cmd = Request[CommandKey]; string configName = Request[ConfigNameKey]; if(string.IsNullOrEmpty(cmd)) return; cmd = cmd.ToLower(); if (cmd == "status") { if (status == null) RefreshStatus(UpdateType.None, 0, 0, 0); Status(); return; } if (cmd == "start") { Start(configName); return; } if (cmd == "getresult") { GetResult(configName); return; } JsonMessage("No command"); }