Pipes
One of the most powerful of JXTA’s services is the pipe service. The idea of a pipe is familiar to users of Unix systems: a pipe is used to connect the output from one command to the input of another command. On a Unix system, if you want to count the number of unique exceptions that occur in a log file, you might use this command:
piccolo% cat log | grep "Exception" | sort | uniq | wc -l
The cat command
prints the log file to its standard output. The
grep command reads this file from its standard
input and searches for lines containing the string
“Exception”; it prints matching
lines to its standard output. The sort command
reads these lines from its standard input and sends the sorted list
to its standard output, where it is read by the
uniq command, which removes duplicate lines. The
unduplicated lines are sent to its standard output, where they are
read by the wc command, which counts the number of
lines and finally prints that number.
Pipes are quite useful in that they allow you to build complex functionality from a number of simple building blocks. JXTA takes the familiar idea of pipes and extends their functionality to the network.
Peer Endpoints
JXTA pipes are defined in terms of the endpoints available to a peer. A peer endpoint is a logical abstraction of an address on a network transport that is capable of sending and receiving network messages. In the examples we’ve seen so far, the network transport has always been IP-based: the shell peer we’ve looked ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access