Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/3.2/ExecutableJobAdapter.cs @ 2121

Last change on this file since 2121 was 2099, checked in by svonolfe, 15 years ago

Further avoided out of memory exceptions by updating the JobResult DAO (#372)

File size: 3.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Text;
26using HeuristicLab.Hive.Server.DataAccess;
27using HeuristicLab.Hive.Contracts.BusinessObjects;
28using System.Linq.Expressions;
29using HeuristicLab.DataAccess.ADOHelper;
30using HeuristicLab.Hive.Server.ADODataAccess.dsHiveServerTableAdapters;
31using System.Data.Common;
32using System.Data.SqlClient;
33using HeuristicLab.Hive.Server.ADODataAccess.TableAdapterWrapper;
34
35namespace HeuristicLab.Hive.Server.ADODataAccess {
36  class ExecutableJobAdapter :
37    DataAdapterBase<dsHiveServerTableAdapters.JobTableAdapter,
38                      ExecutableJob,
39                      dsHiveServer.JobRow>,
40    IExecutableJobAdapter {
41    #region Fields
42    private IJobAdapter jobAdapter = null;
43
44    private IJobAdapter JobAdapter {
45      get {
46        if (jobAdapter == null)
47          jobAdapter =
48            this.Session.GetDataAdapter<Job, IJobAdapter>();
49
50        return jobAdapter;
51      }
52    }
53    #endregion
54
55    public ExecutableJobAdapter(): base(new ExecutableJobAdapterWrapper()) {
56    }
57
58    #region Overrides
59    protected override ExecutableJob ConvertRow(dsHiveServer.JobRow row,
60      ExecutableJob job) {
61      if (row != null && job != null) {
62        JobAdapter.GetById(job);
63
64        if (!row.IsSerializedJobNull())
65          job.SerializedJob = row.SerializedJob;
66        else
67          job.SerializedJob = null;
68
69        return job;
70      } else
71        return null;
72    }
73
74    protected override dsHiveServer.JobRow ConvertObj(ExecutableJob job,
75      dsHiveServer.JobRow row) {
76      if (job != null && row != null) {
77        row.SerializedJob = job.SerializedJob;
78      }
79
80      return row;
81    }
82
83    protected override void doUpdate(ExecutableJob obj) {
84      if (obj != null) {
85        JobAdapter.Update(obj);
86
87        base.doUpdate(obj);
88      }
89    }
90    #endregion
91
92    public ICollection<ExecutableJob> FindJobs(State state, int cores, int memory,
93      Guid resourceId) {
94      return
95         base.FindMultiple(
96           delegate() {
97             return Adapter.GetDataByStateCoresMemoryResource(
98               state.ToString(),
99               cores,
100               memory,
101               resourceId);
102           });
103    }
104  }
105}
Note: See TracBrowser for help on using the repository browser.