Beispiel #1
0
        // Connect...
        public Submission(string db)
        {
            InitializeComponent();
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            Title = "Connecting...";

            WindowInteropHelper helper = new WindowInteropHelper(this);
            SubmissionWorker w = new SubmissionWorker(helper.Handle, workers.Count());
            w.DoWork += new DoWorkEventHandler(worker_DoWork);
            w.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
            w.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            w.WorkerReportsProgress = true;
            w.WorkerSupportsCancellation = false;

            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            DoubleAnimation a = new DoubleAnimation(0.0, 100.0, new Duration(TimeSpan.FromSeconds(1)));
            a.RepeatBehavior = RepeatBehavior.Forever;
            a.AutoReverse = true;

            RowDefinition r = new RowDefinition();
            outerGrid.RowDefinitions.Add(r);
            r.Height = new GridLength(26);
            ColumnDefinition c1 = new ColumnDefinition();
            ColumnDefinition c2 = new ColumnDefinition();
            c1.Width = new GridLength(170);
            c2.Width = new GridLength(75);
            outerGrid.ColumnDefinitions.Add(c1);
            outerGrid.ColumnDefinitions.Add(c2);

            Label l = new Label();
            l.Content = "Connecting...";
            l.Height = 26;
            Grid.SetRow(l, 0);
            Grid.SetColumn(l, 0);
            outerGrid.Children.Add(l);

            ProgressBar p = new ProgressBar();
            p.Height = 26;
            p.Width = 75;
            Grid.SetRow(p, outerGrid.RowDefinitions.Count() - 1);
            Grid.SetColumn(p, 1);
            outerGrid.Children.Add(p);

            returnSQL = null;
            String[] args = { "Connect", db };
            workers.Add(workers.Count(), w);
            w.RunWorkerAsync(args);
        }
