Esempio n. 1
0
        /// <summary>
        /// Captures a snapshot of the program state.
        /// </summary>
        /// <param name="traceStep">Trace step</param>
        internal void CaptureState(TraceStep traceStep)
        {
            var fingerprint     = PSharpRuntime.GetProgramState();
            var enabledMachines = PSharpRuntime.BugFinder.GetEnabledMachines();
            var state           = new State(fingerprint, enabledMachines, PSharpRuntime.LivenessChecker.GetMonitorStatus());

            if (traceStep.Type == TraceStepType.SchedulingChoice)
            {
                Output.Debug("<LivenessDebug> Captured program state '{0}' at " +
                             "scheduling choice.", fingerprint.GetHashCode());
            }
            else if (traceStep.Type == TraceStepType.NondeterministicChoice)
            {
                Output.Debug("<LivenessDebug> Captured program state '{0}' at nondeterministic " +
                             "choice '{1}'.", fingerprint.GetHashCode(), traceStep.Choice);
            }
            else if (traceStep.Type == TraceStepType.FairNondeterministicChoice)
            {
                Output.Debug("<LivenessDebug> Captured program state '{0}' at fair nondeterministic choice " +
                             "'{1}-{2}'.", fingerprint.GetHashCode(), traceStep.NondetId, traceStep.Choice);
            }

            var stateExists = this.StateMap.Values.Any(val => val.Fingerprint.Equals(fingerprint));

            this.StateMap.Add(traceStep, state);

            if (stateExists && PSharpRuntime.Configuration.CheckLiveness)
            {
                Output.Debug("<LivenessDebug> Detected potential infinite execution.");
                PSharpRuntime.LivenessChecker.CheckLivenessAtTraceCycle(state.Fingerprint, this.StateMap);
            }
        }
Esempio n. 2
0
 internal void AfterTableClientState(TableClientState triggerState, Action action)
 {
     OnTableClientState(triggerState, () => {
         PSharpRuntime.SendEvent(machineId, new GenericDispatchableEvent(), new ActionDispatchable(action));
         return(Task.CompletedTask);
     });
 }
