Create a testing environment

Assignment Help JAVA Programming
Reference no: EM131861833

(A) Test Environment

Here, we will modify the server so that it can serve multiple connections simultaneously. First, let's create a testing environment.

Download StressTest.java and add it to your project. It creates many simultaneous connections (using threads) to the server. It is meant to be run after starting the web server.

The method getURLQ returns the URL to be retrieved. You can change it to retrieve either the main page or the /address form, whereas the address form is actually a submission to add another address to the database. You can change it to suit your needs (e.g., if you don't use port 12345).

Start your server, then start StressTest.java (right-click on the file, select Run to run it). The output should be like so:

finished. 3080 ms.

500 out of 500 successful.

The program expects the server to always send back the same page - otherwise it won't count as "successful".

Note the execution time.

(B) Change the server

Now for the programming bit.

Change the server so that for each incoming connection, you create a new thread. You will need to make an object of a new class HttpConnection for each connection. The run method of this class will handle the connection, receive the incoming requests such as GET / HTTP/1.1 and make the View object to produce a view.

After the connection object is created, make a new Thread object with it, and start the thread with the Thread.start() method. Read up in your favorite textbook (and/or the slides or the example code from last time) on how to do this in detail.

Think about which shared resources the thread will have. You will find that you'll naturally keep resources in the connection object. That's why these objects (implementing Runnable) are so useful -it's easy to see which resources will be shared between threads.

Are the data structures thread-safe? If not, when do you need to protect them? Add appropriate code to use thread-safe data structures or "synchronize" the essential code blocks.

Hint: if you don't want to add "serialized" blocks, consider using a data structure that is better than AddressList for this purpose, and that supports concurrency:

Queue<AddressModel> addresses = new ConcurrentLinkedQueue<AddressModel>();

Attachment:- Assignment Files.rar

Reference no: EM131861833

Questions Cloud

Types of events might require higher escalation : What types of events might require higher escalation, and how administrators might respond to different types of breaches?
What procedures did you have in place to mitigate : If so, describe some of the challenges your department faced in implementing its electronic medical / health record system.
Computer architecture and computer organisation : Explain the difference between computer architecture and computer organisation.
Create a prescriptive summary providing guidelines : Create a prescriptive summary providing guidelines to secure each of these areas:
Create a testing environment : Here, we will modify the server so that it can serve multiple connections simultaneously. First, let's create a testing environment
Determine the two critical feedback loops : Determine the two critical feedback loops. Describe each Feedback Loop that you identify in your organization and explain why you selected them
Reference monitor for an operating system : When designing a reference monitor for an operating system, why is the granularity of the objects protected an important consideration?
What each of the women might think about womens current role : What each of the women might think about women's current roles. Explain how key social, cultural, and artistic contributions contribute to historical changes.
Explain the elements of a legal contract : Jim and Laura have an appointment to see a lawyer in a few days, but know you are a student taking a business law class and come to you for advice.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd