// public static List<Thread> threadsArray=new List<Thread>(); static void Main(string[] args) { initPuppetMaster(); setOperatorOutputs(); //RUN MACHINES foreach (MachineWithReplicas x in machines) { Console.WriteLine("Executing Machine: " + x.machineURL); LogService.log("PuppetMaster: Executing Machine " + x.machineURL, false); //starting machine process Process p = new Process(); p.StartInfo.WorkingDirectory = "..\\..\\..\\Machine\\bin\\Debug"; p.StartInfo.FileName = "Machine.exe"; p.StartInfo.Arguments = Convert.ToString(x.machineIDport); p.Start(); //send packet to machine process MachinePackage mp = new MachinePackage(); mp.machines = machines; ThreadMachine m = new ThreadMachine(x.machineIDport, mp); Thread t1 = new Thread(new ThreadStart(m.start)); t1.Start(); } Thread.Sleep(2000); // Delegate the startup of all Operators to ThreadOperators foreach (OperatorInformation info in operatorsArray) { Console.WriteLine("Starting new Operator in Thread with port: " + info.port); LogService.log("PuppetMaster: Starting new Operator in Thread with port: " + info.port, false); ThreadOperator op1 = new ThreadOperator(info, sourceoperators); Thread t1 = new Thread(new ThreadStart(op1.start)); t1.Start(); } setReplicaID(); // Get the logging thread running ThreadLog log = new ThreadLog(logging); Thread t2 = new Thread(new ThreadStart(log.start)); t2.Start(); //commands from console consoleCommands(); }
public void start() { string address = "tcp://localhost:" + Convert.ToInt32(portnumber) + "/machine"; MachinePackage op = (MachinePackage)Activator.GetObject( typeof(MachinePackage), address); op.setMachines(machines2); if (op == null) { Console.WriteLine("Could not locate server"); } else { op.test = true; } }
static void initMachine(int port) { Console.WriteLine("Connecting to PM at port: " + port); //SERVER TcpChannel channel = new TcpChannel(port); ChannelServices.RegisterChannel(channel, false); m1 = new MachinePackage(); RemotingServices.Marshal(m1, "machine", typeof(MachinePackage)); //trying to connect do { Console.WriteLine("... trying to connect to PM"); Thread.Sleep(300); } while (!m1.test); Console.WriteLine("... CONNECTED to PM"); machines = m1.machines; }
public ThreadMachine(int portnumber, MachinePackage machines) { this.portnumber = portnumber; this.machines = machines; this.machines2 = machines.machines; }