Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/19/10 12:41:05 (14 years ago)
Author:
cneumuel
Message:

consolidated Response objects to use only StatusMessage with enums instead of strings.
removed Success property from Response. success is now represented by StatusMessage alone. (#1159)

Location:
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3
Files:
9 edited

Legend:

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

    r4253 r4263  
    1111using HeuristicLab.Hive.Server.Core.InternalInterfaces;
    1212using System.ServiceModel;
     13using HeuristicLab.Hive.Contracts.ResponseObjects;
    1314
    1415namespace HeuristicLab.Hive.Server.Core {
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/DefaultScheduler.cs

    r4254 r4263  
    3131        using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = ApplicationConstants.ISOLATION_LEVEL_SCOPE })) {
    3232          ClientDto slave = DaoLocator.ClientDao.FindById(slaveId);
    33           LinkedList<JobDto> allOfflineJobsForSlave =
    34             new LinkedList<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave(State.Offline, slave.NrOfFreeCores, slave.FreeMemory, slave.Id));
     33          LinkedList<JobDto> allOfflineJobsForSlave = new LinkedList<JobDto>(DaoLocator.JobDao.FindFittingJobsForSlave(State.Offline, slave.NrOfFreeCores, slave.FreeMemory, slave.Id));
    3534          if (allOfflineJobsForSlave != null && allOfflineJobsForSlave.Count > 0) {
    3635            jobToCalculate = allOfflineJobsForSlave.First.Value;
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Facades/ExecutionEngineFacade.cs

    r4170 r4263  
    2828using HeuristicLab.Hive.Contracts.BusinessObjects;
    2929using HeuristicLab.Hive.Server.DataAccess;
     30using HeuristicLab.Hive.Contracts.ResponseObjects;
    3031
    3132namespace HeuristicLab.Hive.Server.Core {
     
    6061    public ResponseObject<SerializedJob> GetLastSerializedResult(Guid jobId, bool requested, bool snapshot) {
    6162      using (contextFactory.GetContext(false)) {
    62         return jobManager.GetLastSerializedJobResultOf(jobId, requested, snapshot);
     63        return jobManager.GetLastSerializedResult(jobId, requested, snapshot);
    6364      }
    6465    }
     
    7778
    7879
    79     public ResponseObject<JobResultList> GetAllJobResults(IEnumerable<Guid> jobIds) {
     80    public ResponseObject<JobResultList> GetJobResults(IEnumerable<Guid> jobIds) {
    8081      using (contextFactory.GetContext(false)) {
    81         return jobManager.GetAllJobResults(jobIds);
     82        return jobManager.GetJobResults(jobIds);
    8283      }
    8384    }
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Facades/ServerConsoleFacade.cs

    r4253 r4263  
    3131using System.ServiceModel;
    3232using HeuristicLab.Hive.Server.DataAccess;
     33using HeuristicLab.Hive.Contracts.ResponseObjects;
    3334
    3435
     
    5354      sessionID = secMan.Login(username, password);
    5455      if (sessionID == Guid.Empty) {
    55         resp.Success = false;
    56         resp.StatusMessage = ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_FAILED;
    57       } else {
    58         resp.Success = true;
    59         resp.StatusMessage =
    60           ApplicationConstants.RESPONSE_SERVERCONSOLE_LOGIN_SUCCESS;
     56        resp.StatusMessage = ResponseStatus.Login_LoginFaild;
    6157      }
    6258      return resp;
     
    6460
    6561
    66     public ResponseList<ClientDto> GetAllClients() {
     62    public ResponseList<ClientDto> GetAllSlaves() {
    6763      using (contextFactory.GetContext(false)) {
    6864        secMan.Authorize("AccessClients", sessionID, Guid.Empty);
    69         return slaveManager.GetAllClients();
     65        return slaveManager.GetAllSlaves();
    7066      }
    7167    }
     
    140136    }
    141137
    142     public ResponseObject<JobDto> GetLastJobResultOf(Guid jobId) {
     138    //public ResponseObject<JobDto> GetLastJobResultOf(Guid jobId) {
     139    //  using (contextFactory.GetContext(false)) {
     140    //    secMan.Authorize("AccessJobResults", sessionID, jobId);
     141    //    return jobManager.GetLastJobResultOf(jobId);
     142    //  }
     143    //}
     144
     145    public ResponseObject<SerializedJob> GetLastSerializedResult(Guid jobId, bool requested, bool snapshot) {
    143146      using (contextFactory.GetContext(false)) {
    144147        secMan.Authorize("AccessJobResults", sessionID, jobId);
    145         return jobManager.GetLastJobResultOf(jobId);
    146       }
    147     }
    148 
    149     public ResponseObject<SerializedJob> GetLastSerializedJobResultOf(Guid jobId, bool requested, bool snapshot) {
    150       using (contextFactory.GetContext(false)) {
    151         secMan.Authorize("AccessJobResults", sessionID, jobId);
    152         return jobManager.GetLastSerializedJobResultOf(jobId, requested, snapshot);
    153       }
    154     }
    155 
    156     public ResponseObject<JobResultList> GetAllJobResults(IEnumerable<Guid> jobIds) {
     148        return jobManager.GetLastSerializedResult(jobId, requested, snapshot);
     149      }
     150    }
     151
     152    public ResponseObject<JobResultList> GetJobResults(IEnumerable<Guid> jobIds) {
    157153      using (contextFactory.GetContext(false)) {
    158154        //secMan.Authorize("AccessJobResults", sessionID, jobId); skip authorization
    159         return jobManager.GetAllJobResults(jobIds);
    160       }
    161     }
    162 
    163     public Response RemoveJob(Guid jobId) {
    164       using (contextFactory.GetContext()) {
    165         secMan.Authorize("RemoveJob", sessionID, jobId);
    166         return jobManager.RemoveJob(jobId);
    167       }
    168     }
     155        return jobManager.GetJobResults(jobIds);
     156      }
     157    }
     158
     159    //public Response RemoveJob(Guid jobId) {
     160    //  using (contextFactory.GetContext()) {
     161    //    secMan.Authorize("RemoveJob", sessionID, jobId);
     162    //    return jobManager.RemoveJob(jobId);
     163    //  }
     164    //}
    169165
    170166    public Response RequestSnapshot(Guid jobId) {
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Facades/SlaveFacade.cs

    r4254 r4263  
    3535using HeuristicLab.Hive.Server.LINQDataAccess;
    3636using HeuristicLab.Hive.Server.DataAccess;
     37using HeuristicLab.Hive.Contracts.ResponseObjects;
    3738
    3839namespace HeuristicLab.Hive.Server.Core {
     
    8586    }
    8687
    87     public ResponseList<CachedHivePluginInfoDto> SendPlugins(List<HivePluginInfoDto> pluginList) {
    88       return slaveCommunicator.SendPlugins(pluginList);     
     88    public ResponseList<CachedHivePluginInfoDto> GetPlugins(List<HivePluginInfoDto> pluginList) {
     89      return slaveCommunicator.GetPlugins(pluginList);     
    8990    }
    9091
     
    9495      }
    9596    }
    96 
    9797
    9898    public ResponseCalendar GetCalendar(Guid clientId) {
     
    114114    /// Do not use automatic transactions here
    115115    /// </summary>
    116     public Stream SendStreamedJob(Guid clientId) {
     116    public Stream GetStreamedJob(Guid clientId) {
    117117      using (contextFactory.GetContext(false)) {
    118118        MultiStream stream = new MultiStream();
     
    125125        stream.AddStream(new StreamedObject<ResponseObject<JobDto>>(job));
    126126
    127         IJobManager jobManager = ServiceLocator.GetJobManager();
    128         IInternalJobManager internalJobManager = (IInternalJobManager)jobManager;
     127        IInternalJobManager internalJobManager = (IInternalJobManager)ServiceLocator.GetJobManager();
    129128
    130129        //second stream the job binary data
    131130        MemoryStream memoryStream = new MemoryStream();
    132         if (job.Obj != null)
     131        if (job.Obj != null) {
    133132          stream.AddStream(new MemoryStream(internalJobManager.GetSerializedJobDataById(job.Obj.Id)));
     133        }
    134134
    135135        OperationContext clientContext = OperationContext.Current;
     
    144144    }
    145145
    146     public Stream SendStreamedPlugins(List<HivePluginInfoDto> pluginList) {
    147       return new StreamedObject<ResponseList<CachedHivePluginInfoDto>>(this.SendPlugins(pluginList));
     146    public Stream GetStreamedPlugins(List<HivePluginInfoDto> pluginList) {
     147      return new StreamedObject<ResponseList<CachedHivePluginInfoDto>>(this.GetPlugins(pluginList));
    148148    }
    149149
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/InternalInterfaces/IInternalSlaveCommunicator.cs

    r4253 r4263  
    2727using HeuristicLab.Hive.Contracts;
    2828using System.IO;
     29using HeuristicLab.Hive.Contracts.ResponseObjects;
    2930
    3031namespace HeuristicLab.Hive.Server.Core.InternalInterfaces {
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/JobManager.cs

    r4254 r4263  
    3838using HeuristicLab.Hive.Server.LINQDataAccess;
    3939using IsolationLevel = System.Transactions.IsolationLevel;
     40using HeuristicLab.Hive.Contracts.ResponseObjects;
    4041
    4142namespace HeuristicLab.Hive.Server.Core {
     
    5051      lifecycleManager.RegisterStartup(new EventHandler(lifecycleManager_OnStartup));
    5152      lifecycleManager.RegisterShutdown(new EventHandler(lifecycleManager_OnShutdown));
    52     }
    53 
    54     private JobDto GetLastJobResult(Guid jobId) {
    55       return DaoLocator.JobDao.FindById(jobId);
    5653    }
    5754
     
    8582    public ResponseList<JobDto> GetAllJobs() {
    8683      ResponseList<JobDto> response = new ResponseList<JobDto>();
    87 
    8884      response.List = new List<JobDto>(DaoLocator.JobDao.FindAll());
    89       response.Success = true;
    90       response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ALL_JOBS;
    91 
    9285      return response;
    9386    }
     
    9689      ResponseList<JobDto> response = new ResponseList<JobDto>();
    9790      response.List = new List<JobDto>(DaoLocator.JobDao.FindWithLimitations(jobState, offset, count));
    98       response.Success = true;
    9991      return response;
    10092    }
     
    118110      response.Obj = DaoLocator.JobDao.FindById(jobId);
    119111      if (response.Obj != null) {
    120         response.Success = true;
    121         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_GET_JOB_BY_ID;
     112        response.StatusMessage = ResponseStatus.Ok;
    122113      } else {
    123         response.Success = false;
    124         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_DOESNT_EXIST;
     114        response.StatusMessage = ResponseStatus.GetJobById_JobDoesNotExist;
    125115      }
    126116
     
    135125      job.Obj = DaoLocator.JobDao.FindById(jobId);
    136126      if (job.Obj != null) {
    137         job.Success = true;
    138         job.StatusMessage = ApplicationConstants.RESPONSE_JOB_GET_JOB_BY_ID;
     127        job.StatusMessage = ResponseStatus.Ok;
    139128
    140129        job.Obj.Client = DaoLocator.ClientDao.GetClientForJob(jobId);
    141130      } else {
    142         job.Success = false;
    143         job.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_DOESNT_EXIST;
     131        job.StatusMessage = ResponseStatus.GetJobByIdWithDetails_JobDoesNotExist;
    144132      }
    145133      return job;
     
    166154      if (job != null && job.JobInfo != null) {
    167155        if (job.JobInfo.State != State.Offline) {
    168           response.Success = false;
    169           response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOBSTATE_MUST_BE_OFFLINE;
     156          response.StatusMessage = ResponseStatus.AddNewJob_JobStateMustBeOffline;
    170157          return response;
    171158        }
    172159        if (job.JobInfo.Id != Guid.Empty) {
    173           response.Success = false;
    174           response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ID_MUST_NOT_BE_SET;
     160          response.StatusMessage = ResponseStatus.AddNewJob_JobIdMustNotBeSet;
    175161          return response;
    176162        }
    177163        if (job.SerializedJobData == null) {
    178           response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_NULL;
    179           response.Success = false;
     164          response.StatusMessage = ResponseStatus.AddNewJob_JobNull;
    180165          return response;
    181166        }
     
    185170        DaoLocator.PluginInfoDao.InsertPluginDependenciesForJob(job.JobInfo);
    186171
    187         response.Success = true;
    188172        response.Obj = job.JobInfo;
    189         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_ADDED;
    190173      } else {
    191         response.Success = false;
    192         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_NULL;
     174        response.StatusMessage = ResponseStatus.AddNewJob_JobNull;
    193175      }
    194176
     
    198180    /// <summary>
    199181    /// Removes a job from the database
     182    ///
     183    /// [chn] this is currently not used anywhere -> check redundancy with AbortJob
    200184    /// </summary>
    201185    /// <param name="jobId"></param>
    202186    /// <returns></returns>
    203     public Response RemoveJob(Guid jobId) {
    204       Response response = new Response();
    205 
    206       JobDto job = DaoLocator.JobDao.FindById(jobId);
    207       if (job == null) {
    208         response.Success = false;
    209         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_DOESNT_EXIST;
    210         return response;
    211       }
    212       DaoLocator.JobDao.Delete(job);
    213       response.Success = false;
    214       response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_REMOVED;
    215 
    216       return response;
    217     }
    218 
    219     public ResponseObject<JobDto> GetLastJobResultOf(Guid jobId) {
    220       ResponseObject<JobDto> result = new ResponseObject<JobDto>();
    221 
    222       result.Obj = GetLastJobResult(jobId);
    223       result.Success = result.Obj != null;
    224 
    225       return result;
    226     }
     187    //public Response RemoveJob(Guid jobId) {
     188    //  Response response = new Response();
     189
     190    //  JobDto job = DaoLocator.JobDao.FindById(jobId);
     191    //  if (job == null) {
     192    //    response.StatusMessage = ResponseStatusMessage.RemoveJob_JobDoesNotExist;
     193    //    return response;
     194    //  }
     195    //  DaoLocator.JobDao.Delete(job);
     196
     197    //  return response;
     198    //}
     199
     200    ///
     201    /// [chn] currently not used anywhere
     202    ///
     203    //public ResponseObject<JobDto> GetLastJobResultOf(Guid jobId) {
     204    //  ResponseObject<JobDto> result = new ResponseObject<JobDto>();
     205
     206    //  result.Obj = DaoLocator.JobDao.FindById(jobId);
     207    //  if (result.Obj == null) {
     208    //    result.StatusMessage = ResponseStatusMessage.
     209    //  }
     210
     211    //  return result;
     212    //}
    227213
    228214    // [chn] [refactor] why does this method handle 3 different cases? wouldn't 3 methods be easier?
     
    230216    // requested==true: resultat mit job
    231217    // requested==false:
    232     public ResponseObject<SerializedJob> GetLastSerializedJobResultOf(Guid jobId, bool requested, bool snapshot) {
     218    public ResponseObject<SerializedJob> GetLastSerializedResult(Guid jobId, bool requested, bool snapshot) {
    233219      ResponseObject<SerializedJob> response = new ResponseObject<SerializedJob>();
    234220
     
    237223      //if it's a snapshot but the result hasn't reached the server yet...
    238224      if (snapshot && (job.State == State.RequestSnapshot || job.State == State.RequestSnapshotSent)) {
    239         response.Success = true;
    240         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_RESULT_NOT_YET_HERE;
     225        response.StatusMessage = ResponseStatus.GetLastSerializedResult_JobResultNotYetThere;
    241226
    242227        return response;
     
    245230      //if it's NOT a snapshot, NEITHER request NOR is it finished
    246231      if (!requested && !snapshot && job.State != State.Finished) {
    247         response.Success = true;
    248         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_RESULT_NOT_YET_HERE;
     232        response.StatusMessage = ResponseStatus.GetLastSerializedResult_JobResultNotYetThere;
    249233
    250234        return response;
     
    252236
    253237      //every other case - snapshot, job finished or it's requested
    254       response.Success = true;
    255       response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_RESULT_SENT;
    256238      response.Obj = new SerializedJob();
    257239      response.Obj.JobInfo = job;
     
    267249      JobDto job = DaoLocator.JobDao.FindById(jobId);
    268250      if (job.State == State.RequestSnapshot || job.State == State.RequestSnapshotSent) {
    269         response.Success = true;
    270         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_REQUEST_ALLREADY_SET;
     251        response.StatusMessage = ResponseStatus.RequestSnapshot_SnapshotAlreadyRequested;
    271252        return response;
    272253      }
    273254      if (job.State != State.Calculating) {
    274         response.Success = false;
    275         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_IS_NOT_BEEING_CALCULATED;
     255        response.StatusMessage = ResponseStatus.RequestSnapshot_JobIsNotBeeingCalculated;
    276256        return response;
    277257      }
     
    280260      DaoLocator.JobDao.Update(job);
    281261
    282       response.Success = true;
    283       response.StatusMessage = ApplicationConstants.RESPONSE_JOB_REQUEST_SET;
    284 
    285       return response;
    286     }
    287 
     262      return response;
     263    }
     264
     265    /// <summary>
     266    /// [chn] rename to RequestAbortJob?
     267    /// </summary>
    288268    public Response AbortJob(Guid jobId) {
    289269      Response response = new Response();
     
    291271      JobDto job = DaoLocator.JobDao.FindById(jobId);
    292272      if (job == null) {
    293         response.Success = false;
    294         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_JOB_DOESNT_EXIST;
     273        //response.Success = false;
     274        response.StatusMessage = ResponseStatus.AbortJob_JobDoesNotExist;
    295275        return response; // no commit needed
    296276      }
    297277      if (job.State == State.Abort) {
    298         response.Success = true;
    299         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ABORT_REQUEST_ALLREADY_SET;
     278        //response.Success = true;
     279        response.StatusMessage = ResponseStatus.AbortJob_AbortAlreadyRequested;
    300280        return response; // no commit needed
    301281      }
    302282      if (job.State != State.Calculating && job.State != State.RequestSnapshot && job.State != State.RequestSnapshotSent) {
    303         response.Success = false;
    304         response.StatusMessage = ApplicationConstants.RESPONSE_JOB_IS_NOT_BEEING_CALCULATED;
     283        //response.Success = false;
     284        response.StatusMessage = ResponseStatus.AbortJob_JobIsNotBeeingCalculated;
    305285        return response; // no commit needed
    306286      }
     
    309289      DaoLocator.JobDao.Update(job);
    310290
    311       response.Success = true;
    312       response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ABORT_REQUEST_SET;
    313 
    314291      return response;
    315292    }
     
    320297    /// <param name="jobIds"></param>
    321298    /// <returns></returns>
    322     public ResponseObject<JobResultList> GetAllJobResults(IEnumerable<Guid> jobIds) {
     299    public ResponseObject<JobResultList> GetJobResults(IEnumerable<Guid> jobIds) {
    323300      ResponseObject<JobResultList> response = new ResponseObject<JobResultList>();
    324301      JobResultList jobResultList = new JobResultList();
     
    335312      }
    336313      response.Obj = jobResultList;
    337       response.Success = true;
    338       response.StatusMessage = ApplicationConstants.RESPONSE_JOB_ALL_JOBS;
    339314      return response;
    340315    }
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/SlaveCommunicator.cs

    r4254 r4263  
    3333using HeuristicLab.PluginInfrastructure;
    3434using HeuristicLab.Tracing;
     35using HeuristicLab.Hive.Contracts.ResponseObjects;
    3536
    3637namespace HeuristicLab.Hive.Server.Core {
     
    168169    /// A hearbeat entry is created as well (login is the first hearbeat)
    169170    /// </summary>
    170     /// <param name="clientInfo"></param>
     171    /// <param name="slaveInfo"></param>
    171172    /// <returns></returns>
    172     public Response Login(ClientDto clientInfo) {
     173    public Response Login(ClientDto slaveInfo) {
    173174      Response response = new Response();
    174175
    175176      heartbeatLock.EnterWriteLock();
    176       if (lastHeartbeats.ContainsKey(clientInfo.Id)) {
    177         lastHeartbeats[clientInfo.Id] = DateTime.Now;
     177      if (lastHeartbeats.ContainsKey(slaveInfo.Id)) {
     178        lastHeartbeats[slaveInfo.Id] = DateTime.Now;
    178179      } else {
    179         lastHeartbeats.Add(clientInfo.Id, DateTime.Now);
     180        lastHeartbeats.Add(slaveInfo.Id, DateTime.Now);
    180181      }
    181182      heartbeatLock.ExitWriteLock();
    182183
    183       ClientDto dbClient = DaoLocator.ClientDao.FindById(clientInfo.Id);
     184      ClientDto dbClient = DaoLocator.ClientDao.FindById(slaveInfo.Id);
    184185
    185186      //Really set offline?
    186187      //Reconnect issues with the currently calculating jobs
    187       clientInfo.State = State.Idle;
    188       clientInfo.CalendarSyncStatus = dbClient != null ? dbClient.CalendarSyncStatus : CalendarState.NotAllowedToFetch;
     188      slaveInfo.State = State.Idle;
     189      slaveInfo.CalendarSyncStatus = dbClient != null ? dbClient.CalendarSyncStatus : CalendarState.NotAllowedToFetch;
    189190
    190191      if (dbClient == null)
    191         DaoLocator.ClientDao.Insert(clientInfo);
     192        DaoLocator.ClientDao.Insert(slaveInfo);
    192193      else
    193         DaoLocator.ClientDao.Update(clientInfo);
    194       response.Success = true;
    195       response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_LOGIN_SUCCESS;
     194        DaoLocator.ClientDao.Update(slaveInfo);
     195
    196196      return response;
    197197    }
     
    202202      ClientDto client = DaoLocator.ClientDao.FindById(clientId);
    203203      if (client == null) {
    204         response.Success = false;
    205         response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_RESOURCE_NOT_FOUND;
     204        //response.Success = false;
     205        response.StatusMessage = ResponseStatus.GetCalendar_ResourceNotFound;
    206206        return response;
    207207      }
     
    211211      IEnumerable<AppointmentDto> appointments = DaoLocator.UptimeCalendarDao.GetCalendarForClient(client);
    212212      if (appointments.Count() == 0) {
    213         response.StatusMessage = ApplicationConstants.RESPONSE_UPTIMECALENDAR_NO_CALENDAR_FOUND;
    214         response.Success = false;
     213        response.StatusMessage = ResponseStatus.GetCalendar_NoCalendarFound;
     214        //response.Success = false;
    215215      } else {
    216         response.Success = true;
     216        //response.Success = true;
    217217        response.Appointments = appointments;
    218218      }
     
    227227      ClientDto client = DaoLocator.ClientDao.FindById(clientId);
    228228      if (client == null) {
    229         response.Success = false;
    230         response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_RESOURCE_NOT_FOUND;
     229        //response.Success = false;
     230        response.StatusMessage = ResponseStatus.GetCalendar_ResourceNotFound;
    231231        return response;
    232232      }
     
    234234      client.CalendarSyncStatus = state;
    235235      DaoLocator.ClientDao.Update(client);
    236 
    237       response.Success = true;
    238       response.StatusMessage = ApplicationConstants.RESPONSE_UPTIMECALENDAR_STATUS_UPDATED;
    239236
    240237      return response;
     
    259256      // check if the client is logged in
    260257      if (client.State == State.Offline || client.State == State.NullState) {
    261         response.Success = false;
    262         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN;
     258        // response.Success = false;
     259        response.StatusMessage = ResponseStatus.ProcessHeartBeat_UserNotLoggedIn;
    263260        response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage));
    264261
     
    288285      //check if new Cal must be loaded
    289286      if (client.CalendarSyncStatus == CalendarState.Fetch || client.CalendarSyncStatus == CalendarState.ForceFetch) {
    290         response.Success = true;
    291         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_FETCH_OR_FORCEFETCH_CALENDAR;
    292287        response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchOrForceFetchCalendar));
    293288
     
    306301      }
    307302      Logger.Debug(" END Looked for Client Jobs");
    308       response.Success = true;
    309       response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HEARTBEAT_RECEIVED;
    310303
    311304      DaoLocator.ClientDao.Update(client);
     
    347340      if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) {
    348341        if (jobsOfClient == null || jobsOfClient.Count == 0) {
    349           response.Success = false;
    350           response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
     342          //response.Success = false;
     343          //response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
    351344
    352345          foreach (Guid jobId in hbData.JobProgress.Keys) {
     
    362355          curJob.Client = DaoLocator.ClientDao.GetClientForJob(curJob.Id);
    363356          if (curJob.Client == null || curJob.Client.Id != hbData.SlaveId) {
    364             response.Success = false;
    365             response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
     357            //response.Success = false;
     358            //response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
    366359            response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));
    367360            Logger.Error("There is no job calculated by this user " + hbData.SlaveId + " Job: " + curJob);
     
    439432        response.Obj = job2Calculate;
    440433        response.Obj.PluginsNeeded = DaoLocator.PluginInfoDao.GetPluginDependenciesForJob(response.Obj);
    441         response.Success = true;
     434
    442435        Logger.Info("Job pulled: " + job2Calculate + " for user " + clientId);
    443         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED;
    444436        lock (newAssignedJobs) {
    445437          if (!newAssignedJobs.ContainsKey(job2Calculate.Id))
     
    447439        }
    448440      } else {
    449         response.Success = false;
     441        //response.Success = false;
    450442        response.Obj = null;
    451         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT;
     443        response.StatusMessage = ResponseStatus.GetJob_NoJobsAvailable;
    452444        Logger.Info("No more Jobs left for " + clientId);
    453445      }
     
    473465      ResponseResultReceived response = ProcessJobResult(result.ClientId, result.JobId, new byte[] { }, result.Percentage, result.Exception, finished);
    474466
    475       if (response.Success) {
     467      if (response.StatusMessage == ResponseStatus.Ok) {
    476468        Logger.Debug("Trying to aquire WCF Job Stream");
    477469        //jobStream = DaoLocator.JobDao.GetSerializedJobStream(result.JobId);
     
    500492    }
    501493
    502 
    503     private ResponseResultReceived ProcessJobResult(Guid clientId,
    504       Guid jobId,
    505       byte[] result,
    506       double? percentage,
    507       string exception,
    508       bool finished) {
    509 
     494    private ResponseResultReceived ProcessJobResult(Guid clientId, Guid jobId, byte[] result, double? percentage, string exception, bool finished) {
    510495      Logger.Info("BEGIN Job received for Storage - SUB method: " + jobId);
    511496
     
    521506        }
    522507      }
    523      
     508
    524509      if (job != null && job.JobInfo == null) {
    525         response.Success = false;
    526         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID;
     510        //response.Success = false;
     511        response.StatusMessage = ResponseStatus.ProcessJobResult_JobDoesNotExist;
    527512        response.JobId = jobId;
    528513        Logger.Error("No job with Id " + jobId);
     
    532517      }
    533518      if (job.JobInfo.State == State.Abort) {
    534         response.Success = false;
    535         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_WAS_ABORTED;
     519        //response.Success = false;
     520        response.StatusMessage = ResponseStatus.ProcessJobResult_JobAborted;
    536521
    537522        Logger.Error("Job was aborted! " + job.JobInfo);
     
    541526      }
    542527      if (job.JobInfo.Client == null) {
    543         response.Success = false;
    544         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
     528        //response.Success = false;
     529        response.StatusMessage = ResponseStatus.ProcessJobResult_JobIsNotBeeingCalculated;
    545530        response.JobId = jobId;
    546531
     
    551536      }
    552537      if (job.JobInfo.Client.Id != clientId) {
    553         response.Success = false;
    554         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB;
     538        //response.Success = false;
     539        response.StatusMessage = ResponseStatus.ProcessJobResult_WrongClientForJob;
    555540        response.JobId = jobId;
    556541
     
    561546      }
    562547      if (job.JobInfo.State == State.Finished) {
    563         response.Success = true;
    564         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED;
     548        response.StatusMessage = ResponseStatus.Ok;
    565549        response.JobId = jobId;
    566550
     
    574558        job.JobInfo.State = State.Calculating;
    575559      }
    576       if (job.JobInfo.State != State.Calculating &&
    577         job.JobInfo.State != State.Pending) {
    578         response.Success = false;
    579         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_JOB_STATE;
     560      if (job.JobInfo.State != State.Calculating && job.JobInfo.State != State.Pending) {
     561        //response.Success = false;
     562        response.StatusMessage = ResponseStatus.ProcessJobResult_InvalidJobState;
    580563        response.JobId = jobId;
    581564
     
    600583      DaoLocator.JobDao.Update(job.JobInfo);
    601584
    602       response.Success = true;
    603       response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED;
     585      response.StatusMessage = ResponseStatus.Ok;
    604586      response.JobId = jobId;
    605587      response.Finished = finished;
     
    652634      ClientDto client = DaoLocator.ClientDao.FindById(clientId);
    653635      if (client == null) {
    654         response.Success = false;
    655         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_LOGOUT_CLIENT_NOT_REGISTERED;
     636        //response.Success = false;
     637        response.StatusMessage = ResponseStatus.Logout_SlaveNotRegistered;
    656638        return response;
    657639      }
     
    668650      DaoLocator.ClientDao.Update(client);
    669651
    670       response.Success = true;
    671       response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_LOGOUT_SUCCESS;
    672 
    673652      return response;
    674653    }
     
    684663      JobDto job = DaoLocator.JobDao.FindById(jobId);
    685664      if (job == null) {
    686         response.Success = false;
    687         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_DOESNT_EXIST;
     665        //response.Success = false;
     666        response.StatusMessage = ResponseStatus.IsJobStillNeeded_JobDoesNotExist;
    688667        Logger.Error("Job doesn't exist (anymore)! " + jobId);
    689668        return response;
    690669      }
    691670      if (job.State == State.Finished) {
    692         response.Success = true;
    693         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_ALLREADY_FINISHED;
     671        //response.Success = true;
     672        response.StatusMessage = ResponseStatus.IsJobStillNeeded_JobAlreadyFinished;
    694673        Logger.Error("already finished! " + job);
    695674        return response;
     
    702681      DaoLocator.JobDao.Update(job);
    703682
    704       response.Success = true;
    705       response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_SEND_JOBRESULT;
    706       return response;
    707     }
    708 
    709     public ResponseList<CachedHivePluginInfoDto> SendPlugins(List<HivePluginInfoDto> pluginList) {
     683      return response;
     684    }
     685
     686    public ResponseList<CachedHivePluginInfoDto> GetPlugins(List<HivePluginInfoDto> pluginList) {
    710687      ResponseList<CachedHivePluginInfoDto> response = new ResponseList<CachedHivePluginInfoDto>();
     688      response.List = new List<CachedHivePluginInfoDto>();
    711689      foreach (HivePluginInfoDto pluginInfo in pluginList) {
    712690        if (pluginInfo.Update) {
    713691          //check if there is a newer version         
    714           IPluginDescription ipd =
    715             ApplicationManager.Manager.Plugins.Where(pd => pd.Name == pluginInfo.Name && pd.Version.Major == pluginInfo.Version.Major && pd.Version.Minor == pluginInfo.Version.Minor && pd.Version.Revision > pluginInfo.Version.Revision).SingleOrDefault();
     692          IPluginDescription ipd = ApplicationManager.Manager.Plugins.Where(pd => pd.Name == pluginInfo.Name && pd.Version.Major == pluginInfo.Version.Major && pd.Version.Minor == pluginInfo.Version.Minor && pd.Version.Revision > pluginInfo.Version.Revision).SingleOrDefault();
    716693          if (ipd != null) {
    717             response.List.Add(convertPluginDescriptorToDto(ipd));
     694            response.List.Add(ConvertPluginDescriptorToDto(ipd));
    718695          }
    719696        } else {
    720           IPluginDescription ipd =
    721             ApplicationManager.Manager.Plugins.Where(pd => pd.Name == pluginInfo.Name && pd.Version.Major == pluginInfo.Version.Major && pd.Version.Minor == pluginInfo.Version.Minor && pd.Version.Revision >= pluginInfo.Version.Revision).SingleOrDefault();
     697          IPluginDescription ipd = ApplicationManager.Manager.Plugins.Where(pd => pd.Name == pluginInfo.Name && pd.Version.Major == pluginInfo.Version.Major && pd.Version.Minor == pluginInfo.Version.Minor && pd.Version.Revision >= pluginInfo.Version.Revision).SingleOrDefault();
    722698          if (ipd != null) {
    723             response.List.Add(convertPluginDescriptorToDto(ipd));
     699            response.List.Add(ConvertPluginDescriptorToDto(ipd));
    724700          } else {
    725             response.Success = false;
    726             response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_PLUGINS_NOT_AVAIL;
     701            //response.Success = false;
     702            response.StatusMessage = ResponseStatus.GetPlugins_PluginsNotAvailable;
    727703            return response;
    728704          }
    729705        }
    730706      }
    731       response.Success = true;
    732       response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_PLUGINS_SENT;
    733 
    734       return response;
    735     }
    736 
    737     private CachedHivePluginInfoDto convertPluginDescriptorToDto(IPluginDescription currPlugin) {
     707      return response;
     708    }
     709
     710    private CachedHivePluginInfoDto ConvertPluginDescriptorToDto(IPluginDescription currPlugin) {
    738711      CachedHivePluginInfoDto currCachedPlugin = new CachedHivePluginInfoDto {
    739712        Name = currPlugin.Name,
  • branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/SlaveManager.cs

    r4253 r4263  
    3333using HeuristicLab.Hive.Server.LINQDataAccess;
    3434using ClientGroup=HeuristicLab.Hive.Contracts.BusinessObjects.ClientGroupDto;
     35using HeuristicLab.Hive.Contracts.ResponseObjects;
    3536
    3637namespace HeuristicLab.Hive.Server.Core {
     
    4849    /// </summary>
    4950    /// <returns></returns>
    50     public ResponseList<ClientDto> GetAllClients() {
     51    public ResponseList<ClientDto> GetAllSlaves() {
    5152      ResponseList<ClientDto> response = new ResponseList<ClientDto>();
    52 
    5353      response.List = new List<ClientDto>(DaoLocator.ClientDao.FindAll());
    54       response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_GET_ALL_CLIENTS;
    55       response.Success = true;
    56 
    5754      return response;
    5855    }
     
    6562      ResponseList<ClientGroup> response = new ResponseList<ClientGroup>();
    6663
    67       List<ClientGroup> allClientGroups =
    68         new List<ClientGroup>(DaoLocator.ClientGroupDao.FindAllWithSubGroupsAndClients());
     64      List<ClientGroup> allClientGroups = new List<ClientGroup>(DaoLocator.ClientGroupDao.FindAllWithSubGroupsAndClients());
    6965      ClientGroup emptyClientGroup = new ClientGroup();
    7066      IEnumerable<ClientDto> groupLessClients = DaoLocator.ClientDao.FindAllClientsWithoutGroup();
     
    7874
    7975      response.List = allClientGroups;
    80       response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_GET_ALL_CLIENTGROUPS;
    81       response.Success = true;
    8276
    8377      return response;
    8478    }
    8579
     80    /// <summary>
     81    /// [chn] check usage
     82    /// </summary>
    8683    public ResponseList<UpTimeStatisticsDto> GetAllUpTimeStatistics() {
    87       ResponseList<UpTimeStatisticsDto> response = new ResponseList<UpTimeStatisticsDto>();
    88       response.Success = true;
    89       return response;
     84      return new ResponseList<UpTimeStatisticsDto>();
    9085    }
    9186
     
    9994
    10095      if (clientGroup.Id != Guid.Empty) {
    101         response.Success = false;
    102         response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_ID_MUST_NOT_BE_SET;
     96        //response.Success = false;
     97        response.StatusMessage = ResponseStatus.AddClientGroup_SlaveIdMustNotBeSet;
    10398      }
    10499      else {
     
    106101        //clientGroupAdapter.Update(clientGroup);
    107102        response.Obj = clientGroup;
    108         response.Success = true;
    109         response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_CLIENTGROUP_ADDED;
    110103      }
    111104
     
    124117      ClientGroup clientGroup = DaoLocator.ClientGroupDao.FindById(clientGroupId);
    125118      if (clientGroup == null) {
    126         response.Success = false;
    127         response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_CLIENTGROUP_DOESNT_EXIST;
     119        //response.Success = false;
     120        response.StatusMessage = ResponseStatus.AddResourceToGroup_SlaveGroupDoesNotExist;
    128121        return response;
    129122      }
     
    138131        DaoLocator.ClientDao.SetServerSideCalendar(dbr, clientGroup.Id); 
    139132      }
    140 
    141       response.Success = true;
    142       response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_RESOURCE_ADDED_TO_GROUP;
    143133
    144134      return response;
     
    156146      ClientGroup clientGroup = DaoLocator.ClientGroupDao.FindById(clientGroupId);
    157147      if (clientGroup == null) {
    158         response.Success = false;
    159         response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_CLIENTGROUP_DOESNT_EXIST;
     148        // response.Success = false;
     149        response.StatusMessage = ResponseStatus.AddResourceToGroup_SlaveGroupDoesNotExist;
    160150        return response;
    161151      }
    162152     
    163153      DaoLocator.ClientGroupDao.RemoveRessourceFromClientGroup(resourceId, clientGroup.Id);
    164      
    165       response.Success = true;
    166       response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_RESOURCE_REMOVED;
    167154      return response;               
    168155    }
     
    175162        ClientGroupDtoList groupsOfClient = new ClientGroupDtoList(DaoLocator.ClientGroupDao.MemberOf(client));
    176163        response.Obj = groupsOfClient;
    177         response.Success = true;
    178         response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_GET_GROUPS_OF_CLIENT;
    179       }
    180       else {
     164      } else {
    181165        response.Obj = new ClientGroupDtoList();
    182         response.Success = false;
    183         response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_RESOURCE_NOT_FOUND;
     166        //response.Success = false;
     167        response.StatusMessage = ResponseStatus.GetAllGroupsOfResource_ResourceNotFound;
    184168      }
    185169
     
    192176      ClientGroup clientGroup = DaoLocator.ClientGroupDao.FindById(clientGroupId);
    193177      if (clientGroup == null) {
    194         response.Success = false;
    195         response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_CLIENTGROUP_DOESNT_EXIST;
     178        response.StatusMessage = ResponseStatus.DeleteClientGroup_SlaveGroupDoesNotExist;
    196179        return response;
    197180      }
    198181
    199182      DaoLocator.ClientGroupDao.Delete(clientGroup);
    200 
    201       response.Success = true;
    202       response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_CLIENTGROUP_DELETED;
    203183      return response;
    204184    }
     
    207187      ResponseList<AppointmentDto> response = new ResponseList<AppointmentDto>();
    208188      response.List = new List<AppointmentDto>(DaoLocator.UptimeCalendarDao.GetUptimeCalendarForResource(guid));
    209       response.Success = true;
    210189      return response;
    211190    }
     
    214193      DaoLocator.UptimeCalendarDao.SetUptimeCalendarForResource(guid, appointments);
    215194      DaoLocator.UptimeCalendarDao.NotifyClientsOfNewCalendar(guid, isForced);
    216       return new Response {Success = true};
     195      return new Response();
    217196    }
    218197    #endregion
Note: See TracChangeset for help on using the changeset viewer.