[4593] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2010 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;
|
---|
[5599] | 23 | using System.Runtime.Serialization;
|
---|
[4593] | 24 | using HeuristicLab.Common;
|
---|
| 25 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 26 |
|
---|
[4615] | 27 | namespace HeuristicLab.Services.Hive.Common {
|
---|
[4593] | 28 | /// <summary>
|
---|
| 29 | /// The MessageContainer is a container class for Messages. Its two parts are:
|
---|
| 30 | /// the actual message itself and the JobId, refered by the message
|
---|
| 31 | /// </summary>
|
---|
| 32 | [StorableClass]
|
---|
| 33 | [Serializable]
|
---|
[5599] | 34 | [DataContract]
|
---|
[4905] | 35 | public class MessageContainer : IDeepCloneable {
|
---|
[4593] | 36 |
|
---|
| 37 | public enum MessageType {
|
---|
[5078] | 38 | // *** commands from hive server ***
|
---|
[5404] | 39 | CalculateJob, // slave should calculate a job. the job is already assigned to the slave
|
---|
[5078] | 40 | StopJob, // slave should stop the job and submit results
|
---|
[5450] | 41 | StopAll, // stop all and submit results
|
---|
[5078] | 42 | AbortJob, // slave should shut the job down immediately without submitting results
|
---|
[5450] | 43 | AbortAll, // slave should abort all jobs immediately
|
---|
| 44 | PauseJob, // pause the job and submit the results
|
---|
| 45 | PauseAll, // pause all jobs and submit results
|
---|
[5451] | 46 | Restart, // restart operation after Sleep
|
---|
| 47 | Sleep, // disconnect from server, but don't shutdown
|
---|
[5078] | 48 | ShutdownSlave, // slave should shutdown immediately without submitting results
|
---|
| 49 | SayHello, // Slave should say hello, because he is unknown to the server
|
---|
[4615] | 50 |
|
---|
[5078] | 51 | // *** commands from execution engine ***
|
---|
| 52 | AddChildJob, // adds a new child job for the provided jobId
|
---|
| 53 | GetChildJobs, // return all child jobs of the provided jobId
|
---|
| 54 | DeleteChildJobs, // delete all child jobs of the provided jobId
|
---|
[4593] | 55 | };
|
---|
| 56 |
|
---|
| 57 | [Storable]
|
---|
[5599] | 58 | [DataMember]
|
---|
[4593] | 59 | public MessageType Message { get; set; }
|
---|
[5599] | 60 |
|
---|
[4593] | 61 | [Storable]
|
---|
[5599] | 62 | [DataMember]
|
---|
[4593] | 63 | public Guid JobId { get; set; }
|
---|
| 64 |
|
---|
[4796] | 65 | protected MessageContainer() { }
|
---|
[4593] | 66 | public MessageContainer(MessageType message) {
|
---|
| 67 | Message = message;
|
---|
| 68 | JobId = Guid.Empty;
|
---|
| 69 | }
|
---|
| 70 | public MessageContainer(MessageType message, Guid jobId) {
|
---|
| 71 | Message = message;
|
---|
| 72 | JobId = jobId;
|
---|
| 73 | }
|
---|
[4905] | 74 | protected MessageContainer(MessageContainer original, Cloner cloner) {
|
---|
| 75 | cloner.RegisterClonedObject(original, this);
|
---|
[4796] | 76 | this.Message = original.Message;
|
---|
| 77 | this.JobId = original.JobId;
|
---|
[4593] | 78 | }
|
---|
[4905] | 79 | public virtual IDeepCloneable Clone(Cloner cloner) {
|
---|
[4796] | 80 | return new MessageContainer(this, cloner);
|
---|
[4593] | 81 | }
|
---|
[4905] | 82 | public object Clone() {
|
---|
| 83 | return Clone(new Cloner());
|
---|
| 84 | }
|
---|
[4593] | 85 | }
|
---|
| 86 | }
|
---|