The P2P Dashboard is a standalone application designed to have two main components: a graphical user interface (GUI front end), and a JXTA integration (back end), which utilize the latest JXTA platform release. The GUI displays peer and group information for monitoring purposes. The update of such information is handled by the JXTA integration. When launched from the desktop, the Dashboard appears with two adjacent panels, one for displaying the names of peers, and the other for displaying the groups (see Figure 19.1). For further details, refer to the section "Application Details." Figure 19.1. The P2P Dashboard.The text fields and buttons on the bottom section of the Dashboard let you perform the following operations:
The Tooltip accompanying each action widget describes its purpose. Application DetailsThe code for the P2P Dashboard application is contained in a zip file. Extract the contents of this zip file to a directory on your local disk. Let's refer to this directory as the installation directory. The readme.txt file in the installation directory contains information for building and running the P2P Dashboard application. The P2P Dashboard requires a JXTA configuration before it can run. The JXTA Configurator is a part of the JXTA platform. All applications automatically call the JXTA Configurator if no JXTA configuration exists. First, you must create the default peer using the JXTA Configurator, then you can use the Dashboard for performing several tasks concerning peers and groups as outlined in this section. When you create the default peer, the application creates the default group. GroupsAll the command buttons, text fields, radio buttons, and names that are necessary to add/remove and monitor the peers are displayed in the Groups section of the Dashboard. To add a new group:
To remove a group:
Note If the group contains peers, those peers are also removed. To perform local group discovery:
To perform remote group discovery:
To flush local group cache information, click the Flush button. PeersAll the command buttons, text fields, radio buttons, check boxes, and names that are necessary to add/remove and monitor the peers are displayed in the Peers section of the Dashboard. To add a new peer:
To remove a peer:
To perform local peer discovery:
To perform remote peer discovery:
Note Note that remote discovery of peers or groups is possible only in a network environment. To list all the peers in a specific group:
To list all the groups a specific peer belongs to:
To flush local peer cache information, click the Flush button. Sample IllustrationsThis section presents a few samples to illustrate the various features of the P2P Dashboard program. Creating Peers and Groups (Community Formation)Let's first create the default peer, peer1, using the JXTA Configurator. The Dashboard application creates the default group to accommodate the default peer. Follow these steps on the Dashboard:
When you add peers and groups in this manner and select the default group on the Dashboard, the entire Dashboard looks similar to Figure 19.2. Figure 19.2. Newly added peers and groups.Discovering Peers (Presence)Now you want to find out how many peers are present in group3. All you need to do is clear the Groups check box and select group3. The peers in group3 are displayed in the Peers section, as shown in Figure 19.3. Figure 19.3. Discovering peers in group3.If you want to discover the peers in group1, first make sure that the Groups box is unchecked, then select group1. The peers in group1 are displayed in the Peers section, as shown in Figure 19.4. Figure 19.4. Discovering peers in group1.To see where peer2 is located:
The Groups section displays all the groups (group1 and group2) that peer2 belongs to, as shown in Figure 19.5. Also notice that the Groups box is checked. Figure 19.5. Discovering groups for peer2.PurposeThe purpose of P2P Dashboard is to illustrate the Peer Membership Protocol and Peer Monitoring/Discovery Protocol of the JXTA technology. The philosophy behind the design of the P2P dashboard program is to de-couple the graphical user interface from the JXTA platform as much as possible. Use CasesA perfect sample use of the P2P Dashboard is in creating, monitoring, and administering various system-level services operating in an enterprise. Other examples are outlined in the following sections. Chat Room AdministratorLet's suppose that an online site called Oz has administrators that require software to maintain and monitor their online chat rooms. Administrators can add/remove peers in the default Oz group (community). Users of the online chat rooms can add/remove themselves from different user-made-groups that are created based on various chattopics. If a user (a peer) deviates from the Oz online charter, the administrator can remove that user from the online groups by removing the peer definition for that user from the Dashboard. Random chat room monitoring can proceed smoothly while administrators passively participate in various group activities during specified peak activity hours. Buying StockCustomers routinely trade stocks online. Brokerage houses (groups) allow their customers (peers) to place orders to buy and sell stock online. Customers can interact with one or more brokerage houses in order to perform such stock trading activities. Real-time stock quotes use the mechanism of publish-subscribe for delivering up-to-date stock quotes for customers who require it. Customers interact with their various groups in order to get stock quotes and conduct stock trades. Brokerage houses maintain their online customers through an administrative software package that allows them to add/delete customers and classify customer investment needs. Class DesignFour Java classes make up the P2P Dashboard sample program. P2PDashboard is the main class that encapsulates all graphical user interface elements and directly interfaces with the JXTA platform. PeerDiscovery is the class that handles local/remote peer discovery management. GroupDiscovery is the class that handles local/remote group discovery management. SortedListModel is a helper class that performs list-related tasks. Special DetailsThe current implementation of the graphical user interface depends on a JAR file from the latest version of the integrated development environment NetBeans Version 3.3. The file AbsoluteLayout.jar is required to build and run the P2P Dashboard program. Flushing Peer InformationIt is possible for the Dashboard to have stale peer/group information. In order to pre-empt this occurrence, the discovery feature of the Dashboard provides the capability to manually update this information at any point in time. Before the discovery is done, the flush feature guarantees that all existing peer/group advertisements are cleaned up. |