コード例 #1
0
ファイル: Application.cs プロジェクト: tide999/RSL
 public void UnloadReplica(BasicRSLTestMachine replica)
 {
     this._allReplicaSet.Remove(replica);
     this._pausedReplicas.Remove(replica);
     this._replicaSet.Remove(replica);
     Console.WriteLine("{0} unloading  ------------------", replica.Self.MemberId);
     replica.UnloadThisOne();
     Console.WriteLine("{0} unloaded -----------------------", replica.Self.MemberId);
 }
コード例 #2
0
ファイル: Application.cs プロジェクト: tide999/RSL
        public void FailoverAndWaitForPrimary()
        {
            BasicRSLTestMachine prim = this.PrimaryReplica;

            EvictMember(prim.Self.MemberId);

            while (this.PrimaryReplica == prim)
            {
                Thread.Sleep(100);
            }
            WaitForPrimary();
            EvictMember(null);
        }
コード例 #3
0
ファイル: Application.cs プロジェクト: tide999/RSL
        public void ReloadReplica(BasicRSLTestMachine replica)
        {
            Console.WriteLine("{0} reloading  ------------------", replica.Self.MemberId);

            bool res = replica.Initialize(
                cfg,
                replica.Self,
                ManagedRSLProtocolVersion.ManagedRSLProtocolVersion_4,
                false);

            Debug.Assert(res);

            Console.WriteLine("{0} reloaded -----------------------", replica.Self.MemberId);
            this._allReplicaSet.Add(replica);
            this._replicaSet.Add(replica);
        }
コード例 #4
0
ファイル: Application.cs プロジェクト: tide999/RSL
        /// <summary>
        /// Resumes a replica
        /// </summary>
        public void Resume(string replicaId)
        {
            BasicRSLTestMachine replica = null;

            foreach (BasicRSLTestMachine replicaI in _pausedReplicas)
            {
                if (String.Equals(replicaI.Self.MemberId, replicaId))
                {
                    replica = replicaI;
                    break;
                }
            }
            if (replica == null)
            {
                throw new KeyNotFoundException("replica " + replicaId);
            }

            _pausedReplicas.Remove(replica);
            replica.Resume();
            _replicaSet.Add(replica);
        }
コード例 #5
0
ファイル: Application.cs プロジェクト: tide999/RSL
        /// <summary>
        /// Pauses a replica
        /// </summary>
        public void Pause(string replicaId)
        {
            BasicRSLTestMachine replica = null;

            foreach (BasicRSLTestMachine replicaI in _replicaSet)
            {
                if (String.Equals(replicaI.Self.MemberId, replicaId))
                {
                    replica = replicaI;
                    break;
                }
            }
            if (replica == null)
            {
                throw new KeyNotFoundException("replica " + replicaId);
            }
            Console.WriteLine("found replica " + replicaId);
            _replicaSet.Remove(replica);
            replica.Pause();
            _pausedReplicas.Add(replica);
            Console.WriteLine("PAUSED replica " + replicaId);
            System.Threading.Thread.Sleep(10000);
            Console.WriteLine("continue after PAUSED replica " + replicaId);
        }
コード例 #6
0
ファイル: Application.cs プロジェクト: tide999/RSL
        /// <summary>
        /// Starts the configured number of replicas, this function will create
        /// the necessery files that are needed for the aplicaton to run
        /// </summary>
        /// <param name="numberOfReplicas">numberOfReplicas</param>
        /// <returns></returns>
        public int StartUp(int numberOfReplicas)
        {
            cfg = new ManagedRSLConfigParam();
            cfg.NewLeaderGracePeriodSec    = 10;
            cfg.HeartBeatIntervalSec       = 2;
            cfg.ElectionDelaySec           = 5;
            cfg.MaxElectionRandomizeSec    = 1;
            cfg.InitializeRetryIntervalSec = 1;
            cfg.PrepareRetryIntervalSec    = 1;
            cfg.VoteRetryIntervalSec       = 1;
            cfg.CPQueryRetryIntervalSec    = 5;
            cfg.MaxCheckpointIntervalSec   = 0;
            cfg.MaxLogLenMB              = 100;
            cfg.SendTimeoutSec           = 10;
            cfg.ReceiveTimeoutSec        = 10;
            cfg.MaxCacheLengthMB         = 50;
            cfg.MaxVotesInLog            = 1000;
            cfg.MaxOutstandingPerReplica = 10;
            cfg.MaxCheckpoints           = 2;
            cfg.MaxLogs                      = 5;
            cfg.LogLenRandomize              = 20;
            cfg.ElectionRandomize            = 10;
            cfg.FastReadSeqThreshold         = 5;
            cfg.InMemoryExecutionQueueSizeMB = 10;
            cfg.NumReaderThreads             = 5;
            cfg.MaxMessageSizeMB             = 1;
            cfg.WorkingDir                   = RSLWorkingDir;

            ManagedRSLNode[] nodes = new ManagedRSLNode[numberOfReplicas];
            for (int i = 0; i < nodes.Length; i++)
            {
                nodes[i]          = new ManagedRSLNode();
                nodes[i].MemberId = (i + 1).ToString();
                nodes[i].RslPort  = (ushort)(5000 + (100 * (i + 1)));
                nodes[i].HostName = "127.0.0.1";
                nodes[i].Ip       = new IPAddress(0x0100007F); // 127.0.0.1
            }

            int startedReplicas = 0;

            if (_replicaSet == null)
            {
                _replicaSet = new List <BasicRSLTestMachine>();

                ManagedRSLStateMachine.NotificationsCallback = OnNotification;

                ManagedRSLStateMachine.Init(".\\" + RSLDebugLogsDir);
                for (int i = 0; i < nodes.Length; i++)
                {
                    BasicRSLTestMachine replica = new BasicRSLTestMachine(nodes[i]);
                    try
                    {
                        bool res = replica.Initialize(
                            cfg,
                            nodes[i],
                            ManagedRSLProtocolVersion.ManagedRSLProtocolVersion_4,
                            false);
                        Debug.Assert(res);
                        startedReplicas++;
                        _replicaSet.Add(replica);
                        _allReplicaSet.Add(replica);
                    }
                    catch (Exception e)
                    {
                        if (e is NullReferenceException || e is System.Runtime.InteropServices.SEHException)
                        {
                            throw;
                        }
                    } //catch
                }     // for

                Console.WriteLine("Bootstrapping");
                byte[] buf = new byte[] { 1 };
                ManagedRSLMemberSet memberSet = new ManagedRSLMemberSet(nodes, buf, 0, 1);

                foreach (BasicRSLTestMachine replica in _allReplicaSet)
                {
                    RSLResponse resp = replica.Bootstrap(memberSet, 10);
                    Console.WriteLine(resp);
                }
            }
            else
            {
                startedReplicas = _replicaSet.Count;
            }

            return(startedReplicas);
        } //StartUp
コード例 #7
0
ファイル: Application.cs プロジェクト: tide999/RSL
 public void Unload()
 {
     BasicRSLTestMachine.Unload();
 }