Free cookie consent management tool by TermsFeed Policy Generator

Changeset 2608 for trunk


Ignore:
Timestamp:
01/06/10 14:30:05 (15 years ago)
Author:
kgrading
Message:

changed a ton of logging, changed minor job handling and changed the DB IP to localhost (#828)

Location:
trunk/sources/HeuristicLab.Hive.Server.Core/3.2
Files:
1 added
6 edited

Legend:

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

    r2591 r2608  
    3838using System.IO;
    3939using System.Runtime.Serialization.Formatters.Binary;
     40using HeuristicLab.Tracing;
    4041
    4142namespace HeuristicLab.Hive.Server.Core {
     
    8990      ITransaction tx = null;
    9091
     92      HiveLogger.Info(this.ToString() + ": Server Heartbeat ticked");
     93
    9194      try {
    9295        IClientAdapter clientAdapter =
     
    104107
    105108            if (!lastHeartbeats.ContainsKey(client.Id)) {
     109              HiveLogger.Info(this.ToString() + ": Client " + client.Id + " wasn't offline but hasn't sent heartbeats - setting offline");
    106110              client.State = State.offline;
    107111              clientAdapter.Update(client);
    108               foreach (Job job in jobAdapter.GetActiveJobsOf(client)) {
     112              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)) {               
    109114                jobManager.ResetJobsDependingOnResults(job);
    110115              }
     
    116121              if (dif.TotalSeconds > ApplicationConstants.HEARTBEAT_MAX_DIF) {
    117122                // if client calculated jobs, the job must be reset
     123                HiveLogger.Info(this.ToString() + ": Client timed out and is on RESET");
    118124                foreach (Job job in jobAdapter.GetActiveJobsOf(client)) {
    119125                  jobManager.ResetJobsDependingOnResults(job);
     
    136142            heartbeatLock.ExitUpgradeableReadLock();
    137143          } else {
     144            //TODO: RLY neccesary?
     145            //HiveLogger.Info(this.ToString() + ": Client " + client.Id + " has wrong state: Shouldn't have offline or nullstate, has " + client.State);
    138146            heartbeatLock.EnterWriteLock();
     147            //HiveLogger.Info(this.ToString() + ": Client " + client.Id + " has wrong state: Resetting all his jobs");
    139148            if (lastHeartbeats.ContainsKey(client.Id))
    140149              lastHeartbeats.Remove(client.Id);
     
    232241    /// <returns></returns>
    233242    public ResponseHB ProcessHeartBeat(HeartBeatData hbData) {
     243     
    234244      ISession session = factory.GetSessionForCurrentThread();
    235245      ITransaction tx = null;
    236246
     247      HiveLogger.Info(this.ToString() + ": BEGIN Processing Heartbeat for Client " + hbData.ClientId);
     248
    237249      try {
     250        HiveLogger.Info(this.ToString() + ": BEGIN Fetching Adapters");
    238251        IClientAdapter clientAdapter =
    239252          session.GetDataAdapter<ClientInfo, IClientAdapter>();
    240253
    241         IJobAdapter jobAdapter =
     254        IJobAdapter jobAdapter =       
    242255          session.GetDataAdapter<Job, IJobAdapter>();
    243 
     256        HiveLogger.Info(this.ToString() + ": END Fetched Adapters");
     257        HiveLogger.Info(this.ToString() + ": BEGIN Starting Transaction");
    244258        tx = session.BeginTransaction();
     259        HiveLogger.Info(this.ToString() + ": END Started Transaction");
    245260
    246261        ResponseHB response = new ResponseHB();
    247262        response.ActionRequest = new List<MessageContainer>();
    248263
     264        HiveLogger.Info(this.ToString() + ": BEGIN Started Client Fetching");
    249265        ClientInfo client = clientAdapter.GetById(hbData.ClientId);
    250 
     266        HiveLogger.Info(this.ToString() + ": END Finished Client Fetching");
    251267        // check if the client is logged in
    252268        if (client.State == State.offline || client.State == State.nullState) {
    253269          response.Success = false;
    254           response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN;
     270          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_USER_NOT_LOGGED_IN;         
    255271          response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage));
     272
     273          HiveLogger.Error(this.ToString() + " ProcessHeartBeat: Client state null or offline: " + client);
     274
    256275          return response;
    257276        }
     
    261280
    262281        // save timestamp of this heartbeat
     282        HiveLogger.Info(this.ToString() + ": BEGIN Locking for Heartbeats");
    263283        heartbeatLock.EnterWriteLock();
     284        HiveLogger.Info(this.ToString() + ": END Locked for Heartbeats");
    264285        if (lastHeartbeats.ContainsKey(hbData.ClientId)) {
    265286          lastHeartbeats[hbData.ClientId] = DateTime.Now;
     
    271292        // check if client has a free core for a new job
    272293        // if true, ask scheduler for a new job for this client
    273         if (hbData.FreeCores > 0 && scheduler.ExistsJobForClient(hbData))
     294        HiveLogger.Info(this.ToString() + ": BEGIN Looking for Client Jobs");
     295        if (hbData.FreeCores > 0 && scheduler.ExistsJobForClient(hbData)) {
    274296          response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchJob));
    275         else
     297        } else {
    276298          response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.NoMessage));
    277 
     299        }
     300        HiveLogger.Info(this.ToString() + ": END Looked for Client Jobs");
    278301        response.Success = true;
    279302        response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_HEARTBEAT_RECEIVED;
    280303
     304        HiveLogger.Info(this.ToString() + ": BEGIN Processing Heartbeat Jobs");
    281305        processJobProcess(hbData, jobAdapter, clientAdapter, response);
     306        HiveLogger.Info(this.ToString() + ": END Processed Heartbeat Jobs");
     307       
    282308        clientAdapter.Update(client);
    283309
    284310        tx.Commit();
     311        HiveLogger.Info(this.ToString() + ": END Processed Heartbeat for Client " + hbData.ClientId);
    285312        return response;
    286313      }
     
    304331    /// <param name="response"></param>
    305332    private void processJobProcess(HeartBeatData hbData, IJobAdapter jobAdapter, IClientAdapter clientAdapter, ResponseHB response) {
     333      HiveLogger.Info(this.ToString() + " processJobProcess: Started for Client " + hbData.ClientId);     
     334     
    306335      if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) {
    307336        List<Job> jobsOfClient = new List<Job>(jobAdapter.GetActiveJobsOf(clientAdapter.GetById(hbData.ClientId)));
     
    309338          response.Success = false;
    310339          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);     
    311341          return;
    312342        }
     
    317347            response.Success = false;
    318348            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);     
    319350          } else if (curJob.State == State.abort) {
    320351            // a request to abort the job has been set
     
    345376              if (newAssignedJobs.ContainsKey(currJob.Id)) {
    346377                newAssignedJobs[currJob.Id]--;
    347 
     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);                     
    348379                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);                 
     381
    349382                  currJob.State = State.offline;
    350383                  jobAdapter.Update(currJob);
     384
     385                  response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, currJob.Id));
     386
    351387                  newAssignedJobs.Remove(currJob.Id);
    352388                }
    353389              } else {
     390                HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats:  " + currJob);                     
    354391                currJob.State = State.offline;
    355392                jobAdapter.Update(currJob);
     
    358395          } else {
    359396            lock (newAssignedJobs) {
    360               if (newAssignedJobs.ContainsKey(currJob.Id))
     397
     398              if (newAssignedJobs.ContainsKey(currJob.Id)) {
     399                HiveLogger.Info(this.ToString() + " processJobProcess: Job is sending a heart beat, removing it from the newAssignedJobList: " + currJob);                     
    361400                newAssignedJobs.Remove(currJob.Id);
     401              }
    362402            }
    363403          }
     
    391431          response.Job = computableJob;
    392432          response.Success = true;
     433          HiveLogger.Info(this.ToString() + " SendSerializedJob: Job pulled: " + computableJob.JobInfo + " for user " + clientId);                     
    393434          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED;
    394435          lock (newAssignedJobs) {
     
    397438          }
    398439        } else {
     440          HiveLogger.Info(this.ToString() + " SendSerializedJob: No more Jobs left for " + clientId);                     
    399441          response.Success = false;
    400442          response.Job = null;
     
    439481          response.Job = job2Calculate;
    440482          response.Success = true;
     483          HiveLogger.Info(this.ToString() + " SendSerializedJob: Job pulled: " + job2Calculate + " for user " + clientId);                     
    441484          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_PULLED;
    442485          lock (newAssignedJobs) {
     
    448491          response.Job = null;
    449492          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT;
     493          HiveLogger.Info(this.ToString() + " SendSerializedJob: No more Jobs left for " + clientId);                     
    450494        }
    451495
     
    468512      Stream stream,
    469513      bool finished) {
     514
     515      HiveLogger.Info(this.ToString() + " ProcessJobResult: BEGIN Job received for Storage - main method:");
     516     
    470517      ISession session = factory.GetSessionForCurrentThread();
    471518      ITransaction tx = null;
     
    482529        //important - repeatable read isolation level is required here,
    483530        //otherwise race conditions could occur when writing the stream into the DB
    484         tx = session.BeginTransaction(
    485           TransactionIsolationLevel.RepeatableRead);
     531        //just removed TransactionIsolationLevel.RepeatableRead
     532        tx = session.BeginTransaction();
    486533
    487534        ResponseResultReceived response =
     
    520567          tx.Commit();
    521568        }
    522 
     569        HiveLogger.Info(this.ToString() + " ProcessJobResult: END Job received for Storage:");
    523570        return response;
    524571      }
    525572      catch (Exception ex) {
     573        HiveLogger.Error(this.ToString() + " ProcessJobResult: Exception raised: " + ex);
    526574        if (tx != null)
    527575          tx.Rollback();
     
    546594      Exception exception,
    547595      bool finished) {
     596     
     597      HiveLogger.Info(this.ToString() + " ProcessJobResult: BEGIN Job received for Storage - SUB method: " + jobId);
     598
    548599      ISession session = factory.GetSessionForCurrentThread();
     600           
    549601      ITransaction tx = null;
    550602
     
    556608        IJobResultsAdapter jobResultAdapter =
    557609          session.GetDataAdapter<JobResult, IJobResultsAdapter>();
    558 
     610       
     611        //should fetch the existing transaction       
    559612        tx = session.BeginTransaction();
    560613
     
    575628          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOB_WITH_THIS_ID;
    576629          response.JobId = jobId;
     630         
     631          HiveLogger.Error(this.ToString() + " ProcessJobResult: No job with Id " + jobId);                     
     632         
    577633          tx.Rollback();
    578634          return response;
     
    581637          response.Success = false;
    582638          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_WAS_ABORTED;
     639         
     640          HiveLogger.Error(this.ToString() + " ProcessJobResult: Job was aborted! " + job.JobInfo);                     
     641         
    583642          tx.Rollback();
    584643          return response;
     
    588647          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_IS_NOT_BEEING_CALCULATED;
    589648          response.JobId = jobId;
     649
     650          HiveLogger.Error(this.ToString() + " ProcessJobResult: Job is not being calculated (client = null)! " + job.JobInfo);                     
     651
    590652          tx.Rollback();
    591653          return response;
     
    595657          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_CLIENT_FOR_JOB;
    596658          response.JobId = jobId;
     659
     660          HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Client for this Job! " + job.JobInfo + ", Sending Client is: " + clientId);                     
     661
    597662          tx.Rollback();
    598663          return response;
     
    602667          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOBRESULT_RECEIVED;
    603668          response.JobId = jobId;
     669
     670          HiveLogger.Error(this.ToString() + " ProcessJobResult: Job already finished! " + job.JobInfo + ", Sending Client is: " + clientId);                     
     671
    604672          tx.Rollback();
    605673          return response;
     
    613681          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_WRONG_JOB_STATE;
    614682          response.JobId = jobId;
     683
     684          HiveLogger.Error(this.ToString() + " ProcessJobResult: Wrong Job State, job is: " + job.JobInfo);                     
     685
    615686          tx.Rollback();
    616687          return response;
     
    649720        response.finished = finished;
    650721        response.JobResultId = jobResult.Id;
    651 
    652         tx.Commit();
     722       
     723        //Removed for Testing
     724        //tx.Commit();
     725        HiveLogger.Info(this.ToString() + " ProcessJobResult: END Job received for Storage - SUB method: " + jobId);       
    653726        return response;
    654727      }
     
    697770    /// <returns></returns>                       
    698771    public Response Logout(Guid clientId) {
     772
     773      HiveLogger.Info("Client logged out " + clientId);
     774     
    699775      ISession session = factory.GetSessionForCurrentThread();
    700776      ITransaction tx = null;
     
    770846          response.Success = false;
    771847          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_DOESNT_EXIST;
     848          HiveLogger.Error(this.ToString() + " IsJobStillNeeded: Job doesn't exist (anymore)! " + jobId);
    772849          return response;
    773850        }
     
    775852          response.Success = true;
    776853          response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_JOB_ALLREADY_FINISHED;
     854          HiveLogger.Error(this.ToString() + " IsJobStillNeeded: already finished! " + job);
    777855          return response;
    778856        }
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/HeuristicLab.Hive.Server.Core-3.2.csproj

    r2117 r2608  
    117117  <ItemGroup>
    118118    <None Include="app.config" />
     119    <None Include="ClassDiagram1.cd" />
    119120    <None Include="HeuristicLab.snk" />
    120121    <EmbeddedResource Include="Authorization\HivePermissionSet.xsd">
     
    156157      <Name>HeuristicLab.Security.Contracts-3.2</Name>
    157158    </ProjectReference>
     159    <ProjectReference Include="..\..\HeuristicLab.Tracing\3.2\HeuristicLab.Tracing-3.2.csproj">
     160      <Project>{EE2034D9-6E27-48A1-B855-42D45F69A4FC}</Project>
     161      <Name>HeuristicLab.Tracing-3.2</Name>
     162    </ProjectReference>
    158163  </ItemGroup>
    159164  <ItemGroup>
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/JobManager.cs

    r2117 r2608  
    3232using System.Data;
    3333using System.IO;
     34using HeuristicLab.Tracing;
    3435
    3536namespace HeuristicLab.Hive.Server.Core {
     
    6566
    6667    public void ResetJobsDependingOnResults(Job job) {
     68
     69      HiveLogger.Info(this.ToString() + ": Setting job " + job.Id + " offline");
     70
    6771      ISession session = factory.GetSessionForCurrentThread();
    6872      ITransaction tx = null;
     
    122126
    123127    void checkForDeadJobs() {
     128      HiveLogger.Info(this.ToString() + " Searching for dead Jobs");
    124129       ISession session = factory.GetSessionForCurrentThread();
    125130
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/Properties/Settings.Designer.cs

    r1468 r2608  
    22// <auto-generated>
    33//     This code was generated by a tool.
    4 //     Runtime Version:2.0.50727.3053
     4//     Runtime Version:2.0.50727.4927
    55//
    66//     Changes to this file may cause incorrect behavior and will be lost if
     
    2626        [global::System.Configuration.ApplicationScopedSettingAttribute()]
    2727        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
    28         [global::System.Configuration.DefaultSettingValueAttribute("Data Source=10.20.71.10;Initial Catalog=HeuristicLab.Hive;Persist Security Info=T" +
    29             "rue;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true")]
     28        [global::System.Configuration.DefaultSettingValueAttribute("Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive;Persist Security Info=Tru" +
     29            "e;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true")]
    3030        public string HiveServerConnectionString {
    3131            get {
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/Properties/Settings.settings

    r1468 r2608  
    44  <Settings>
    55    <Setting Name="HiveServerConnectionString" Type="System.String" Scope="Application">
    6       <Value Profile="(Default)">Data Source=10.20.71.10;Initial Catalog=HeuristicLab.Hive;Persist Security Info=True;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true</Value>
     6      <Value Profile="(Default)">Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive;Persist Security Info=True;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true</Value>
    77    </Setting>
    88  </Settings>
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/app.config

    r1530 r2608  
    99    <HeuristicLab.Hive.Server.Core.Properties.Settings>
    1010      <setting name="HiveServerConnectionString" serializeAs="String">
    11         <value>Data Source=10.20.71.10;Initial Catalog=HeuristicLab.Hive;Persist Security Info=True;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true</value>
     11        <value>Data Source=127.0.0.1;Initial Catalog=HeuristicLab.Hive;Persist Security Info=True;User ID=hive;Password=hive;Pooling=true;MultipleActiveResultSets=true</value>
    1212      </setting>
    1313    </HeuristicLab.Hive.Server.Core.Properties.Settings>
Note: See TracChangeset for help on using the changeset viewer.