Design


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.

graphics/19fig01.jpg

The text fields and buttons on the bottom section of the Dashboard let you perform the following operations:

  • Add peers or groups (via the Add buttons).

  • Remove peers or groups (via the Remove buttons).

  • Monitor the presence of peers or groups (via the Local and Remote buttons).

  • Discover the presence of peers or groups (via the Discover buttons).

  • Flush the cache storage of names of peers or groups (via the Flush buttons).

  • List all the groups a specific peer belongs to (via the Groups check box).

The Tooltip accompanying each action widget describes its purpose.

Application Details

The 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.

Groups

All 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:

  1. Enter a group name in the text field.

  2. Click the Add button.

To remove a group:

  1. Select a group in the list.

  2. Click the Remove button.

Note

If the group contains peers, those peers are also removed.


To perform local group discovery:

  1. Select the Local button.

  2. Click the Discover button.

To perform remote group discovery:

  1. Select the Remote button.

  2. Click the Discover button.

To flush local group cache information, click the Flush button.

Peers

All 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:

  1. Make sure that the Groups box is unchecked.

  2. Select a group to include the peer.

  3. Enter the name of the peer in the text field (in the Peers section).

  4. Click the Add button (in the Peers section).

To remove a peer:

  1. Make sure that the Groups box is unchecked.

  2. Select a group from which to remove the peer.

  3. Select a peer name in the peer list.

  4. Click the Remove button (in the Peers section).

To perform local peer discovery:

  1. Select the Local radio button.

  2. Click the Discover button.

To perform remote peer discovery:

  1. Select the Remote radio button.

  2. Click the Discover button.

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:

  1. Make sure that the Groups box is unchecked.

  2. Select a group and see all the peers in that group displayed in the Peers section.

To list all the groups a specific peer belongs to:

  1. Make sure that the Groups box is checked.

  2. Select a peer and see all the groups for that peer displayed in the Groups section.

To flush local peer cache information, click the Flush button.

Sample Illustrations

This 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:

  1. Add three groups: group1, group2, and group3.

  2. Make sure that the Groups box is unchecked.

  3. Select group1 and add peer1, peer2, and peer3.

  4. Select group2 and add peer1 and peer2.

  5. Select group3 and add peer1 and peer3.

  6. Select the default group.

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.

graphics/19fig02.jpg

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.

graphics/19fig03.jpg

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.

graphics/19fig04.jpg

To see where peer2 is located:

  1. First perform a local peer discovery by unchecking the Groups box and selecting the Local button, then clicking the Discover button.

  2. Select peer2.

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.

graphics/19fig05.jpg

Purpose

The 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 Cases

A 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 Administrator

Let'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 Stock

Customers 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 Design

Four 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 Details

The 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 Information

It 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.



JavaT P2P Unleashed
JavaT P2P Unleashed
ISBN: N/A
EAN: N/A
Year: 2002
Pages: 209

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net