Esempio n. 3
0
        protected async Task RunAsync(Func <IMachineRuntime, Task> test, Configuration configuration = null)
        {
            configuration = configuration ?? GetConfiguration();

            ILogger logger;

            if (configuration.IsVerbose)
            {
                logger = new TestOutputLogger(this.TestOutput, true);
            }
            else
            {
                logger = new NulLogger();
            }

            try
            {
                var runtime = PSharpRuntime.Create(configuration);
                runtime.SetLogger(logger);
                await test(runtime);
            }
            catch (Exception ex)
            {
                Assert.False(true, ex.Message + "\n" + ex.StackTrace);
            }
            finally
            {
                logger.Dispose();
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var runtime = PSharpRuntime.Create();

            Test.Execute(runtime);
            Console.ReadLine();
        }
Esempio n. 5
0
 internal override async Task HandleLinearizationPoint(IList <TableResult> successfulBatchResult)
 {
     PSharpRuntime.Assert(currentReferenceOutcome == null, "The call already reported a linearization point.");
     this.successfulBatchResult = successfulBatchResult;
     currentReferenceOutcome    = await Catching <StorageException> .Task(
         annotationProxy.AnnotateLastBackendCallAsync(currentReferenceCall, null));
 }
        public void TestCreateWithId5()
        {
            var r      = PSharpRuntime.Create();
            var failed = false;
            var tcs    = new TaskCompletionSource <bool>();

            r.OnFailure += delegate
            {
                failed = true;
                tcs.SetResult(false);
            };

            try
            {
                var m1 = r.CreateMachineIdFromName(typeof(M2), "M2");
                r.CreateMachine(m1, typeof(M2));
                r.CreateMachine(m1, typeof(M2));
            }
            catch (Exception)
            {
                failed = true;
                tcs.SetResult(false);
            }

            tcs.Task.Wait();
            Assert.True(failed);
        }
Esempio n. 7
0
        async Task RunCallAsync(TableCall originalCall, MirrorTableCall referenceCall)
        {
            // TODO: All assertions should show what the call was.
            // XXX: We currently have no way to detect incorrect interleaving of
            // backend calls and AnnotateLastOutgoingCall here.  Most incorrect
            // interleavings will cause an error on the TablesMachine, but some
            // may go undetected.
            // For now, we're not doing streaming queries at all, so we don't have
            // to worry about how to handle them.

            currentReferenceCall = referenceCall;
            object actualOutcome = await Catching <StorageException> .Task(originalCall(migratingTable));

            // Verify that successfulBatchResult was correct if specified.
            // (Ideally, we'd also catch if it isn't specified when it should
            // be, but that's less of a risk as it will likely cause ETag
            // mismatches anyway.)
            if (successfulBatchResult != null)
            {
                var successfulBatchOutcome = new Outcome <object, StorageException>(successfulBatchResult);
                PSharpRuntime.Assert(BetterComparer.Instance.Equals(successfulBatchOutcome, actualOutcome),
                                     "{0} incorrect successfulBatchResult:\n{1}\nExpected:\n{2}\n", machineId,
                                     BetterComparer.ToString(successfulBatchOutcome), BetterComparer.ToString(actualOutcome));
            }

            PSharpRuntime.Assert(currentReferenceOutcome != null, "The call completed without reporting a linearization point.");
            PSharpRuntime.Assert(BetterComparer.Instance.Equals(actualOutcome, currentReferenceOutcome),
                                 "{0} call outcome:\n{1}\nExpected:\n{2}\n", machineId,
                                 BetterComparer.ToString(actualOutcome), BetterComparer.ToString(currentReferenceOutcome));

            // Reset fields
            currentReferenceCall    = null;
            successfulBatchResult   = null;
            currentReferenceOutcome = null;
        }
        public void Monitor_should_notify_safety_bug_if_it_is_existing()
        {
            // Arrange
            var configuration = Configuration.Create().WithMonitorsInProductionEnabled();
            var runtime       = PSharpRuntime.Create(configuration);
            var runtimeHost   = HostInfo.NewRuntimeHost(runtime);
            var safetyMonitor = runtimeHost.New(MonitorInterface.Sender <ISafetyMonitorSender>().Bundler <ISafetyMonitorBundler>().Receiver <SafetyMonitorReceiver>());


            // Act
            var messages = new MessageCollection();

            safetyMonitor.Configure(new ConfigureSafetyMonitor(messages));

            var storageNodeId   = runtime.NewMachine(typeof(StorageNode));
            var storageNodeMock = new Mock <IStorageNodeSender>();

            storageNodeMock.SetupGet(_ => _.Id).Returns(storageNodeId);
            safetyMonitor.Handshake(new HandshakeSafetyMonitor(new[] { storageNodeMock.Object }));


            // Assert
            var expectedExType = typeof(PSharpRuntime).Assembly.GetTypes().First(_ => _.FullName == "Microsoft.PSharp.AssertionFailureException");

            Assert.Throws(expectedExType, () => safetyMonitor.Ack(new Ack()));
        }
Esempio n. 9
0
        static void Main(string[] args)
        {
            // Optional: increases verbosity level to see the P# runtime log.
            var configuration = Configuration.Create().WithVerbosityEnabled(2);

            // Creates a new P# runtime instance, and passes an optional configuration.
            var runtime = PSharpRuntime.Create(configuration);

            // Creates and installs a custom logger.
            ILogger myLogger = new MyLogger();

            runtime.SetLogger(myLogger);

            // Executes the P# program.
            Program.Execute(runtime);

            // Disposes the logger and removes it from the runtime.
            myLogger.Dispose();
            runtime.RemoveLogger();

            // The P# runtime executes asynchronously, so we wait
            // to not terminate the process.
            Console.WriteLine("Press Enter to terminate...");
            Console.ReadLine();
        }
Esempio n. 10
0
        public void TestProcessedOrDropped()
        {
            var config = Configuration.Create();

            config.EnableMonitorsInProduction = true;

            var runtime = PSharpRuntime.Create(config);
            var tcs     = new TaskCompletionSource <bool>();

            runtime.RegisterMonitor(typeof(Monitor3));
            runtime.InvokeMonitor(typeof(Monitor3), new E(tcs));

            runtime.OnFailure += delegate
            {
                Assert.True(false);
                tcs.SetResult(false);
            };

            runtime.OnEventDropped += delegate(Event e, MachineId target)
            {
                runtime.InvokeMonitor(typeof(Monitor3), new EventDropped());
            };

            var m = runtime.CreateMachine(typeof(M3c));

            runtime.CreateMachine(typeof(M3a), new E(m));
            runtime.CreateMachine(typeof(M3b), new E(m));
            tcs.Task.Wait(5000);
        }
Esempio n. 11
0
        public static void Main(String[] args)
        {
            var runtime = PSharpRuntime.Create();

            Program.Execute(runtime);
            Console.ReadLine();
        }
Esempio n. 12
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.RegisterMonitor(typeof(LivenessMonitor));
     runtime.CreateMachine(typeof(Environment));
     runtime.Wait();
     Console.WriteLine("Done!");
 }
