Ejemplo n.º 1
0
        private void Server(string command)
        {
            string[] args = command.Split(' ');
            if (args.Count() != 5)
            {
                throw new Exception("Wrong format for Server command");
            }
            try
            {
                string URL        = args[2];
                string machineIP  = ExtractIP(URL);
                string serverPort = ExtractPort(URL);
                string serverName = ExtractName(URL);

                Console.WriteLine(URL);
                Console.WriteLine(machineIP);
                Console.WriteLine(serverPort);
                Console.WriteLine(serverName);

                string pcsURL = $"tcp://{machineIP}:{PCSPORT}/{PCSNAME}";
                IProcessCreationService pcs = (IProcessCreationService)Activator.GetObject(typeof(IProcessCreationService), pcsURL);
                pcs.Server(args[1], Int32.Parse(serverPort), serverName, Int32.Parse(args[3]), Int32.Parse(args[4]), mode);

                name2URL.Add(args[1], URL);
            } catch (Exception exc)
            {
                Console.WriteLine($"[x] Error during server creation: {exc.Message}");
            }
        }
Ejemplo n.º 2
0
        private void saveProcessPCS(string pid, string url)
        {
            IProcessCreationService pcs = (IProcessCreationService)Activator.GetObject(
                typeof(IProcessCreationService),
                url);

            // pid, pcs remove service
            this.processesPCS.Add(pid, pcs);
        }
Ejemplo n.º 3
0
 public IProcessCreationService connectPCS(string url)
 {
     try{
         pcs = (IProcessCreationService)Activator.GetObject(typeof(IProcessCreationService), url);
     }
     catch (Exception) {
         Console.WriteLine("Couldn't reach IProcessCreationService.");
     }
     return(pcs);
 }
Ejemplo n.º 4
0
        public override void CommandToExecute(string[] parameters)
        {
            string                  pid = parameters[0];
            IAsyncResult            asyncResult;
            IProcessCreationService pcs = processesPCS[pid];

            remoteCallInjectDelay = new injectDealyDel(pcs.InjectDelay);
            asyncResult           = remoteCallInjectDelay.BeginInvoke(pid, parameters[1], null, null);
            asyncResult.AsyncWaitHandle.WaitOne();
            remoteCallInjectDelay.EndInvoke(asyncResult);
        }
Ejemplo n.º 5
0
        public override void CommandToExecute(string[] parameters)
        {
            string                  pid = parameters[0];
            IAsyncResult            asyncResult;
            IProcessCreationService pcs = processesPCS[pid];

            remoteCallFreeze = new freezeDel(pcs.Freeze);
            asyncResult      = remoteCallFreeze.BeginInvoke(pid, null, null);
            asyncResult.AsyncWaitHandle.WaitOne();
            return;
        }
Ejemplo n.º 6
0
        public override void CommandToExecute(string[] parameters)
        {
            string                  pid = parameters[0];
            IAsyncResult            asyncResult;
            IProcessCreationService pcs = processesPCS[pid];

            remoteCallCrash = new crashDel(pcs.Crash);
            asyncResult     = remoteCallCrash.BeginInvoke(pid, null, null);
            asyncResult.AsyncWaitHandle.WaitOne();
            remoteCallCrash.EndInvoke(asyncResult);
        }
Ejemplo n.º 7
0
        public void VisitCreateClient(CreateClient createClient)
        {
            Task.Factory.StartNew(() => {
                if (this.clients.ContainsKey(createClient.Id))
                {
                    Console.WriteLine($"The client_id {createClient.Id} is already associated.");
                    return;
                }

                this.clients.TryAdd(createClient.Id, createClient.Url);
                IProcessCreationService processCreationService = GetProcessCreationService(createClient.Url);

                processCreationService.CreateClient(
                    createClient.Id,
                    createClient.Url,
                    createClient.ScriptFile);
            });
        }
Ejemplo n.º 8
0
        public void VisitCreateServer(CreateServer createServer)
        {
            Task.Factory.StartNew(() => {
                if (this.servers.ContainsKey(createServer.Id))
                {
                    Console.WriteLine($"The server_id {createServer.Id} is already associated.");
                    return;
                }

                this.servers.TryAdd(createServer.Id, createServer.Url);

                IProcessCreationService processCreationService = GetProcessCreationService(createServer.Url);
                processCreationService.CreateServer(
                    createServer.Id,
                    createServer.Url,
                    createServer.MinDelay,
                    createServer.MaxDelay,
                    createServer.Protocol);
            });
        }
Ejemplo n.º 9
0
        //create a new operator and replicas
        public static void addOperator(String opID, int repFact, String[] addresses, String configArgs)
        {
            Replicas opReplicas = new Dictionary <String, IOperatorService>();

            for (int i = 0; i < repFact; i++)
            {
                //String opURL = addresses[i] + i + opID; //small hack to avoid already registered service names
                String opURL = addresses[i]; // the hack is not needed

                // OpID opURL replicaIndex inputOps Routing OpSpec OpParams
                String args = opID + " " + opURL + " " + i + " " + configArgs;


                IProcessCreationService PCS = PCSMan.getPCSbyReplicaURI(opURL);
                if (PCS == null)
                {
                    Logger.errorWriteLine("couldn't get PCS of OP " + opURL);
                    continue;
                }
                bool pcsOK = false;
                while (!pcsOK)
                {
                    try
                    {
                        PCS.ping();
                        PCS.createOperator(args);
                        pcsOK = true;
                    }
                    catch (System.Net.Sockets.SocketException)
                    {
                        Console.WriteLine("Waiting for PCS");
                        Thread.Sleep(100);
                    }
                }
                IOperatorService op = (IOperatorService)Activator.GetObject(typeof(IOperatorService), opURL);

                opReplicas.Add(new KeyValuePair <String, IOperatorService>(opURL, op));
            }
            //add created replicas to operator table, associating them with the new OP
            OperatorTable.Add(new KeyValuePair <String, Replicas>(opID, opReplicas));
        }