Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3220


Ignore:
Timestamp:
03/25/10 19:57:44 (14 years ago)
Author:
kgrading
Message:

improved the DAL further, changed minor details for the presentation (#830)

Location:
trunk/sources
Files:
1 added
1 deleted
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Console/3.2/HiveClientConsole.cs

    r3203 r3220  
    531531          onlineTimes = e.Result.ToList<Appointment>();
    532532          onlineTimes.ForEach(a => a.BorderColor = Color.Red);
     533          dvOnline.Invalidate();
     534
    533535        }
    534536        else
  • trunk/sources/HeuristicLab.Hive.Client.Core/3.2/ConfigurationManager/UptimeManager.cs

    r3203 r3220  
    3333        return instance;
    3434      }
     35    }
     36
     37    public UptimeManager() {
     38      RestoreFromHDD();
    3539    }
    3640
  • trunk/sources/HeuristicLab.Hive.Client.Core/3.2/Core.cs

    r3203 r3220  
    311311    /// <param name="e"></param>
    312312    void wcfService_SendJobCompleted(object sender, SendJobCompletedEventArgs e) {
    313       Logging.Instance.Info(this.ToString(), "Received new job with id " + e.Result.Job.Id);
    314       if (e.Result.StatusMessage != ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT) {       
     313      if (e.Result.StatusMessage != ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT) {
     314        Logging.Instance.Info(this.ToString(), "Received new job with id " + e.Result.Job.Id);     
    315315        bool sandboxed = false;
    316316        List<byte[]> files = new List<byte[]>();
  • trunk/sources/HeuristicLab.Hive.Client.Core/3.2/JobStorage/JobStorageManager.cs

    r2846 r3220  
    6363            Logging.Instance.Error("JobStorageManager", "Job not on hdd but on list - deleting job from list", e);
    6464            storedJobsList.Remove(storedJobsList[index - 1]);
     65            StoreJobList();
    6566          }
    6667     
     
    8283           
    8384      XmlSerializer serializer = new XmlSerializer(typeof(List<JobStorageInfo>));
     85      FileStream stream = null;
    8486      if(File.Exists(Path.Combine(path ,"list.xml"))) {
    8587        try {
    86           FileStream stream = new FileStream(Path.Combine(path, "list.xml"), FileMode.Open);
     88          stream = new FileStream(Path.Combine(path, "list.xml"), FileMode.Open);
    8789          XmlTextReader reader = new XmlTextReader(stream);
    8890          storedJobsList = (List<JobStorageInfo>)serializer.Deserialize(reader);
     
    9193        catch (Exception e) {
    9294          Logging.Instance.Error("JobStorageManager", "Exception while loading the Stored Job List", e);
     95        } finally {
     96          if(stream != null)
     97            stream.Dispose();
    9398        }
    9499      } else {
  • trunk/sources/HeuristicLab.Hive.Contracts/3.2/Interfaces/IExecutionEngineFacade.cs

    r3011 r3220  
    3333    ResponseObject<JobDto> AddJob(SerializedJob job);
    3434    [OperationContract]
     35    ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob jobObj, IEnumerable<string> groups);
     36    [OperationContract]
    3537    Response RequestSnapshot(Guid jobId);
    3638    [OperationContract]
    3739    ResponseObject<SerializedJob> GetLastSerializedResult(Guid jobId, bool requested);
    3840    [OperationContract]
    39     Response AbortJob(Guid jobId);
     41    Response AbortJob(Guid jobId);   
    4042  }
    4143}
  • trunk/sources/HeuristicLab.Hive.Contracts/3.2/Interfaces/IJobManager.cs

    r3011 r3220  
    6161    [OperationContract]
    6262    ResponseList<JobDto> GetJobsByProject(Guid projectId);
     63    [OperationContract]
     64    ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources);
    6365  }
    6466}
  • trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngine.cs

    r3018 r3220  
    9494      var jobObj = CreateJobObj();
    9595      IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(HiveServerUrl);
    96      
    97       if(!String.Empty.Equals(RessourceIds)) {
     96
     97      List<string> groups = new List<string>();
     98      if (!String.Empty.Equals(RessourceIds)) {
     99        groups.AddRange(RessourceIds.Split(';'));       
     100      }
     101
     102      /*if(!String.Empty.Equals(RessourceIds)) {
    98103        String[] ids = RessourceIds.Split(';');
    99104        foreach (string sid in ids) {       
     
    105110          }   
    106111        }
    107       }      
     112      } */     
    108113
    109114      int loops = 1;
     
    114119
    115120      for (int i = 0; i < loops; i++) {
    116         ResponseObject<Contracts.BusinessObjects.JobDto> res = executionEngineFacade.AddJob(jobObj);
     121        ResponseObject<Contracts.BusinessObjects.JobDto> res = executionEngineFacade.AddJobWithGroupStrings(jobObj, groups);
    117122        jobId = res.Obj.Id;
    118123      }
  • trunk/sources/HeuristicLab.Hive.Server.Console/3.2/CgCalendar.Designer.cs

    r3203 r3220  
    2424    /// </summary>
    2525    private void InitializeComponent() {
    26       Calendar.DrawTool drawTool2 = new Calendar.DrawTool();
     26      Calendar.DrawTool drawTool1 = new Calendar.DrawTool();
    2727      this.dvOnline = new Calendar.DayView();
    2828      this.btnSaveCal = new System.Windows.Forms.Button();
     
    4646      // dvOnline
    4747      //
    48       drawTool2.DayView = this.dvOnline;
    49       this.dvOnline.ActiveTool = drawTool2;
     48      drawTool1.DayView = this.dvOnline;
     49      this.dvOnline.ActiveTool = drawTool1;
    5050      this.dvOnline.AmPmDisplay = false;
    5151      this.dvOnline.AppointmentDuration = Calendar.AppointmentSlotDuration.SixtyMinutes;
     
    6767      this.dvOnline.StartDate = new System.DateTime(((long)(0)));
    6868      this.dvOnline.TabIndex = 42;
     69      this.dvOnline.OnSelectionChanged += new System.EventHandler<System.EventArgs>(this.dvOnline_OnSelectionChanged);
    6970      //
    7071      // btnSaveCal
     
    231232      this.Controls.Add(this.dvOnline);
    232233      this.Name = "CgCalendar";
    233       this.Text = "Calendar";
    234234      this.groupBox1.ResumeLayout(false);
    235235      this.groupBox1.PerformLayout();
  • trunk/sources/HeuristicLab.Hive.Server.Console/3.2/CgCalendar.cs

    r3203 r3220  
    2828
    2929    public Guid ResourceId { get; set; }
     30    public string Name { get; set; }
    3031
    3132    [XmlArray("Appointments")]
     
    3334    public List<Appointment> onlineTimes = new List<Appointment>();
    3435
    35     public CgCalendar(Guid resourceId) {
     36    public CgCalendar(Guid resourceId, String name) {     
     37      Name = name;
    3638      ResourceId = resourceId;
     39      this.Text = Name + "(" + ResourceId + ")";
    3740      InitializeComponent();
    3841      InitCalender();
  • trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerManagementConsole.cs

    r3022 r3220  
    131131      menuItemOpenCalendar.Click += (s, e) => {
    132132                                      if (tvClientControl.SelectedNode != null) {
    133                                         CgCalendar cal = new CgCalendar(((ClientGroupDto)tvClientControl.SelectedNode.Tag).Id);                                       
     133                                        CgCalendar cal = new CgCalendar(((ClientGroupDto)tvClientControl.SelectedNode.Tag).Id, ((ClientGroupDto)tvClientControl.SelectedNode.Tag).Name);                                       
    134134                                        cal.Show();
    135135                                      }
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs

    r3203 r3220  
    4141using Linq = HeuristicLab.Hive.Server.LINQDataAccess;
    4242using System.Transactions;
     43using HeuristicLab.Hive.Server.LINQDataAccess;
    4344
    4445namespace HeuristicLab.Hive.Server.Core {
     
    107108                              " wasn't offline but hasn't sent heartbeats - Resetting all his jobs");
    108109              foreach (JobDto job in DaoLocator.JobDao.FindActiveJobsOfClient(client)) {
    109                 jobManager.ResetJobsDependingOnResults(job);
     110                //maybe implementa n additional Watchdog? Till then, just set them offline..
     111                DaoLocator.JobDao.SetJobOffline(job);               
     112                //jobManager.ResetJobsDependingOnResults(job);
    110113              }
    111114            } else {
     
    193196      heartbeatLock.ExitWriteLock();
    194197
     198      ClientDto dbClient = DaoLocator.ClientDao.FindById(clientInfo.Id);
     199
     200      //Really set offline?
     201      //Reconnect issues with the currently calculating jobs
    195202      clientInfo.State = State.idle;
    196 
    197       if (DaoLocator.ClientDao.FindById(clientInfo.Id) == null)
     203      clientInfo.CalendarSyncStatus = dbClient != null ? dbClient.CalendarSyncStatus : CalendarState.NotAllowedToFetch;
     204
     205      if (dbClient == null)
    198206        DaoLocator.ClientDao.Insert(clientInfo);
    199207      else
     
    336344    private void processJobProcess(HeartBeatData hbData, ResponseHB response) {
    337345      HiveLogger.Info(this.ToString() + " processJobProcess: Started for Client " + hbData.ClientId);
    338 
    339       if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) {
    340         List<JobDto> jobsOfClient = new List<JobDto>(DaoLocator.JobDao.FindActiveJobsOfClient(DaoLocator.ClientDao.FindById(hbData.ClientId)));
     346      List<JobDto> jobsOfClient = new List<JobDto>(DaoLocator.JobDao.FindActiveJobsOfClient(DaoLocator.ClientDao.FindById(hbData.ClientId)));
     347      if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) {       
    341348        if (jobsOfClient == null || jobsOfClient.Count == 0) {
    342349          response.Success = false;
     
    369376          DaoLocator.JobDao.Update(curJob);
    370377        }
    371         foreach (JobDto currJob in jobsOfClient) {
    372           bool found = false;
     378       }
     379      foreach (JobDto currJob in jobsOfClient) {
     380        bool found = false;
     381        if(hbData.JobProgress != null) {
    373382          foreach (Guid jobId in hbData.JobProgress.Keys) {
    374383            if (jobId == currJob.Id) {
     
    377386            }
    378387          }
    379           if (!found) {
    380             lock (newAssignedJobs) {
    381               if (newAssignedJobs.ContainsKey(currJob.Id)) {
    382                 newAssignedJobs[currJob.Id]--;
    383                 HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL Reduced by one for job: " + currJob + "and is now: " + newAssignedJobs[currJob.Id] + ". User that sucks: " + currJob.Client);
    384                 if (newAssignedJobs[currJob.Id] <= 0) {
    385                   HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL reached Zero, Job gets removed: " + currJob + " and set back to offline. User that sucks: " + currJob.Client);
    386 
    387                   currJob.State = State.offline;
    388                   DaoLocator.JobDao.Update(currJob);
    389 
    390                   response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, currJob.Id));
    391 
    392                   newAssignedJobs.Remove(currJob.Id);
    393                 }
    394               } else {
    395                 HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats:  " + currJob);
     388        }
     389        if (!found) {
     390          lock (newAssignedJobs) {
     391            if (newAssignedJobs.ContainsKey(currJob.Id)) {
     392              newAssignedJobs[currJob.Id]--;
     393              HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL Reduced by one for job: " + currJob + "and is now: " + newAssignedJobs[currJob.Id] + ". User that sucks: " + currJob.Client);
     394              if (newAssignedJobs[currJob.Id] <= 0) {
     395                HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL reached Zero, Job gets removed: " + currJob + " and set back to offline. User that sucks: " + currJob.Client);
     396
    396397                currJob.State = State.offline;
    397398                DaoLocator.JobDao.Update(currJob);
    398               }
    399             } // lock
    400           } else {
    401             lock (newAssignedJobs) {
    402 
    403               if (newAssignedJobs.ContainsKey(currJob.Id)) {
    404                 HiveLogger.Info(this.ToString() + " processJobProcess: Job is sending a heart beat, removing it from the newAssignedJobList: " + currJob);
     399
     400                response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, currJob.Id));
     401
    405402                newAssignedJobs.Remove(currJob.Id);
    406403              }
     404            } else {
     405              HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats:  " + currJob);
     406              currJob.State = State.offline;
     407              DaoLocator.JobDao.Update(currJob);
     408            }
     409          } // lock
     410        } else {
     411          lock (newAssignedJobs) {
     412
     413            if (newAssignedJobs.ContainsKey(currJob.Id)) {
     414              HiveLogger.Info(this.ToString() + " processJobProcess: Job is sending a heart beat, removing it from the newAssignedJobList: " + currJob);
     415              newAssignedJobs.Remove(currJob.Id);
    407416            }
    408417          }
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientFacade.cs

    r3203 r3220  
    3232using System.ServiceModel;
    3333using HeuristicLab.Hive.Server.Core.InternalInterfaces;
     34using System.Transactions;
    3435
    3536namespace HeuristicLab.Hive.Server.Core {
     
    103104        new MultiStream();
    104105
    105       ResponseJob job =
    106         this.SendJob(clientId);
     106      ResponseJob job = null;
     107
     108      job = this.SendJob(clientId);     
    107109
    108110      //first send response
     
    114116
    115117      //second stream the job binary data
    116       stream.AddStream(
    117         ((IInternalJobManager)(jobManager)).
    118         GetJobStreamById(
    119           job.Job.Id));
    120 
     118     
     119      if(job.Job != null)
     120        stream.AddStream(
     121          ((IInternalJobManager) (jobManager)).
     122            GetJobStreamById(
     123            job.Job.Id));
     124     
    121125      OperationContext clientContext = OperationContext.Current;
    122126        clientContext.OperationCompleted += new EventHandler(delegate(object sender, EventArgs args) {
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/DbTestApp.cs

    r3011 r3220  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Data.SqlClient;
    2425using System.Text;
    2526using HeuristicLab.PluginInfrastructure;
     
    3536using HeuristicLab.Core;
    3637using HeuristicLab.Hive.Server.LINQDataAccess;
     38using System.Transactions;
    3739
    3840namespace HeuristicLab.Hive.Server {
    3941  [Application("Hive DB Test App", "Test Application for the Hive DataAccess Layer")]
    4042  class HiveDbTestApplication : ApplicationBase {
    41     /*  private void TestClientAdapter() {
    42         IClientAdapter clientAdapter =
    43           ServiceLocator.GetClientAdapter();
    44 
    45         ClientInfo client = new ClientInfo();
    46         client.Login = DateTime.Now;
    47         clientAdapter.Update(client);
    48 
    49         ClientInfo clientRead =
    50           clientAdapter.GetById(client.Id);
    51         Debug.Assert(
    52           clientRead != null &&
    53           client.Id == clientRead.Id);
    54 
    55         client.CpuSpeedPerCore = 2000;
    56         clientAdapter.Update(client);
    57         clientRead =
    58           clientAdapter.GetById(client.Id);
    59         Debug.Assert(
    60          clientRead != null &&
    61          client.Id == clientRead.Id &&
    62          clientRead.CpuSpeedPerCore == 2000);
    63 
    64         ICollection<ClientInfo> clients =
    65           clientAdapter.GetAll();
    66         int count = clients.Count;
    67 
    68         clientAdapter.Delete(client);
    69 
    70         clients = clientAdapter.GetAll();
    71         Debug.Assert(count - 1 == clients.Count);
    72       }
    73 
    74       private void TestClientGroupAdapter() {
    75         ISessionFactory factory =
    76           ServiceLocator.GetSessionFactory();
    77 
    78         ISession session =
    79           factory.GetSessionForCurrentThread();
    80 
    81         ITransaction trans = null;
    82 
    83         try {
    84           IClientGroupAdapter clientGroupAdapter =
    85           session.GetDataAdapter<ClientGroup, IClientGroupAdapter>();
    86 
    87           trans =
    88             session.BeginTransaction();
    89 
    90           ClientInfo client =
    91             new ClientInfo();
    92           client.Name = "Stefan";
    93           client.Login = DateTime.Now;
    94 
    95           ClientInfo client2 =
    96             new ClientInfo();
    97           client2.Name = "Martin";
    98           client2.Login = DateTime.Now;
    99 
    100           ClientInfo client3 =
    101             new ClientInfo();
    102           client3.Name = "Heinz";
    103           client3.Login = DateTime.Now;
    104 
    105           ClientGroup group =
    106             new ClientGroup();
    107 
    108           ClientGroup subGroup =
    109             new ClientGroup();
    110           subGroup.Resources.Add(client);
    111 
    112           group.Resources.Add(client3);
    113           group.Resources.Add(client2);
    114           group.Resources.Add(subGroup);
    115 
    116           clientGroupAdapter.Update(group);
    117 
    118           ClientGroup read =
    119             clientGroupAdapter.GetById(group.Id);
    120 
    121           ICollection<ClientGroup> clientGroups =
    122             clientGroupAdapter.GetAll();
    123 
    124           IClientAdapter clientAdapter =
    125             session.GetDataAdapter<ClientInfo, IClientAdapter>();
    126 
    127           clientAdapter.Delete(client3);
    128 
    129           read =
    130              clientGroupAdapter.GetById(group.Id);
    131 
    132           clientGroupAdapter.Delete(subGroup);
    133 
    134           read =
    135              clientGroupAdapter.GetById(group.Id);
    136 
    137           clientGroups =
    138             clientGroupAdapter.GetAll();
    139 
    140           clientGroupAdapter.Delete(group);
    141 
    142           clientGroups =
    143             clientGroupAdapter.GetAll();
    144 
    145           clientAdapter.Delete(client);
    146           clientAdapter.Delete(client2);
    147         }
    148         finally {
    149           if (trans != null)
    150             trans.Rollback();
    151 
    152           session.EndSession();
    153         }
    154       }
    155 
    156       private void InsertTestClientGroups() {
    157         ISessionFactory factory =
    158           ServiceLocator.GetSessionFactory();
    159 
    160         ISession session =
    161           factory.GetSessionForCurrentThread();
    162 
    163         ITransaction trans = null;
    164 
    165         try {
    166           IClientGroupAdapter clientGroupAdapter =
    167           session.GetDataAdapter<ClientGroup, IClientGroupAdapter>();
    168 
    169           trans =
    170             session.BeginTransaction();
    171 
    172           ClientInfo client =
    173             new ClientInfo();
    174           client.Name = "Stefan";
    175           client.Login = DateTime.Now;
    176 
    177           ClientInfo client2 =
    178             new ClientInfo();
    179           client2.Name = "Martin";
    180           client2.Login = DateTime.Now;
    181 
    182           ClientGroup group =
    183             new ClientGroup();
    184           group.Name = "Gruppe1";
    185 
    186           ClientGroup subGroup =
    187             new ClientGroup();
    188           subGroup.Name = "Untergruppe1";
    189           subGroup.Resources.Add(client);
    190 
    191           group.Resources.Add(client2);
    192           group.Resources.Add(subGroup);
    193 
    194           clientGroupAdapter.Update(group);
    195 
    196           trans.Commit();
    197         }
    198         finally {
    199           session.EndSession();
    200         }
    201       }
    202 
    203       private void TestJobAdapter() {
    204         IJobAdapter jobAdapter =
    205           ServiceLocator.GetJobAdapter();
    206         IClientAdapter clientAdapter =
    207           ServiceLocator.GetClientAdapter();
    208 
    209         Job job = new Job();
    210 
    211         ClientInfo client = new ClientInfo();
    212         client.Login = DateTime.Now;
    213 
    214         job.Client = client;
    215         jobAdapter.Update(job);
    216 
    217         ICollection<Job> jobs = jobAdapter.GetAll();
    218 
    219         jobAdapter.Delete(job);
    220         clientAdapter.Delete(client);
    221 
    222         jobs = jobAdapter.GetAll();
    223       }
    224 
    225       private void TestJobResultsAdapter() {
    226         Job job = new Job();
    227 
    228         ClientInfo client = new ClientInfo();
    229         client.Login = DateTime.Now;
    230 
    231         job.Client = client;
    232 
    233         IJobResultsAdapter resultsAdapter =
    234           ServiceLocator.GetJobResultsAdapter();
    235 
    236         byte[] resultByte = {0x0f, 0x1f, 0x2f, 0x3f, 0x4f};
    237 
    238         JobResult result = new JobResult();
    239         result.Client = client;
    240         result.Job = job;
    241         result.Result = resultByte;
    242 
    243         resultsAdapter.Update(result);
    244 
    245         JobResult read =
    246           resultsAdapter.GetById(result.Id);
    247         Debug.Assert(
    248           read.Id == result.Id &&
    249           result.Client.Id == read.Client.Id &&
    250           result.Job.Id == read.Job.Id &&
    251           result.Result == result.Result);
    252 
    253         int count =
    254           resultsAdapter.GetAll().Count;
    255 
    256         resultsAdapter.Delete(result);
    257 
    258         ICollection<JobResult> allResults =
    259           resultsAdapter.GetAll();
    260 
    261         Debug.Assert(allResults.Count == count - 1);
    262 
    263         IJobAdapter jboAdapter =
    264           ServiceLocator.GetJobAdapter();
    265         jboAdapter.Delete(job);
    266         IClientAdapter clientAdapter =
    267           ServiceLocator.GetClientAdapter();
    268         clientAdapter.Delete(client);
    269       }     
    270 
    271       private void TestTransaction() {
    272         ISessionFactory factory =
    273           ServiceLocator.GetSessionFactory();
    274 
    275         ISession session =
    276           factory.GetSessionForCurrentThread();
    277 
    278         IClientAdapter clientAdapter =
    279           session.GetDataAdapter<ClientInfo, IClientAdapter>();
    280 
    281         ITransaction trans =
    282           session.BeginTransaction();
    283 
    284         ClientInfo client = new ClientInfo();
    285         client.Login = DateTime.Now;
    286         clientAdapter.Update(client);
    287 
    288         trans.Rollback();
    289 
    290         session.EndSession();
    291       }  */
    292 
    293     private void TestJobStreaming() {
     43    /*private void TestJobStreaming() {
    29444      ISessionFactory factory =
    29545         ServiceLocator.GetSessionFactory();
     
    489239
    490240      //SpeedTest();
    491       TestJobBytearrFetching();
    492 
     241      //TestJobBytearrFetching();
     242      TestJobStreamFetching();
     243
     244    }
     245
     246    private void TestJobStreamFetching() {
     247      //using (TransactionScope scope = new TransactionScope()) {
     248      HiveDataContext context = ContextFactory.Context;
     249
     250      ContextFactory.Context.Connection.Open();
     251      ContextFactory.Context.Transaction = ContextFactory.Context.Connection.BeginTransaction();
     252     
     253      ClientFacade facade = new ClientFacade();
     254      Stream stream = facade.SendStreamedJob(new Guid("F5CFB334-66A0-417C-A585-71711BA21D3F"));
     255     
     256      byte[] buffer = new byte[3024];
     257      int read = 0;
     258     
     259      while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) {}
     260     
     261      stream.Close();
     262
     263      //Stream stream = DaoLocator.JobDao.GetSerializedJobStream(new Guid("bbb51f87-4e2f-4499-a9b6-884e589c78b6"));
     264      //}
    493265    }
    494266
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ExecutionEngineFacade.cs

    r3011 r3220  
    4444    }
    4545
     46    public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) {     
     47      return jobManager.AddJobWithGroupStrings(job, resources);
     48    }
     49
    4650    public Response RequestSnapshot(Guid jobId) {
    4751      return jobManager.RequestSnapshot(jobId);
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/JobManager.cs

    r3018 r3220  
    3434using HeuristicLab.Tracing;
    3535using System.Transactions;
     36using HeuristicLab.Hive.Server.LINQDataAccess;
    3637
    3738namespace HeuristicLab.Hive.Server.Core {
     
    149150      }
    150151    }   */
     152
     153    public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) {
     154      IClientGroupDao cgd = DaoLocator.ClientGroupDao;
     155      foreach (string res in resources) {
     156        foreach(ClientGroupDto cg in cgd.FindByName(res)) {
     157          job.JobInfo.AssignedResourceIds.Add(cg.Id);
     158        }
     159      }
     160      return AddNewJob(job);
     161    }
    151162
    152163    /// <summary>
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs

    r3203 r3220  
    180180    }
    181181
     182    public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) {
     183      return jobManager.AddJobWithGroupStrings(job, resources);
     184    }
    182185  }
    183186}
  • trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/HeuristicLab.Hive.Server.DataAccess-3.2.csproj

    r3022 r3220  
    9393    <Compile Include="IJobResultsAdapter.cs" />
    9494    <Compile Include="IResourceAdapter.cs" />
    95     <Compile Include="VarBinaryStream.cs" />
    9695  </ItemGroup>
    9796  <ItemGroup>
  • trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/IClientGroupDao.cs

    r3018 r3220  
    1313    IEnumerable<ClientGroupDto> FindAllWithSubGroupsAndClients();
    1414    IEnumerable<Guid> FindAllGroupAndParentGroupIdsForClient(Guid clientId);
     15
     16    IEnumerable<ClientGroupDto> FindByName(string res);
    1517  }
    1618}
  • trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientGroupDao.cs

    r3203 r3220  
    153153      return target;
    154154    }
     155
     156    public IEnumerable<ClientGroupDto> FindByName(string res) {
     157      return (from cq in Context.ClientGroups
     158              where cq.Resource.Name == res
     159              select EntityToDto(cq, null)).ToList();     
     160    }
     161
     162
    155163  }
    156164}
  • trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ContextFactory.cs

    r3011 r3220  
    33using System.Linq;
    44using System.Text;
     5using System.Data.Common;
     6using System.Data.SqlClient;
    57
    68namespace HeuristicLab.Hive.Server.LINQDataAccess {
     
    810    [ThreadStatic]
    911    private static HiveDataContext _hiveDataContext;
     12
     13    [ThreadStatic]
     14    private static SqlTransaction _currentTransaction;
    1015
    1116    public static HiveDataContext Context {
     
    1520        return _hiveDataContext;       
    1621      }
    17       set {
     22      set {       
    1823        _hiveDataContext = value;
    1924      }
    2025    }
     26
     27    public static SqlTransaction CurrentTransaction {
     28      get {
     29        return _currentTransaction;
     30      } set {
     31        _currentTransaction = value;
     32      }
     33    }
    2134  }
    2235}
  • trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/HeuristicLab.Hive.Server.LINQDataAccess-3.2.csproj

    r3022 r3220  
    106106    </Compile>
    107107    <Compile Include="UptimeCalendarDao.cs" />
     108    <Compile Include="VarBinaryStream.cs" />
    108109  </ItemGroup>
    109110  <ItemGroup>
  • trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/JobDao.cs

    r3018 r3220  
    6060      Job job = Context.Jobs.SingleOrDefault(j => j.JobId.Equals(bObj.Id));
    6161      DtoToEntity(bObj, job);
    62       Context.SubmitChanges();
     62      try {
     63        Context.SubmitChanges();
     64      } catch (ChangeConflictException cfe) {
     65       
     66      }
    6367    }
    6468
     
    112116
    113117    public Stream GetSerializedJobStream(Guid jobId) {
    114       HiveDataContext hdc = new HiveDataContext();
    115       String ConnStr = hdc.Connection.ConnectionString;
    116       SqlConnection connection = new SqlConnection(hdc.Connection.ConnectionString);     
    117118      VarBinarySource source =
    118119        new VarBinarySource(
    119           connection, null,
     120          (SqlConnection)Context.Connection, null,
    120121          "Job", "SerializedJob", "JobId", jobId);
    121122
  • trunk/sources/HeuristicLab.Hive.Server/3.2/ServiceCallInterception.cs

    r3203 r3220  
    99
    1010namespace HeuristicLab.Hive.Server {
    11   class ServiceCallInterception: IMethodInterceptor {
    12     #region IMethodInterceptor Members
     11  internal class ServiceCallInterception : IMethodInterceptor {
     12
     13    private bool useTransactions = false;
    1314
    1415    public object Invoke(IMethodInvocation invocation) {
    15       Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Entering Method " + invocation.Method.Name);
     16      Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Entering Method " +
     17                        invocation.Method.Name);
    1618
    17       Object obj;
    18      
    19       using (TransactionScope scope = new TransactionScope()) {
     19      if(ContextFactory.Context != null) {
     20        Console.WriteLine("Error - Not null context found - why wasn't this disposed?");
     21        ContextFactory.Context = null;
     22      }
     23
     24      Object obj = null;
     25
     26      if (invocation.Method.Name.Equals("SendStreamedJob") || invocation.Method.Name.Equals("StoreFinishedJobResultStreamed")) {       
     27        ContextFactory.Context.Connection.Open();
     28        if(useTransactions)
     29          ContextFactory.Context.Transaction = ContextFactory.Context.Connection.BeginTransaction();
    2030        try {
    2131          obj = invocation.Proceed();
    22           scope.Complete();
    23         } finally {
     32          Console.WriteLine("leaving context open for Streaming");
     33        }
     34        catch (Exception e) {         
     35          Console.WriteLine(e);
    2436          ContextFactory.Context.Dispose();
    25           Console.WriteLine("setting old context null");
    2637          ContextFactory.Context = null;
    27           Console.WriteLine("Disposing old Context");     
     38        }       
     39      } else {
     40        if(useTransactions) {
     41          using (TransactionScope scope = new TransactionScope()) {
     42            try {
     43              obj = invocation.Proceed();
     44              scope.Complete();
     45            }
     46            catch (Exception e) {
     47              Console.WriteLine("Exception Occured");
     48              Console.WriteLine(e);
     49            }
     50            finally {
     51              ContextFactory.Context.Dispose();
     52              Console.WriteLine("setting old context null");
     53              ContextFactory.Context = null;
     54              Console.WriteLine("Disposing old Context");
     55            }
     56          }
     57        } else {
     58          try {
     59            obj = invocation.Proceed();           
     60          }
     61          catch (Exception e) {
     62            Console.WriteLine("Exception Occured");
     63            Console.WriteLine(e);
     64          }
     65          finally {
     66            ContextFactory.Context.Dispose();
     67            Console.WriteLine("setting old context null");
     68            ContextFactory.Context = null;
     69            Console.WriteLine("Disposing old Context");
     70          } 
    2871        }
    29       }     
    30       Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Leaving Method " + invocation.Method.Name);           
     72      }
     73      Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Leaving Method " +
     74                          invocation.Method.Name);
     75
    3176      return obj;
    3277    }
    33 
    34     #endregion
    3578  }
    3679}
     80     
     81 
Note: See TracChangeset for help on using the changeset viewer.