Introduction
Before reading further, you may wish to review the general project description from Old project: You can use this OLD PROJECT SOLUTION as your starting point. There is no change to the client side of the code. Follow the instructions in Oldproject to prepare and run your code. Only the server needs to be changed for this project.
Creating the Request Matcher
For this project, you will create a concurrent request-response matcher. In old project , every time a request or response is submitted, the server checks if the request/response can be assigned and if not possible, it was added to an internal list. For Project 8, we separate this into two different tasks, each to be executed as a thread.
For this project the server will have two threads of execution. We will call them Listener thread and Matcher thread. The Listener is your 'main' thread. The Listener will listen for incoming connections. When it receives a request/response, the server adds it to either the request or response list and goes back to listening. In other words, this thread does NOT do any scheduling or matching.
When the server starts, you need to create a new thread(the Matcher thread) that will monitor the set of requests and responses every 'x' seconds. This Matcher thread will wake up after 'x' seconds and check both request and response lists. If there are values in the request list that can be matched with a response, it will perform the matching - that is assign the request to the response. The Matcher thread will try to match all requests with responses before going back to sleep again.
Implementation
Server
You should modify your Server class from Old project. The server should start a Matcher thread(see below) when it starts. Also you should modify your server logic in such a way that when messages are received, it is added to the request or response list and no assignment or matching happens.
Your server should also take in two extra parameters from the command line - matching type and sleep time. This means now your server takes in 3 command line parameters java Server port matchtype sleep.
eg: java Server 1234 FCFS 1000 means start the server at port 1234, with matching type FCFS and a sleep time of 1000 milli seconds.
DataFeeder Interface
Create a new interface DataFeeder with the code given below in the appropriate folder. Note the package structure and make sure your folder structure matches it.
package ll give you
public interface DataFeeder {
a pseudo code will be provided;
}
Matcher Thread
'f', An implementation of DataFeeder interface.
'sleep', the sleep interval for the thread in milli seconds.
'matchingType', The type of matching to be performed.
'channel', The channel you have defined and initialized in the server. By using this, you can send messages to the responder and requester after each assignment.
Every time the matcher thread wakes up, it calls methods in DataFeeder interface to assign requests to a response. If it cannot find a match, it will just go back to sleep. The thread keeps on matching as many requests and responses as possible. Once it has matched all possibilities, it goes back to sleep. You have to implement two kinds of matchers, FCFS in which the first request is matched with the first response and MostRecent in which the last request is matched with the last response first.
package will be provided
public class Matcher extends Thread {
a pseudo code will be provided
}
}
DataFeeder Implementation
You need to create one class that implements the DataFeeder interface. This class should have request and response lists into which the main Listener thread keeps adding entries.
Synchronization Issues
You can use synchronized block/methods or use thread safe data structures like vectors to ensure this.
Hello, I have many years of experience in this field. Can you explain better what do you need for this project? I think that in 20 days i can give you the result .
regards
We are freelance software developers. If you contact me I can give a quote for your project and we can discuss the details. <b><i>Removed by Admin</i></b>