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) { MessageMaker mm = new MessageMaker(); Message msg = mm.makeMessage("fromFoo", "toBar"); Utilities.showMessage(msg); Console.Write("\n\n"); }
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); } }
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) { 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"); 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(); } } }
//----< 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"); } }