Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/27/10 11:11:52 (14 years ago)
Author:
gkronber
Message:

Implemented an enumerable to iterate through all PluginFiles as suggested by swagner, replaced the Assemblies enumerable with an AssemblyName enumerable for internal usage in the plugin infrastructure and replaced Assembly.LoadFrom calls with Assembly.Load() to prevent loading from GAC as far as possible.

#850 (PluginInfrastructure should provide a way to get assemblies associated with a plug-in)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs

    r2608 r2688  
    111111              clientAdapter.Update(client);
    112112              HiveLogger.Info(this.ToString() + ": Client " + client.Id + " wasn't offline but hasn't sent heartbeats - Resetting all his jobs");
    113               foreach (Job job in jobAdapter.GetActiveJobsOf(client)) {               
     113              foreach (Job job in jobAdapter.GetActiveJobsOf(client)) {
    114114                jobManager.ResetJobsDependingOnResults(job);
    115115              }
     
    241241    /// <returns></returns>
    242242    public ResponseHB ProcessHeartBeat(HeartBeatData hbData) {
    243      
     243
    244244      ISession session = factory.GetSessionForCurrentThread();
    245245      ITransaction tx = null;
     
    252252          session.GetDataAdapter<ClientInfo, IClientAdapter>();
    253253
    254         IJobAdapter jobAdapter =       
     254        IJobAdapter jobAdapter =
    255255          session.GetDataAdapter<Job, IJobAdapter>();
    256256        HiveLogger.Info(this.ToString() + ": END Fetched Adapters");
     
    268268        if (client.State == State.offline || client.State == State.nullState) {
    269269          response.Success = false;
    270           response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN;         
     270          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN;
    271271          response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage));
    272272
     
    305305        processJobProcess(hbData, jobAdapter, clientAdapter, response);
    306306        HiveLogger.Info(this.ToString() + ": END Processed Heartbeat Jobs");
    307        
     307
    308308        clientAdapter.Update(client);
    309309
     
    331331    /// <param name="response"></param>
    332332    private void processJobProcess(HeartBeatData hbData, IJobAdapter jobAdapter, IClientAdapter clientAdapter, ResponseHB response) {
    333       HiveLogger.Info(this.ToString() + " processJobProcess: Started for Client " + hbData.ClientId);     
    334      
     333      HiveLogger.Info(this.ToString() + " processJobProcess: Started for Client " + hbData.ClientId);
     334
    335335      if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) {
    336336        List<Job> jobsOfClient = new List<Job>(jobAdapter.GetActiveJobsOf(clientAdapter.GetById(hbData.ClientId)));
     
    338338          response.Success = false;
    339339          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
    340           HiveLogger.Error(this.ToString() + " processJobProcess: There is no job calculated by this user " + hbData.ClientId);     
     340          HiveLogger.Error(this.ToString() + " processJobProcess: There is no job calculated by this user " + hbData.ClientId);
    341341          return;
    342342        }
     
    347347            response.Success = false;
    348348            response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
    349             HiveLogger.Error(this.ToString() + " processJobProcess: There is no job calculated by this user " + hbData.ClientId + " Job: " + curJob);     
     349            HiveLogger.Error(this.ToString() + " processJobProcess: There is no job calculated by this user " + hbData.ClientId + " Job: " + curJob);
    350350          } else if (curJob.State == State.abort) {
    351351            // a request to abort the job has been set
     
    376376              if (newAssignedJobs.ContainsKey(currJob.Id)) {
    377377                newAssignedJobs[currJob.Id]--;
    378                 HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL Reduced by one for job: " + currJob + "and is now: " + newAssignedJobs[currJob.Id] + ". User that sucks: " + currJob.Client);                     
     378                HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL Reduced by one for job: " + currJob + "and is now: " + newAssignedJobs[currJob.Id] + ". User that sucks: " + currJob.Client);
    379379                if (newAssignedJobs[currJob.Id] <= 0) {
    380                   HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL reached Zero, Job gets removed: " + currJob + " and set back to offline. User that sucks: " + currJob.Client);                 
     380                  HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL reached Zero, Job gets removed: " + currJob + " and set back to offline. User that sucks: " + currJob.Client);
    381381
    382382                  currJob.State = State.offline;
     
    388388                }
    389389              } else {
    390                 HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats:  " + currJob);                     
     390                HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats:  " + currJob);
    391391                currJob.State = State.offline;
    392392                jobAdapter.Update(currJob);
     
    397397
    398398              if (newAssignedJobs.ContainsKey(currJob.Id)) {
    399                 HiveLogger.Info(this.ToString() + " processJobProcess: Job is sending a heart beat, removing it from the newAssignedJobList: " + currJob);                     
     399                HiveLogger.Info(this.ToString() + " processJobProcess: Job is sending a heart beat, removing it from the newAssignedJobList: " + currJob);
    400400                newAssignedJobs.Remove(currJob.Id);
    401401              }
     
    431431          response.Job = computableJob;
    432432          response.Success = true;
    433           HiveLogger.Info(this.ToString() + " SendSerializedJob: Job pulled: " + computableJob.JobInfo + " for user " + clientId);                     
     433          HiveLogger.Info(this.ToString() + " SendSerializedJob: Job pulled: " + computableJob.JobInfo + " for user " + clientId);
    434434          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED;
    435435          lock (newAssignedJobs) {
     
    438438          }
    439439        } else {
    440           HiveLogger.Info(this.ToString() + " SendSerializedJob: No more Jobs left for " + clientId);                     
     440          HiveLogger.Info(this.ToString() + " SendSerializedJob: No more Jobs left for " + clientId);
    441441          response.Success = false;
    442442          response.Job = null;
     
    481481          response.Job = job2Calculate;
    482482          response.Success = true;
    483           HiveLogger.Info(this.ToString() + " SendSerializedJob: Job pulled: " + job2Calculate + " for user " + clientId);                     
     483          HiveLogger.Info(this.ToString() + " SendSerializedJob: Job pulled: " + job2Calculate + " for user " + clientId);
    484484          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED;
    485485          lock (newAssignedJobs) {
     
    491491          response.Job = null;
    492492          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT;
    493           HiveLogger.Info(this.ToString() + " SendSerializedJob: No more Jobs left for " + clientId);                     
     493          HiveLogger.Info(this.ToString() + " SendSerializedJob: No more Jobs left for " + clientId);
    494494        }
    495495
     
    514514
    515515      HiveLogger.Info(this.ToString() + " ProcessJobResult: BEGIN Job received for Storage - main method:");
    516      
     516
    517517      ISession session = factory.GetSessionForCurrentThread();
    518518      ITransaction tx = null;
     
    594594      Exception exception,
    595595      bool finished) {
    596      
     596
    597597      HiveLogger.Info(this.ToString() + " ProcessJobResult: BEGIN Job received for Storage - SUB method: " + jobId);
    598598
    599599      ISession session = factory.GetSessionForCurrentThread();
    600            
     600
    601601      ITransaction tx = null;
    602602
     
    608608        IJobResultsAdapter jobResultAdapter =
    609609          session.GetDataAdapter<JobResult, IJobResultsAdapter>();
    610        
     610
    611611        //should fetch the existing transaction       
    612612        tx = session.BeginTransaction();
     
    628628          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID;
    629629          response.JobId = jobId;
    630          
    631           HiveLogger.Error(this.ToString() + " ProcessJobResult: No job with Id " + jobId);                     
    632          
     630
     631          HiveLogger.Error(this.ToString() + " ProcessJobResult: No job with Id " + jobId);
     632
    633633          tx.Rollback();
    634634          return response;
     
    637637          response.Success = false;
    638638          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_WAS_ABORTED;
    639          
    640           HiveLogger.Error(this.ToString() + " ProcessJobResult: Job was aborted! " + job.JobInfo);                     
    641          
     639
     640          HiveLogger.Error(this.ToString() + " ProcessJobResult: Job was aborted! " + job.JobInfo);
     641
    642642          tx.Rollback();
    643643          return response;
     
    648648          response.JobId = jobId;
    649649
    650           HiveLogger.Error(this.ToString() + " ProcessJobResult: Job is not being calculated (client = null)! " + job.JobInfo);                     
     650          HiveLogger.Error(this.ToString() + " ProcessJobResult: Job is not being calculated (client = null)! " + job.JobInfo);
    651651
    652652          tx.Rollback();
     
    658658          response.JobId = jobId;
    659659
    660           HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Client for this Job! " + job.JobInfo + ", Sending Client is: " + clientId);                     
     660          HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Client for this Job! " + job.JobInfo + ", Sending Client is: " + clientId);
    661661
    662662          tx.Rollback();
     
    668668          response.JobId = jobId;
    669669
    670           HiveLogger.Error(this.ToString() + " ProcessJobResult: Job already finished! " + job.JobInfo + ", Sending Client is: " + clientId);                     
     670          HiveLogger.Error(this.ToString() + " ProcessJobResult: Job already finished! " + job.JobInfo + ", Sending Client is: " + clientId);
    671671
    672672          tx.Rollback();
     
    682682          response.JobId = jobId;
    683683
    684           HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Job State, job is: " + job.JobInfo);                     
     684          HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Job State, job is: " + job.JobInfo);
    685685
    686686          tx.Rollback();
     
    720720        response.finished = finished;
    721721        response.JobResultId = jobResult.Id;
    722        
     722
    723723        //Removed for Testing
    724724        //tx.Commit();
    725         HiveLogger.Info(this.ToString() + " ProcessJobResult: END Job received for Storage - SUB method: " + jobId);       
     725        HiveLogger.Info(this.ToString() + " ProcessJobResult: END Job received for Storage - SUB method: " + jobId);
    726726        return response;
    727727      }
     
    772772
    773773      HiveLogger.Info("Client logged out " + clientId);
    774      
     774
    775775      ISession session = factory.GetSessionForCurrentThread();
    776776      ITransaction tx = null;
     
    892892            };
    893893
    894             foreach (String assemblyPath in currPlugin.Files) {
    895               currCachedPlugin.PluginFiles.Add(File.ReadAllBytes(assemblyPath));
     894            foreach (string fileName in from file in currPlugin.Files select file.Name) {
     895              currCachedPlugin.PluginFiles.Add(File.ReadAllBytes(fileName));
    896896            }
    897897            response.Plugins.Add(currCachedPlugin);
Note: See TracChangeset for help on using the changeset viewer.