












































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!













































commit coordinator called “Coordinator” in our case coordinates these events. This Coordinator implements Coordinator part of the two phase commit i.e. openTransaction, closeTransaction, abortTransaction and join. Voting is an automatic process and it requires both OfficeBallotServer and ReferendumBallotServer to commit otherwise the vote submission fails. The following diagram illustrates how this project is implemented.
Use Case Diagram:
L o g i n g e t B a l l o t V o t e L o g o u t
g g g g e t B a l l o t g e t R e s u l t g e t R e s u l t s Fig.1 User interaction with server through client
Fig.2 Server interaction with Coordinator and Ballot Server Figure 2 shows the interaction of VoteServer with Coordinator and BallotServer. When the user submits his vote through client program to VoteServer, it sends the vote to BallotServer. Coordinator creates a transactionID and the VoteServer registers the transactionID for that transaction. The following is the detailed explanation of the server interactive methods Coordinator Methods: openTransaction: This method initiates transaction with the coordinator and the coordinator creates a transactionID for the VoteServer for that particular transaction. Commit: This method causes the coordinator to commit the transaction indicated.
BallotServer Methods: getNumberofBallots: This method returns the number of ballots held by the server implementing this interface. getBallot: This method returns an individual ballot for each user. Vote: This method is used to store the results, that user submitted to server, of individual Ballots. Fig.3 BallotServer interaction with Coordinator Figure 3 shows the interaction of BallotServer with Coordinator. When Ballot server receives a vote it joins the transaction with coordinator.
Client Server Co-ordinator Ballot Server Login SubmitVote Invalid Login valid Login join openTransaction submitVote Transaction ID join response Confirm Vote response successfull or not response commit (^) cancommit do commit do Abort do operation response Fig. Communication Diagram Activity Diagrams: The below diagram shows us the activities of all the servers.
Collaboration Diagram Depicting the initiating of saving a ballot.
Class Diagram:
Deployment Diagram: Deployment diagram for Voteclient and VoteServer The above deployment diagram shows us the RMI registry, Stubs and the interface. Client program creates stubs. Server registers its methods with RMI registry. Client and server interact through RMI interface. The below deployment diagram shows us the interaction between VoteServer and Coordinator and Coordinator. Coordinator registers its methods with RMI registry. VoteServer and BallotServer can access them through RMI interface. BallotServer also register its method with RMI registry. VoteServer access these methods through RMI interface.
Stub Login getBallot Vote logout RMI Registry
1. Voter: This interface has four methods: login, logout, vote, and getBallot. public String login(String Name) throws RemoteException; Object getBallot(String SessionID) throws RemoteException; boolean vote(String SessionID, Object Ballotvar) throws RemoteException int logout(String SessionID) throws RemoteException; This interface is implemented with the name Voterimpl. 2. Coordinator: This interface has four methods: openTransaction, Commit, Abort, join public int openTransaction() throws RemoteException; public boolean commit(int transID) throws RemoteException; public boolean abort(int transID) throws RemoteException; public boolean join(int transID, Participant phandle ) throws RemoteException; This interface is implemented with the name Coorimpl. 3. Participant: This Interface has three methods: canCommit, doCommit, doAbort public boolean doCommit(int transID) throws RemoteException; public void doAbort(int transID) throws RemoteException; public boolean canCommit(int transID) throws RemoteException; 4. OfficeBallotServer: This interface extends participant and has the following methods: getBallots, Vote. public Object getBallot(int ballotID) throws IOException, RemoteException public boolean vote(Object vBallot, int transID) throws IOException, RemoteException This interface is implemented with the name OBSimpl. 5. ReferendumBallotServer: This interface extends participant and has the following methods: getBallots, Vote. public Object getBallot(int ballotID) throws IOException, RemoteException public boolean vote(Object vBallot, int transID) throws IOException, RemoteException This interface is implemented with the name RBSimpl. The name of the client program is VoteClient. This program allows users to enter into the Electronic Voting system. This program uses the remote methods in the server (VoteServer) and interacts with the user. After the user submits his vote through
VoteClient, the VoteServer opens a transaction with the Coordinator using the method openTransaction (public int openTransaction() throws RemoteException;). This method returns the transaction id for that transaction. VoteServer takes this transaction id and sends the ballot of votes to Ballot Servers (OfficeBallotServer & ReferendumBallotServer). These Ballot servers store the ballots and indicate the Coordinator that they join in the transaction by using the method join. public boolean join(int transID, Participant phandle ) throws RemoteException;). Now the VoteServer asks the Coordinator to Commit using the method commit. (boolean commit(int transID) throws RemoteException;). The Coordinator asks the Ballot servers if then can commit. Then Coordinator asks them to do commit or to do abort. User can close his session using logout method. Results of the Runs: The below figure illustrates the use of electronic voting system. After VoteClient program is started, you will see the following messages: Electronic Voting System Enter Your Name: Enter your name and if you are not voted already, you will see the follwing messages: To view the choices enter V To exit enter X Enter your choice: Enter your choice. If you enter “V” then the following choices are displayed. Office Ballot: President Referendum Ballot: Globalization Enter O: for President Election Enter R: for Referendum Election Enter your choice: Enter your choice. If you enter “O” the Office ballot participants is displayed. If you enter “R” the Referendum ballot participants is displayed. After selecting the appropriate options, u can enter “X” to logout. User selecting Office Ballot:
User logging out without viewing the Ballot:
Message is displayed saying that user is already voted: Conclusion: Lessons Learnt: Before this project I had no prior knowledge about two-phase commit protocol. I learned the concepts and methods of two-phase commit protocol. While doing the coding for this project, I learned how to implement two-phase commit protocol. Difficulties: I felt very difficult to implement this project in the beginning. But while implementing I learned a lot. Extension: This project can be extended in many ways. Here are some of my ideas which can be implemented for the future versions: a) A more secure voting system can be implemented b) A good GUI can be implemented c) Registration of Users can implemented d) Can be implemented for multicast objects. e) Can be tested for reliability