Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2924_DotNetCoreMigration/HeuristicLab.PluginInfrastructure/3.3/Isolation/RunnerMessage.cs @ 17025

Last change on this file since 17025 was 17013, checked in by dpiringe, 5 years ago

#2924:

  • some changes in CLIApplication.cs to reduce unnecessary allocation of string objects
  • renamed AppTest to ConsoleOptimizer and fixed race condition
  • replaced enum RunnerJob with class RunnerMessage for more control of saved data
  • changed usage of BinaryFormatter with HEAL.Attic, following types are now Storable:
    • ConsoleOptimizer
    • InspectApplication
    • ApplicationBase
    • ApplicationRunner
    • AssemblyInfo
    • Runner
    • UniPath
    • RunnerMessage
  • switched QuietMode from ApplicationRunner to IRunner
  • DockerRunnerHost can now automatically build docker images for linux and windows containers (also identifies which container type is active) -> removes the condition to have the image preinstalled
    • to achieve this, there are two new folders DockerLinuxBuild and DockerWindowsBuild included in build output, which include Dockerfiles to build images for linux and windows container
  • added NuGet package System.CodeDom to project HeuristicLab.Scripting-3.3
  • added method Send(RunnerMessage) to IRunnerHost and transferred methods Pause and Resume to IRunner
  • added internal reference of RunnerHost in Runner
  • added abstract method SendMessage(RunnerMessage) in RunnerHost which gets called from method Send(RunnerMessage)
  • because of a Google.Protobuf "bug", RunnerMessages cannot get serialized/deserialized directly on stream -> workaround with a byte array, which gets written and read
    • additionally, the length of the array gets sent first (length as integer -> 4 bytes)
    • static method in RunnerMessage to read a message from a stream
    • the method SendMessage(RunnerMessage) in RunnerHost implements this functionality
File size: 1.7 KB
Line 
1using System;
2using System.IO;
3using HEAL.Attic;
4
5namespace HeuristicLab.PluginInfrastructure {
6
7  [StorableType(StorableMemberSelection.MarkedOnly, "081DC79E-1E57-49A2-AB25-D9AC42A40911")]
8  public class RunnerMessage {
9    private static ProtoBufSerializer serializer = new ProtoBufSerializer();
10    public static RunnerMessage ReadMessageFromStream(Stream stream) {
11      byte[] buf = new byte[4];
12      stream.Read(buf, 0, buf.Length);
13      int bufSize = BitConverter.ToInt32(buf, 0);
14      buf = new byte[bufSize];
15      stream.Read(buf, 0, buf.Length);
16      return (RunnerMessage)serializer.Deserialize(buf);
17    }
18
19    /// <summary>
20    /// This will get set from the RunnerHost and helps to identify the correct message flow.
21    /// </summary>
22    [Storable]
23    public DateTime SendTime { get; set; }
24  }
25
26
27  [StorableType(StorableMemberSelection.AllProperties, "84771CF3-46CA-4D0B-96D1-7F2E8EAC50B7")]
28  public class PauseRunnerMessage : RunnerMessage { }
29
30
31  [StorableType(StorableMemberSelection.AllProperties, "FE2AEE66-E2A2-4DE1-8E60-C116F084D2AA")]
32  public class ResumeRunnerMessage : RunnerMessage { }
33
34
35  [StorableType(StorableMemberSelection.AllProperties, "2C836B74-C28B-4F4A-9645-E1ED5F4415A7")]
36  public class CancelRunnerMessage : RunnerMessage { }
37
38
39  [StorableType(StorableMemberSelection.AllProperties, "2D8D1D8F-58D4-4D92-BB15-62DF55DC0459")]
40  public class TransportRunnerMessage : RunnerMessage {
41    public IRunner Runner { get; set; }
42    public TransportRunnerMessage(IRunner runner) => Runner = runner;
43
44    [StorableConstructor]
45    private TransportRunnerMessage(StorableConstructorFlag _) { }
46  }
47
48}
Note: See TracBrowser for help on using the repository browser.