Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Services.Hive/3.3/MessageContainer.cs @ 17475

Last change on this file since 17475 was 17181, checked in by swagner, 5 years ago

#2875: Merged r17180 from trunk to stable

File size: 3.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 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.Runtime.Serialization;
24using HEAL.Attic;
25using HeuristicLab.Common;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Services.Hive {
29  /// <summary>
30  /// The MessageContainer is a container class for Messages. Its two parts are:
31  /// the actual message itself and the TaskId, refered by the message
32  /// </summary>
33  [StorableClass]
34  [Serializable]
35  [DataContract]
36  public class MessageContainer : IDeepCloneable {
37
38    public enum MessageType {
39      // *** commands from hive server ***
40      CalculateTask, // slave should calculate a task. the task is already assigned to the slave
41      StopTask,   // slave should stop the task and submit results
42      StopAll,   // stop all and submit results
43      AbortTask,  // slave should shut the task down immediately without submitting results
44      AbortAll,  // slave should abort all task immediately
45      PauseTask,  // pause the task and submit the results   
46      PauseAll,  // pause all task and submit results
47      Restart,   // restart operation after Sleep
48      Sleep,     // disconnect from server, but don't shutdown
49      ShutdownSlave,  // slave should shutdown immediately without submitting results
50      SayHello,  // Slave should say hello, because job is unknown to the server
51      NewHBInterval, // change the polling to a new interval
52      ShutdownComputer, // shutdown the computer the slave runs on
53    };
54
55    [Storable]
56    [DataMember]
57    public MessageType Message { get; set; }
58
59    [Storable]
60    [DataMember]
61    public Guid TaskId { get; set; }
62
63    [StorableConstructor]
64    protected MessageContainer(bool deserializing) { }
65    protected MessageContainer() { }
66    public MessageContainer(MessageType message) {
67      Message = message;
68      TaskId = Guid.Empty;
69    }
70    public MessageContainer(MessageType message, Guid jobId) {
71      Message = message;
72      TaskId = jobId;
73    }
74    protected MessageContainer(MessageContainer original, Cloner cloner) {
75      cloner.RegisterClonedObject(original, this);
76      this.Message = original.Message;
77      this.TaskId = original.TaskId;
78    }
79    public virtual IDeepCloneable Clone(Cloner cloner) {
80      return new MessageContainer(this, cloner);
81    }
82    public object Clone() {
83      return Clone(new Cloner());
84    }
85  }
86}
Note: See TracBrowser for help on using the repository browser.