Coconut AIO
Kasper Nielsen <[email protected]> Wed, 25 Aug 2004 17:25:06 +0200
| Newsgroups | gmane.comp.java.seda.user |
|---|---|
| Message-ID | <[email protected]> |
Hi,
Although not directly related to sandstorm I thought somebody on this
list might be interested in it. Basicly Coconut AIO serves the same
functionality as aSocket and ADisk in sandstorm. However is has a number
of additional features, here are some of them:
* 2 other completion notification programming styles in addition to the
sink-based approach used in sandstorm. Future-style (polling, blocking)
and Callback style.
* JXM enabled, bytes read/written, sockets accepted, ...
* Fine grained monitoring, for example, you can dynamically specify
callbacks that are called whenever a socket read, writes, connects,
binds, closes, … I've used that, for example, for implementing a
primitive debugging mechanism (sample output from logs):
Socket[83] Connected to localhost/127.0.0.1:12338 from /127.0.0.1:1066
Socket[83] Wrote 20 bytes to localhost/127.0.0.1:12338
Socket[83] position 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
------text------
Socket[83] 00000000 48 65 6C 6C 6F 48 65 6C 6C 6F 48 65 6C 6C 6F 48
HelloHelloHelloH
Socket[83] 00000010 65 6C 6C 6F ello
Socket[83] Closed
* SocketGroups and DatagramGroups are a way of "bundling" together a
number of related sockets or datagram sockets. Consider, for example, an
P2P application where we have a number of outgoing sockets and a number
of incoming sockets. Many P2P applications are characterized with a high
churn (the continuous process of node arrival and departure) and new
connections must be established frequently. These applications might
have a connection policy, for example, that no more (and no less) then
100 outgoing connections must be active at the same time.
class 100ConnectionPolicy implements Handler<AsyncSocket socket> {
AsyncSocketGroup group;
void handle(AsyncSocket socket) {
if (group.size() < 100 ) {
AsyncSocket socket = AsyncSocket.open();
socket.setGroup(group);
socket.connect(some remote host);
}
}
}
This callback is called by the runtime whenever a socket leaves the
group (normally by calling close() or due to some exception). Later on I
hope to use to use these groups for bandwidth restraining or for
prioritizing requests from certain connections over others.
Anyway take a look Coconut AIO at http://coconut.codehaus.org if you are
interested (just ignore the other stuff on the site). Until now the
primary focus has been on the API. But I hope to spend some more time on
optimizations and eventually bugs that should show up. The manual is
under development but take a look at some of the unit test which
displays most of the functionality or just try the mailing list. If
you have used sandstorm there should be few surprises.
A quick warning, Coconut AIO is Java 1.5 only. The API
(http://coconut.codehaus.org/sites/coconut-aio-api/apidocs/index.html)
is designed in such a way that it "fits" nicely into java.util.concurrent.
- Kasper
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285