1 / 70

JXTA Innovation

JXTA Innovation. An Introduction By Daniel Brookshier. Why Are You Here?. JXTA, what’s that? JXTA sounds cool. JXTA will enter you life in a Big way Time to get ready or… be left behind . The world is not flat It’s a network. Daniel Brookshier A.K.A. Turbogeek. Java since 1995

Download Presentation

JXTA Innovation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.


Presentation Transcript

  1. JXTAInnovation An Introduction By Daniel Brookshier

  2. Why Are You Here? • JXTA, what’s that? • JXTA sounds cool. • JXTA will enter you life in a Big way • Time to get ready or… be leftbehind. The world is not flat It’s a network

  3. Daniel Brookshier A.K.A. Turbogeek • Java since 1995 • Multiple JXTA Projects • Verizon, Boeing, Texas Instruments (etc.) • Books & Articles • Industrial Strength Java • JavaBeans Developer’s Reference • Database Programming With Visual J++ (Please burn) • JXTA: Java™ P2P Programming (four versions) • English • Simplified Chinese • Traditional Chinese • India, Pakistan, Bangladesh,Nepal,Sri Lanka,Maldives

  4. All in the Name JXTA is short for Juxtapose • Juxtapose = To place side by side • juxtapositing = To place in close connection or contiguity. • Contiguity = Intimate association; nearness; proximity. Closeness in space or time to something, or actual contact • JXTA = Connect any group of computers into their own network regardless of each computer’s location or addressability.

  5. JXTAism • Java = Platform independence • XML = Application independence • JXTA = Network independence

  6. Why P2P?Barriers to Connectivity • Network blockage - Firewall, NAT, DHCP • Mobility - Laptop/Phone/PDA • Devices do not have a permanent address or even a public address • PC’s can find, but cannot be found • Cost of infrastructure to create a service

  7. Really? Work Laptop DHCP Firewall Proxy Firewall Internet DHCP NAT Firewall Home PC

  8. How? Peers outside of barriers serve as DNS and HTTP Tunnel relays Relay RDV Work Laptop DHCP Firewall Proxy Firewall Internet DHCP NAT Firewall Home PC JXTA Protocol Routes messages via an ID in the JXTA network

  9. More and More: Why P2P?When the Server is Gone,Chaos Rules • Loss of centralization • Decentralized resources • Transactions become looser and optimistic • Central authority for security, reference and for validation moves toward decentralized authorities for authentication • P2P increases complexity: • Instead of many to one, it is many to many • There are millions of computers, which one am I looking for? P2P services help solve these problems

  10. Solutions Provided by JXTA P2P • Replace IP and ports with an ID space • Virtual network to route/relay information to and from firewalled and NAT hidden peers • Ad hoc functionality • Grouping • Communications • Searching • Security • API that hides (most of) the complexity Ad hoc: Network created for the applicationor the current application goal.

  11. Business Reasons for P2P • Reduce the need for managed resources • Save on centralized hardware/bandwidth • Get out of the man in the middle business • Increase user-to-user and user-to-company interaction

  12. Why Should You Learn JXTA ?

  13. JXTA • Build Internet applications with “zero” investment (Free as in Free Beer) • Scalability is design dependent - not money dependent • Simple ideas are simple to develop • Usually GUI-based, so fewer parts to understand, develop, & debug • JXTA and P2P is fun and very new

  14. Connect to the source of data and opportunity Multi-Player Games Monitor Control Network Enable PC Software Chat Share Create webs of people Large Scale Multiprocessing Distribution systems Update software Update data Laptop connectivity Robotics Use your imagination Cool Things to Do

  15. High Level View of JXTA

  16. Four Levels of UnderstandingJXTA P2P Applications JXTA Frameworks/Utilities JXTA API / Implementations JXTA Protocol JXTA is simple to start using. Complexity is application dependent. Most of the harder work is hidden.

  17. Short Lesson in JXTA Terminology • Peer = Device/Application • Pipe = Abstraction used by JXTA to wrap peer-to-peer messaging. • Relay = A peer used to relay messages • HTTP Tunneling, Proxy, Protocol conversion • Rendezvous (RDV) • Propagate messages • DNS • ID - Various ID’s are used to identify and route

  18. Simplified JXTA Peer A has an Output Pipe X Peer B Peer A Peer B has an Input Pipe X Because A is looking for a pipe ID of X, JXTA connects the two peers. A can send messages to B.

  19. Propagation Pipes Peer C has an Input propagation PipeX Peer C Peer A has an Output propagation Pipe, X Peer B Peer A Peer B has an Input propagation Pipe X Peer D Peer D has an Input propagation Pipe X Because B,C,D are ‘listening” to a pipe ID of X, JXTA delivers messages from A to all input pipes.

  20. Types of Pipe • Unreliable Unicast • Secure/Reliable Unicast • Propagation Pipe • BiDiPipe (Pipe with input/output pair) • Can be secure(thus reliable) • SocketPipe (similar to socket/stream API) • Can be reliable and/or secure • More to come

  21. Coding • Complexity is mainly in the setup • New techniques, utilities, and improved API have reduced the drudgery.

  22. Getting Started • JXTA “boot” and connect to the network peerGroup=PeerGroupFactory.newNetPeerGroup(); waitForRendezVous(netPeerGroup); PeerGroup is context to a P2P network and its services. You should create a subgroup to isolate your ID space

  23. Utility MethodwaitForRendezVous() boolean waitForRendezVous(PeerGroup peerGroup)throws Exception{ RendezVousService rdv = peerGroup.getRendezVousService(); int count = 0; while (!rdv.isConnectedToRendezVous()){ Thread.currentThread().sleep(1*1000); if (++count >= 300){ LOG.error("becomming a rendezvous"); rdv.startRendezVous(); return true; } } return rdv.isConnectedToRendezVous(); } This method tests that we are connected to the/a JXTA network.

  24. BiDiPipe Example • Pipe Advertisement • Setup a BiDi server • Open client to another server • Process BiDI server connection • Send Message • Process messages

  25. Pipe Advertisement - BiDiPipe Advertisement adv = null; adv = AdvertisementUtilities.createPipeAdvertisement(pipeID,type); Type for BiDiPipe can only be Unicast or UnicastSecure

  26. Creating a BiDi Server Pipe jxtaServerPipe =new JxtaServerPipe(peerGroup, adv);

  27. Processing BiDi Connections while (running) { // Block until another peer connects to this socket JxtaBiDiPipe jxtaBiDiPipe = jxtaServerPipe.accept(); if (jxtaBiDiPipe != null ) { //call the listener } } This code is in a thread for processing incoming connections and calls a listener to use the new connection.

  28. Open client to another server - BiDiPipe PipeMsgListener listener= new InputListener(); if(peerID != null){ jxtaBiDiPipe = new JxtaBiDiPipe(); jxtaBiDiPipe.connect( applicationPeerGroup , peerID // To connect direct , pipeAdvertisement , timeout , listener); }else{ jxtaBiDiPipe = new JxtaBiDiPipe(applicationPeerGroup , pipeAdvertisement , listener); }

  29. Pipe Timeouts • Timeout time duration in milliseconds to wait for a successful pipe resolution. • Timeout of 0 will wait indefinitely. • Timeout when not specified are defaulted

  30. Send Message - BiDiPipe Message message = new Message(); StringMessageElementstringElement = new StringMessageElement( tag , messageValue , null , null); message.addMessageElement(stringElement); messenger = jxtaBiDiPipe.getMessenger(); while (!messenger.sendMessage(message)){ wait(1000); }

  31. Process messages - BiDiPipe class InputListener implements PipeMsgListener{ public void pipeMsgEvent(PipeMsgEvent pipeMsgEvent) { Message message = pipeMsgEvent.getMessage(); <<< Do something with the message >>> } }

  32. Propagation Pipe Example • Create pipe ID • Create Pipe Advertisement • Open input pipe • Open output pipe • Send messages

  33. Create Pipe Advertisement Propagation Pipe PipeBinaryID pipeID = digestTool.createPipeID(peerGroup.getPeerGroupID() , broadcastName , "invite pipe "+PipeService.PropagateType); PipeAdvertisement adv = null; adv = AdvertisementUtilities.createPipeAdvertisement(pipeID , PipeService.PropagateType); PipeService pipeService = peerGroup.getPipeService(); BroadcastListener listener = new BroadcastListener(); InputPipe broadcastIn = pipeService.createInputPipe(adv, listener );

  34. Open Propagation Input Pipe PipeBinaryID pipeID; pipeID = digestTool.createPipeID( peerGroup.getPeerGroupID() , broadcastName , "invite pipe "+broadcastType); PipeAdvertisement adv = null; adv = AdvertisementUtilities.createPipeAdvertisement(pipeID ,broadcastType); broadcastIn = peerGroup.getPipeService().createInputPipe( adv,new BroadcastListener());

  35. Open output pipe Propagation Pipe String broadcastType =PipeService.PropagateType; PipeBinaryID pipeID = digestTool.createPipeID( group.getPeerGroupID() ,broadcastName , "invite pipe "+broadcastType); PipeAdvertisement adv; adv = AdvertisementUtilities.createPipeAdvertisement( pipeID,broadcastType); broadcastOut = group.getPipeService().createOutputPipe(adv,0);

  36. Send messages Propagation Pipe Message message = new Message(); message.addMessageElement( null ,new StringMessageElement( newGame,gameStats.toXML(),null)); broadcastOut.send(message);

  37. Processing Propagation Pipe Messages • Propagation messages are identical to the normal pipe message • The key issue: Messages flow also to the sender if the sender is listening • Process change: Use Peer ID to realize echo’s of messages to self

  38. Check for PeerID in data class BroadcastListener implements PipeMsgListener{ public synchronized void pipeMsgEvent(PipeMsgEvent event) { Message message = event.getMessage(); MessageElement data = message.getMessageElement(null,”NewGame”); GameStats opponant = null; opponant = GameStats.fromXML(data.toString()); if (opponant.getPeerID().equals(peerGroup.getPeerID().toString())){ System.out.println("echo of self"); return; } else{ <<< Do something >>> } } } This application sends the peer ID in an XML message so that it can be ignored on propagation echo.

  39. JXTA Protocols and API

  40. JXTA Capabilities • One to one • One to many • Distributed XML Indexing & Search • Grouping of • Services • Identity • Communications • Security • Encrypted channels • Crypto Identification

  41. JXTA Protocol • Language Neutral • Combination of binary/XML messages • Defines a minimum set of functionality for P2P • Describes grouping, routing, searching, resolution, relay, and messaging • Implemented over other other protocols like HTTP, TCP/IP, IP Multicast and others.

  42. What is JXTA Not? • Not Java centric (perhaps Java biased) JXTA is a protocol • Not 100% XML • Not 100% secure (yet) • Not Simple (but simple to use) • Not an application or a tool (you need to write code) • Not the death of server technology • Not a cure for all the ills of mankind.

  43. More JXTA Concepts • Peer • PeerGroup • Pipe • Advertisement • Rendezvous (RDV) • Relay • Module • Platform

  44. JXTA Stack Applications JXTA API PeerGroup ID XML SocketPipe BiDiPipe BinaryID UUID CBID Pipe Rendezvous Relay Discovery Resolver HTTP/TCP/UDP

  45. It’s Open Source • Need volunteers • C/C++ • Opportunity to learn Java • Pad your skills and your resume • Software testing • Use current demos to prove concepts • Learn about new methods of P2P

  46. Information • www.jxta.org • www.p2pjournal.com • people.jxta.org/turbogeek/ • JXTA P2P User’s group • First Wednesday of the month at JC Penney • My email: turbogeek@cluck.com

  47. Questions Daniel Brookshier Turbogeek@cluck.com

  48. It’s never that easy…

  49. Web Services Point to point Requires server Limited discovery IP bound .NET Same as Web Services with hodgepodge of centralized services. IP bound Note: MS P2P is IPv6 and very limited (I.e. does not threaten other MS products) J2EE/EJB/Servlet/JSP IP bound Lots of maintenance High cost to scale JINI LAN centric Not meant to scale to web Java centric design Roll your own networking High cost Low support Other P2P JXTA is generic, others serve specific purposes (usually file share) JXTA vs. What I Know

  50. More: Why P2P?Monolithic Server • A server is required to allow a PC to communicate to others • Server applications require large amounts of storage, bandwidth, and processing power (scalability = $$$$) • Thin Client = Very Fat Server • Servers are not zero maintenance • Servers must exist (no ad-hoc networking)

More Related