Beispiel #2
0
        public void Run(string[] args)
        {
            SubmissionWorker w = new SubmissionWorker(IntPtr.Zero, 0);
            w.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
            w.WorkerReportsProgress = true;
            w.WorkerSupportsCancellation = false;

            Configuration config;

            if (args.Count() == 1)
            {
                if (args[0] == "-h" || args[0] == "--help" || args[0] == "/?")
                {
                    Console.WriteLine("Usage: ClusterSubmit [config-file]");
                    return;
                }
                else
                    config = new Configuration(args[0]);
            }
            else
                config = new Configuration("config.xml");

            string executable = findBinary(config.z3_drop_dir, config.z3_release_dir, config.z3_exe);

            if (executable == "")
            {
                Console.WriteLine(now() + ": Z3 not found.");
                return;
            }
            else if (File.Exists("last_binary"))
            {
                FileStream lf = File.OpenRead("last_binary");
                StreamReader sr = new StreamReader(lf);
                long last = Convert.ToInt64(sr.ReadLine());
                if (last >= File.GetLastWriteTime(executable).ToFileTimeUtc())
                {
                    Console.WriteLine(now() + ": No new binary.");
                    return;
                }
                sr.Close();
                lf.Close();
            }

            bool haveBinId = false;
            int binId = 0;

            try
            {
                string bestCluster = SubmissionWorker.FindCluster(config.cluster, config.alternativeClusters);
                Console.WriteLine(now() + ": Submitting job to " + bestCluster + " with the following binary: " + executable);

                w.UploadBinary(config.db, executable, ref haveBinId, ref binId);

                string sExecutor = "";
                int jid =
                    w.SetupExperiment(config.db, config.category, config.sharedDir, config.memout, config.timeout, config.executor, config.parameters,
                                      bestCluster, config.nodegroup, config.locality, config.minResources, config.maxResources, config.username, config.priority, config.extension, config.note, ref haveBinId, ref binId, ref sExecutor);
                w.SubmitHPCJob(config.db, true, jid, config.cluster, config.nodegroup, config.priority, config.locality, config.minResources, config.maxResources, config.sharedDir, sExecutor);

                saveBinaryDate(executable);

                uint retries = 0;
                if (File.Exists(config.fuzzer_target))
                {
                retry:
                    if (File.GetLastWriteTime(executable) > File.GetLastWriteTime(config.fuzzer_target))
                    {
                        try
                        {
                            File.Copy(executable, config.fuzzer_target, true);
                        }
                        catch (Exception ex)
                        {
                            retries++;
                            if (retries < config.fuzzer_max_retries)
                                goto retry;
                            else
                                throw ex;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(now() + ": Exception caught: " + ex.Message);
            }
        }
Beispiel #3
0
        private void submit(string db, string categories, string sharedDir, string memout, string timeout, string executor,
                            string parameters, string cluster, string nodegroup, string locality, string limitsMin, string limitsMax,
                            string username, int priority, string extension, string note,
                            string jobTemplate,
                            int jobTimeout, int taskTimeout)
        {
            string[] cats = categories.Split(',');
            foreach (string category in cats)
            {
                WindowInteropHelper helper = new WindowInteropHelper(this);
                SubmissionWorker w = new SubmissionWorker(helper.Handle, workers.Count());
                w.DoWork += new DoWorkEventHandler(worker_DoWork);
                w.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
                w.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
                w.WorkerReportsProgress = true;
                w.WorkerSupportsCancellation = false;

                RowDefinition r = new RowDefinition();
                outerGrid.RowDefinitions.Add(r);
                r.Height = new GridLength(26);
                Label l = new Label();
                l.Content = category.Replace("_", "__");
                l.Height = 26;
                Grid.SetRow(l, outerGrid.RowDefinitions.Count() - 1);
                Grid.SetColumn(l, 0);
                outerGrid.Children.Add(l);

                ProgressBar p = new ProgressBar();
                p.Height = 26;
                p.Width = 75;
                Grid.SetRow(p, outerGrid.RowDefinitions.Count() - 1);
                Grid.SetColumn(p, 1);
                outerGrid.Children.Add(p);

                pbars.Add(w.id, p);
                Object[] args = { "Submit", db, category, sharedDir, memout, timeout, executor,
                                  parameters, cluster, nodegroup, locality, limitsMin, limitsMax, username, priority, extension, note,
                                  jobTemplate, jobTimeout, taskTimeout};

                workers.Add(workers.Count(), w);
                w.RunWorkerAsync(args);
            }
        }
Beispiel #4
0
        private void uploadBinary(string db, string executable)
        {
            haveBinId = false;

            WindowInteropHelper helper = new WindowInteropHelper(this);
            SubmissionWorker w = new SubmissionWorker(helper.Handle, workers.Count());
            w.DoWork += new DoWorkEventHandler(worker_DoWork);
            w.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
            w.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            w.WorkerReportsProgress = true;
            w.WorkerSupportsCancellation = false;

            RowDefinition row = new RowDefinition();
            outerGrid.RowDefinitions.Add(row);
            row.Height = new GridLength(26);
            Label l = new Label();
            l.Content = "Upload binary...";
            l.Height = 26;
            Grid.SetRow(l, outerGrid.RowDefinitions.Count() - 1);
            Grid.SetColumn(l, 0);
            outerGrid.Children.Add(l);

            ProgressBar p = new ProgressBar();
            p.Height = 26;
            p.Width = 75;
            Grid.SetRow(p, outerGrid.RowDefinitions.Count() - 1);
            Grid.SetColumn(p, 1);
            outerGrid.Children.Add(p);

            DoubleAnimation a = new DoubleAnimation(0.0, 100.0, new Duration(TimeSpan.FromSeconds(1)));
            a.RepeatBehavior = RepeatBehavior.Forever;
            a.AutoReverse = true;
            p.BeginAnimation(System.Windows.Controls.ProgressBar.ValueProperty, a);

            pbars.Add(w.id, p);
            Object[] args = { "Upload", db, executable };
            workers.Add(w.id, w);
            w.RunWorkerAsync(args);
        }
Beispiel #5
0
        // Catchall job submission
        public Submission(string db, string cluster, string locality, int priority, string nodegroup, string executor, string min, string max, string jobTemplate, int jobTimeout, int taskTimeout)
        {
            InitializeComponent();
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            Title = "Submitting catchall job...";

            ColumnDefinition c1 = new ColumnDefinition();
            ColumnDefinition c2 = new ColumnDefinition();
            c1.Width = new GridLength(170);
            c2.Width = new GridLength(75);
            outerGrid.ColumnDefinitions.Add(c1);
            outerGrid.ColumnDefinitions.Add(c2);

            workers.Clear();

            WindowInteropHelper helper = new WindowInteropHelper(this);
            SubmissionWorker w = new SubmissionWorker(helper.Handle, workers.Count());
            w.DoWork += new DoWorkEventHandler(worker_DoWork);
            w.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
            w.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            w.WorkerReportsProgress = true;
            w.WorkerSupportsCancellation = false;

            RowDefinition r = new RowDefinition();
            outerGrid.RowDefinitions.Add(r);
            r.Height = new GridLength(26);
            Label l = new Label();
            l.Content = "Catchall...";
            l.Height = 26;
            Grid.SetRow(l, outerGrid.RowDefinitions.Count() - 1);
            Grid.SetColumn(l, 0);
            outerGrid.Children.Add(l);

            ProgressBar p = new ProgressBar();
            p.Height = 26;
            p.Width = 75;
            Grid.SetRow(p, outerGrid.RowDefinitions.Count() - 1);
            Grid.SetColumn(p, 1);
            outerGrid.Children.Add(p);

            pbars.Add(w.id, p);
            Object[] args = { "Catchall", db, cluster, locality, priority, nodegroup, executor, min, max, jobTemplate, jobTimeout, taskTimeout};
            workers.Add(workers.Count(), w);
            w.RunWorkerAsync(args);

            Mouse.OverrideCursor = null;
        }
Beispiel #6
0
        // Copy a job...
        public Submission(string db, string backupdb, Int32Collection jobs, bool move = false)
        {
            InitializeComponent();
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            Title = move ? "Moving..." : "Copying...";

            ColumnDefinition c1 = new ColumnDefinition();
            ColumnDefinition c2 = new ColumnDefinition();
            c1.Width = new GridLength(170);
            c2.Width = new GridLength(75);
            outerGrid.ColumnDefinitions.Add(c1);
            outerGrid.ColumnDefinitions.Add(c2);

            workers.Clear();

            Int32Collection.Enumerator e = jobs.GetEnumerator();
            while (e.MoveNext())
            {
                int jobID = e.Current;

                WindowInteropHelper helper = new WindowInteropHelper(this);
                SubmissionWorker w = new SubmissionWorker(helper.Handle, workers.Count());
                w.DoWork += new DoWorkEventHandler(worker_DoWork);
                w.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
                w.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
                w.WorkerReportsProgress = true;
                w.WorkerSupportsCancellation = false;

                RowDefinition r = new RowDefinition();
                outerGrid.RowDefinitions.Add(r);
                r.Height = new GridLength(26);
                Label l = new Label();
                l.Content = (move ? "Moving" : "Copying") + " Job #" + jobID.ToString() + "...";
                l.Height = 26;
                Grid.SetRow(l, outerGrid.RowDefinitions.Count() - 1);
                Grid.SetColumn(l, 0);
                outerGrid.Children.Add(l);

                ProgressBar p = new ProgressBar();
                p.Height = 26;
                p.Width = 75;
                Grid.SetRow(p, outerGrid.RowDefinitions.Count() - 1);
                Grid.SetColumn(p, 1);
                outerGrid.Children.Add(p);

                pbars.Add(w.id, p);
                String[] args = { "Copy", db, backupdb, jobID.ToString(), move.ToString() };
                workers.Add(workers.Count(), w);
                w.RunWorkerAsync(args);
            }

            Mouse.OverrideCursor = null;
        }
Beispiel #7
0
        private void showUpdateBinaryCommand(object target, ExecutedRoutedEventArgs e)
        {
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

            System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();

            dlg.DefaultExt = "exe";
            dlg.Filter = "Executable files (*.exe)|*.exe|All Files (*.*)|*.*";
            dlg.Multiselect = true;

            string exe = null;

            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (dlg.FileNames.Count() == 1)
                {
                    exe = dlg.FileName;
                }
                else if (dlg.FileNames.Count() > 1)
                {
                    // Create a ZipPackage
                    string fn = System.IO.Path.GetTempFileName();

                    ZipPackage pkg = (ZipPackage)ZipPackage.Open(fn, FileMode.Create);

                    string mainFile = "";
                    int exe_count = 0;
                    foreach (string f in dlg.FileNames)
                    {
                        if (f.EndsWith(".exe"))
                        {
                            mainFile = f;
                            exe_count++;
                        }
                    }

                    if (exe_count != 1)
                    {
                        SelectMainExe sme = new SelectMainExe();
                        foreach (string f in dlg.FileNames)
                            sme.lbFiles.Items.Add(f);
                        sme.Owner = this;
                        Mouse.OverrideCursor = null;
                        if (sme.ShowDialog() == true)
                            mainFile = sme.selectedFile;
                        Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
                    }

                    foreach (string f in dlg.FileNames)
                    {
                        Uri uri = PackUriHelper.CreatePartUri(new Uri(System.IO.Path.GetFileName(f), UriKind.Relative));
                        ZipPackagePart p = (ZipPackagePart)pkg.CreatePart(uri, System.Net.Mime.MediaTypeNames.Application.Octet, CompressionOption.Maximum);
                        CopyStream(new FileStream(f, FileMode.Open, FileAccess.Read), p.GetStream());
                        if (f == mainFile)
                            pkg.CreateRelationship(uri, TargetMode.Internal, "http://schemas.openxmlformats.org/package/2006/relationships/meta data/thumbnail");
                    }

                    pkg.Close();

                    exe = fn;
                }
            }

            if (exe != null)
            {

                WindowInteropHelper helper = new WindowInteropHelper(this);
                SubmissionWorker w = new SubmissionWorker(helper.Handle, 0);
                bool haveBinID = false;
                int binID = 0;
                w.UploadBinary(txtDatabase.Text, exe, ref haveBinID, ref binID);

                if (!haveBinID || binID == 0)
                    System.Windows.MessageBox.Show("Error uploading binary.", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                else
                {
                    foreach (DataRowView j in dataGrid.SelectedItems)
                    {
                        SqlCommand cmd = new SqlCommand("UPDATE Experiments SET Binary=" + binID + ";", sql);
                        cmd.CommandTimeout = 0;
                        cmd.ExecuteNonQuery();
                    }
                }
            }
            else
                System.Windows.MessageBox.Show("No binary selected; did not update database.", "Error", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);

            Mouse.OverrideCursor = null;
        }
Beispiel #8
0
        private void showRestartCommand(object sender, ExecutedRoutedEventArgs e)
        {
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

            try
            {
                Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;

                double total = (double)dataGrid.SelectedItems.Count;
                IList drviews = dataGrid.SelectedItems;
                bool stop = false;

                for (int i = 0; i < total && !stop; i++)
                {
                    Progress p = new Progress(this, dataGrid.SelectedItems.Count, "Restarting",
                        (sndr, ea) =>
                        {
                            ProgressWorker w = (ProgressWorker)sndr;
                            Object[] args = (Object[])ea.Argument;
                            DataRowView drv = (DataRowView)drviews[i];
                            int eid = (int)drv["ID"];

                            string sharedDir = null;
                            string cluster = null;
                            string nodegroup = null;
                            string locality = null;
                            int clusterJobID = 0;
                            string executor = null;
                            string jobTemplate = null;
                            int jobTimeout = 0;
                            int taskTimeout = 0;

                            int priority = 2;
                            int min = 1, max = 100;

                            SqlCommand cmd = new SqlCommand("SELECT SharedDir, Cluster, Nodegroup, Locality, ClusterJobID, Executor, JobTemplate, JobTimeout, TaskTimeout FROM Experiments WHERE ID=" + eid + ";", sql);
                            cmd.CommandTimeout = 0;
                            SqlDataReader r = cmd.ExecuteReader();
                            while (r.Read())
                            {
                                sharedDir = (string)r[0];
                                cluster = (string)r[1];
                                nodegroup = (string)r[2];
                                locality = (string)r[3];
                                clusterJobID = (int)r[4];
                                executor = (string)r[5];
                                jobTemplate = (string)r[6];
                                jobTimeout = (int)r[7];
                                taskTimeout = (int)r[8];
                            }
                            r.Close();

                            Scheduler scheduler = new Scheduler();
                            scheduler.Connect(cluster);

                            try
                            {
                                ISchedulerJob job = scheduler.OpenJob(clusterJobID);
                                switch (job.Priority)
                                {
                                    case JobPriority.Lowest: priority = 0; break;
                                    case JobPriority.BelowNormal: priority = 1; break;
                                    case JobPriority.Normal: priority = 2; break;
                                    case JobPriority.AboveNormal: priority = 3; break;
                                    case JobPriority.Highest: priority = 4; break;
                                }

                                if (locality == "Socket")
                                {
                                    min = job.MinimumNumberOfSockets;
                                    max = job.MaximumNumberOfSockets;
                                }
                                else if (locality == "Core")
                                {
                                    min = job.MinimumNumberOfCores;
                                    max = job.MaximumNumberOfCores;
                                }
                                else if (locality == "Node")
                                {
                                    min = job.MinimumNumberOfNodes;
                                    max = job.MaximumNumberOfNodes;
                                }

                                JobState state = job.State;
                                if (state == JobState.Running || state == JobState.Queued ||
                                    state == JobState.Validating || state == JobState.Submitted ||
                                    state == JobState.ExternalValidation)
                                    scheduler.CancelJob(clusterJobID, "", true);
                            }
                            catch (SchedulerException)
                            {
                                // OK, job doesn't exist anymore.
                            }
                            catch (Exception ex)
                            {
                                Dispatcher.Invoke(new Action(() =>
                                    System.Windows.MessageBox.Show(this, "Exception: " + ex.Message, "Error",
                                                            MessageBoxButton.OK, MessageBoxImage.Error)));
                                return;
                            }

                            cmd = new SqlCommand("DELETE FROM Data WHERE ExperimentID=" + eid + ";" +
                                                 "DELETE FROM JobQueue WHERE ExperimentID=" + eid + ";", sql);
                            cmd.CommandTimeout = 0;
                            cmd.ExecuteNonQuery();

                            scheduler.Close();

                            string wrkrpath = System.IO.Path.Combine(sharedDir, executor);
                            if (!File.Exists(wrkrpath))
                            {
                                string exc = (string)Registry.GetValue(keyName, "Executor", "");
                                File.Copy(exc, wrkrpath, true);
                            }

                            if (w.CancellationPending == true)
                            {
                                stop = true;
                            }

                            Dispatcher.Invoke(new Action(() =>
                            {
                                WindowInteropHelper helper = new WindowInteropHelper(this);
                                SubmissionWorker sw = new SubmissionWorker(helper.Handle, 0);
                                sw.SubmitHPCJob(txtDatabase.Text, true, eid,
                                                cluster, nodegroup, priority,
                                                locality, min.ToString(), max.ToString(),
                                                sharedDir, executor, jobTemplate,
                                                jobTimeout, taskTimeout);
                            }));

                            if (w.WorkerReportsProgress)
                                w.ReportProgress((int)(100.0 * ((double)i / (double)total)));
                        });

                    p.Go();
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(this, "Exception: " + ex.Message, "Error",
                                                MessageBoxButton.OK, MessageBoxImage.Error);
            }

            Mouse.OverrideCursor = null;
        }
Beispiel #9
0
        // Recovery job submission
        public Submission(string db, int jobid, string cluster, int numWorkers, int priority, string executor)
        {
            InitializeComponent();
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            Title = "Submit recovery job...";

            ColumnDefinition c1 = new ColumnDefinition();
            ColumnDefinition c2 = new ColumnDefinition();
            c1.Width = new GridLength(170);
            c2.Width = new GridLength(75);
            outerGrid.ColumnDefinitions.Add(c1);
            outerGrid.ColumnDefinitions.Add(c2);

            workers.Clear();

            WindowInteropHelper helper = new WindowInteropHelper(this);
            SubmissionWorker w = new SubmissionWorker(helper.Handle, workers.Count());
            w.DoWork += new DoWorkEventHandler(worker_DoWork);
            w.ProgressChanged += new ProgressChangedEventHandler(worker_ProgressChanged);
            w.RunWorkerCompleted += new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted);
            w.WorkerReportsProgress = true;
            w.WorkerSupportsCancellation = false;

            RowDefinition r = new RowDefinition();
            outerGrid.RowDefinitions.Add(r);
            r.Height = new GridLength(26);
            Label l = new Label();
            l.Content = "Job #" + jobid.ToString() + "...";
            l.Height = 26;
            Grid.SetRow(l, outerGrid.RowDefinitions.Count() - 1);
            Grid.SetColumn(l, 0);
            outerGrid.Children.Add(l);

            ProgressBar p = new ProgressBar();
            p.Height = 26;
            p.Width = 75;
            Grid.SetRow(p, outerGrid.RowDefinitions.Count() - 1);
            Grid.SetColumn(p, 1);
            outerGrid.Children.Add(p);

            pbars.Add(w.id, p);
            Object[] args = { "Recovery", db, jobid, cluster, priority, numWorkers, executor };
            workers.Add(workers.Count(), w);
            w.RunWorkerAsync(args);

            Mouse.OverrideCursor = null;
        }