Example #1
0
            public STORunner(int numInstances, int systemId, int start, int?end, bool noKill)
            {
                this.numInstances = numInstances;
                this.systemId     = systemId;
                this.start        = start;
                this.noKill       = noKill;
                details           = SystemDetailsTable.DETAILS.details(systemId);
                this.end          = end.HasValue ? end.Value : details.lastRunNumber();
                writer            = new STOMetricsWriter(details, false);
                STO.populateSymbolsPortfolios(details, out symbols, out portfolios);
                runner = new EC2Runner(systemId + "-" + Dates.yyyyMmDdHhMmSsNoSeparator(Dates.now()));
                LogC.info("checking for completed runs");
                existingRuns = completedRuns();
                var allRunsComplete = true;

                for (var i = this.start; i <= this.end; i++)
                {
                    if (!existingRuns.Contains(i))
                    {
                        allRunsComplete = false;
                        break;
                    }
                }
                if (allRunsComplete)
                {
                    this.numInstances = 0;
                }
                unhandledExceptionProcessor = ((sender, args) => killRun(LogC.errMessage("unhandled exception", (Exception)args.ExceptionObject)));
            }
Example #2
0
        public void logAndAlert(string s, Exception e)
        {
            var message = LogC.errMessage(s, e);

            LogC.err(message);
            alertUser(s + ": examine " + LogC.errFile() + "\n" + message);
        }
Example #3
0
        public static void Main(string[] args)
        {
            ThreadPool.SetMaxThreads(50, 50);
            STORunner stoRunner    = null;
            var       arguments    = Arguments.arguments(args, jStrings("numInstances", "id", "start", "end", "maxRunHours", "DO_NOT_USE_THIS_OPTION_UNLESS_YOU_ARE_JERIC"));
            var       numInstances = arguments.integer("numInstances");
            var       systemId     = arguments.integer("id");
            var       start        = arguments.get("start", 1);
            var       end          = arguments.containsKey("end") ? arguments.integer("end") : (int?)null;
            var       maxRunMillis = numInstances == 0 ? 0 : (long)(arguments.numeric("maxRunHours") * 3600 * 1000);
            var       noKill       = arguments.get("DO_NOT_USE_THIS_OPTION_UNLESS_YOU_ARE_JERIC", false);

            try {
                stoRunner = new STORunner(numInstances, systemId, start, end, noKill);
                stoRunner.createDirectories();
                var dbServer = stoRunner.startDbServer();
                stoRunner.initialize(maxRunMillis);
                stoRunner.enqueueRequests();
                stoRunner.processResults();
                dbServer.stopServer();
                stoRunner.copyMetrics();
            } catch (Exception e) {
                if (stoRunner != null)
                {
                    stoRunner.killRun(LogC.errMessage("caught exception in Main: ", e));
                }
            }
            Environment.Exit(0);
        }
Example #4
0
        public void logAndAlert(string s, Exception e)
        {
            var message = LogC.errMessage("failed during simulation run\n", e);

            LogC.err(message);
            alertUser("failed during simulation. examine " + LogC.errFile() + "\n" + message);
        }
Example #5
0
 public Fields reply(Fields fields)
 {
     try {
         return(makeResponse(fields));
     } catch (Exception e) {
         throw Bomb.toss(LogC.errMessage("caught exception in responder", e));
     }
 }
Example #6
0
 public static void handleUncaughtException(Exception ex, string appName)
 {
     LogC.useJavaLog = false;
     LogC.setErr(@"C:\logs\" + appName + "Crash.log");
     LogC.err("uncaught exception: ", ex);
     MessageBox.Show(
         LogC.errMessage("exception written to C:\\logs\\" + appName + "Crash.log: ", ex),
         "Exception - Crashing", MessageBoxButton.OK, MessageBoxImage.Error);
 }
Example #7
0
 T nullIfFails <T>(Producer <T> t, Producer <string> makeMessage) where T : class
 {
     try { return(t()); }
     catch (Exception e) {
         var message = LogC.errMessage(makeMessage(), e);
         gui.alertUser(message);
         LogC.err(message);
         return(null);
     }
 }
Example #8
0
 void writeResultsToFile(int run, IDictionary <string, Dictionary <string, double> > results)
 {
     try {
         writer.writeResults(run, results);
         lock (runsLeftLock) {
             runsLeft--;
             LogC.info("completed run " + run + ". " + runsLeft + " left.");
         }
     } catch (Exception e) {
         LogC.info(LogC.errMessage("exception thrown in writeResults", e));
         throw;
     }
 }
Example #9
0
        static void handleUncaughtExceptions(object sender, UnhandledExceptionEventArgs e)
        {
            var ex = (Exception)e.ExceptionObject;

            Email.problem("STOServer crashed (" + hostname() + ")", LogC.errMessage("uncaught exception ", ex)).sendTo("us");
        }