sg.edu.nus.peer.request
Class ServerRequestManager

java.lang.Object
  extended by sg.edu.nus.peer.request.ServerRequestManager

public class ServerRequestManager
extends java.lang.Object

Implement all request operation of the super peer.

Version:
1.0 2007-2-17
Author:
Xu Linhao

Constructor Summary
ServerRequestManager()
           
ServerRequestManager(ServerPeer serverpeer)
          Construct a request manager for server peer.
 
Method Summary
 void createMatchesTable(java.sql.Connection conn)
          mihai, june 24th, 2008 creates a table to map the schema mappings.
 void indexData(java.lang.String columnName, java.lang.String tableName)
          Implemented by Quang Hieu, Jun 01, 2008 Index a column
static void main(java.lang.String[] args)
           
 boolean performCancelJoinRequest(java.lang.String ip, int port)
          Perform a JOIN_FAILURE request to the bootstrap server, who will remove the registered information from OnlinePeerManager.
 void performCheckImbalance(int seconds)
           
 boolean performJoinRequest(java.lang.String ip, int port)
          Perform a SP_LOGIN request to an online super peer, who will be responsible for routing the SP_JOIN request to the proper super peer, and initializing the routing table and other necessary information of the newcomer.
 void performLeaveRequest()
          Perform a LEAVE request when a super peer signs off
 void performLoginRequest(LoginPanel window, java.lang.String user, java.lang.String pwd, java.lang.String ip, int port)
          Perform a LOGIN request to the bootstrap server, who is responsible for validating the correctness of the super peer's identifier and then returning all online super peers as its bootstrap in order to allow it to join the super peer network.
 boolean performLogoutRequest(java.lang.String ip, int port)
          Perform a LOGOUT (I_WILL_LEAVE) request to the bootstrap server, who is responsible for removing the registered information from the OnlinePeerManager and updating the UI components.
 boolean performRefreshRequest(java.lang.String ip, int port, Message msg)
           
 void performRegisterRequest(java.awt.Window window, java.lang.String user, java.lang.String pwd, java.lang.String ip, int port, java.lang.String email)
          Perform a REGISTER request to the bootstrap server, who is responsible for registering the peer information to the back-end database and returning all online super peer information to the newcomer for letting it to select one as the bootstrap to join the super peer network.
 void performSchemaUpdate(java.lang.String newSchema)
          Mihai drops the existing schema and creates a new one as indicated by the bootstrap node
 boolean performStabilizeRequest(java.lang.String ip, int port, Message msg)
           
 boolean performSuccessJoinRequest(java.lang.String ip, int port)
          Perform a JOIN_SUCCESS request to the bootstrap server, who will add the registered information to OnlinePeerManager/
 void shareDatabase(java.util.Vector<java.lang.String> listOfTables, java.util.Vector<java.util.Vector<java.lang.String>> listOfIndexedColumns, java.util.Vector<java.util.Vector<java.lang.String>> listOfUnindexedColumns)
          Implemented by Quang Hieu, Jun 01, 2008 Share a table
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServerRequestManager

public ServerRequestManager()

ServerRequestManager

public ServerRequestManager(ServerPeer serverpeer)
Construct a request manager for server peer.

Parameters:
serverpeer - the handler of the ServerPeer
Method Detail

performLoginRequest

public void performLoginRequest(LoginPanel window,
                                java.lang.String user,
                                java.lang.String pwd,
                                java.lang.String ip,
                                int port)
Perform a LOGIN request to the bootstrap server, who is responsible for validating the correctness of the super peer's identifier and then returning all online super peers as its bootstrap in order to allow it to join the super peer network.

Parameters:
window - the handler of the login window
user - the user identifier
pwd - the password
ip - the IP address of the bootstrap server
port - the port of the bootstrap server

performRegisterRequest

public void performRegisterRequest(java.awt.Window window,
                                   java.lang.String user,
                                   java.lang.String pwd,
                                   java.lang.String ip,
                                   int port,
                                   java.lang.String email)
Perform a REGISTER request to the bootstrap server, who is responsible for registering the peer information to the back-end database and returning all online super peer information to the newcomer for letting it to select one as the bootstrap to join the super peer network.

Parameters:
window - the handler of the login window
user - the user identifier
pwd - the password
ip - the IP address of the bootstrap server
port - the port of the bootstrap server
email - the email address of the register user

performLogoutRequest

public boolean performLogoutRequest(java.lang.String ip,
                                    int port)
Perform a LOGOUT (I_WILL_LEAVE) request to the bootstrap server, who is responsible for removing the registered information from the OnlinePeerManager and updating the UI components.

If the super peer signs out successfully, then another online super peer may be selected to replace the empty position of the super peer in order to maintain the correctness of the network structure.

Parameters:
ip - the IP address of the bootstrap server
port - the port of the bootstrap server
Returns:
if logout successfully, return true; otherwise, return false

performJoinRequest

public boolean performJoinRequest(java.lang.String ip,
                                  int port)
Perform a SP_LOGIN request to an online super peer, who will be responsible for routing the SP_JOIN request to the proper super peer, and initializing the routing table and other necessary information of the newcomer.

Parameters:
ip - the IP address of an online super peer
port - the port of the online super per
Returns:
if join the super peer network successfully, return true; otherwise, return false

performSuccessJoinRequest

public boolean performSuccessJoinRequest(java.lang.String ip,
                                         int port)
Perform a JOIN_SUCCESS request to the bootstrap server, who will add the registered information to OnlinePeerManager/

Parameters:
ip - the IP address of the bootstrap server
port - the port of the bootstrap server
Returns:
if join operation is success, return true; otherwise, return false

performCancelJoinRequest

public boolean performCancelJoinRequest(java.lang.String ip,
                                        int port)
Perform a JOIN_FAILURE request to the bootstrap server, who will remove the registered information from OnlinePeerManager.

Parameters:
ip - the IP address of the bootstrap server
port - the port of the bootstrap server
Returns:
if join operation is canceled, return true; otherwise, return false

performLeaveRequest

public void performLeaveRequest()
Perform a LEAVE request when a super peer signs off


performStabilizeRequest

public boolean performStabilizeRequest(java.lang.String ip,
                                       int port,
                                       Message msg)

performRefreshRequest

public boolean performRefreshRequest(java.lang.String ip,
                                     int port,
                                     Message msg)

performCheckImbalance

public void performCheckImbalance(int seconds)

performSchemaUpdate

public void performSchemaUpdate(java.lang.String newSchema)
Mihai drops the existing schema and creates a new one as indicated by the bootstrap node

Parameters:
newSchema -

createMatchesTable

public void createMatchesTable(java.sql.Connection conn)
                        throws java.lang.Exception
mihai, june 24th, 2008 creates a table to map the schema mappings.

Throws:
java.lang.Exception

shareDatabase

public void shareDatabase(java.util.Vector<java.lang.String> listOfTables,
                          java.util.Vector<java.util.Vector<java.lang.String>> listOfIndexedColumns,
                          java.util.Vector<java.util.Vector<java.lang.String>> listOfUnindexedColumns)
Implemented by Quang Hieu, Jun 01, 2008 Share a table

Parameters:
tableName -

indexData

public void indexData(java.lang.String columnName,
                      java.lang.String tableName)
Implemented by Quang Hieu, Jun 01, 2008 Index a column

Parameters:
columnName -
tableName -

main

public static void main(java.lang.String[] args)