Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1369 for trunk/sources


Ignore:
Timestamp:
03/19/09 17:09:32 (16 years ago)
Author:
msteinbi
Message:

Implementing Lifecycle Management (#453)

Location:
trunk/sources
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Contracts/ApplicationConstants.cs

    r1272 r1369  
    7373    public static string RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED = "Communicator.JobIsNotBeenigCalculated";
    7474    public static string RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB = "Communicator.WrongClientForJob";
     75    public static string RESPONSE_COMMUNICATOR_JOB_ALLREADY_FINISHED = "Job allready finished. Not needed anymore";
     76    public static string RESPONSE_COMMUNICATOR_JOB_DOESNT_EXIST = "No job exists with this id";
     77    public static string RESPONSE_COMMUNICATOR_SEND_JOBRESULT = "Please send the Jobresult to the server";
    7578
    7679    public static string RESPONSE_JOB_ALL_JOBS = "Job.AllJobs";
  • trunk/sources/HeuristicLab.Hive.Contracts/HeuristicLab.Hive.Contracts.csproj

    r1175 r1369  
    103103    <Compile Include="ResponseHB.cs" />
    104104    <Compile Include="ResponseList.cs" />
     105    <Compile Include="ResponsePlugin.cs" />
    105106    <Compile Include="ResponseResultReceived.cs" />
    106107  </ItemGroup>
  • trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/IClientCommunicator.cs

    r1365 r1369  
    4848    [OperationContract]
    4949    Response Logout(Guid clientId);
     50    [OperationContract]
     51    Response IsJobStillNeeded(long jobId);
     52    [OperationContract]
     53    ResponsePlugin SendPlugins(List<String> pluginList);
    5054  }
    5155}
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientCommunicator.cs

    r1368 r1369  
    4646      new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
    4747
    48     // todo: access modifier!
    49     IClientAdapter clientAdapter;
    50     IJobAdapter jobAdapter;
    51     IJobResultsAdapter jobResultAdapter;
    52     ILifecycleManager lifecycleManager;
    53     IInternalJobManager jobManager;
    54     IScheduler scheduler;
     48    private IClientAdapter clientAdapter;
     49    private IJobAdapter jobAdapter;
     50    private IJobResultsAdapter jobResultAdapter;
     51    private ILifecycleManager lifecycleManager;
     52    private IInternalJobManager jobManager;
     53    private IScheduler scheduler;
    5554
    5655    /// <summary>
     
    145144
    146145      // todo: allClients legacy ?
    147       ICollection<ClientInfo> allClients = clientAdapter.GetAll();
    148146      ClientInfo client = clientAdapter.GetById(clientInfo.ClientId);
    149147      if (client != null && client.State != State.offline && client.State != State.nullState) {
     
    167165    /// <param name="hbData"></param>
    168166    /// <returns></returns>
    169     // todo: new name for "SendHeartBeat" e.g. ProcessHeartBeat
    170167    public ResponseHB ProcessHeartBeat(HeartBeatData hbData) {
    171168      ResponseHB response = new ResponseHB();
    172169
     170      // check if the client is logged in
    173171      response.ActionRequest = new List<MessageContainer>();
    174172      if (clientAdapter.GetById(hbData.ClientId).State == State.offline ||
     
    180178      }
    181179
     180      // save timestamp of this heartbeat
    182181      heartbeatLock.EnterWriteLock();
    183182      if (lastHeartbeats.ContainsKey(hbData.ClientId)) {
     
    190189      response.Success = true;
    191190      response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HEARTBEAT_RECEIVED;
     191      // check if client has a free core for a new job
     192      // if true, ask scheduler for a new job for this client
    192193      if (hbData.FreeCores > 0 && scheduler.ExistsJobForClient(hbData))
    193194        response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchJob));
     
    208209            response.Success = false;
    209210            response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
     211          } else if(curJob.State == State.finished) {
     212            // another client has finished this job allready
     213            // the client can abort it
     214            response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, curJob.Id));       
    210215          } else {
     216            // save job progress
    211217            curJob.Percentage = jobProgress.Value;
    212218            jobAdapter.Update(curJob);
     
    279285        return response;
    280286      }
     287      if (job.State == State.finished) {
     288        response.Success = true;
     289        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED;
     290        return response;       
     291      }
    281292      if (job.State != State.calculating) {
    282293        response.Success = false;
     
    358369    }
    359370
     371    /// <summary>
     372    /// If a client goes offline and restores a job he was calculating
     373    /// he can ask the client if he still needs the job result
     374    /// </summary>
     375    /// <param name="jobId"></param>
     376    /// <returns></returns>
     377    public Response IsJobStillNeeded(long jobId) {
     378      Response response = new Response();
     379      Job job = jobAdapter.GetById(jobId);
     380      if (job == null) {
     381        response.Success = false;
     382        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_DOESNT_EXIST;
     383        return response;
     384      }
     385      if (job.State == State.finished) {
     386        response.Success = true;
     387        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_ALLREADY_FINISHED;
     388        return response;
     389      }
     390      job.State = State.finished;
     391      jobAdapter.Update(job);
     392     
     393      response.Success = true;
     394      response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_SEND_JOBRESULT;
     395      return response;
     396    }
     397
     398    public ResponsePlugin SendPlugins(List<string> pluginList) {
     399      throw new NotImplementedException();
     400    }
     401
    360402    #endregion
    361403  }
  • trunk/sources/HeuristicLab.Hive.Server.Core/ClientFacade.cs

    r1365 r1369  
    6161    }
    6262
     63    public Response IsJobStillNeeded(long jobId) {
     64      return clientCommunicator.IsJobStillNeeded(jobId);
     65    }
     66
     67    public ResponsePlugin SendPlugins(List<string> pluginList) {
     68      return clientCommunicator.SendPlugins(pluginList);
     69    }
     70
    6371    #endregion
    6472  }
Note: See TracChangeset for help on using the changeset viewer.