Esempio n. 13
0
        /// <summary>
        /// Initializes the network provider.
        /// </summary>
        /// <param name="runtime">PSharpRuntime</param>
        /// <param name="applicationAssembly">ApplicationAssembly</param>
        public void Initialize(PSharpRuntime runtime, Assembly applicationAssembly)
        {
            this.Runtime             = runtime;
            this.ApplicationAssembly = applicationAssembly;

            //var channels = new Dictionary<string, IRemoteCommunication>();

            if (runtime.Configuration.ContainerId == 0)
            {
                Uri address = new Uri("http://" + this.IpAddress + ":" + this.Port + "/request/" + 1 + "/");

                WSHttpBinding   binding  = new WSHttpBinding();
                EndpointAddress endpoint = new EndpointAddress(address);

                this.Channel = ChannelFactory <IRemoteCommunication> .CreateChannel(binding, endpoint);
            }
            else
            {
                Uri address = new Uri("http://" + this.IpAddress + ":" + this.Port + "/request/" + 0 + "/");

                WSHttpBinding   binding  = new WSHttpBinding();
                EndpointAddress endpoint = new EndpointAddress(address);

                this.Channel = ChannelFactory <IRemoteCommunication> .CreateChannel(binding, endpoint);
            }
        }
        /// <summary>
        /// Creates a new machine of the given type with an optional payload.
        /// </summary>
        /// <param name="type">Type of the machine</param>
        /// <param name="payload">Optional payload</param>
        /// <returns>Machine id</returns>
        MachineId IRemoteCommunication.CreateMachine(string type, params Object[] payload)
        {
            Output.PrintLine("Received request to create machine of type {0}", type);
            var resolvedType = PSharpRuntime.AppAssembly.GetType(type);

            return(PSharpRuntime.CreateMachine(resolvedType, payload));
        }
Esempio n. 15
0
        public static void Execute(PSharpRuntime runtime)
        {
            var s = (StateImpl)PTesterCommandLine.main_s.Clone();

            s.UserBooleanChoice = delegate()
            {
                return(runtime.Random());
            };

            s.CreateMachineCallback = delegate(PrtImplMachine machine)
            {
                PTesterCommandLine.coverage.DeclareMachine(machine);
            };

            s.DequeueCallback = delegate(PrtImplMachine machine, string evName, string senderMachineName, string senderMachineStateName)
            {
                PTesterCommandLine.coverage.ReportDequeue(machine, evName, senderMachineName, senderMachineStateName);
            };

            s.StateTransitionCallback = delegate(PrtImplMachine machine, PrtState from, PrtState to, string reason)
            {
                PTesterCommandLine.coverage.ReportStateTransition(machine, from, to, reason);
            };

            PTesterCommandLine.currentImpl = s;

            runtime.CreateMachine(typeof(PSharpMachine), new MachineInitEvent(s));
        }
