[1101] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
| 25 | using System.Text;
|
---|
| 26 | using HeuristicLab.Hive.Contracts.Interfaces;
|
---|
| 27 | using HeuristicLab.Hive.Contracts.BusinessObjects;
|
---|
| 28 | using HeuristicLab.Hive.Contracts;
|
---|
[1445] | 29 | using HeuristicLab.PluginInfrastructure;
|
---|
[1939] | 30 | using System.IO;
|
---|
| 31 | using System.Runtime.Serialization.Formatters.Binary;
|
---|
[1941] | 32 | using System.ServiceModel;
|
---|
[1101] | 33 |
|
---|
| 34 | namespace HeuristicLab.Hive.Server.Core {
|
---|
[1941] | 35 | [ServiceBehavior(InstanceContextMode =
|
---|
| 36 | InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)]
|
---|
[1101] | 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 |
|
---|
[1365] | 48 | public ResponseHB ProcessHeartBeat(HeartBeatData hbData) {
|
---|
| 49 | return clientCommunicator.ProcessHeartBeat(hbData);
|
---|
[1101] | 50 | }
|
---|
| 51 |
|
---|
[1365] | 52 | public ResponseJob SendJob(Guid clientId) {
|
---|
| 53 | return clientCommunicator.SendJob(clientId);
|
---|
[1101] | 54 | }
|
---|
| 55 |
|
---|
[1374] | 56 | public ResponseResultReceived StoreFinishedJobResult(Guid clientId,
|
---|
[1449] | 57 | Guid jobId,
|
---|
[1103] | 58 | byte[] result,
|
---|
[1133] | 59 | double percentage,
|
---|
[1374] | 60 | Exception exception) {
|
---|
| 61 | return clientCommunicator.StoreFinishedJobResult(clientId, jobId, result, percentage, exception);
|
---|
[1101] | 62 | }
|
---|
| 63 |
|
---|
| 64 | public Response Logout(Guid clientId) {
|
---|
| 65 | return clientCommunicator.Logout(clientId);
|
---|
| 66 | }
|
---|
| 67 |
|
---|
[1449] | 68 | public Response IsJobStillNeeded(Guid jobId) {
|
---|
[1369] | 69 | return clientCommunicator.IsJobStillNeeded(jobId);
|
---|
| 70 | }
|
---|
| 71 |
|
---|
[1593] | 72 | public ResponsePlugin SendPlugins(List<HivePluginInfo> pluginList) {
|
---|
[1369] | 73 | return clientCommunicator.SendPlugins(pluginList);
|
---|
| 74 | }
|
---|
| 75 |
|
---|
[1449] | 76 | public ResponseResultReceived ProcessSnapshot(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) {
|
---|
[1600] | 77 | return clientCommunicator.ProcessSnapshot(clientId, jobId, result, percentage, exception);
|
---|
[1374] | 78 | }
|
---|
| 79 |
|
---|
[1101] | 80 | #endregion
|
---|
[1939] | 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
|
---|
[1101] | 123 | }
|
---|
| 124 | }
|
---|