JXTA: Java P2P Programming

  • Authors:
  • Daniel Brookshier;Darren Govoni;Navaneeth Krishnan;Juan Carlos Soto

  • Affiliations:
  • -;-;-;-

  • Venue:
  • JXTA: Java P2P Programming
  • Year:
  • 2002

Quantified Score

Hi-index 0.00

Visualization

Abstract

From the Book:IntroductionBy Daniel Brookshier When thinking about how to introduce this book, I thought I might start bywelcoming you to a new concept in software. I have worked with many types ofsoftware, and I have programmed exclusively in Java since it was introduced in1995. I've seen my share of new concepts and ideas that would change theworld. Java has had the biggest impact in my life, and I believe the evidenceshows that it has changed the computer world. What about JXTA? Why should you orI use a technology that is so new and a departure from Web Services and clientserver technology?When I started looking around, I found that JXTA is not so much a new conceptas it is a revolution. Not a revolution in the sense of new orgroundbreaking—a revolution like the French Revolution.As with most situations where things go wrong, you blame those in power. TheFrench had some rather large grievances with their government. Under Louis XIVand Louis XV, there was extravagant spending, unpopular wars on foreign soil,state bankruptcy, and high taxes imposed mostly on the common man. The Frenchrevolutionaries decided that the monarchy and the elite class all had to go.And, as they say, heads would roll.Peer-to-peer is a response to a sort of server-based tyranny. Client-server,multi-tier, and Web server technologies are like kings. Servers concentratepower and resources, limit access, and restrict an individual's ability toaccess and control his or her own data. This is not exactly an affront to ourcivil rights, but it can mean that a corporation has my data on theirservers.There is also a barrier to the entry. The rich and noble born and elite ofFrance controlled resources, and only large organizations have the resources tobuy and maintain large servers. With the rise of Linux, you can create ashoestring operation, but you still need to pay for bandwidth and otherresources. Servers hold the applications and data we use, but we have no stakeor control in them. As individuals and even large groups, we cannot muster theresources to create our own servers unless we were born rich like a noble orhave the resources like a corporation.Oust the king and suddenly you are looking for someone else to govern. TheFrench, while architecting their revolution, had some of the same thoughts astoday's JXTA developers. On August 26, 1789, the National Assembly ofFrance approved a document, entitled Declaration of the Rights of Man and of theCitizen. They based it somewhat on the declaration of independence written inAmerica. The French document seems to be more about individuals operating in asociety and, thus, more like a peer-to-peer system. Let's look at a few ofthe articles of the declaration to see where the French revolutionaries and JXTAagree. Men are born and remain free and equal in rights. Social distinctions may be founded only upon the general good (Article 1).Peers also achieve social status via the information or unique processingthey contribute. In a server world, the server has almost all resources, whileclients have little or none. The principle of all sovereignty resides essentially in the nation. No body nor individual may exercise any authority which does not proceed directly from the nation (Article 3). JXTA creates a community where no individual computer has the ability toaffect the entire network unless other member peers allow it. In a sense, thisis like a democracy but on a more personal level, because you vote byparticipation in a group or application. Rights of individual computers are alsogranted by the protocols that every computer on the peer-to-peer network mustfollow. In a server environment, the client must follow the rules of the serversoftware and the owners of the server. When there are many servers, there arealso many masters, causing the clients to follow too many different andconflicting rules. Liberty consists in the freedom to do everything which injures no one else; hence the exercise of the natural rights of each man has no limits except those which assure to the other members of the society the enjoyment of the same rights. These limits can only be determined by law (Article 4). Liberty in JXTA, like real liberty, is difficult to define. But the keydifference from client/server technology is the ability to be an acting part ofthe application. The benefits are a bit ethereal, but imagine the ability totruly control your data. You can also process the data at any time. Is thisfreedom? Hard to say, but it is a start.JXTA promotes freedom as well as the right to punish those that abuse it.Even a free society has laws. For a network to succeed, there needs to be someway to know when others are harmed and provide a consequence to thoseresponsible. In a P2P network, the ability of one member to do harm is limited.The redundancy of the network reduces the impact on the society of peers but,like any society, there are criminals (or at least perceived to be). JXTA hasthe notion of a credential. If a peer fails to be a good citizen, its rights maybe forfeited and the credential invalidated.Server environments are a bit different. Beyond denial of service attacks,being a good or a bad client is a gray area, mainly because the applications arevery constrained for normal users. The server is often cast as the villain, as ahoarder of data and even breaking the trust of clients by allowing the sale of aclient's data. All the citizens have a right to decide, either personally or by their representatives, as to the necessity of the public contribution; to grant this freely; to know to what uses it is put; and to fix the proportion, the mode of assessment and of collection and the duration of the taxes (Article 14).Taxation should be compared to a service fee or cost to create a service. AJXTA peer determines the level of participation in the network and, thus, thecost of its hardware and other resources. Like a consumption tax, there is atendency to pay more, the more you use the network. Due to redundancy and sharedprocessing, all users benefit, rather than suffering because of poorhardware.Users make their own decisions on how they configure and use their P2Psoftware. Inappropriate and draconian controls instituted by a server'sowners or chosen software are eliminated.In another way, article 14 also shows the difference between server and P2Ptechnology. With servers, an infrastructure must be maintained. Server software,because of its costs, looks like a government that requires a tax to operatethat is usually flat rather than based on participation. With a peer network,peers share resources and each peer pays its share by its existence and level ofparticipation. A society in which the observance of the law is not assured, nor the separation of powers defined, has no constitution at all (Article 16).This is sort of an obvious statement for JXTA. If you don't use JXTAprotocols (our Constitution and basic laws), you cannot be a member of thecommunity. If you are using JXTA and do abuse its community, you are usuallyjust hurting yourself. Since property is an inviolable and sacred right, no one shall be deprived thereof except where public necessity, legally determined, shall clearly demand it, and then only on condition that the owner shall have been previously and equitably indemnified (Article 17).P2P started to become popular with the introduction of Napster. Sadly, theimplication was that P2P was associated with piracy. Although Napster wasoriginally formed with the idea that only valid owners of music would accessdigital versions, there was probably more piracy than legitimate use.Consequently, Napster has suffered in court with a severe reduction in thenumber of users.P2P networks, such as Gnutella, are also devoid of rights management. Thesesystems cannot be taken to court as Napster was because they are trulydistributed. However, because of their uncontrolled nature, corporations andISPs are restricting their traffic, and individual users are being charged withcrimes or losing rights to services. It is highly probable that these systemswill be disabled or at least inconvenienced.The ultimate goal for JXTA is to be a good citizen and respect copyright andproperty laws. The reason is simple, without respectability, JXTA is seen asanother Napster or Gnutella and will be filtered by ISPs and corporations.Respect others' rights to their property and you will be treated as afellow citizen and allowed to use the Internet and corporateinfrastructures.Most of us live in a commercial society, and we deal with commercialentities. Where there is unfair trade or criminal activity, the system ofgovernment or those affected will tend to remove those who abuse the system.Although you may argue that entities like record companies are not actingfairly, the fact is that the laws are currently written to protect them—notthose who dislike the law and protest it by circumvention. Napster and the newerincarnations have not changed any laws through their public protests and activebreaking of laws. We still need to follow the rule of law to succeed.JXTA ScaleAnother revolutionary idea of JXTA is what it empowers you to build. Withouta central server, with its costs and limits, much more is possible. This doesnot necessarily mean new types of applications, just a greater scale than waspossible in a server environment.A good example of the scalability of JXTA applications is simple catalog fore-commerce. Normally, you would need a large number of clustered servers tohandle a large number of transactions. With JXTA, the catalog and its softwareare distributed automatically among peer computers. Instead of a server thatmust show the same catalog to millions of users, you just need one PC todistribute the first copy and any updates. All that needs to be centralized isthe final order acceptance and credit card transaction, and even that isdistributable to some extent.There are many benefits of a P2P catalog from cost savings to the ability ofa user to access the catalog offline. The application also runs faster becausethe user is not as limited to his or her connection speed or waiting in a queueof other users. Add to this 100 percent availability to most users, and youensure that the verities of the Internet or of a server farm are no longer apart of the risk equation.Another scale feature is raw computing power. In a server environment, eachclient has access only to limited resources that must be shared by all users.With JXTA, each peer has all the power of the machine it is running on, plus theshared power of all the other peers with which it is collaborating. Is JXTA a New Concept?Just by reading this far, you may have seen very familiar concepts. In theprior examples on scale, it is very easy to associate the same goals withdistributed computing. The examples of P2P throughout the book are all possibleusing other methods. However, the point of JXTA is not necessarily to replacethese methods. JXTA is a platform with specific protocols to talk to other JXTAplatforms in a peer-to-peer network. It is not an application or a librarycreated to build specific applications. The reason JXTA exists is to enable therefactoring of many different applications in a P2P environment. Like thecatalog example, the idea is to move away from centralized infrastructures togain the benefits of a distributed system.RMI, CORBA, and Web Services are distant cousins of JXTA. They are eitheroriented toward a client/server or limited point-to-point communications. JXTAmay seem to provide similar services, but the framework beneath is verydifferent. For example, you can implement remote method invocation. The keydifference between JXTA and others is that the delivery of the command toexecute can span barriers like firewalls. The remote command can be sent togroups of computers or just a single computer, depending on the type oftask.JXTA RisksI think we can safely agree that JXTA is not like anything else. Is JXTAsomething to bet your time as well as your fortune on? There are risks. Some arenew and others are well known. Some are being fixed as you read this book, andothers simply need to be implemented on the current JXTA platform.The largest risk now is that JXTA will be in flux over the next couple ofyears. The good news is that the community of developers will try to keep thenetwork stable for the purpose of keeping their products working. When you reacha certain point, developers learn to hate change, even when the project is opensource.It is not all a bed of roses in other areas. There are aspects to a P2Psystem that can be problematic. In our catalog example, it does take time topropagate the catalog to all users. The same time delay is true of updates andtransactions.We are at the start of the JXTA revolution. It is time to thinkrevolutionarily thoughts. The reign of client server is about to fall. Read onand join the revolution. Viva la revolution!Daniel Brookshier JXTA Community Member, Java Consultant January 2002, Dallas, TexasWhat This Book CoversThis book will only cover the Java J2SE reference platform implementation ofJXTA. We will not cover the C++, J2ME, Pearl, or other languages that are beingused to create JXTA platforms. The J2SE version is the reference platform andbest for experimentation or explanation of JXTA protocols. Java is also the mostpopular language for JXTA development at this time.This book is intended to introduce new developers to the JXTA API andselected applications and services. Our goal is for the reader to understand P2Pconcepts and be able to build useful applications using JXTA.We do not cover detailed aspects of how the JXTA platform is implementedunless it adds value to the explanation on how to use it.Who Should Use This Book?This book is written for readers who need an introduction to P2P and forthose who want to learn JXTA. You should already be comfortable with Java. Youdo not need to know anything about JXTA or peer-to-peer programming.By the end of the book, you should be able to create simple P2P applicationsusing JXTA and the J2SE JXTA reference platform.How This Book is OrganizedThis book is organized with two goals. The first goal is to explain P2P andJXTA in general terms. The second goal is to create applications that use JXTA.Finally, we cover specific applications with the aim of furthering anunderstanding of JXTA while showing how more complete applications are written.This arrangement was chosen so that the reader can get an overview of JXTA andthen build an understanding of how to use its various parts.Web Resources and Example CodeYou can download the source code for examples presented in this book fromhttp://www.samspublishing.com.When you reach that page, enter this book's ISBN number (0672323664) in thesearch box to access information about the book and a Source Code link.The NetBeans IDE was used for much of the code that is found in the book.NetBeans is available athttp://www.netbeans.org.Because Forte from Sun Microsystems is derived from NetBeans, it should work aswell. You can also use your favorite editor or IDE, but the ANT scripts werecreated within NetBeans and Forte.Also on the site are files that can be used with MagicDraw from NoMagic athttp://www.MagicDraw.com.The tool is written in Java and runs on most Java-compatible platforms. The demoversion will allow you to browse and print the JXTA diagrams used in the book,but it will not allow you to save changes. The MagicDraw files follow the XMIstandard for UML representation in XML, so other UML tools that support thestandard should work (drawings may look different).© Copyright Pearson Education. All rights reserved.