Exemplo n.º 1
0
            public override void ExecuteInPrimary(BasicStateMachine basicStateMachine, ref bool saveState)
            {
                if (basicStateMachine == null)
                {
                    throw new ArgumentNullException(nameof(basicStateMachine));
                }

                base.ExecuteInPrimary(basicStateMachine, ref saveState);

                this.action();
            }
Exemplo n.º 2
0
            public virtual void ExecuteInSecondary(BasicStateMachine basicStateMachine, ref bool saveState)
            {
                if (basicStateMachine == null)
                {
                    throw new ArgumentNullException(nameof(basicStateMachine));
                }

                saveState = false;

                basicStateMachine.commands.Add(this);
            }
Exemplo n.º 3
0
            public static BasicStateMachine CreateSM(int instance, bool designatedPrimary, TestConfig cfg, TestTracer tracer)
            {
                ManagedRSLNode[] nodes = new ManagedRSLNode[cfg.Ports.Length / 2];
                for (int i = 0; i < nodes.Length; i++)
                {
                    nodes[i] = BasicStateMachine.CreateNode(cfg.Ports[2 * i], cfg.Ports[(2 * i) + 1]);
                }

                BasicStateMachine sm = new BasicStateMachine(tracer, nodes[instance].RslPort, nodes[instance].RslLearnPort);

                try
                {
                    sm.CanBP = designatedPrimary;

                    using (ManagedRSLConfigParam rslCfg = SetupConfiguration(cfg.RslData))
                    {
                        Stopwatch w = Stopwatch.StartNew();

                        while (true)
                        {
                            if (sm.Initialize(rslCfg, sm.SelfNode, ManagedRSLProtocolVersion.ManagedRSLProtocolVersion_5, false))
                            {
                                break;
                            }

                            if (w.ElapsedMilliseconds > 10000)
                            {
                                throw new InvalidOperationException("couldn't initialize the SM");
                            }

                            Thread.Sleep(100);
                        }

                        sm.InitiateBootstrap(nodes, 10);

                        return(sm);
                    }
                }
                catch (Exception e)
                {
                    try
                    {
                        sm.Log("Exception during InitializeStateMachine {0}", e);
                    }
                    catch (Exception)
                    {
                        // ignore
                    }

                    sm.Dispose();
                    throw;
                }
            }
Exemplo n.º 4
0
            public virtual void ExecuteInPrimary(BasicStateMachine basicStateMachine, ref bool saveState)
            {
                if (basicStateMachine == null)
                {
                    throw new ArgumentNullException(nameof(basicStateMachine));
                }

                saveState = false;

                Command firstInqueue = basicStateMachine.inflight.Dequeue();

                if (firstInqueue != this)
                {
                    throw new ArgumentException("first in queue should be this command");
                }

                basicStateMachine.commands.Add(this);

                if (this.OnCompletion != null)
                {
                    this.OnCompletion();
                }
            }
Exemplo n.º 5
0
            public static BasicStateMachine.Reference CreateSMSec(int instance, TestConfig cfg, TestTracer tracer)
            {
                BasicStateMachine sm = CreateSM(instance, false, cfg, tracer);

                return(sm.SMReference);
            }
Exemplo n.º 6
0
 public Reference(BasicStateMachine sm)
 {
     this.sm = sm;
 }
Exemplo n.º 7
0
 public override void ExecuteInSecondary(BasicStateMachine basicStateMachine, ref bool saveState)
 {
     base.ExecuteInSecondary(basicStateMachine, ref saveState);
 }