public void sendEachRequest(XElement request, TestExec clnt, Message msg, Sender sndr, Receiver rcvr, MessageMaker testExecInput)
 {//send each request to construct xml request message and send it to the server
     msg = new Message();
     msg = testExecInput.makeMessage(clnt.localUrl, clnt.remoteUrl, request);
     if (!sndr.Connect(msg.toUrl))
     {
         Console.Write("\n  could not connect in {0} attempts", sndr.MaxConnectAttempts);
         sndr.shutdown();
         rcvr.shutDown();
         return;
     }
     while (true)
     {
         //msg.content = "Message #" + (++counter).ToString();
         Console.Write("\n============Start of the Message==========\n");
         Console.Write("\n  Sending Message:");
         Console.Write("\n==========================\n");
         Console.WriteLine(msg.content);
         Console.WriteLine("==================End of Message===============");
         if (!sndr.sendMessage(msg))
         {
             return;
         }
         Thread.Sleep(100);
         break;
     }
 }
Example #2
0
 public void sendEachRequest(XElement request,TestExec clnt, Message msg, Sender sndr, Receiver rcvr, MessageMaker testExecInput)
 {//send each request to construct xml request message and send it to the server
     msg = new Message();
     msg = testExecInput.makeMessage(clnt.localUrl, clnt.remoteUrl, request);
     if (!sndr.Connect(msg.toUrl))
     {
         Console.Write("\n  could not connect in {0} attempts", sndr.MaxConnectAttempts);
         sndr.shutdown();
         rcvr.shutDown();
         return;
     }
     while (true)
     {
         //msg.content = "Message #" + (++counter).ToString();
         Console.Write("\n============Start of the Message==========\n");
         Console.Write("\n  Sending Message:");
         Console.Write("\n==========================\n");
         Console.WriteLine(msg.content);
         Console.WriteLine("==================End of Message===============");
         if (!sndr.sendMessage(msg))
             return;
         Thread.Sleep(100);
         break;
     }
 }
        static void Main(string[] args)
        {
            Console.Write("\n  starting CommService client");
            Console.Write("\n =============================\n");
            Console.Title = "Test Executive Client to display the results of remote NoSQL database operations";
            TestExec clnt = new TestExec();

            clnt.processCommandLine(args);
            HiResTimer timerTestExec = new HiResTimer();
            string     localPort     = Util.urlPort(clnt.localUrl);
            string     localAddr     = Util.urlAddress(clnt.localUrl);
            Receiver   rcvr          = new Receiver(localPort, localAddr);

            rcvr.setTimerFromClient(timerTestExec);
            clnt.startRcvrService(rcvr);
            Console.WriteLine("\n The Message request is");
            Console.Write("\n =================================\n");
            Sender       sndr = new Sender(clnt.localUrl); // Sender needs localUrl for start message
            MessageMaker testExecInput = new MessageMaker();
            Message      msg = new Message();
            string       fileName = ".\\TestExecInput.xml";
            XDocument    xmldoc = XDocument.Load(fileName);
            var          requests = xmldoc.Descendants("Request");
            int          requestCount = 0, readers = 0, writers = 0, portReader = 0, portWriter = 0, numberOfRequests = 0, numberOfRequestsWriters = 0;
            string       readerDisplay = "", writerDisplay = "";

            clnt.getReadersWritersCount(xmldoc, ref readers, ref writers, ref portReader, ref portWriter, ref numberOfRequests, ref readerDisplay, ref writerDisplay, ref numberOfRequestsWriters);
            timerTestExec.Start();
            foreach (var request in requests)
            {   //send each request to construct message and send it to the server
                clnt.sendEachRequest(request, clnt, msg, sndr, rcvr, testExecInput);
                Console.Title = "TestExec Client to display the NoSQl database operations: Operations " + (++requestCount) + " are Sent";
            }
            msg.content = "done";
            Util.waitForUser();
            rcvr.shutDown();
            sndr.shutdown();
            Console.Write("\n\n");
            if (args.Count() != 0)
            {
                readers                 = Convert.ToInt32(args[0]);
                writers                 = Convert.ToInt32(args[1]);
                numberOfRequests        = Convert.ToInt32(args[2]);
                numberOfRequestsWriters = Convert.ToInt32(args[3]);
            }
            for (int i = 1; i <= writers; i++)
            {
                System.Diagnostics.Process.Start(".\\Client\\bin\\Debug\\Client.exe", "" + (portWriter++) + " " + numberOfRequestsWriters + " " + writerDisplay);
            }
            for (int j = 1; j <= readers; j++)
            {
                System.Diagnostics.Process.Start(".\\Client2\\bin\\Debug\\Client2.exe", ("" + (portReader++) + " " + numberOfRequests + " " + readerDisplay));
            }
        }
        static void Main(string[] args)
        {
            Console.Write("\n     Starting Test-Executive    ");
            Console.Write("\n =============================\n");
            Console.Title = "Test Executive";
            TestExec testExec = new TestExec();

            testExec.requirementR2();
            testExec.requirementR3();
            testExec.requirementR4();
            testExec.requirementR5();
            testExec.requirementR6();
            testExec.requirementR7();
            testExec.requirementR8();

            // Test if input arguments were supplied:
            Process.Start(testExec.getProcessPath("Server"));
            Process.Start(testExec.getProcessPath("WpfClient"));
            if (args.Length == 3)
            {
                string arg = "";
                testExec.processCommandLine(args);
                int i = 0;
                while (i < testExec.numR)
                {
                    arg = "/R http://localhost:" + TestExec.serverPort + "/CommService /L http://localhost:" + (TestExec.readerClientPort + i) + "/CommService";
                    if (testExec.log == "Y")
                    {
                        arg = arg + " /O";
                    }
                    Process.Start(testExec.getProcessPath("Client2"), arg);
                    i++;
                }
                i = 0;
                while (i < testExec.numW)
                {
                    arg = "/R http://localhost:" + TestExec.serverPort + "/CommService /L http://localhost:" + (TestExec.writerClientPort + i) + "/CommService";
                    if (testExec.log == "Y")
                    {
                        arg = arg + " /O";
                    }
                    Process.Start(testExec.getProcessPath("Client"), arg);
                    i++;
                }
                return;
            }
            else
            {
                Console.WriteLine("  Invalid command line arguments.");
                return;
            }
        }
