|
using System;
using
System.Collections.Generic;
using System.Text;
using MCSharp;
namespace
Examples.runtimeapi
{
public class
RuntimeAPITest
{
public static void Usage()
{
Console.WriteLine("This
example demostrates how to boot or halt” +
“ MC#
Runtime Environment programatically");
Console.WriteLine("Usage:");
Console.WriteLine("
To start Runtime System run command:");
Console.WriteLine(" RuntimeAPITest.exe boot
[<fileName>]");
Console.WriteLine("
To halt Runtime System run command(this fails” +
“ if there
are running applications):");
Console.WriteLine(" RuntimeAPITest.exe halt");
Console.WriteLine("
To halt Runtime System and stop all running” +
“
applications run command:");
Console.WriteLine(" RuntimeAPITest.exe halt force");
Console.WriteLine("
To display the list of currently loaded” +
“ nodes run
command:");
Console.WriteLine(" RuntimeAPITest.exe nodes");
}
public static void Main(string[] args)
{
if (args.Length == 0)
{
Usage();
return;
}
Runtime.RMPort =
25001;
Runtime.WNPort =
25002;
if (args[0] == "boot")
{
// Booting Cluster Environment
string output = "";
if (args.Length > 1)
{
bool res =
MCSharp.Runtime.Init(new string[] { args[1] }, out
output);
Console.WriteLine("Result
of operation: " + res);
Console.WriteLine("Description: \n" + output);
}
else
{
bool res = MCSharp.Runtime.Init(new string[] {}, out output);
Console.WriteLine("Result
of operation: " + res);
Console.WriteLine("Description:
\n" + output);
}
}
else if (args[0] ==
"nodes")
{
string output = "";
bool res = MCSharp.Runtime.GetNodesList(out output);
Console.WriteLine("Result
of operation: " + res);
Console.WriteLine("Description:
\n" + output);
}
else if (args[0] ==
"halt")
{
// Halting Runtime Environment
if (args.Length > 1)
{
// Halt all running user applications...
string output = "";
bool res = MCSharp.Runtime.Finalize(true, out output);
Console.WriteLine("Result
of operation: " + res);
Console.WriteLine("Description:
\n" + output);
}
else
{
// Halt only if there aren't running user applications
string output = "";
bool res = MCSharp.Runtime.Finalize(false, out output);
Console.WriteLine("Result
of operation: " + res);
Console.WriteLine("Description:
\n" + output);
}
}
}
}
}
|