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; } }
private void sendMessageToServer(IEnumerable <XElement> results, HiResTimer timer, MessageMaker msgMaker, Sender sndr, Receiver rcvr) { timer.Start(); foreach (var eachInput in results) { Message msg = new Message(); msg = msgMaker.makeMessage(this.localUrl, this.remoteUrl, eachInput); if (!sndr.Connect(msg.toUrl)) { Console.Write("\n could not connect in {0} attempts", sndr.MaxConnectAttempts); sndr.shutdown(); rcvr.shutDown(); return; } "Message sent".endofTest(); "Content".title(); Console.Write("\n\n{0}\n", msg.content); "End of message".endofTest(); while (true) { if (sndr.sendMessage(msg)) { Thread.Sleep(200); break; } } sndr.SendReaderLatency(rcvr.totalExecutionTime / rcvr.count); sndr.SendWriterLatency(rcvr.totalExecutionTime / rcvr.count); } }
static void Main(string[] args) { MessageMaker mm = new MessageMaker(); Message msg = mm.makeMessage("fromFoo", "toBar"); Utilities.showMessage(msg); Console.Write("\n\n"); }
static void Main(string[] args) { MessageMaker mm = new MessageMaker(); XElement keyValue = new XElement("key", 2); var message = mm.makeMessage("localhost:8090", "localhost:8080", keyValue); Console.WriteLine(message.content); }
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) { MessageMaker msgMaker = new MessageMaker(); Console.Write("\nStarting Test Executive"); Console.Write("\n=============================\n"); Message msg = new Message(); HiResTimer timer = new HiResTimer(); Console.Title = "Write Client"; WriteClient writeClient = new WriteClient(); if (args.Length == 2) { writeClient.numMsg = Convert.ToInt32(args[1]); } writeClient.processCommandLine(args); string localPort = Util.urlPort(writeClient.localUrl); string localAddr = Util.urlAddress(writeClient.localUrl); Receiver rcvr = new Receiver(localPort, localAddr, timer); if (rcvr.StartService()) { rcvr.doService(rcvr.defaultServiceAction()); } Sender sndr = new Sender(writeClient.localUrl); // Sender needs localUrl for start message XDocument xmlInput = writeClient.GetInputFromXml(); var results = xmlInput.Descendants("element"); writeClient.sendMessageToServer(results, timer, msgMaker, sndr, rcvr); Console.Write("\n sender's url is {0}", writeClient.localUrl); Console.Write("\n attempting to connect to {0}\n", writeClient.remoteUrl); //Wait until all messages from server are received. while (rcvr.count < writeClient.numMsg) { sndr.SendWriterLatency(rcvr.totalExecutionTime / rcvr.count); } msg.content = "done"; msg.fromUrl = writeClient.localUrl; msg.toUrl = writeClient.remoteUrl; sndr.sendMessage(msg); Util.waitForUser(); sndr.SendWriterLatency(rcvr.totalExecutionTime / rcvr.count); rcvr.shutDown(); sndr.shutdown(); }
static void Main(string[] args) { TestExecutive test = new TestExecutive(); if (args.Count() == 4) { test.readers = Convert.ToInt32(args[0]); test.writers = Convert.ToInt32(args[1]); test.numReaderMessages = Convert.ToInt32(args[2]); test.numWriterMessages = Convert.ToInt32(args[3]); } MessageMaker msgMaker = new MessageMaker(); HiResTimer timer = new HiResTimer(); Message msg = new Message(); Console.Write("\nStarting Test Executive"); Console.Write("\n=============================\n"); Console.Title = "Test Executive"; string localPort = Util.urlPort(test.localUrl); string localAddr = Util.urlAddress(test.localUrl); Receiver rcvr = new Receiver(localPort, localAddr, timer); if (rcvr.StartService()) { rcvr.doService(rcvr.defaultServiceAction()); } Sender sndr = new Sender(test.localUrl); // Sender needs localUrl for start message XDocument xmlInput = test.GetInputFromXml(); var results = xmlInput.Descendants("element"); Console.Write("\n sender's url is {0}", test.localUrl); Console.Write("\n attempting to connect to {0}\n", test.remoteUrl); timer.Start(); test.sendMessageToServer(results, timer, msgMaker, sndr, rcvr); msg.content = "done"; msg.fromUrl = test.localUrl; msg.toUrl = test.remoteUrl; sndr.sendMessage(msg); Console.WriteLine("\n\nPress any key to start performance testing..."); Util.waitForUser(); test.LaunchReadersAndWriters(); rcvr.shutDown(); sndr.shutdown(); }
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"); HiResTimer timerReader = new HiResTimer(); Client clnt = new Client(); clnt.processCommandLine(args); string localPort = args[0]; clnt.localUrl = "http://localhost:" + localPort + "/CommService"; string localAddr = Util.urlAddress(clnt.localUrl); Receiver rcvr = new Receiver(localPort, localAddr); rcvr.setTimerFromClient(timerReader); clnt.startRcvrService(rcvr); Sender sndr = new Sender(clnt.localUrl); // Sender needs localUrl for start message MessageMaker readerInput = new MessageMaker(); string fileName = ".\\ReaderClientInput.xml"; Message msg = new Message(); int numRequests = Convert.ToInt32(args[1]); XDocument xmldoc = XDocument.Load(fileName); var requests = xmldoc.Descendants("Request"); int requestCount = 0, i = 0; List <XElement> totalrequest = new List <XElement>(); while (i < numRequests) //set the specified number of requests to send { totalrequest.Add(requests.ElementAt(i)); i++; } timerReader.Start(); foreach (var request in totalrequest) //send each request to the message maker to create a message { msg = new Message(); msg = readerInput.makeMessage(clnt.localUrl, clnt.remoteUrl, request); Console.Title = "Reader Client to query the NoSQl database: Querying " + (++requestCount) + " requests"; if (!sndr.Connect(msg.toUrl)) //send url of the destination to the sender { Console.Write("\n could not connect in {0} attempts", sndr.MaxConnectAttempts); sndr.shutdown(); rcvr.shutDown(); return; } Thread.Sleep(700); while (true) { clnt.printMessage(msg); //print the message contents if (!sndr.sendMessage(msg)) // send the message to the sender { return; } Thread.Sleep(100); break; } sndr.sendLatencyReader(rcvr.avgLatency); } Console.Write("\n Sender's url is {0}", msg.fromUrl); Console.Write("\n Attempting to connect to {0}\n", msg.toUrl); msg.content = "done"; sndr.sendMessage(msg); Util.waitForUser(); rcvr.shutDown(); sndr.shutdown(); }
static void Main(string[] args) { Console.Write("\n starting CommService client"); Console.Write("\n =============================\n"); HiResTimer timerReader = new HiResTimer(); Client clnt = new Client(); clnt.processCommandLine(args); string localPort = args[0]; clnt.localUrl = "http://localhost:" + localPort + "/CommService"; string localAddr = Util.urlAddress(clnt.localUrl); Receiver rcvr = new Receiver(localPort, localAddr); rcvr.setTimerFromClient(timerReader); clnt.startRcvrService(rcvr); Sender sndr = new Sender(clnt.localUrl); // Sender needs localUrl for start message MessageMaker readerInput = new MessageMaker(); string fileName = ".\\ReaderClientInput.xml"; Message msg = new Message(); int numRequests = Convert.ToInt32(args[1]); XDocument xmldoc = XDocument.Load(fileName); var requests = xmldoc.Descendants("Request"); int requestCount = 0, i = 0; List<XElement> totalrequest = new List<XElement>(); while (i < numRequests) { //set the specified number of requests to send totalrequest.Add(requests.ElementAt(i)); i++;} timerReader.Start(); foreach (var request in totalrequest) { //send each request to the message maker to create a message msg = new Message(); msg = readerInput.makeMessage(clnt.localUrl, clnt.remoteUrl, request); Console.Title = "Reader Client to query the NoSQl database: Querying " + (++requestCount) + " requests"; if (!sndr.Connect(msg.toUrl)) { //send url of the destination to the sender Console.Write("\n could not connect in {0} attempts", sndr.MaxConnectAttempts); sndr.shutdown(); rcvr.shutDown(); return; } Thread.Sleep(700); while (true) { clnt.printMessage(msg); //print the message contents if (!sndr.sendMessage(msg)) // send the message to the sender return; Thread.Sleep(100); break;} sndr.sendLatencyReader(rcvr.avgLatency);} Console.Write("\n Sender's url is {0}", msg.fromUrl); Console.Write("\n Attempting to connect to {0}\n", msg.toUrl); msg.content = "done"; sndr.sendMessage(msg); Util.waitForUser(); rcvr.shutDown(); sndr.shutdown(); } } }
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)); } }
//----< send a test performance request message >-------------------- private void send_Click(object sender, RoutedEventArgs e) { try { #region ///////////////////////////////////////////////////// // This commented code was put here to allow // user to change local port and address after // the channel was started. // // It does what is intended, but would throw // if the new port is assigned a slot that // is in use or has been used since the // TCP tables were last updated. // // if (!localPort.Equals(lPort.Text)) // { // localAddress = rcvr.address = lAddr.Text; // localPort = rcvr.port = lPort.Text; // rcvr.shutDown(); // setupChannel(); // } #endregion if (!remoteAddress.Equals(rAddr.Text) || !remotePort.Equals(rPort.Text)) { remoteAddress = rAddr.Text; remotePort = rPort.Text; } // - Make a demo message to send // - You will need to change MessageMaker.makeMessage // to make messages appropriate for your application design // - You might include a message maker tab on the UI // to do this. MessageMaker maker = new MessageMaker(); Message msg = maker.makeMessage(Utilities.makeUrl(lAddr.Text, lPort.Text), Utilities.makeUrl(rAddr.Text, rPort.Text)); lStat.Text = "sending to" + msg.toUrl; sndr.localUrl = msg.fromUrl; sndr.remoteUrl = msg.toUrl; lStat.Text = "attempting to connect"; if (sndr.sendMessage(msg)) lStat.Text = "connected"; else lStat.Text = "connect failed"; postSndMsg(msg.content); } catch (Exception ex) { lStat.Text = ex.Message; } }
//-------< on button click parse user input to generate //------- messages to be sent to server >------------------- private void button_Click(object sender, RoutedEventArgs e) { MessageMaker maker = new MessageMaker(); Message msg = maker.makeMessage( Utilities.makeUrl(lAddr.Text, lPort.Text), Utilities.makeUrl(rAddr.Text, rPort.Text) ); if (sndr != null) { sndr.localUrl = msg.fromUrl; sndr.remoteUrl = msg.toUrl; get_DB_type(ref msg); msg.content += "query,querytype,"; if (comboBox_query.SelectedItem.ToString() == "Insert Element" || comboBox_query.SelectedItem.ToString() == "Edit Element Metadata" || comboBox_query.SelectedItem.ToString() == "Edit Element Metadata and Add Children" || comboBox_query.SelectedItem.ToString() == "Edit Element Metadata and Remove Children" || comboBox_query.SelectedItem.ToString() == "Edit Element Metadata and Edit Payload" || comboBox_query.SelectedItem.ToString() == "Delete Element" || comboBox_query.SelectedItem.ToString() == "Persist Database" || comboBox_query.SelectedItem.ToString() == "Restore Database") { write_client_query(ref msg); } else { read_client_query(ref msg); } } else { Result_Box.Items.Insert(0, "First Connect to Server in Connect Tab"); } }