#region License Information
/* HeuristicLab
* Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using System;
using System.Runtime.Serialization;
using HEAL.Attic;
using HeuristicLab.Common;
namespace HeuristicLab.Services.Hive {
///
/// The MessageContainer is a container class for Messages. Its two parts are:
/// the actual message itself and the TaskId, refered by the message
///
[StorableType("67DEE81F-81FA-4B47-B043-93DBC2028DB5")]
[Serializable]
[DataContract]
public class MessageContainer : IDeepCloneable {
[StorableType("A907BDB0-99E3-4EE2-BA31-72FFD29F7B19")]
public enum MessageType {
// *** commands from hive server ***
CalculateTask, // slave should calculate a task. the task is already assigned to the slave
StopTask, // slave should stop the task and submit results
StopAll, // stop all and submit results
AbortTask, // slave should shut the task down immediately without submitting results
AbortAll, // slave should abort all task immediately
PauseTask, // pause the task and submit the results
PauseAll, // pause all task and submit results
Restart, // restart operation after Sleep
Sleep, // disconnect from server, but don't shutdown
ShutdownSlave, // slave should shutdown immediately without submitting results
SayHello, // Slave should say hello, because job is unknown to the server
NewHBInterval, // change the polling to a new interval
ShutdownComputer, // shutdown the computer the slave runs on
};
[Storable]
[DataMember]
public MessageType Message { get; set; }
[Storable]
[DataMember]
public Guid TaskId { get; set; }
[StorableConstructor]
protected MessageContainer(StorableConstructorFlag _) { }
protected MessageContainer() { }
public MessageContainer(MessageType message) {
Message = message;
TaskId = Guid.Empty;
}
public MessageContainer(MessageType message, Guid jobId) {
Message = message;
TaskId = jobId;
}
protected MessageContainer(MessageContainer original, Cloner cloner) {
cloner.RegisterClonedObject(original, this);
this.Message = original.Message;
this.TaskId = original.TaskId;
}
public virtual IDeepCloneable Clone(Cloner cloner) {
return new MessageContainer(this, cloner);
}
public object Clone() {
return Clone(new Cloner());
}
}
}