![]() |
The OceanStore
Project Tapestry Application HOWTO |
This page attempts to describe the information necessary to write software which interfaces with Tapestry, the peer-to-peer routing infrastructure of OceanStore. If you're trying to build a new peer-to-peer application using Tapestry, this page is for you.
There are several components to writing applications for OceanStore. This
document will cover the basic operations necessary to write Tapestry applications.
For information about interfacing with the other components of OceanStore,
please see online documents at the OceanStore
website
.
OceanStore is a project designing an architecture for global-scale storage at Berkeley.
All that said, here are the directions.
ostore.tapestry.api
classes. There are several interesting
types of messages you can send in Tapestry. Check the
javadocs
for details. Good starting points include
type_code
function. This function
was part of a legacy interface. Instead, just write this:
public int type_code () {
throw new NoSuchMethodError ();
}
ostore.util.TypeTable.register_type ("my.class.Name");
mdw.sandStorm.api.EventHandlerIF
. Here are some important
steps:
init
function, you need to listen for the types
of messages you intend to receive. Here's some sample code to do just that
(all sample code in this document is copied more or less verbatim from
ostore.inner.FakeInner
, in case you want to look up the full source):
_self_node_id = new NodeId (config.getString ("node_id"));
_classifier = Classifier.getClassifier (_self_node_id);
String [] msg_types = {
"ostore.rp.InnerRingCreateReqMsg",
"ostore.inner.UpdateReqMsg",
"ostore.inner.LatestHeartbeatReqMsg",
"ostore.inner.TimedHeartbeatReqMsg",
"ostore.inner.BlockReadReqMsg"
};
for (int i = 0; i < msg_types.length; ++i) {
// register the type
ostore.util.TypeTable.register_type (msg_types [i]);
// set up a filter
Filter filter = new Filter ();
if (! filter.requireType (Class.forName (msg_types [i])))
BUG (tag + ": could not require type " + msg_types [i]);
if (! filter.requireValue ("inbound", new Boolean (true)))
BUG (tag + ": could not require inbound = true for "
+ msg_types [i]);
_classifier.subscribe (filter, _this_sink);
}
handleEvent
, write the event handlers for
each of the messages you listened for in init
. Here's some
more sample code:
public void handleEvent(QueueElementIF item)
throws EventHandlerException {
if (item instanceof InnerRingCreateReqMsg) {
InnerRingCreateReqMsg msg = (InnerRingCreateReqMsg) item;
// do something with it
}
// etc.
else {
BUG (tag + ": received unknown QueueElementIF: " + item + ".");
}
}
ostore.dispatch.Classifier.dispatch
()
. Like this:
UpdateRespMsg resp_msg = new UpdateRespMsg (signed_resp);
try {
_classifier.dispatch(item);
} catch (SinkException e) {
BUG (class_tag + ".dispatch: could not dispatch " + item);
}
.cfg
file for your stage, and then
use oceanstore/pond/ostore/run-sandstorm
to run it. You also
need to include Tapestry stages in this file. More details to come.