Share

Alchemi [.NET Grid Computing Framework]

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

A few questions from a beginner.

You are viewing a single message from this topic. View all messages.

  1. 2009-03-09 02:25:17 UTC
    Alright, here's an update.

    I found out that a lot of the problems I were experiencing were due to using the 1.0.6 release. I rolled back to 1.0.5 and things seem to be working a lot easier now.

    The only problem I'm having is with my threads not being executed out. I'm able to start the grid application and it appears on the Manager Console application, but my ThreadFinished method isn't being kicked off. Every time I run through my prototype, the list of applications get longer in the Console app - it's as if nothing is being done. (I have one Executor client connected into the manager that's configured as a dedicated client.)

    I know it seems pretty vague, but can anyone give me some insight on how to approach solving this issue? Here's the code I'm using. (Be advised that this is a class that is called in another app, but you should be able to piece it together.)

    public class Grid : ExtensionBase,
    IFFObjectExtension,
    IGrid
    {
    static GApplication ga;
    private string _host;
    private int _port;
    private string _user;
    private string _password;
    private ArrayList threads = new ArrayList();
    static string threadstatus = "negative";

    [STAThread]
    public void GridAppConfig(string host, int port, string user, string password)
    {
    _host = host;
    _port = port;
    _user = user;
    _password = password;
    }

    [STAThread]
    public void RunGridApp()
    {
    ga = new GApplication();
    ga.ApplicationName = "FF Test";
    ga.Connection = new GConnection(_host, _port, _user, _password);
    //ga.Manifest.Add(new ModuleDependency(typeof(FreeFlyerThread).Module));
    ga.Manifest.Add(new ModuleDependency(typeof(MultiplierThread).Module));

    ga.ThreadFinish += new GThreadFinish(ThreadFinished);
    ga.ApplicationFinish += new GApplicationFinish(ApplicationFinished);

    foreach (string str in threads)
    {
    //FreeFlyerThread thread = new FreeFlyerThread(str);
    MultiplierThread thread = new MultiplierThread(4, 5);
    ga.Threads.Add(thread);
    }

    ga.Start();
    }

    public void AddThread(string FFcmdline)
    {
    threads.Add(FFcmdline);
    }

    [STAThread]
    static void ThreadFinished(GThread th)
    {
    // cast GThread back to MultiplierThread
    //FreeFlyerThread thread = (FreeFlyerThread)th;
    MultiplierThread thread = (MultiplierThread)th;
    threadstatus = thread.Result.ToString();
    //Console.WriteLine("thread # {0} finished with result '{1}'",thread.Id,thread.Result);
    }

    [STAThread]
    static void ApplicationFinished()
    {
    threadstatus = "done";
    //Console.WriteLine("\napplication finished");
    //Console.WriteLine("\n[enter] to continue ...");
    }

    }

    [Serializable]
    public class FreeFlyerThread : GThread
    {
    private string _FFcmd;
    private int _Result;



    public int Result
    {
    get { return _Result; }
    }

    public FreeFlyerThread(string cmd)
    {
    _FFcmd = cmd;
    }

    public override void Start()
    {
    //Process FreeFlyerProcess;
    //FreeFlyerProcess = Process.Start(_FFcmd);
    //FreeFlyerProcess.WaitForExit();
    //FreeFlyerProcess.Close();
    _Result = 1;
    }
    }

    [Serializable]
    public class MultiplierThread : GThread
    {
    private int _A, _B, _Result;

    public int Result
    {
    get { return _Result; }
    }

    public MultiplierThread(int a, int b)
    {
    _A = a;
    _B = b;
    }

    public override void Start()
    {
    if (Id == 0) { int x = 5 / Id; } // divide by zero
    _Result = _A * _B * _A;
    }
    }
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.