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

  Write the definition of a void method

Write the definition of a void method that takes as input two parameters of type int, say sum and testScore. The method updates the value of sum by adding the value of testScore. The new value of sum is sent back to the caller statement

  Write a method called sigma

Write a method called sigma that takes an int parameter n and returns the sum of all the integers from 1 to n (inclusive). For example, sigma(4) should return 10.

  The program randomly generates the quiz question one by

the program randomly generates the quiz question one by one from a set of available questions on general knowledge

  How does a client send a string ti the server using udp

How does a client send a string ti the server using UDP? Show what the client would do to get data from some string, and create a datagram packet destined for a server at "www.google.com", port 12345.

  Write a blog article for a codingtechnical community

write a blog article for a codingtechnical community blog.the theme is general c or java. choose any subject under this

  Write a recursive java method that will rearrange an array

Write a short recursive Java method that will rearrange an array of int values so that all the even values appear before all the odd values.

  Create a class named pizza - instantiate pizza objects

Create a class named Pizza class must not have the main method and cannot be run independently. It should be used in driver class to instantiate Pizza objects.

  Create a world class that contains a 2d array

You have to create a world class that contains a 2d array then create an abstract class called organism that contains move() method the organism should move randomly one step at the time.

  Determine the return types based on the semantic of helper

Implement the following helpers for the class, determine the return types based on the semantic of the helper.

  Create a program that asks a user for a number

Create a program that asks a user for a number between 1 and 100, the program should then output to the user higher, lower, or correct, depending upon the input from the user and the random number assigned to the number to be guessed

  Program buttons that implements a window with three button

Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter

  Alicia creates a button using the code jbutton exit button

Alicia creates a button using the code JButton exitButton = new JButton("exit"); and places it into a JFrame named mainFrame

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