Skip to content

Commit

Permalink
merging ActorRuntime with ControlledRuntime
Browse files Browse the repository at this point in the history
  • Loading branch information
Christine Zhou committed Aug 16, 2024
1 parent 645624d commit f4a4f76
Show file tree
Hide file tree
Showing 15 changed files with 941 additions and 750 deletions.
5 changes: 3 additions & 2 deletions Src/PChecker/CheckerCore/Actors/ActorId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Globalization;
using System.Runtime.Serialization;
using PChecker.SystematicTesting;

namespace PChecker.Actors
{
Expand Down Expand Up @@ -62,7 +63,7 @@ public sealed class ActorId : IEquatable<ActorId>, IComparable<ActorId>
/// <summary>
/// Initializes a new instance of the <see cref="ActorId"/> class.
/// </summary>
internal ActorId(Type type, string name, ActorRuntime runtime, bool useNameForHashing = false)
internal ActorId(Type type, string name, ControlledRuntime runtime, bool useNameForHashing = false)
{
Runtime = runtime;
Endpoint = string.Empty;
Expand Down Expand Up @@ -97,7 +98,7 @@ internal ActorId(Type type, string name, ActorRuntime runtime, bool useNameForHa
/// <summary>
/// Bind the actor id.
/// </summary>
internal void Bind(ActorRuntime runtime)
internal void Bind(ControlledRuntime runtime)
{
Runtime = runtime;
}
Expand Down
1,212 changes: 606 additions & 606 deletions Src/PChecker/CheckerCore/Actors/ActorRuntime.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Src/PChecker/CheckerCore/Actors/Logging/JsonWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ public JsonWriter()

/// <summary>
/// Enum representing the different log types the JSON error trace logs.
/// Referenced from PLogFormatter.cs and ActorRuntimeLogTextFormatter.cs
/// Referenced from PLogFormatter.cs and PCheckerLogTextFormatter.cs
/// to see what those formatter logs. Check IActorRuntimeLog.cs to see
/// each log types' description and when they are invoked.
/// </summary>
Expand Down
16 changes: 8 additions & 8 deletions Src/PChecker/CheckerCore/Actors/Logging/LogWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ internal TextWriter SetLogger(TextWriter logger)
{
Logger = TextWriter.Null;

var textLog = GetLogsOfType<ActorRuntimeLogTextFormatter>().FirstOrDefault();
var textLog = GetLogsOfType<PCheckerLogTextFormatter>().FirstOrDefault();
if (textLog != null)
{
textLog.Logger = Logger;
Expand All @@ -573,17 +573,17 @@ internal TextWriter SetLogger(TextWriter logger)
/// <param name="jsonLogger">The jsonLogger instance created from runtime before running tests.</param>
internal void SetJsonLogger(JsonWriter jsonLogger) => JsonLogger = jsonLogger;

private ActorRuntimeLogTextFormatter GetOrCreateTextLog()
private PCheckerLogTextFormatter GetOrCreateTextLog()
{
var textLog = GetLogsOfType<ActorRuntimeLogTextFormatter>().FirstOrDefault();
var textLog = GetLogsOfType<PCheckerLogTextFormatter>().FirstOrDefault();
if (textLog == null)
{
if (Logger == null)
{
Logger = new ConsoleLogger();
}

textLog = new ActorRuntimeLogTextFormatter
textLog = new PCheckerLogTextFormatter
{
Logger = Logger
};
Expand All @@ -605,9 +605,9 @@ internal void RegisterLog(IActorRuntimeLog log)
}

// Make sure we only have one text logger
if (log is ActorRuntimeLogTextFormatter a)
if (log is PCheckerLogTextFormatter a)
{
var textLog = GetLogsOfType<ActorRuntimeLogTextFormatter>().FirstOrDefault();
var textLog = GetLogsOfType<PCheckerLogTextFormatter>().FirstOrDefault();
if (textLog != null)
{
Logs.Remove(textLog);
Expand All @@ -619,9 +619,9 @@ internal void RegisterLog(IActorRuntimeLog log)
}
}

// If log is or of subclass ActorRuntimeLogJsonFormatter (i.e. when log is PJsonFormatter),
// If log is or of subclass PCheckerLogJsonFormatter (i.e. when log is PJsonFormatter),
// update the Writer reference to the JsonLogger instance defined within LogWriter.cs
if (log is ActorRuntimeLogJsonFormatter tempJsonFormatter)
if (log is PCheckerLogJsonFormatter tempJsonFormatter)
{
tempJsonFormatter.Writer = JsonLogger;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ namespace PChecker.Actors.Logging
/// <summary>
/// This class implements IActorRuntimeLog and generates log output in an XML format.
/// </summary>
public class ActorRuntimeLogJsonFormatter : IActorRuntimeLog
public class PCheckerLogJsonFormatter : IActorRuntimeLog
{
/// <summary>
/// Get or set the JsonWriter to write to.
/// </summary>
public JsonWriter Writer { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="ActorRuntimeLogJsonFormatter"/> class.
/// Initializes a new instance of the <see cref="PCheckerLogJsonFormatter"/> class.
/// </summary>
protected ActorRuntimeLogJsonFormatter()
protected PCheckerLogJsonFormatter()
{
Writer = new JsonWriter();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ namespace PChecker.Actors.Logging
/// <summary>
/// This class implements IActorRuntimeLog and generates output in a a human readable text format.
/// </summary>
public class ActorRuntimeLogTextFormatter : IActorRuntimeLog
public class PCheckerLogTextFormatter : IActorRuntimeLog
{
/// <summary>
/// Get or set the TextWriter to write to.
/// </summary>
public TextWriter Logger { get; set; }

/// <summary>
/// Initializes a new instance of the <see cref="ActorRuntimeLogTextFormatter"/> class.
/// Initializes a new instance of the <see cref="PCheckerLogTextFormatter"/> class.
/// </summary>
public ActorRuntimeLogTextFormatter()
public PCheckerLogTextFormatter()
{
Logger = new ConsoleLogger();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ namespace PChecker.Actors.Logging
/// <summary>
/// This class implements IActorRuntimeLog and generates log output in an XML format.
/// </summary>
internal class ActorRuntimeLogXmlFormatter : IActorRuntimeLog
internal class PCheckerLogXmlFormatter : IActorRuntimeLog
{
private readonly XmlWriter Writer;
private bool Closed;

public ActorRuntimeLogXmlFormatter(XmlWriter writer)
public PCheckerLogXmlFormatter(XmlWriter writer)
{
Writer = writer;
Writer.WriteStartElement("Log");
Expand Down
5 changes: 3 additions & 2 deletions Src/PChecker/CheckerCore/Actors/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using PChecker.Actors.StateTransitions;
using PChecker.Exceptions;
using PChecker.IO.Debugging;
using PChecker.SystematicTesting;
using EventInfo = PChecker.Actors.Events.EventInfo;


Expand All @@ -34,7 +35,7 @@ public abstract class StateMachine
/// <summary>
/// The runtime that executes this state machine.
/// </summary>
internal ActorRuntime Runtime { get; private set; }
internal ControlledRuntime Runtime { get; private set; }

/// <summary>
/// Unique id that identifies this state machine.
Expand Down Expand Up @@ -155,7 +156,7 @@ protected StateMachine()
/// <summary>
/// Configures the state machine.
/// </summary>
internal void Configure(ActorRuntime runtime, ActorId id, IStateMachineManager manager, IEventQueue inbox)
internal void Configure(ControlledRuntime runtime, ActorId id, IStateMachineManager manager, IEventQueue inbox)
{
Runtime = runtime;
Id = id;
Expand Down
48 changes: 0 additions & 48 deletions Src/PChecker/CheckerCore/Actors/StateMachineFactory.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Src/PChecker/CheckerCore/PRuntime/PJsonFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace PChecker.PRuntime
/// <summary>
/// This class implements IActorRuntimeLog and generates log output in an XML format.
/// </summary>
public class PJsonFormatter : ActorRuntimeLogJsonFormatter
public class PJsonFormatter : PCheckerLogJsonFormatter
{

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Src/PChecker/CheckerCore/PRuntime/PLogFormatter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace PChecker.PRuntime
/// <summary>
/// Formatter for the runtime log.
/// </summary>
public class PLogFormatter : ActorRuntimeLogTextFormatter
public class PLogFormatter : PCheckerLogTextFormatter
{
public PLogFormatter() : base()
{
Expand Down
4 changes: 3 additions & 1 deletion Src/PChecker/CheckerCore/Runtime/RuntimeFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using PChecker.Actors;
using PChecker.Random;
using PChecker.SystematicTesting;
using PChecker.SystematicTesting.Strategies.Probabilistic;

namespace PChecker.Runtime
{
Expand Down Expand Up @@ -66,7 +68,7 @@ private static CoyoteRuntime CreateWithConfiguration(CheckerConfiguration checke
}

var valueGenerator = new RandomValueGenerator(checkerConfiguration);
return new ActorRuntime(checkerConfiguration, valueGenerator);
return new ControlledRuntime(checkerConfiguration, valueGenerator);
}
}
}
5 changes: 3 additions & 2 deletions Src/PChecker/CheckerCore/Specifications/Monitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using PChecker.Actors.Logging;
using PChecker.Actors.StateTransitions;
using PChecker.Exceptions;
using PChecker.SystematicTesting;

namespace PChecker.Specifications.Monitors
{
Expand Down Expand Up @@ -61,7 +62,7 @@ public abstract class Monitor
/// <summary>
/// The runtime that executes this monitor.
/// </summary>
private ActorRuntime Runtime;
private ControlledRuntime Runtime;

/// <summary>
/// The active monitor state.
Expand Down Expand Up @@ -172,7 +173,7 @@ protected Monitor()
/// Initializes this monitor.
/// </summary>
/// <param name="runtime">The runtime that executes this monitor.</param>
internal void Initialize(ActorRuntime runtime)
internal void Initialize(ControlledRuntime runtime)
{
Runtime = runtime;
}
Expand Down
Loading

0 comments on commit f4a4f76

Please sign in to comment.