JXTA架构概览
目前,SUN的计算机技术专家正在致力于组成JXTA的架构和技术,一个全新的、开放源码的为peer-to-peer[P2P]应用的计算结构。
Recently, Sun Microsystems released JXTA (pronounced juxta) as a platform for P2P applications. The project is an open-source effort accessible from jxta.org. In this article, we focus on the architecture and technologies that make up JXTA.
"When you consider a typical P2P application, you can see that JXTA has attempted to provide an architecture that matches the most common requirements."
The application platform in many ways reflect on the requirements of the architecture. For example, Client/Server requires the client to do a lot of work, and so it led to creation of "fat" clients. Consider for a moment, your favorite P2P application. Such applications are composed of a number of distinct nodes (peers) running on different physical machines. Given a collection of such peers, what are some of the things you need to create applications? Obviously you will need communication among peers. Such communication cannot be random, so you need a way to uniquely identify each peer. The collection is not static as peers will join and abandon the network, so there is a need to dynamically determine (discover) other peers. The few points mentioned above make up the foundation of peer-to-peer platforms.
JXTA is an attempt to create a framework by providing the capabilities that most P2P applications require.
JXTA relies heavily on XML to achieve its goals. Messages that are exchanged among the peers are in XML format, which makes JXTA platform independent. By separating protocol from specific language bindings, the platform is also technically language dependent, although it has initially been implemented using Java. The JXTA Shell (written in Java) is a sample application that relies on the JXTA platform, but it also shows many features of the platform.
When you start the Shell, it becomes one of the peers participating in the network. You can learn about (discover) other peers and communicate with them. Management of individual peers becomes complex as the number of peers increase. One way to address this problem is by introducing a "grouping" concept where multiple peers could collectively belong to a group. A set of membership services are provided to facilitate organization of peer groups which includes adding members, deleting members, finding members and exchange of messages among members. There are also services around security, authentication, access control, and pipe connections. It is interesting to note that the JXTA specification does not indicate when or why a peer group is to be formed, but it merely provides the infrastructure for forming and managing groups.
Once a network of peers is put together, the next challenge is communication among peers. This is done via pipes. Think of a pipe as a television channel. Messages that are sent into a pipe are sent to all peer endpoints that are listening to that pipe. The Pipe Binding protocol controls how peers are connected and disconnected to a pipe at runtime. Not all messages needs to be broadcast and JXTA recognizes that. It also offers a point-to-point pipe where one-way communication occurs between two peers.
Based on XML, pipes, peers, and services are represented via advertisements. For example, Peer Advertisements describe peer information such as name, peer id, properties, and services. The core advertisements types in JXTA are peer, peer group, pipe, service, content, endpoint and user-defined advertisements. You can think of advertisements as the "glue" that allows various peers on the network to communicate via pipes.
When you consider a typical P2P application, you can see that JXTA has attempted to provide an architecture that matches the most common requirements. It allows for management of peers and groups of peers. It allows for communication among peers via pipes. It defines the message structure exchanged among peers in advertisements. As a reference application, the JXTA Shell uses the P2P infrastructure provided by the platform. It provides a simple interface to various aspects of the JXTA platform that you can experiment with. After you feel comfortable with the Shell and its behavior, then you can focus development of your own P2P application on top of JXTA.
In my future "Class of the Month" columns, I'll cover the essence of a JXTA-based application and the set of Java classes that implement the JXTA protocol.
关于作者:
Piroz Mohseni is president of Bita Technologies, focusing on business improvement through the effective use of technology. His areas of interest include enterprise Java, XML, and e-commerce applications.