Esempio n. 1
0
 ///<summary>Print batch job error information, if any</summary>
 static void printbatcherrorinfo(ref GRBBatch batch)
 {
     if (batch.BatchErrorCode == 0)
     {
         return;
     }
     Console.WriteLine("Batch ID: " + batch.BatchID + ", Error code: " +
                       batch.BatchErrorCode + "(" +
                       batch.BatchErrorMessage + ")");
 }
Esempio n. 2
0
    ///<summary>Instruct the cluster manager to discard all data relating
    /// to this BatchID</summary>
    static void batchdiscard(string batchID)
    {
        // Setup and start environment, create local Batch handle object
        GRBEnv env = setupbatchenv();

        env.Start();
        GRBBatch batch = new GRBBatch(env, batchID);

        // Remove batch request from manager
        batch.Discard();

        // Cleanup
        batch.Dispose();
        env.Dispose();
    }
Esempio n. 3
0
    ///<summary>Wait for the final status of the batch. Initially the
    /// status of a batch is <see cref="GRB.BatchStatus.SUBMITTED"/>;
    /// the status will change once the batch has been processed
    /// (by a compute server).</summary>
    static void waitforfinalstatus(string batchID)
    {
        // Wait no longer than one hour
        double   maxwaittime = 3600;
        DateTime start       = DateTime.Now;

        // Setup and start environment, create local Batch handle object
        GRBEnv env = setupbatchenv();

        env.Start();
        GRBBatch batch = new GRBBatch(env, batchID);

        try {
            while (batch.BatchStatus == GRB.BatchStatus.SUBMITTED)
            {
                // Abort this batch if it is taking too long
                TimeSpan interval = DateTime.Now - start;
                if (interval.TotalSeconds > maxwaittime)
                {
                    batch.Abort();
                    break;
                }
                // Wait for two seconds
                System.Threading.Thread.Sleep(2000);

                // Update the resident attribute cache of the Batch object
                // with the latest values from the cluster manager.
                batch.Update();

                // If the batch failed, we retry it
                if (batch.BatchStatus == GRB.BatchStatus.FAILED)
                {
                    batch.Retry();
                    System.Threading.Thread.Sleep(2000);
                    batch.Update();
                }
            }
        } finally {
            // Print information about error status of the job
            // that processed the batch
            printbatcherrorinfo(ref batch);
            batch.Dispose();
            env.Dispose();
        }
    }
Esempio n. 4
0
    ///<summary>Final Report for Batch Request</summary>
    static void printfinalreport(string batchID)
    {
        // Setup and start environment, create local Batch handle object
        GRBEnv env = setupbatchenv();

        env.Start();
        GRBBatch batch = new GRBBatch(env, batchID);

        switch (batch.BatchStatus)
        {
        case GRB.BatchStatus.CREATED:
            Console.WriteLine("Batch status is 'CREATED'\n");
            break;

        case GRB.BatchStatus.SUBMITTED:
            Console.WriteLine("Batch is 'SUBMITTED\n");
            break;

        case GRB.BatchStatus.ABORTED:
            Console.WriteLine("Batch is 'ABORTED'\n");
            break;

        case GRB.BatchStatus.FAILED:
            Console.WriteLine("Batch is 'FAILED'\n");
            break;

        case GRB.BatchStatus.COMPLETED:
            Console.WriteLine("Batch is 'COMPLETED'\n");
            // Get JSON solution as string
            Console.WriteLine("JSON solution:" + batch.GetJSONSolution());

            // Write the full JSON solution string to a file
            batch.WriteJSONSolution("batch-sol.json.gz");
            break;

        default:
            // Should not happen
            Console.WriteLine("Unknown BatchStatus" + batch.BatchStatus);
            Environment.Exit(1);
            break;
        }
        // Cleanup
        batch.Dispose();
        env.Dispose();
    }