Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientFacade.cs @ 2070

Last change on this file since 2070 was 1941, checked in by svonolfe, 15 years ago

Changed the Service behavior of the ClientFacade (#354)

File size: 4.0 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      JobResult result = (JobResult)formatter.Deserialize(stream);
100
101      return this.StoreFinishedJobResult(
102          result.ClientId,
103          result.JobId,
104          result.Result,
105          result.Percentage,
106          result.Exception);
107    }
108
109    public ResponseResultReceived ProcessSnapshotStreamed(Stream stream) {
110      BinaryFormatter formatter =
111          new BinaryFormatter();
112      JobResult result = (JobResult)formatter.Deserialize(stream);
113
114      return this.ProcessSnapshot(
115          result.ClientId,
116          result.JobId,
117          result.Result,
118          result.Percentage,
119          result.Exception);
120    }
121
122    #endregion
123  }
124}
Note: See TracBrowser for help on using the repository browser.