” 辅导CSCI 5105程序语言、 写作Java编程CSCI 5105 (Spring 2021)Introduction to Distributed Systems(Instructor: Anand Tripathi)Assignment 5 (100 points)Due March 21, 2021This assignment can be done in a group of up to two students.See the last page for clarifications on HALT request processing. (March 9)This is a programming assignment building upon the work you did on Assignment 3. You will beimplementing the server as a group of replicated processes.Submission Instructions: Put all your files with program code and other documentation in asingle file zipped (.zip or .tar or .tar.gz or .tgz) file and submit it using the Homework Submissionlink on the Canvas page for the course.You are allowed toChange or modify your submission until the due date, so submit early andoften. Verify that all your files are in the submission. Failure to submit necessary files will result ina score of zero for all missing parts.General guidelines for all submissions are as follows: Include your name(s) and x500 at the top of each submitted file.o For a group Assignment, both partners should submit the work. All files MUSTinclude the names and x500 IDs of both partners. The submission with the latesttimestamp will be graded. Name your zip or tar or tgz file to contain thelastnames of both partners: For example, when Smith and Jones are submitting itas a team, name it as:Jones-Smith-Assignment-5.zip. Your solutions to non-programming portions of the assignment must be in a PDF format. If there is a programming component, please make sure your submission contains all thenecessary files to compile and run the programming portion of the assignment. Yourprogram must compile and run correctly on a CSE-Lab Linux machine as grading will beperformed on these machines.o Include a README to list any known issues and or assumptions about yourprograms. Also list the machine(s) you used to test your code.Grace Day usageIf you are using your grace days, indicate how many you are using at the top of each submittedfile in your submission, e.g. .pdf or .c files. The following is a sufficient enough indication ofgrace days being used:Using # grace DaysLate submissions which omit the indication will be graded with the following penalties:1-day late 10% penalty2-days late 20% penalty3-days late 30% penaltySubmission after 3 days, no credit unless you are using any grace days.Showing your workPlease show all of your work for questions that ask you to derive a formula or compute a certainquantity. This can include proofs, diagrams, or step-by-step derivations/calculations. Answers,correct or not, without sufficient proof of work may be penalized. On the other hand, answers thatare incorrect may earn partial credit if the work was correct but had minor mistakes. All programsin the programming part must be commented with proper instructions for compiling and executingthe code. If your code does not work for any of the testcase, please indicate so.Include a README file, and a makefile when necessary.2CSCI 5105 (Spring 2021)Introduction to Distributed Systems(Instructor: Anand Tripathi)Assignment 5 (100 points)Due March 21, 2017This assignment can be done in a group of up to two students.Goals: The goal of this assignment is to learn how to implement a replicated service using theState Machine Model. Implemented using Lamport clocks.Problem Statement: In this assignment you will build upon the server program which youimplemented in Assignment 3. You will create a group of replicated server processes, and eachprocess in the group will execute the same server code. All processes will maintain exactly thesame data about the bank accounts and they will execute exactly the same sequence ofoperations. All these processes will be required to execute the same sequence of operations, usingthe State Machine Model. (Discussed in my Lecture Notes 8 and in the paper on logicalclocks by Lamport.) Each process in the server group Will be assigned a unique integer ID, which will be usedfor total ordering of events using timestamps based on Lamport clock.You must use the Java RMI-based server from Assignment 3 for this assignment.Options in designing your program: You have the option to implement the communication between server process groupmembers using Java RMI or Thrift RPC, if you want. It is your choice.A typical execution environment will have multiple clients, and a client will connect to any one ofthe server processes in the replicated server group to request an operation. The set of allowedoperations will be the same as defined for Assignment 3.For implementing the State Machine Model, you will need to implement Lamport clock (logicalclock) at each server process. All message communication and significant events in a processwill need to advance the Lamport clock value appropriately. The client processes do not need tomaintain the Lamport clock.State Machine Model Protocol Description:Terminology used in the following outline of the State Machine protocol: Server Process Group: refers to the group of processes executing the server programcode. Server Process Replica: refers to a member process in the Server Process Group.The clients and Server Process Group members will execute as follows:1. A client process will send its request to one of the members of the Server Process Group.2. A Server Process Replica receiving a request from a client will multicast the requestmessage to all other members in the Server Process Group. Before multicasting therequest message, it will be marked with a timestamp based on the Lamport clock of theserver process replica. The multicast will be implemented by process-to-process RMIcall or Thrift RPC.33. On receiving such a Multicast request message, a Server Process Replica willappropriately advance its Lamport clock and send an acknowledgement with its current(i.e. advanced) Lamport clock value to the sender Server Process Replica.4. Each Server Process Replica will maintain a queue of all requests received either directlyfrom clients or indirectly from other members of the Server Process Group throughmulticast request messages. The requests in the queue will be ordered in the increasingvalues of their timestamps. The request at the head of the queue will be the one with thesmallest timestamp value.5. When a server process replica finds that at the head of the queue is a request which ithad originally received from a client and timestamped it for multicasting, and if it iscertain that there will be no future request in the system with any smaller timestampvalue, then: It will remove that request from the queue and execute it locally, and it will also sendan execute command to all other Server Process Group members to execute it.(Remember that each request is uniquely identified by its Lamport timestamp.) On receiving an execute command from another member of the Server ProcessGroup, a server process replica will remove from its local queue the specified requestand execute it locally, but without sending any response message to the client or anyServer Process Replica. The Server Process Replica which originally received the request from a client willsend a response message to that client after executing the request according to theState Machine model described above.Configuration and Testing of Replicated Servers:If you are using the RMI-based server, then you may consider having two different interfaces one for communication between the clients and the servers, and the other for communicationbetween peer server Replicas.You have the option to use either Java RMI or Thrift for peer communication between serverreplicas.In your design, if you are using Thrift RPC for peer-to-peer communication between serverreplicas, then your server will use a specified port number for Thrift RPC. Please follow a suitableformat for the configuration file and clearly describe it in your README file.You should be able to run the server processes either on one or multiple computers. You willcreate a configuration file to indicate the server process ID and the host on which it will berunning, and the rmiregistry port number.In the example below a configfile is shown for a system with three server processes, which are tobe executed on three different hosts with names alpha, beta, and delta. For each host, the serverIDand the rmiregistry port number are specified. In this configuration, server replica with id 0 willbe running on alpha.cselabs.umn.edu, and the rmiregistry on that host will be running on port5000.Note: The fourth column will be needed only if you are using Thrift RPC for server-to-servercommunication. Otherwise, you do not need the fourth column at all.Example of a configuration file data:Hostname SERVER-ID RMI registry Thrift RPC Portalpha.cselabs.umn.edu 0 5000 4000beta.cselabs.umn.eedu 1 5001 4001delta.cselabs.umn.edu 2 5002 40024Note: If you are running all these three processes on the same host Then there will be only one rmiregistry on that host and the same hostname andrmiregistry port number will be specified for all three server processes. However, theserver processes must Register themselves with the local rmiregistry with distinctlydifferent names such as Server_0, Server_1, Server_2 etc. You will need to make sure that you choose different Thrift port numbers for them if youare executing the server processes on the same host.You will start a server process on each one of the hosts as specified in your configfile and you willgive as command line arguments the server ID and the configuration filename.java server server-ID configFile // start server with the specified IDNote: Make sure that the host where are you are running this and the server-ID are consistentwith the contents of the configFile.Server Data Initialization:When a server process is started, it will first create 20 accounts. These will be sequentially giveninteger account ID values, starting with 1. It will also initialize the balance of each account to1000. After that the server will print to the console (screen) a message indicating that theinitialization is complete and it is ready to get requests.Client Process Structure:When all servers are initialized and ready, you will start your client processes. You will write amultithreaded client, and the number of threads will be specified as an argument to the clientprocess. You will also pass as argument the config filename to the client process.For example:Java client Client-ID 24 configFile // will create the client process with 24 threadsEach client process will be assigned a unique ID, which will be communicated to the server alongwith the operation request. A client thread will randomly pick one of the servers and send arequest (as noted below) to that server and wait for the response before sending the nextrequest. It will repeat this step for 200 times, and in each iteration it will randomly pick one of theSever Process Replicas.Each client thread will perform the following two operations 200 times and terminate.1. It will randomly pick two accounts and transfer 10 from one account to the other.2. It will write to the client logfile a record indicating the operation request and server processID. It will also write a log record when a response is received.After all client threads have terminated, the main thread will send a HALT command to theserver process with ID equal to 0. Note the HALT should be communicated and executed by eachserver process replica using the State Machine Model. Each server process will execute thiscommand as follows:1. The server process Will write to the logfile the current balance in each of the 20 accounts andthe sum of the balance in all 20 accounts, which should be 20000 if your system workscorrectly. The server processes will also write to the logfile the pending requests in therequest queue. It will also write the results of the performance measurement experimentnoted below. There should be none in the queue. After that the server process will terminate.2. The server processes will close all the log files and terminate.53. The server with ID equal to 0 will send a response to the client indicating that it has executedHALT.The client process, after getting response for HALT, will write to its client logfile, close the log fileand terminate.Logging requirements in your implementation:Server and client processes will be writing all important events to their respective log files. Eachevent will be recorded as new line appended to the log file. These will be helpful in tracing theevent logs for debugging and verification.Each client process will be assigned a unique ID. You may choose any suitable scheme for theseunique ID (just an integer value or some string name). You may have to include the Client ID inthe requests which are sent by a client to the server group. A client process will write to its log filethe requests that it sends to the server, along with the ID of the server. All client threads in aclient process will write to the same single log file.Each server process will also be maintaining a log file and it will write to its log file informationabout the requests as follows. Each such record is written as one line in the log file, and it mustbe in the order in which the events occur in the process.Naming of Log files: You should make sure that the log file created by a server is appropriatelynamed so it is clearly associated with that servers ID. Similarly, appropriately include the client IDin a clients log file name.Server Logging of Events:When a server receives a request from a client, the server process will log it as follows. TheServer-ID in the example log line below is the unique integer ID of the server.Server-ID CLIENT-REQ Physical-clock-time Request-Timestamp Operation-name ParametersFor example:Server-2 CLIENT-REQ 2021-03-04T11:50:41.011694 [678, 2] GetBalance(To get physical clock time, you can use now() method of Java LocalDateTime class from java.timepackage.)The string CLNT-REQ is to indicate that the request came directly from a client. The requesttimestamp of a request will be a Pair of two integers: [Lamport clock, ID]. It will be assigned to therequest by the Server Process Replica that originally received the request. This will be used todetermine the order of the requests.When a server replica receives a request multicast by another Server Process Replica, it willwrite a log line:Server-ID SRV-REQ Physical-clock-time Request-Timestamp Operation-name ParametersThe string SRV-REQ is to indicate that the request came indirectly from another peer serverprocess replica through a multicast.When a server removes a request from the request queue for processing, it will write a log line:Server-ID REQ_PROCESSING Physical-clock-time Request-Timestamp6Client Logging of Events:The client process (thread) will write to the logfile an event record when it sends a request to aserver process. The structure of the log line will be as follows:CLNT-ID SRV-ID REQ Physical-clock-time Operation-name ParametersIt will also write a log record to the file when a response is received.CLNT-ID SRV-ID RSP Physical-clock-time Response statusPerformance Measurement Experiment:The goal of this experiment is to measure the overhead due to replication management using theState Machine Model. At each server, measure the average value of the service processing time,i.e. the time between receiving a request from a client to the time when a response is sent to theclient for that request.For measuring elapsed time Between two events, you should use System classs getNano() method:long t0 = System.nanoTime(); //event 1..long t1 = System.nanoTime(); //event 2Measure this value for three different configurations with the number of replicated serverprocesses set to 1, 3, and 5. For this experiment, use just one client process with 24 threads. Allserver processes and the client process must be running on different hosts. Also compute theaverage value of the response time observed by the clients.Submission Requirements:1. Server code2. Client code3. Any other related code files4. Sample config file5. Results of your performance measurement data that you observed for the three systemsizes with the number of server processes set to 1, 3, and 5. In reporting the data for thisexperiment, indicate the CSELab machines on which you tested your program.6. README file witha. Instructions on how to run and test your program.b. Indicate what will be the names of the log files generated by running yoursystem.c. Any known bugs in your code7. A script file to compile your programs. You can also consider writing a script file to startserver processes on a specified list of nodes. Assume that all nodes have the same NFSfile system structure. Please include any script file you used to verify the correctness ofyour program.Submission Instructions: Each member in the group must submit the project work. Please include names and student-IDs of all group members. Submit one UNIX tar file containing parts listed under the requirements.7Grading Criteria: Grading will be based on the following allocation points:a) Test Case 1: (Points 25): Correct operations of the State Machine Model at allprocesses with a configuration of 5 server processes and one client process with 24threads, when all are executed on a single host.a. Correct order of request Processing at each server process as verified usingserver logs. (15%).b. Identical final state of accounts database at all server processes. (10%)b) Test Case 2: (Points 35): Correct operations of the State Machine Model at allprocesses with a configuration of 5 server processes when server processes areexecuted on a five different hosts and 3 client processes, each with 24 threads, areexecuted on some other host.a. Correct order of request processing at each server process as verified usingserver logs. (25%)b. Identical final state of accounts database at all server processes. (10%)c) Performance experiment data. (10 %)d) Correctly writing the log files at the server (10%)e) Correctly writing the log files at the client (10%)f) Documentation Items: (i) README file, (ii) code documentation, (iii) example config file,(iv) detailed instructions on how to test your program, (iv) Indicate on which CSELabmachines you tested your program. (10%)Clarifications on HALT request processing:When we have multiple client processes, should Server-0 wait to receive HALT requestfrom all client processes before stopping the system or should it stop the system aftergetting the first HALT command?In out testcases it is better that the system is halted only after getting the HALT command from allclient processes.This means Server-0 should know how many client processes are running in our testcaseexecution. For that purpose, just add one additional command line argument indicating thenumber of client processes in the test run.java server server-ID ConfigFile numClientsServer-0 will initiate system shutdown only when it has received HALT requests from all of theclients. When that happens, there cannot be any pending request in of the servers queue.Therefore, Server-0 on receiving HALT requests from all clients can simply send a command toall other server processes to execute HALT. There would not be any need to process the HALTrequest using the State Machine protocol.For example, when we are Running the system with 3 clients, when the Server-0 receives the firstand the second HALT requests, it can either keep them pending or just send a reply with OKresponse and let that client process terminate. Only upon receiving the third HALT request, itwould initiate server shutdown.请加QQ:99515681 或邮箱:99515681@qq.com WX:codehelp
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。