This project is to implement a prototype of distributed servers on which clients can register, login and broadcast objects to all the other clients.
This project has 4 collaborators including: @dongjize, @mason1002, @Lo1nt, @GatoY.
Our servers' architecture is a binary tree. A single server will connect to another server as a child connection and get connections by another 2 servers as a parent connection. So make sure do not connect more than 2 servers to a single server as child connections, it will throw system failure.
Clients can log in on any available servers whatever the load may be, because the server will redirect the login request to another server when this server has to many loads to handle.
There're 2 jar files in the project. To launch the project, firstly run the Server by:
java -jar ActivityStreamerClient.jar -lp 3780 -s 123
Then we can run another server connecting to the former one by:
java -jar ActivityStreamerClient.jar -rp 3781 -rh localhost -lp 3780 -s 123
Then we register several clients by running scripts like:
java -jar ActivityStreamerServer.jar -rh localhost -rp 3780 -u user1
Then we are able to send and receive activities in the GUI
Specific arguments is described in help functions of this project.
During the implementation of this project, we have faced many bugs and some bugs are fatal and hard to detect and handled, so we recorded the most annoying bugs here and how the triggers are and how we solved them.
It has the source code of this project. Server.java has the main method for server. Client.java has the main method for client.
This file records the main test cases. Of course, we have tested other circumstances like very complicated structure but we didn't put the details here.
This file records the common command and arguments to use both in Server and Client. Feel free to use these to have a try.
We can improve this project in some ways.
We can improve 'server.control.onLockAllowed' by make a node to send 'LOCK_ALLOWED' after it gets 'LOCK_ALLOWED' either from parent connection or all the active child connections. Use this logic, we don't have to send as many 'LOCK_ALLOWED' message as we did.
We can improve 'server.control.onLockDenied' by make a node to send 'LOCK_DENIED' immediately only to where it received 'LOCK_REQUEST' and not transfer the 'LOCK_REQUEST' when this node find the username has been registered already.
Our architecture in this project is a binary tree. We can make more than 2 child nodes to connect.