コード例 #1
0
ファイル: Commands.cs プロジェクト: icokosik/DADproject
        public static void crash(List <String> x)
        {
            string operatorID = x[1].ToString();
            string replicaID  = x[2].ToString();
            string address    = "";

            String machine = "";
            int    counter = 0;
            int    index   = 0;

            foreach (var i in Program.replicasArray)
            {
                if (i.operatorID.Equals(operatorID) && i.replicaID.Equals(Convert.ToInt32(replicaID)))
                {
                    string address2 = "tcp://localhost:" + Convert.ToInt32(i.replicaIDport) + "/op";
                    Console.WriteLine(address2);

                    Operator op = (Operator)Activator.GetObject(
                        typeof(Operator),
                        address2);
                    op.eraseMe();

                    machine = i.machineURL;
                    index   = counter;
                }
                counter++;
            }


            //remove crashed replica from array
            Console.WriteLine("index: " + index);
            Program.replicasArray.RemoveAt(index);
            foreach (var m in Program.machines)
            {
                if (m.operatorID.Equals(operatorID))
                {
                    m.RemoveReplica(Convert.ToInt32(replicaID));
                }
            }

            string machinePort = "";

            foreach (var ii in Program.machines)
            {
                if (ii.machineURL.Equals(machine))
                {
                    machinePort = Convert.ToString(ii.machineIDport);
                }
            }

            address = "tcp://localhost:" + machinePort + "/kill";
            Console.WriteLine("connecting to killObject at Machine by URL: " + address);
            KillReplica killObject = (KillReplica)Activator.GetObject(
                typeof(KillReplica),
                address);

            killObject.replicaID    = replicaID;
            killObject.deathInQueue = true;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: icokosik/DADproject
 public static void killLoop(KillReplica k)
 {
     while (true)
     {
         if (k.deathInQueue)
         {
             killReplica(Convert.ToInt32(k.replicaID));
             k.deathInQueue = false;
         }
         Thread.Sleep(300);
     }
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: icokosik/DADproject
        static void Main(string[] args)
        {
            puppetMasterPort = Int32.Parse(args[0]);
            Console.WriteLine("I´m Machine at port: " + puppetMasterPort);

            initMachine(puppetMasterPort);
            runOperators();

            KillReplica killObject = new KillReplica();

            RemotingServices.Marshal(killObject, "kill",
                                     typeof(KillReplica));

            killLoop(killObject);

            Console.ReadLine();
        }