Example #5
0
 static void Main(string[] args)
 {
     Console.Write("\n  starting CommService client");
     Console.Write("\n =============================\n");
     Console.Title = "Test Executive Client to display the results of remote NoSQL database operations";
     TestExec clnt = new TestExec();
     clnt.processCommandLine(args);
     HiResTimer timerTestExec = new HiResTimer();
     string localPort = Util.urlPort(clnt.localUrl);
     string localAddr = Util.urlAddress(clnt.localUrl);
     Receiver rcvr = new Receiver(localPort, localAddr);
     rcvr.setTimerFromClient(timerTestExec);
     clnt.startRcvrService(rcvr);
     Console.WriteLine("\n The Message request is");
     Console.Write("\n =================================\n");
     Sender sndr = new Sender(clnt.localUrl);  // Sender needs localUrl for start message
     MessageMaker testExecInput = new MessageMaker(); 
     Message msg = new Message();
     string fileName = ".\\TestExecInput.xml"; 
     XDocument xmldoc = XDocument.Load(fileName);
     var requests = xmldoc.Descendants("Request");
     int requestCount = 0, readers = 0, writers = 0, portReader = 0, portWriter = 0, numberOfRequests = 0, numberOfRequestsWriters = 0;
     string readerDisplay = "", writerDisplay = "";
     clnt.getReadersWritersCount(xmldoc, ref readers, ref writers, ref portReader, ref portWriter, ref numberOfRequests, ref readerDisplay, ref writerDisplay, ref numberOfRequestsWriters);
     timerTestExec.Start();
     foreach (var request in requests)
     {   //send each request to construct message and send it to the server
         clnt.sendEachRequest(request,clnt,msg,sndr,rcvr,testExecInput);
         Console.Title = "TestExec Client to display the NoSQl database operations: Operations " + (++requestCount) + " are Sent";
     }
     msg.content = "done";
     Util.waitForUser();
     rcvr.shutDown();
     sndr.shutdown();
     Console.Write("\n\n");
     if(args.Count() != 0)
     {
         readers = Convert.ToInt32(args[0]);
         writers = Convert.ToInt32(args[1]);
         numberOfRequests = Convert.ToInt32(args[2]);
         numberOfRequestsWriters = Convert.ToInt32(args[3]);
     }
     for(int i = 1; i <= writers; i++)
     {
         System.Diagnostics.Process.Start(".\\Client\\bin\\Debug\\Client.exe",""+(portWriter++) + " " + numberOfRequestsWriters + " "+writerDisplay);
     }
     for(int j = 1; j <= readers; j++)
     {
         System.Diagnostics.Process.Start(".\\Client2\\bin\\Debug\\Client2.exe",(""+(portReader++)+" "+numberOfRequests+" "+readerDisplay));
     }
 }
        static void Main(string[] args)
        {
            Console.Write("\n Test-Executive  ");
            Console.Write("\n ***********************\n");
            Console.Title = "Test Executive";
            TestExec testExec = new TestExec();

            testExec.R1();
            testExec.R2();
            testExec.R3();
            testExec.R4();
            testExec.R5();
            testExec.R6();
            testExec.R7();
            testExec.R8();

            try
            {
                Process.Start(testExec.findPath("Server"));
            }
            catch (Exception e)
            {
                Console.WriteLine("****************************Please check Server.exe file*********************");
            }
            try
            {
                Process.Start(testExec.findPath("WpfClient"));
            }
            catch (Exception e)
            {
                Console.WriteLine("****************************Please check WpfClient.exe file*********************");
            }

            if (args.Length == 3)
            {
                string arg = "";
                testExec.processCommandLine(args);

                int i = 0;
                while (i < testExec.Writers)
                {
                    arg = "/R http://localhost:" + TestExec.serverPort + "/CommService /L http://localhost:" + (TestExec.writerPort + i) + "/CommService " + testExec.logger;
                    try
                    {
                        Process.Start(testExec.findPath("Client"), arg);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("****************************Please check Client.exe file*********************");
                    }
                    i++;
                }
                i = 0;
                Thread.Sleep(1500);
                while (i < testExec.Readers)
                {
                    arg = "/R http://localhost:" + TestExec.serverPort + "/CommService /L http://localhost:" + (TestExec.readerPort + i) + "/CommService " + testExec.logger;
                    try
                    {
                        Process.Start(testExec.findPath("Client2"), arg);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("****************************Please check Client2.exe file*********************");
                    }
                    i++;
                }
                return;
            }
            else
            {
                return;
            }
        }