private void startButton_Click(object sender, EventArgs e) { if (nameTextBox.Text.Trim() == string.Empty) { MessageBox.Show("Please enter a name for the job before uploading it!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Content.Job.ProjectId == null || Content.Job.ProjectId == Guid.Empty) { MessageBox.Show("Please select a project before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Content.Job.ResourceIds == null || !Content.Job.ResourceIds.Any()) { MessageBox.Show("Please select resources before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); } else if (Content.ExecutionState == ExecutionState.Paused) { var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content); task.ContinueWith((t) => { Content.Progress.Finish(); MessageBox.Show("An error occured resuming the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); Content.Log.LogException(t.Exception); }, TaskContinuationOptions.OnlyOnFaulted); } else { HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken()); UpdateSelectorDialog(); } }
protected override void OnClosed(FormClosedEventArgs e) { if (Content != null && Content.Jobs != null) { Content.ClearHiveClient(); Content = null; } base.OnClosed(e); }
public override void Execute() { IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; content = activeView.Content as IItem; //IOptimizer and IExecutables need some special care if (content is IOptimizer) { ((IOptimizer)content).Runs.Clear(); } if (content is IExecutable) { IExecutable exec = content as IExecutable; if (exec.ExecutionState != ExecutionState.Prepared) { exec.Prepare(); } } HiveClient.Instance.Refresh(); ItemTask hiveTask = ItemTask.GetItemTaskForItem(content); HiveTask task = hiveTask.CreateHiveTask(); RefreshableJob rJob = new RefreshableJob(); rJob.Job.Name = content.ToString(); rJob.HiveTasks.Add(task); task.ItemTask.ComputeInParallel = content is Experiment || content is BatchRun; var hiveResourceSelectorDialog = new HiveResourceSelectorDialog(rJob.Job.Id, rJob.Job.ProjectId); if (HiveClient.Instance.Projects.Count == 1) { var project = HiveClient.Instance.Projects.FirstOrDefault(); if (project != null && project.Id != Guid.Empty) { hiveResourceSelectorDialog.SelectedProjectId = project.Id; } } if (hiveResourceSelectorDialog.ShowDialog((UserControl)activeView) == DialogResult.OK) { var selectedProject = hiveResourceSelectorDialog.SelectedProject; if (selectedProject != null) { rJob.Job.ProjectId = selectedProject.Id; rJob.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList(); progress = Progress.Show(this.content, "Uploading to Hive...", ProgressMode.Indeterminate); rJob.Progress = progress; progress.ProgressStateChanged += progress_ProgressStateChanged; HiveClient.StartJob(new Action <Exception>(HandleEx), rJob, new CancellationToken()); } } }
private void refreshPermissionsButton_Click(object sender, EventArgs e) { if (this.Content.Job.Id == Guid.Empty) { MessageBox.Show("You have to upload the Job first before you can share it.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { hiveExperimentPermissionListView.Content = HiveClient.GetJobPermissions(this.Content.Job.Id); } }
protected override void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs <JobPermission> e) { base.Content_ItemsRemoved(sender, e); foreach (var item in e.Items) { if (item.GrantedUserId != Guid.Empty) { HiveClient.Delete(item); } } }
/// <summary> /// Uploads the taskData and sets a new taskState (while correctly setting Transferring state) /// </summary> public void UpdateTaskData(Task task, TaskData taskData, Guid slaveId, TaskState state, string exception = "") { CallHiveService(service => { service.UpdateTask(task); task = service.UpdateTaskState(task.Id, TaskState.Transferring, slaveId, null, null); HiveClient.TryAndRepeat(() => { service.UpdateTaskData(task, taskData); }, HeuristicLab.Clients.Hive.SlaveCore.Properties.Settings.Default.PluginDeletionRetries, "Could not upload jobdata."); service.UpdateTaskState(task.Id, state, slaveId, null, exception); }); }
private static HiveClient CreateApacheHiveClient() { var hdfsClient = new WebHdfsHttpClient(Connect.WithTestUser(WebHdfsBase)); var hCatalogClient = new WebHCatalogJobClient(Connect.WithTestUser(WebHcatBase)); var client = new HiveClient(hdfsClient, hCatalogClient, new HiveClientConfig { ResultsFolderBase = @"/tmp/hiveQueries/", StrandardOutputFileName = "stdout" }); return client; }
private static HiveClient CreateApacheHiveClient() { var hdfsClient = new WebHdfsHttpClient(Connect.WithTestUser(WebHdfsBase)); var hCatalogClient = new WebHCatalogJobClient(Connect.WithTestUser(WebHcatBase)); var client = new HiveClient(hdfsClient, hCatalogClient, new HiveClientConfig { ResultsFolderBase = @"/tmp/hiveQueries/", StrandardOutputFileName = "stdout" }); return(client); }
private void InitializeHiveCommands() { HiveConnect = new RelayCommand(async obj => { HiveAccountState = "Подключение"; AuthenticationStatus st = await Task.Run(() => HiveClient.HiveAuthentication(HiveLogin, HivePasswordReceive)); if (st.Status) { await Task.Run(async() => { GenSettings.HiveLogin = HiveLogin; GenSettings.HivePassword = HivePasswordReceive; _model.cmd_SaveGenSettings(GenSettings);; HiveAccountState = "Аккаунт подключен"; HiveConnection = true; HiveConnectionState = "Подключение к Hive установлено"; HiveWorkers = await Task.Run(() => HiveClient.GetWorkers()); List <string> LST = (from w in HiveWorkers select w.name).ToList(); LST.Insert(0, "---"); HiveWorkersNames = LST; }); } else { HiveAccountState = st.Message; HiveConnection = false; HiveConnectionState = "Подключение к Hive отсутствует"; } }); HiveDisonnect = new RelayCommand(obj => { GenSettings.HiveLogin = null; GenSettings.HivePassword = null; _model.cmd_SaveGenSettings(GenSettings);; HiveLogin = ""; HivePasswordSend = ""; HiveAccountState = "Аккаунт не подключен"; HiveWorkersNames = null; HiveConnection = false; HiveConnectionState = "Подключение к Hive отсутствует"; }); }
public override void Execute() { IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; content = activeView.Content as IItem; //IOptimizer and IExecutables need some special care if (content is IOptimizer) { ((IOptimizer)content).Runs.Clear(); } if (content is IExecutable) { IExecutable exec = content as IExecutable; if (exec.ExecutionState != ExecutionState.Prepared) { exec.Prepare(); } } HiveClient.Instance.Refresh(); ItemTask hiveTask = ItemTask.GetItemTaskForItem(content); HiveTask task = hiveTask.CreateHiveTask(); RefreshableJob rJob = new RefreshableJob(); rJob.Job.Name = content.ToString(); rJob.HiveTasks.Add(task); task.ItemTask.ComputeInParallel = content is Experiment || content is BatchRun; progress = MainFormManager.GetMainForm <MainForm.WindowsForms.MainForm>().AddOperationProgressToContent(this.content, "Uploading to Hive..."); rJob.Progress = progress; progress.ProgressStateChanged += progress_ProgressStateChanged; HiveClient.StartJob(new Action <Exception>(HandleEx), rJob, new CancellationToken()); }
private void ResumeJobAsync(object job) { Content.Progress.Start("Resuming job..."); HiveClient.ResumeJob((RefreshableJob)job); Content.Progress.Finish(); }
private void StopJobAsync(object job) { Content.Progress.Start("Stopping job..."); HiveClient.StopJob((RefreshableJob)job); Content.Progress.Finish(); }
private void PauseJobAsync(object job) { Content.Progress.Start("Pausing job...", ProgressMode.Indeterminate); HiveClient.PauseJob((RefreshableJob)job); Content.Progress.Finish(); }
public void StartWach() { if (!HiveWach) { HiveWach = true; if (!HiveWachdog) { HiveWachdog = true; Task.Run(() => { Thread.Sleep(HiveOSWachdogDelay * 1000); CurrentHiveStatus = HiveStatus.Normal; UserInformer.SendMSG(Config.Name, "Start hive wach"); BackToLoop: while (CurrentHiveStatus == HiveStatus.Normal && InternetConnection) { Thread.Sleep(1000); } if (InternetConnection) { //задержка for (int n = 0; n < 100; n++) { if (CurrentHiveStatus == HiveStatus.Normal) { goto BackToLoop; } Thread.Sleep(100); } string msg = ""; switch (CurrentHiveStatus) { case HiveStatus.LowHashrate: { msg = "Hive: Low hashrate"; } break; case HiveStatus.WorkerOffline: { msg = "Hive: Worker offline"; } break; } UserInformer.SendMSG(Config.Name, msg); Rig.eWeReboot(); } HiveWachdog = false; }); } Task.Run(() => { while (!App.HiveConnection) { Thread.Sleep(100); } while (HiveWach && InternetConnection) { var mi = HiveClient.GetWorkerInfo(Config.HiveFarmID.Value, Config.HiveWorkerID.Value); if (mi != null) { InformReceived?.Invoke(new RigInform { Indication = true, InfHashrates = mi.Value.Hashrates, InfTemperatures = mi.Value.Temperatures }); // low hashrate wachdog if (Config.WachdogMinHashrate != null) { if (mi.Value.Hashrates.Length > 0) { CurrentHiveStatus = mi.Value.Hashrates.Sum() < Config.WachdogMinHashrate.Value ? HiveStatus.LowHashrate : HiveStatus.Normal; } else { CurrentHiveStatus = HiveStatus.LowHashrate; } } else { CurrentHiveStatus = HiveStatus.Normal; } } else { InformReceived?.Invoke(new RigInform { Indication = false }); CurrentHiveStatus = HiveStatus.WorkerOffline; goto EndHiveWach; } Thread.Sleep(new TimeSpan(0, 0, HiveOSRequestDelay)); } EndHiveWach: HiveWach = false; }); } }
private void ModelChanged(object sender, PropertyChangedEventArgs e) { switch (e.PropertyName) { case "Rigs": { Rigs = new ObservableCollection <Settings.Rig>(_model.Rigs); RigsNames = from r in Rigs orderby r.Index select r.Name; for (int i = 0; i < RigsNames.Count(); i++) { Indicators.Add(RigStatus.offline); Watch.Add(Rigs[i].Waching); { if (Rigs[i].Waching) { AddRigPanel(i); } else { RemoveRigPanel(i); } } } } break; case "PoolsSets": { for (int i = 0; i < _model.PoolsSets.Count; i++) { Selection.Add(false); PoolsSets.Add(_model.PoolsSets[i]); if (_model.PoolsSets[i].Wach) { WachPoolStart(i); } } } break; case "GenSettings": { GenSettings = _model.GenSettings; StartOfRange = GenSettings.TotalMinTemp; StartOfRangeD = GenSettings.TotalMinTemp; EndOfRange = GenSettings.TotalMaxTemp; EndOfRangeD = GenSettings.TotalMaxTemp; eWeLogin = GenSettings.eWeLogin; eWePasswordSend = GenSettings.eWePassword; if (!String.IsNullOrEmpty(eWeLogin) && !String.IsNullOrEmpty(eWePasswordSend)) { Task.Run(() => eWeConnect()); } Task.Run(() => { if (!string.IsNullOrEmpty(GenSettings.HiveLogin) && !string.IsNullOrEmpty(GenSettings.HivePassword)) { AuthenticationStatus st = HiveClient.HiveAuthentication( GenSettings.HiveLogin, GenSettings.HivePassword); if (st.Status) { HiveLogin = GenSettings.HiveLogin; HivePasswordSend = GenSettings.HivePassword; HiveConnection = true; App.HiveConnection = true; HiveAccountState = "Подключение к Hive установлено"; HiveConnectionState = "Подключение к Hive установлено"; HiveWorkers = HiveClient.GetWorkers(); if (HiveWorkers != null) { List <string> LST = (from w in HiveWorkers select w.name).ToList(); LST.Insert(0, "---"); HiveWorkersNames = LST; } } else { HiveAccountState = st.Message; } } else { HiveAccountState = "Подключение к Hive отсутствует"; HiveConnectionState = "Подключение к Hive отсутствует"; } }); VKuserID = GenSettings.VKuserID; } break; } }