The actual procedure followed to implement the proposed design as mentioned in the previous chapter is explained in this chapter. As mentioned the proposed design is implemented using Java and the all the required screens are designed using the Java swings and the data base is created in Oracle SQL. This chapter summarizes all the important classes and tables used along with the flow of the application are clearly described in this chapter.
Classes used in the application
Every aspect across java programming is an object and these objects can be inherited in the form of class and the objects of the class can be created to initiate the core functionality used across the class. Following are the classes created in this project with respect to initiate the flow of the application. All the classes used across this application are created using the Java swings framework and the flow of the business logic is as listed below
All the java files are created with an extension of .java and the corresponding logic used across these java files are as given below
Required logic to add the clients to the servers is given in this class. As per the design few clients can be added to the server and the corresponding procedure is coded in this class. Java swing frame work is used to create this logic and all the basic components of the swing class like text fields, layouts and gaps are used to create the basic layout out the of the screen and is as shown in the appendix section. A separate client id is issued to the newly added client and assigned to the desired server and the corresponding logic used here is that the server id is tracked against adding the required client and the newly added client is to the serve and the server is identified with the server id. Once the client is added, a new row is added to the client table and the corresponding query used here is Initially the number of clients are calculated and if this count is as per the defined handled clients for the server, then only the client is added to the desired server else the client is added to the next available server. Once the required constraints are satisfied the client is added to the client table and the rows are incremented by 1 against the table. Whenever the client is added to the server and the database is updated, the link status of the server and the client is also updated and set to on the corresponding logic is written.
When the client is added to the server, the corresponding client IP address and the client name are also updated against the database table client.
Administration.java class is used to create the user interface for all the administration activities and the coding procedure followed is explained in this section. The key administration tasks used in this project are to start or stop the master server, check the status of the links, start the distribution mode of the network and initiate the mobile agent for detecting the faults across the distributed networks. Administrator can check the status of the links between the clients and the server at any point of time and they are provided an option with respect to this. A link status form is opened at the user interface and the administrators can view the status of the desired links at this window and even this window is created using the swings. Distributed network option is also available to the administrator and they can initiate the distributed mode of the network. Admin is provided with an Mobile agent button and the users can click on the button to start the mobile agent, where this agent collects the information related to the distributed network faults and suggests the options for the fault recovery options. The key java code used to create this logic is as given below
A new object is created in the private methods to initiate the administrator requests and thus the overall functionality of the admin module is coded in this java class.
This class is used to created the frequently used java functions like the database functions and thus if at all a new instance of the database is required an object is created for this class and initiated to dump the complete coding logic in this case. Following are the important methods used in this class and the corresponding description of the methods are also given below
This method is used create the connection to the database and the basic JDBC drivers are used to create the connection to the database using the Connection class across java. Once the connection is established, the corresponding statements and other parameters are initiated. Oracle thin driver is used to create the bridge to the database in this class and the user name and password to access the database are also provided in this method
This method can be used to get the server name by providing the server if as the required parameter. A separate global server is used as the required table and the server information is recorded in this table and thus the information is fetched from the database and the corresponding query used for this process is as given below
This method can be used get the server name by providing the server name as the required parameter and the value is fetched from the global server database table. Following is the query used to get the required information from the table
This method can be used to fetch the required client id with the help of client name and the client name is provided as the required parameter to the method. Below is the query is used to get the required client information with the help of client name
This method can be used to get the client name by providing the client id as the required parameter and this name is fetched from the database table known as client and the actual query is used in this context is as given below
As mentioned the administrator can check the status of the links from the desired server and the client and the corresponding code is given in this java class. User interface is provided in such a way that the users can select the desired from the dropdown list and also can select the client id from the list and the swing components are used to create this interface. All the ids of servers and clients are fetched from the corresponding database tables and the required logic is given in this class. Once the users selects these values, these values are given as the input to the query built and this query is fired on the status table to get the current status of the desired server and client and the corresponding coding logic used is as shown below
Thus the current status of the client and the server can be fetched using this logic and the query as shown above.
Master server is initiated across this project and the corresponding logic used is given in this java class. From the master server user can start the desired server and in this project two servers are created and named as Server A and Server B and once the user clicks on the desired button, the actual server operations are started. Java swings are used as the required framework and all the key components are added to get the required interface to the application. The actual action performed by user is captured using the action events provided with the swings package and based on the action performed the corresponding server is started and the key coding logic used in this context is as shown below
From the above code it is clear that if server A is selected the corresponding ID is tracked and the actual server module is started and this procedure is repeated for both the servers as shown in the above code.
This is the important class used among all the classes created in this application. Mobile agent is the java class that captures all the link failure information and displays to the administrator and the administrator can set the status to On again using this class and the corresponding functionality used. User is also provided the required suggestion to check the alternative paths across this process and the corresponding functionality is provided in this class. The link status information is fetched from the database and the corresponding logic is used as given below
From the above code it is clear that the required information is gathered from the database table link_status and the status values are iterated in a loop using the result set object available with the JDBC package and the fetched values are displayed to the users in a tabular form and required rows are added to this table using this information fetched from the database table. A vector object is used to store all the values retrieved from the database and the loop is iterated against this loop.
As mentioned in the design of this project, clients and servers can receive the data from the any other servers and clients and the required programming logic is given in this java class. All the data received from any other client or server is displayed to the users in the form a table and the required logic is written using the java swings framework and the corresponding components in the swing framework. Database connections are established to gain the access to the information related to all the received data by a particular client or server. A table with name datapackets is created in the database and that particular information is gained from this table and displayed to the users in a tabular form. All the data received is fetched from the table and stored in a vector object and thus a loop is iterated using the JDBC result set object and the corresponding values are displayed to the user and the corresponding screenshot is as shown in the next chapter. The actual coding logic used for this java class is as shown below
As mentioned in the design chapter, any client or server can send to the desired client and server and the required programming logic is created in this java file. A window is created across this section and the users can type the desired message to be sent and actual number of packets is also calculated using this logic. A separate text field is created in this class and the client or server can add the required message to the text area and the data entered is sent to the desired client or server and the number of packets sent is also calculated in this class and the corresponding coding done is as given below
From the above code given it is clear that all the data sent is saved in the database table datapackets and the inserted text is converted to the desired format and the corresponding client and server information are added as well. A prepared statement is created and the query is inserted to the prepared statement and executed to insert these values in to the database table.
Following are the database tables used in this application
- Link status
- Data packets
All the important classes are explained in this chapter and the corresponding code is also provided. The actual results achieved against this implementation are given in the next chapter.