Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/23/10 09:37:57 (14 years ago)
Author:
cneumuel
Message:

resolved issues with 3.3, hive-server now executable (1096)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/ClientCommunicator.cs

    r4060 r4091  
    2222using System;
    2323using System.Collections.Generic;
     24using System.IO;
    2425using System.Linq;
    25 using System.Text;
     26using System.Runtime.Serialization.Formatters.Binary;
     27using System.Threading;
     28using System.Transactions;
     29using HeuristicLab.Hive.Contracts;
    2630using HeuristicLab.Hive.Contracts.BusinessObjects;
    2731using HeuristicLab.Hive.Contracts.Interfaces;
    28 using HeuristicLab.Hive.Contracts;
    29 using HeuristicLab.Core;
    30 using HeuristicLab.Hive.Server.DataAccess;
    31 using System.Resources;
    32 using System.Reflection;
    33 using HeuristicLab.Hive.JobBase;
    3432using HeuristicLab.Hive.Server.Core.InternalInterfaces;
    35 using System.Threading;
    3633using HeuristicLab.PluginInfrastructure;
    37 using HeuristicLab.DataAccess.Interfaces;
    38 using System.IO;
    39 using System.Runtime.Serialization.Formatters.Binary;
    4034using HeuristicLab.Tracing;
    41 using Linq = HeuristicLab.Hive.Server.LINQDataAccess;
    42 using System.Transactions;
    43 using HeuristicLab.Hive.Server.LINQDataAccess;
    4435
    4536namespace HeuristicLab.Hive.Server.Core {
     
    7566
    7667      lifecycleManager = ServiceLocator.GetLifecycleManager();
    77       jobManager = ServiceLocator.GetJobManager() as
    78         IInternalJobManager;
     68      jobManager = ServiceLocator.GetJobManager() as IInternalJobManager;
    7969      scheduler = ServiceLocator.GetScheduler();
    8070
    81       lifecycleManager.RegisterHeartbeat(
    82         new EventHandler(lifecycleManager_OnServerHeartbeat));
     71      lifecycleManager.RegisterHeartbeat(new EventHandler(lifecycleManager_OnServerHeartbeat));
    8372    }
    8473
     
    10998              foreach (JobDto job in DaoLocator.JobDao.FindActiveJobsOfClient(client)) {
    11099                //maybe implementa n additional Watchdog? Till then, just set them offline..
    111                 DaoLocator.JobDao.SetJobOffline(job);                               
     100                DaoLocator.JobDao.SetJobOffline(job);
    112101              }
    113102            } else {
     
    168157            if (pendingJobs[currJob.Id] <= 0) {
    169158              currJob.State = State.offline;
    170               DaoLocator.JobDao.Update(currJob);             
     159              DaoLocator.JobDao.Update(currJob);
    171160            } else {
    172161              pendingJobs[currJob.Id]--;
     
    216205
    217206      ClientDto client = DaoLocator.ClientDao.FindById(clientId);
    218       if(client == null) {
     207      if (client == null) {
    219208        response.Success = false;
    220209        response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_RESOURCE_NOT_FOUND;
    221210        return response;
    222211      }
    223      
     212
    224213      response.ForceFetch = (client.CalendarSyncStatus == CalendarState.ForceFetch);
    225      
     214
    226215      IEnumerable<AppointmentDto> appointments = DaoLocator.UptimeCalendarDao.GetCalendarForClient(client);
    227216      if (appointments.Count() == 0) {
     
    239228
    240229    public Response SetCalendarStatus(Guid clientId, CalendarState state) {
    241       Response response = new Response();     
     230      Response response = new Response();
    242231      ClientDto client = DaoLocator.ClientDao.FindById(clientId);
    243232      if (client == null) {
     
    246235        return response;
    247236      }
    248      
     237
    249238      client.CalendarSyncStatus = state;
    250239      DaoLocator.ClientDao.Update(client);
    251      
     240
    252241      response.Success = true;
    253242      response.StatusMessage = ApplicationConstants.RESPONSE_UPTIMECALENDAR_STATUS_UPDATED;
    254      
     243
    255244      return response;
    256245    }
     
    298287
    299288      Logger.Debug("BEGIN Processing Heartbeat Jobs");
    300       processJobProcess(hbData, response);
     289      ProcessJobProcess(hbData, response);
    301290      Logger.Debug("END Processed Heartbeat Jobs");
    302291
     
    306295        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_FETCH_OR_FORCEFETCH_CALENDAR;
    307296        response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchOrForceFetchCalendar));
    308        
     297
    309298        //client.CalendarSyncStatus = CalendarState.Fetching;
    310        
    311         Logger.Info("fetch or forcefetch sent");       
     299
     300        Logger.Info("fetch or forcefetch sent");
    312301      }
    313302
     
    338327    /// <param name="clientAdapter"></param>
    339328    /// <param name="response"></param>
    340     private void processJobProcess(HeartBeatData hbData, ResponseHB response) {
     329    private void ProcessJobProcess(HeartBeatData hbData, ResponseHB response) {
    341330      Logger.Debug("Started for Client " + hbData.ClientId);
    342331      List<JobDto> jobsOfClient = new List<JobDto>(DaoLocator.JobDao.FindActiveJobsOfClient(DaoLocator.ClientDao.FindById(hbData.ClientId)));
    343       if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) {       
     332      if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) {
    344333        if (jobsOfClient == null || jobsOfClient.Count == 0) {
    345334          response.Success = false;
     
    372361          DaoLocator.JobDao.Update(curJob);
    373362        }
    374        }
     363      }
    375364      foreach (JobDto currJob in jobsOfClient) {
    376365        bool found = false;
    377         if(hbData.JobProgress != null) {
     366        if (hbData.JobProgress != null) {
    378367          foreach (Guid jobId in hbData.JobProgress.Keys) {
    379368            if (jobId == currJob.Id) {
     
    428417      JobDto job2Calculate = scheduler.GetNextJobForClient(clientId);
    429418      if (job2Calculate != null) {
    430         response.Job = job2Calculate;       
     419        response.Job = job2Calculate;
    431420        response.Job.PluginsNeeded = DaoLocator.PluginInfoDao.GetPluginDependenciesForJob(response.Job);
    432421        response.Success = true;
     
    437426            newAssignedJobs.Add(job2Calculate.Id, ApplicationConstants.JOB_TIME_TO_LIVE);
    438427        }
    439       } else {                 
     428      } else {
    440429        response.Success = false;
    441430        response.Job = null;
     
    449438    }
    450439
    451     public ResponseResultReceived ProcessJobResult(
    452       Stream stream,
    453       bool finished) {
    454 
     440    public ResponseResultReceived ProcessJobResult(Stream stream, bool finished) {
    455441      Logger.Info("BEGIN Job received for Storage - main method:");
    456442
    457 
    458       Stream jobResultStream = null;
    459       Stream jobStream = null;
     443      //Stream jobResultStream = null;
     444      //Stream jobStream = null;
    460445
    461446      //try {
    462       BinaryFormatter formatter =
    463         new BinaryFormatter();
    464 
    465       JobResult result =
    466         (JobResult)formatter.Deserialize(stream);
     447      BinaryFormatter formatter = new BinaryFormatter();
     448
     449      JobResult result = (JobResult)formatter.Deserialize(stream);
    467450
    468451      //important - repeatable read isolation level is required here,
     
    487470        List<byte> serializedJob = new List<byte>();
    488471        int read = 0;
    489         int i = 0;       
    490         while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) {         
     472        int i = 0;
     473        while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) {
    491474          for (int j = 0; j < read; j++) {
    492475            serializedJob.Add(buffer[j]);
    493476          }
    494           if (i% 100 == 0)
    495             Logger.Debug("Writing to stream: " + i);         
     477          if (i % 100 == 0)
     478            Logger.Debug("Writing to stream: " + i);
    496479          //jobStream.Write(buffer, 0, read);
    497480          i++;
    498481        }
    499         Logger.Debug("Done Writing, closing the stream!");               
     482        Logger.Debug("Done Writing, closing the stream!");
    500483        //jobStream.Close();
    501484
     
    518501
    519502      ResponseResultReceived response = new ResponseResultReceived();
    520       ClientDto client =
    521         DaoLocator.ClientDao.FindById(clientId);
    522 
    523       SerializedJob job =
    524         new SerializedJob();
     503      ClientDto client = DaoLocator.ClientDao.FindById(clientId);
     504
     505      SerializedJob job = new SerializedJob();
    525506
    526507      if (job != null) {
    527         job.JobInfo =
    528           DaoLocator.JobDao.FindById(jobId);
     508        job.JobInfo = DaoLocator.JobDao.FindById(jobId);
    529509        job.JobInfo.Client = job.JobInfo.Client = DaoLocator.ClientDao.GetClientForJob(jobId);
    530510      }
     
    650630
    651631      Logger.Info("Client logged out " + clientId);
    652      
     632
    653633      Response response = new Response();
    654634
     
    680660
    681661      return response;
    682     } 
     662    }
    683663
    684664    /// <summary>
Note: See TracChangeset for help on using the changeset viewer.