Esempio n. 16
0
        public void Monitor_should_not_notify_safety_bug_if_it_is_not_existing()
        {
            // Arrange
            var configuration = Configuration.Create().WithMonitorsInProductionEnabled();
            var runtime       = PSharpRuntime.Create(configuration);
            var runtimeHost   = HostInfo.NewRuntimeHost(runtime);
            var safetyMonitor = runtimeHost.New(MonitorInterface.Sender <ISafetyMonitorSender>().Bundler <ISafetyMonitorBundler>().Receiver <SafetyMonitorReceiver>());


            // Act
            var messages = new MessageCollection();

            safetyMonitor.Configure(new ConfigureSafetyMonitor(messages));

            var storageNodeId   = runtime.NewMachine(typeof(StorageNode));
            var storageNodeMock = new Mock <IStorageNodeSender>();

            storageNodeMock.SetupGet(_ => _.Id).Returns(storageNodeId);
            safetyMonitor.Handshake(new HandshakeSafetyMonitor(new[] { storageNodeMock.Object }));

            safetyMonitor.LogUpdated(new LogUpdated(storageNodeMock.Object, 42));


            // Assert
            Assert.DoesNotThrow(() => safetyMonitor.Ack(new Ack()));
        }
        public void TestNoMemoryLeakInEventSending()
        {
            var runtime = PSharpRuntime.Create();

            Program.Execute(runtime);
            runtime.Wait();
        }
Esempio n. 18
0
        static string StartClients(string sctx, SynchronizedLogger logger, out DomainCommunicationProvider clientsNetworkProvider)
        {
            var configuration = Configuration.Create().WithMonitorsInProductionEnabled().WithVerbosityEnabled(2);
            var runtime       = PSharpRuntime.Create(configuration);
            var runtimeHost   = HostInfo.NewRuntimeHost(runtime);

            clientsNetworkProvider = new DomainCommunicationProvider(runtimeHost, "clients");
            runtimeHost.SetNetworkProvider(clientsNetworkProvider);
            runtimeHost.SetLogger(logger);

            var messages = new MessageCollection();

            messages.CollectionChanged += (sender, e) => logger.WriteLine(e.NewItems[0].ToString());
            var ctx = sctx.FromJson <DistributedStorageContext>();

            var synchronizable = Synchronizable.Empty();

            foreach (var storageNode in ctx.StorageNodes)
            {
                var waitIfHandledReplReq = logger.MachineActionHandledWait((machineId, _, actionName) => Equals(machineId, storageNode.Id) && actionName == "HandleReplReq");
                synchronizable = synchronizable.Then(waitIfHandledReplReq.Delay(10));
            }
            logger.ApplySynchronization(synchronizable);

            NewClients(runtimeHost, ctx, messages);
            logger.WaitForWriting(6000);
            return(ctx.ToJson());
        }
Esempio n. 19
0
        public void TestNoMemoryLeakAfterHalt()
        {
            var runtime = PSharpRuntime.Create();

            Program.Execute(runtime);
            runtime.Wait();
        }
