Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/23/09 11:35:41 (15 years ago)
Author:
svonolfe
Message:

Avoid out of memory exceptions related to job objects (#372)

Location:
trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/ClientAdapter.cs

    r1999 r2082  
    189189
    190190    public ClientInfo GetByName(string name) {
    191       ClientInfo client = new ClientInfo();
    192       Resource res =
    193         ResAdapter.GetByName(name);
    194 
    195       return GetById(res.Id);
     191      return (ClientInfo)
     192        base.doInTransaction(
     193        delegate() {
     194          ClientInfo client = new ClientInfo();
     195          Resource res =
     196            ResAdapter.GetByName(name);
     197
     198          return GetById(res.Id);
     199        });
    196200    }
    197201
    198202    protected override bool doDelete(ClientInfo client) {
    199       bool success = false;
    200      
    201       if (client != null) {
    202         dsHiveServer.ClientRow row =
    203           GetRowById(client.Id);
    204 
    205         if (row != null) {
    206           success = base.doDelete(client) &&
    207             ResAdapter.Delete(client);
    208         }
    209       }
    210 
    211       return success;
     203      return (bool)base.doInTransaction(
     204        delegate() {
     205          bool success = false;
     206
     207          if (client != null) {
     208            dsHiveServer.ClientRow row =
     209              GetRowById(client.Id);
     210
     211            if (row != null) {
     212              success = base.doDelete(client) &&
     213                ResAdapter.Delete(client);
     214            }
     215          }
     216
     217          return success;
     218        });
    212219    }
    213220
  • trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/JobAdapter.cs

    r2066 r2082  
    166166          job.Percentage = 0.0;
    167167
    168         if (!row.IsSerializedJobNull())
    169           job.SerializedJob = row.SerializedJob;
    170         else
    171           job.SerializedJob = null;
    172 
    173168        if (!row.IsDateCreatedNull())
    174169          job.DateCreated = row.DateCreated;
     
    255250
    256251        row.Percentage = job.Percentage;
    257 
    258         row.SerializedJob = job.SerializedJob;
    259252
    260253        if (job.DateCreated != DateTime.MinValue)
     
    422415    }
    423416
     417    /// <summary>
     418    /// Gets the computable job with the secified jobId
     419    /// </summary>
     420    /// <param name="jobId"></param>
     421    /// <returns></returns>
     422    public ComputableJob GetComputableJob(Guid jobId) {
     423      return (ComputableJob)base.doInTransaction(
     424        delegate() {
     425          ComputableJob job =
     426            new ComputableJob();
     427
     428          job.JobInfo = GetById(jobId);
     429          dsHiveServer.JobRow row
     430            = GetRowById(jobId);
     431
     432          if (job.JobInfo != null && row != null &&
     433            !row.IsSerializedJobNull()) {
     434
     435            job.SerializedJob =
     436              row.SerializedJob;
     437
     438            return job;
     439          } else {
     440            return null;
     441          }
     442        });
     443    }
     444
     445    /// <summary>
     446    /// Saves or update the computable job
     447    /// </summary>
     448    /// <param name="jobId"></param>
     449    public void UpdateComputableJob(ComputableJob job) {
     450      if(job != null &&
     451        job.JobInfo != null) {
     452        base.doInTransaction(
     453          delegate() {
     454            dsHiveServer.JobRow row
     455              = GetRowById(job.JobInfo.Id);
     456
     457            if (row != null) {
     458              Update(job.JobInfo);
     459              row.SerializedJob =
     460                job.SerializedJob;
     461
     462              base.Adapter.Update(row);
     463            }
     464
     465            return true;
     466          });
     467      }
     468     
     469    }
     470
    424471    #endregion
    425472  }
Note: See TracChangeset for help on using the changeset viewer.