Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive_Milestone3/sources/HeuristicLab.Hive.Server.Core/3.2/ClientFacade.cs @ 2687

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

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

File size: 4.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.Contracts.Interfaces;
27using HeuristicLab.Hive.Contracts.BusinessObjects;
28using HeuristicLab.Hive.Contracts;
29using HeuristicLab.PluginInfrastructure;
30using System.IO;
31using System.Runtime.Serialization.Formatters.Binary;
32using System.ServiceModel;
33
34namespace HeuristicLab.Hive.Server.Core {
35  [ServiceBehavior(InstanceContextMode =
36    InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
37  class ClientFacade: IClientFacade {
38
39    private IClientCommunicator clientCommunicator =
40      ServiceLocator.GetClientCommunicator();
41
42    #region IClientCommunicator Members
43
44    public Response Login(ClientInfo clientInfo) {
45      return clientCommunicator.Login(clientInfo);
46    }
47
48    public ResponseHB ProcessHeartBeat(HeartBeatData hbData) {
49      return clientCommunicator.ProcessHeartBeat(hbData);
50    }
51
52    public ResponseJob SendJob(Guid clientId) {
53      return clientCommunicator.SendJob(clientId);
54    }
55
56    public ResponseResultReceived StoreFinishedJobResult(Guid clientId,
57      Guid jobId,
58      byte[] result,
59      double percentage,
60      Exception exception) {
61      return clientCommunicator.StoreFinishedJobResult(clientId, jobId, result, percentage, exception);
62    }
63
64    public Response Logout(Guid clientId) {
65      return clientCommunicator.Logout(clientId);
66    }
67
68    public Response IsJobStillNeeded(Guid jobId) {
69      return clientCommunicator.IsJobStillNeeded(jobId);
70    }
71
72    public ResponsePlugin SendPlugins(List<HivePluginInfo> pluginList) {
73      return clientCommunicator.SendPlugins(pluginList);
74    }
75
76    public ResponseResultReceived ProcessSnapshot(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) {
77      return clientCommunicator.ProcessSnapshot(clientId, jobId, result, percentage, exception);
78    }
79
80    #endregion
81
82    #region IClientFacade Members
83
84    public Stream SendStreamedJob(Guid clientId) {
85      return
86        new StreamedObject<ResponseJob>(
87          this.SendJob(clientId));
88    }
89
90    public Stream SendStreamedPlugins(List<HivePluginInfo> pluginList) {
91      return
92        new StreamedObject<ResponsePlugin>(
93          this.SendPlugins(pluginList));
94    }
95
96    public ResponseResultReceived StoreFinishedJobResultStreamed(Stream stream) {
97      BinaryFormatter formatter =
98          new BinaryFormatter();
99      SerializedJobResult result =
100        (SerializedJobResult)formatter.Deserialize(stream);
101
102      return this.StoreFinishedJobResult(
103          result.JobResult.ClientId,
104          result.JobResult.JobId,
105          result.SerializedJobResultData,
106          result.JobResult.Percentage,
107          result.JobResult.Exception);
108    }
109
110    public ResponseResultReceived ProcessSnapshotStreamed(Stream stream) {
111      BinaryFormatter formatter =
112          new BinaryFormatter();
113      SerializedJobResult result = (SerializedJobResult)formatter.Deserialize(stream);
114
115      return this.ProcessSnapshot(
116          result.JobResult.ClientId,
117          result.JobResult.JobId,
118          result.SerializedJobResultData,
119          result.JobResult.Percentage,
120          result.JobResult.Exception);
121    }
122
123    #endregion
124  }
125}
Note: See TracBrowser for help on using the repository browser.