Esempio n. 20
0
        public void Context_should_return_same_Machine_if_it_is_in_local_and_single_application()
        {
            // Arrange
            var ctx      = default(DistributedStorageContext);
            var expected = default(int);
            var actual   = default(int);

            // Act
            {
                var configuration = Configuration.Create();
                var runtime       = PSharpRuntime.Create(configuration);
                var runtimeHost   = HostInfo.NewRuntimeHost(runtime);

                ctx        = runtimeHost.New <DistributedStorageContext>();
                ctx.Server = runtimeHost.New(MachineInterface.Sender <IServerSender>().Bundler <IServerBundler>().Receiver <ServerReceiverWithoutBug>());
                expected   = RuntimeHelpers.GetHashCode(ctx.Server);
            }

            {
                actual = RuntimeHelpers.GetHashCode(ctx.Server);
            }


            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 21
0
        public void Context_should_return_same_Machine_if_it_is_in_remote_and_single_application()
        {
            // Arrange
            var expected  = default(int);
            var actual    = default(int);
            var parameter = default(string);

            // Act
            {
                var configuration = Configuration.Create();
                var runtime       = PSharpRuntime.Create(configuration);
                var runtimeHost   = HostInfo.NewRuntimeHost(runtime);

                var ctx = runtimeHost.New <DistributedStorageContext>();
                ctx.Server = runtimeHost.New(MachineInterface.Sender <IServerSender>().Bundler <IServerBundler>().Receiver <ServerReceiverWithoutBug>());
                expected   = RuntimeHelpers.GetHashCode(ctx.Server);
                parameter  = ctx.ToJson();
            }

            GC.Collect();
            GC.WaitForPendingFinalizers();
            GC.Collect();

            {
                var ctx = parameter.FromJson <DistributedStorageContext>();
                actual = RuntimeHelpers.GetHashCode(ctx.Server);
            }


            // Assert
            Assert.AreEqual(expected, actual);
        }
Esempio n. 22
0
        public void Machine_can_be_created_faster_than_the_first_time()
        {
            AppDomain.CurrentDomain.RunAtIsolatedDomain(() =>
            {
                // Arrange
                var configuration = Configuration.Create();
                var runtime       = PSharpRuntime.Create(configuration);
                var runtimeHost   = HostInfo.NewRuntimeHost(runtime);


                // Act
                var sw1 = Stopwatch.StartNew();
                runtimeHost.New(MachineInterface.Sender <IServerSender>().Bundler <IServerBundler>().Receiver <ServerReceiverWithoutBug>());
                var elapsed1 = sw1.ElapsedTicks;

                var sw10 = Stopwatch.StartNew();
                for (var i = 0; i < 10; i++)
                {
                    runtimeHost.New(MachineInterface.Sender <IServerSender>().Bundler <IServerBundler>().Receiver <ServerReceiverWithoutBug>());
                }
                var elapsed10 = sw10.ElapsedTicks;


                // Assert
                Assert.Less(elapsed10, elapsed1 / 10);
            });
        }
Esempio n. 23
0
        public void TestAssertFailureEventHandler()
        {
            var tcsFail = new TaskCompletionSource <bool>();
            int count   = 0;

            PSharpRuntime runtime = PSharpRuntime.Create();

            runtime.OnFailure += delegate(Exception exception)
            {
                if (!(exception is MachineActionExceptionFilterException))
                {
                    count++;
                    tcsFail.SetException(exception);
                }
            };

            var tcs = new TaskCompletionSource <bool>();

            runtime.CreateMachine(typeof(M), new Configure(tcs));
            tcs.Task.Wait();
            Task.Delay(10).Wait(); // give it some time

            AggregateException ex = Assert.Throws <AggregateException>(() => tcsFail.Task.Wait());

            Assert.IsType <AssertionFailureException>(ex.InnerException);
            Assert.Equal(1, count);
        }
Esempio n. 24
0
        public void TestUnhandledExceptionEventHandler()
        {
            var  tcsFail            = new TaskCompletionSource <bool>();
            int  count              = 0;
            bool sawFilterException = false;

            PSharpRuntime runtime = PSharpRuntime.Create();

            runtime.OnFailure += delegate(Exception exception)
            {
                // This test throws an exception that we should receive a filter call for
                if (exception is MachineActionExceptionFilterException)
                {
                    sawFilterException = true;
                    return;
                }
                count++;
                tcsFail.SetException(exception);
            };

            var tcs = new TaskCompletionSource <bool>();

            runtime.CreateMachine(typeof(N), new Configure(tcs));
            tcs.Task.Wait();
            Task.Delay(10).Wait(); // give it some time

            AggregateException ex = Assert.Throws <AggregateException>(() => tcsFail.Task.Wait());

            Assert.IsType <AssertionFailureException>(ex.InnerException);
            Assert.IsType <InvalidOperationException>(ex.InnerException.InnerException);
            Assert.Equal(1, count);
            Assert.True(sawFilterException);
        }
Esempio n. 25
0
        public void TestNullCustomLoggerFail()
        {
            PSharpRuntime runtime = PSharpRuntime.Create();

            InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() => runtime.SetLogger(null));

            Assert.Equal("Cannot install a null logger.", ex.Message);
        }
