Free cookie consent management tool by TermsFeed Policy Generator

Changeset 811


Ignore:
Timestamp:
11/24/08 13:38:55 (16 years ago)
Author:
kgrading
Message:

implemented the async calls to GetSnapshot and GetFinishedJob (#383)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs

    r808 r811  
    6767
    6868    public void Start() {
    69       Heartbeat beat = new Heartbeat { Interval = 30000 };
     69      Heartbeat beat = new Heartbeat { Interval = 5000 };
    7070      beat.StartHeartbeat();
    7171
     
    124124          break;
    125125        case MessageContainer.MessageType.SnapshotReady:
    126           //Grabbing of the snapshot will need some time, so let's make this functun async
    127           GetASnapshotDelegate ssd = new GetASnapshotDelegate(engines[container.JobId].GetSnapshot);
    128           ssd.BeginInvoke(new AsyncCallback(SnapshotReceived), null);
    129           //engines[container.JobId].GetSnapshot();
     126          Thread ssr = new Thread(new ParameterizedThreadStart(GetSnapshot));
     127          ssr.Start(container.JobId);         
    130128          break;
    131129
    132 
    133         case MessageContainer.MessageType.FetchJob:         
     130        case MessageContainer.MessageType.FetchJob:
    134131          clientCommunicator.PullJobAsync(Guid.NewGuid());
    135           break;
    136 
     132          break;         
    137133        case MessageContainer.MessageType.FinishedJob:
    138           engines[container.JobId].GetFinishedJob();
    139           AppDomain.Unload(appDomains[container.JobId]);
    140           appDomains.Remove(container.JobId);
    141           engines.Remove(container.JobId);
    142           Status.CurrentJobs--;
    143           Debug.WriteLine("Decrement CurrentJobs to:"+Status.CurrentJobs.ToString());
    144           break;
     134          Thread finThread = new Thread(new ParameterizedThreadStart(GetFinishedJob));
     135          finThread.Start(container.JobId);         
     136          break;     
    145137      }
    146138    }
    147139
    148     void SnapshotReceived(IAsyncResult res) {
    149       AsyncResult ar = (AsyncResult) res;
    150       GetASnapshotDelegate gss = (GetASnapshotDelegate) ar.AsyncDelegate;
    151       String objectRepr = gss.EndInvoke(res);
     140    private void GetFinishedJob(object jobId) {
     141      long jId = (long)jobId;
     142      String obj = engines[jId].GetFinishedJob();
     143      engines[jId].GetFinishedJob();
     144      AppDomain.Unload(appDomains[jId]);
     145      appDomains.Remove(jId);
     146      engines.Remove(jId);
     147
     148      Status.CurrentJobs--;
     149      Debug.WriteLine("Decrement CurrentJobs to:" + Status.CurrentJobs.ToString());     
     150    }
     151
     152    private void GetSnapshot(object jobId) {
     153      long jId = (long)jobId;
     154      String obj = engines[jId].GetSnapshot();
    152155    }
    153156
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs

    r805 r811  
    1414    List<ClientInfo> clients;
    1515    LinkedList<long> jobs;
    16     int nrOfJobs = 10;
     16    int nrOfJobs = 3;
    1717
    1818    public ClientCommunicator() {
    1919      jobs = new LinkedList<long>();
    20       for (long i = 1; i < nrOfJobs; i++) {
     20      for (long i = 0; i < nrOfJobs; i++) {
    2121        jobs.AddFirst(i);
    2222      }
Note: See TracChangeset for help on using the changeset viewer.