oreilly.comSafari Books Online.Conferences.
Articles Radar Books  

Learning the JXTA Shell
Pages: 1, 2, 3, 4, 5

Old Favorites

We'll start with a few old shell favorites.



If at any point you need help, the standard *nix man provides man(ual) pages for supported functionality. Typing just man displays information about man itself, along with a list of available commands.

JXTA>man
The 'man' command is the primary manual system for the JXTA shell.
The usage of man is:
 
   JXTA> man <commandName>
 
  For instance typing
   JXTA> man Shell
         displays man page about the Shell
 
The following is the list of commands available:
 
 cat        Display the content of an environment variable
 chpgrp     Change the default peer group
...
 who        Display member identity in a peer group
 whoami     Display peer and peer-group information
 
JXTA>

(For a complete list of JXTA shell commands, see "JXTA Commands.")

env, as expected, displays all defined shell environment variables.

JXTA>env
peer0 = stored local peer advertisement 
        (class net.jxta.impl.protocol.PeerGroupAdv)
stdout = Default OutputPipe (class net.jxta.impl.shell.ShellOutputPipe)
stdin = Default InputPipe (class net.jxta.impl.shell.ShellInputPipe)
Shell = Root Shell (class net.jxta.impl.shell.bin.Shell.Shell)
consout = Default Console OutputPipe 
          (class net.jxta.impl.shell.ShellOutputPipe)
consin = Default Console InputPipe (class net.jxta.impl.shell.ShellInputPipe)
stdgroup = Default Group (class net.jxta.impl.peergroup.StdPeerGroup)

Comment on this articleHave you explored JXTA? Tell us your first impressions and let others know what you've learned so far.
Post your findings

One thing to note in the above readout is that standard input (reading keyboard input) and output (displaying output to the console) are JXTA pipes, the same conduits by which peers communicate with each other. The same is true for the shell console's consin/consout. We'll delve more into pipes in a bit.

Here are a few more simple commands to try for fun:

  • man | wc
  • env | grep -i stdin
  • cat peer0 | more
  • Shell -s

Getting to know me

Let's get to know ourselves a little, shall we? The whoami command functions as expected, albeit a little more interesting than the standard printing of my username.

JXTA>whoami
<Peer>milne</Peer>
<Keywords>NetPeerGroup by default</Keywords>
<PeerId>jxta://59616261646162614A78746150325033237B7161401449269
6789EFFBC49968B0000000000000000000000000000000000000000000000000000000
000000301</PeerId>
<TransportAddress>tcp://1.2.3.4:6001/</TransportAddress>
<TransportAddress>http://JxtaHttpClient59616261646162614A7874615
0325033237B71614014492696789EFFBC49968B0000000000000000000000000000000
000000000000000000000000000000301/</TransportAddress>

JXTA>whoami -g
<PeerGroup>NetPeerGroup</PeerGroup>
<Keywords>NetPeerGroup by default</Keywords>
<PeerGroupId>jxta://59616261646162614A757874614D5047000000000000
0000000000000000000000000000000000000000000000000000000000000000000000
00000000000201</PeerGroupId>
<Service>jxta.service.resolver</Service>
<Service>jxta.service.membership</Service>
<Service>jxta.service.discovery</Service>
<Service>jxta.service.pipe</Service>
<Service>jxta.service.peerinfo</Service>
</code></pre>

The first whoami claims that I am a peer named "milne" with the unique identifier, "jxta://596162..." I am, by default, a member of the "NetPeerGroup" -- more on groups in a moment. I am communicating via TCP directly at IP address 1.2.3.4, port 6001, and via an HTTP proxy if behind a firewall/NAT. Note that even though I may be using HTTP to get past my firewall, direct TCP communication is still useful for peers on my LAN. The second whoami provides a little more detail about my current peer-group membership, including group identifier and available services.

For more details, there's whoami -l . This is but a pretty representation of the actual peer advertisement, viewable in its native XML by printing the "peer0" environment variable we saw above.

JXTA>whoami -l | more
jxta:PeerGroupAdvertisement : 
  Name : NetPeerGroup
  PeerName : milne
  Keywords : NetPeerGroup by default
  Pid : jxta://59616261646162614A78746150325033237B7161401449269
        6789EFFBC49968B0000000000000000000000000000000000000000
        00000000000000000000301
  Gid : jxta://59616261646162614A757874614D504700000000000000000
        00000000000000000000000000000000000000000000000000000000
        00000000000000000000201
  isRendezvous : false
  Services : 
    jxta:ServiceAdvertisement : 
      Name : jxta.service.resolver
      Version : JXTA1.0
      Keywords : resolver
      PipeService : 
      Params : http://216.15.60.14:6002
      Params : tcp://129.144.36.190:6001
      Params : http://209.25.154.239:6002
      Params : http://63.115.99.228:6002
      Params : http://206.132.188.132:6002
      Uri : http:/www.jxta.org/download/jxta.jar
      Provider : sun.com
-----More-----

JXTA>cat peer0 | more
<?xml version="1.0"?>
<!DOCTYPE jxta:PeerGroupAdvertisement>
<jxta:PeerGroupAdvertisement>
  <Name>NetPeerGroup</Name>
  <PeerName>milne</PeerName>
  <Keywords>NetPeerGroup by default</Keywords>
  <Pid>jxta://59616261646162614A78746150325033237B7161401449269
       6789EFFBC49968B00000000000000000000000000000000000000000
       00000000000000000000301</Pid>
  <Gid>jxta://59616261646162614A757874614D504700000000000000000
       00000000000000000000000000000000000000000000000000000000
       00000000000000000000201</Gid>
  <isRendezvous>false</isRendezvous>
-----More-----

These settings reflect the initial JXTA configurator settings we breezed through earlier. To reconfigure your JXTA peer from within the shell, take a gander at the peerconfig command (type: man peerconfig).

So much, then, for the preamble; let's get on to the interesting P2P pieces.

Pages: 1, 2, 3, 4, 5

Next Pagearrow





P2P Weblogs

Richard Koman Richard Koman's Weblog
Supreme Court Decides Unanimously Against Grokster
Updating as we go. Supremes have ruled 9-0 in favor of the studios in MGM v Grokster. But does the decision have wider import? Is it a death knell for tech? It's starting to look like the answer is no. (Jun 27, 2005)

> More from O'Reilly Developer Weblogs


More Weblogs
FolderShare remote computer search: better privacy than Google Desktop? [Sid Steward]

Data Condoms: Solutions for Private, Remote Search Indexes [Sid Steward]

Behold! Google the darknet/p2p search engine! [Sid Steward]

Open Source & The Fallacy Of Composition [Spencer Critchley]