Esempio n. 26
0
        static void Main(string[] args)
        {
            var configuration = Configuration.Create().WithVerbosityEnabled(1);
            var runtime       = PSharpRuntime.Create(configuration);

            Execute(runtime);
            Console.ReadLine();
        }
Esempio n. 27
0
 void DispatchTableCall()
 {
     numTableCalls++;
     // Crude liveness check, since a monitor did not work (see below).
     PSharpRuntime.Assert(numTableCalls <= MigrationModel.TABLE_CALL_LIMIT,
                          "A service machine may be in an infinite loop.");
     DispatchPayload();
 }
Esempio n. 28
0
        public void TestAssertFailureNoEventHandler()
        {
            PSharpRuntime runtime = PSharpRuntime.Create();
            var           tcs     = new TaskCompletionSource <bool>();

            runtime.CreateMachine(typeof(M), new Configure(tcs));
            tcs.Task.Wait();
        }
        public void TestCreateWithId9()
        {
            var r  = PSharpRuntime.Create();
            var m1 = r.CreateMachineIdFromName(typeof(M4), "M4");
            var m2 = r.CreateMachineIdFromName(typeof(M4), "M4");

            Assert.True(m1.Equals(m2));
        }
Esempio n. 30
0
 public static void Execute(PSharpRuntime runtime)
 {
     // Monitors must be registered before the first P# machine
     // gets created (which will kickstart the runtime).
     runtime.RegisterMonitor(typeof(Safety));
     runtime.RegisterMonitor(typeof(Liveness));
     runtime.CreateMachine(typeof(Driver), new Driver.Config(2));
 }
Esempio n. 31
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(Server), "TheUltimateServerMachine");
 }
Esempio n. 32
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.RegisterMonitor(typeof(WatchDog));
     runtime.CreateMachine(typeof(EventHandler));
 }
Esempio n. 33
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="type">Type</param>
        /// <param name="runtime">PSharpRuntime</param>
        internal MachineId(Type type, PSharpRuntime runtime)
        {
            this.Runtime = runtime;

            lock (MachineId.TypeIdCounter)
            {
                if (!MachineId.TypeIdCounter.ContainsKey(type))
                {
                    MachineId.TypeIdCounter.Add(type, 0);
                }

                this.Value = MachineId.IdCounter++;
                this.Type = type.Name;
                this.MVal = MachineId.TypeIdCounter[type]++;
                this.IpAddress = "";
                this.Port = "";
            }
        }
Esempio n. 34
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(Environment));
 }
Esempio n. 35
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(Environment),
         new Environment.Config(Test.NumOfNodes));
 }
Esempio n. 36
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="runtime">PSharpRuntime</param>
 public DefaultNetworkProvider(PSharpRuntime runtime)
 {
     this.Runtime = runtime;
     this.LocalEndPoint = "";
 }
Esempio n. 37
0
 public static void Execute(PSharpRuntime runtime)
 {
     // The type "A" is visible to IntelliSense
     // (after building once)
     runtime.CreateMachine(typeof(A));
 }
Esempio n. 38
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(Broker), new Broker.Config(10));
 }
Esempio n. 39
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(EventHandler));
 }
Esempio n. 40
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(ClusterManager));
 }
Esempio n. 41
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.RegisterMonitor(typeof(InvariantMonitor));
     runtime.RegisterMonitor(typeof(ServerResponseSeqMonitor));
     runtime.CreateMachine(typeof(Environment));
 }
Esempio n. 42
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(TwoPhaseCommit));
 }
Esempio n. 43
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="type">Machine type</param>
        /// <param name="friendlyName">Friendly machine name</param>
        /// <param name="runtime">PSharpRuntime</param>
        internal MachineId(Type type, string friendlyName, PSharpRuntime runtime)
        {
            this.FriendlyName = friendlyName;
            this.Runtime = runtime;

            this.Type = type.FullName;
            this.EndPoint = this.Runtime.NetworkProvider.GetLocalEndPoint();

            this.Value = Interlocked.Increment(ref IdCounter);

            if (this.FriendlyName != null && this.FriendlyName.Length > 0)
            {
                this.Name = string.Format("{0}({1})", this.FriendlyName, this.Value);
            }
            else
            {
                this.Name = string.Format("{0}({1})", this.Type, this.Value);
            }
        }
Esempio n. 44
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(Receiver));
 }
Esempio n. 45
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(TaskCreator));
 }
 public static void Send(PSharpRuntime runtime, MachineId target)
 {
     runtime.SendEvent(target, new E1(2));
 }
Esempio n. 47
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.RegisterMonitor(typeof(SafetyMonitor));
     runtime.CreateMachine(typeof(ClusterManager));
 }
        /// <summary>
        /// Initializes the network provider.
        /// </summary>
        /// <param name="runtime">PSharpRuntime</param>
        /// <param name="applicationAssembly">ApplicationAssembly</param>
        public void Initialize(PSharpRuntime runtime, Assembly applicationAssembly)
        {
            this.Runtime = runtime;
            this.ApplicationAssembly = applicationAssembly;

            //var channels = new Dictionary<string, IRemoteCommunication>();

            if (runtime.Configuration.ContainerId == 0)
            {
                Uri address = new Uri("http://" + this.IpAddress + ":" + this.Port + "/request/" + 1 + "/");

                WSHttpBinding binding = new WSHttpBinding();
                EndpointAddress endpoint = new EndpointAddress(address);

                this.Channel = ChannelFactory<IRemoteCommunication>.CreateChannel(binding, endpoint);
            }
            else
            {
                Uri address = new Uri("http://" + this.IpAddress + ":" + this.Port + "/request/" + 0 + "/");

                WSHttpBinding binding = new WSHttpBinding();
                EndpointAddress endpoint = new EndpointAddress(address);

                this.Channel = ChannelFactory<IRemoteCommunication>.CreateChannel(binding, endpoint);
            }
        }
Esempio n. 49
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="runtime">PSharpRuntime</param>
 /// <param name="machineTasks">Machine tasks</param>
 internal TaskWrapperScheduler(PSharpRuntime runtime, ConcurrentBag<Task> machineTasks)
 {
     this.Runtime = runtime;
     this.MachineTasks = machineTasks;
     this.WrappedTasks = new ConcurrentBag<Task>();
 }
Esempio n. 50
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(Employee));
 }
Esempio n. 51
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.RegisterMonitor(typeof(M));
     runtime.CreateMachine(typeof(Environment));
 }
Esempio n. 52
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.RegisterMonitor(typeof(ValMachineCheck));
     runtime.CreateMachine(typeof(GodMachine));
 }
Esempio n. 53
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="runtime">PSharpRuntime</param>
 /// <param name="machineTasks">Machine tasks</param>
 internal TaskWrapperScheduler(PSharpRuntime runtime, List<Task> machineTasks)
 {
     this.Runtime = runtime;
     this.MachineTasks = machineTasks;
     this.WrappedTasks = new List<Task>();
 }
Esempio n. 54
0
 /// <summary>
 /// Initializes the P# runtime.
 /// </summary>
 private static void InitializePSharpRuntime()
 {
     Container.PSharpRuntime = PSharpRuntime.Create(Container.Configuration, Container.NetworkProvider);
     Container.NetworkProvider.Initialize(Container.PSharpRuntime, Container.RemoteApplicationAssembly);
     Container.NotifyManagerInitialization();
 }
Esempio n. 55
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(Driver), new Driver.Config(30));
 }
Esempio n. 56
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.RegisterMonitor(typeof(LivenessMonitor));
     runtime.CreateMachine(typeof(M));
 }
Esempio n. 57
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(Simulation),
         new Simulation.Config(Test.NumOfBodies, Test.NumOfSteps));
 }
Esempio n. 58
0
 public static void Execute(PSharpRuntime runtime)
 {
     runtime.CreateMachine(typeof(Program));
 }
Esempio n. 59
0
 /// <summary>
 /// Sets the id of this machine.
 /// </summary>
 /// <param name="mid">MachineId</param>
 internal void SetMachineId(MachineId mid)
 {
     this.Id = mid;
     this.Runtime = mid.Runtime;
 }