|
The OceanStore Project
OceanStore HelloWorld HOWTO by Hakim Weatherspoon, Chiu Wah Kelvin So, and Jason Lee |
The goal of this OceanStore HelloWorld excercise is for each user to individually practice writing, compiling, running, and debuging your own OceanStore code. Please attempt to work through the excercise before looking at answer solution. Also, you can direct questions to Hakim Weatherspoon <hweather@cs.berkeley.edu>, Jason Lee <jlee81@cs.berkeley.edu>, Jeremy Stribling <strib@cs.berkeley.edu>, and/or Chiu Wah Kelvin So <kelvinso@cs.berkeley.edu>.
Your mission, should you accept it, is to create two nodes that pass a simple msg to each: client->server "Hello! How are you?", server->client "Great! The weather is wonderful today!"
Note all DD java classes you will be using are defined in the
dd.api package. Also, all HelloWorld
classes and files will be placed into the dd.demo.helloworld.step1
package/directory.
Note make sure to be explicit about what classes are being imported (e.g.
do NOT use import ostore.util.*), make sure to comment code
(look at dd.directmail.impl.DirectMailTester for an example), and make sure to break up code into constants, static variables, variables,
static constructors, constructors, static methods, methods, and
inner classes (again DirectMailTester and other classes mentioned as
examples are good examples).
HelloWorldServer publishes the fact that it is a
helloworld server.HelloWorldTag extends DDTag)HelloWorldClient locates and sends msg to HelloWorldServer by sending a HelloWorldLocateMsg.
HelloWorldLocateMsg extends DDLocateMsg)HelloWorldLocateMsg constructor takes as input
a Service Provider GUID, a DDQuery, a DDQueryState,
and a Unique ID to identify any response to the msg
(e.g. msg response or a DDLocateFailure).HelloWorldQuery that extend DDQuery.
HelloWorldQuery returns DDQueryResultMatch if a
HelloWorldTag is found; otherwise, returns a
DDQueryResultNoMatch.HelloWorldServer receives the HelloWorldLocateMsg it needs
to print the msg to the screen and respond with a HelloWorldRouteMsg
acknowledging that it received the msg and containing a response msg
that the client can print to the screen.HelloWorldLocateMsg's. The ostore.dispatch.Resender will assist
in timingout as explained below.Standard Stage thoroughly; note the predefined stuff. Also, look at the ArchiverStage at how they use Signal with resender.DDPublishMsg')helloworld step1 impl directory in dd/demo/helloworld/step1/impl
(i.e. oceanstore/dd/demo/helloworld/step1/impl), and a helloworld step1 api
directory in dd/demo/helloworld/step1/api demo.helloworld.step1.impl package.demo.helloworld.step1.api
package.
demo/dynamic into your helloworld/api and helloworld/step1 directory and change the DD_Home path so that it points to root directory of dd.
.cvsignore file from ostore/apps/test into your helloworldHelloWorldClient and
HelloWorldServer.HelloWorldServer needs to listen for two events:
DDReadyMsg and HelloWorldLocateMsg.HelloWorldLocateMsg is a msg you create for the client to locate and
send msg to server.HelloWorldServer constructor you need to enable your stage to
be able to receive events by assigning event_types, inb_msg_types
and serializable_types like below
// Events to register
event_types = new Class[]{dd.api.DDReadyMsg.class};
// Inbound messages to register (off the wire)
inb_msg_types = new Class[]{demo.helloworld.api.HelloWorldLocateMsg.class};
// Objects that are serializable but not an event or message.
serializable_types = new Class[]{
demo.helloworld.api.HelloWorldQuery.class,
demo.helloworld.api.HelloWorldRouteMsg.class,
demo.helloworld.api.HelloWorldTag.class
};
HelloWorldClient needs to listen for four events:HelloWorldRouteMsg,
DDLocateFailure.Resender needs your stage to listen for timeouts.
ostore.archive.RequestorStage is a good example of how to use
the Resender.HelloWorldRouteMsg is a msg you create for the server to
respond to the client with.node_guid).HelloWorldServer publishes its services AFTER receiving the
DDReadyMsg.HelloWorldClient attempts to locate HelloWorldServer AFTER
receiving the DDReadyMsg (note: Although HelloWorldClient receives DDReadyMsg, Bamboo is not actually ready for all the stages. Therefore, if HelloWorldClient sends out HelloWorldLocateMsg right after DDReadyMsg, HelloWorldClient will get a DDLocateFailure. To avoid that, HelloWorldClient can use Classifier.dispatch_later to dispatch an event that tells the HelloWorldClient to start a few seconds later after getting DDReadyMsg)handleDDReadyMsg
will send DDPublishMsg for server and/or dispatch_later(StartTest)
for client. You can create StartTest by creating an inner class in HelloWorldClient. Also, in Client, create a method to handle StartTest. When receiving StartTest, use resender.resend(HelloWorldLocateMsg).HelloWorldClient needs to record that fact that it sent a
HelloWorldLocateMsg and is waiting for a response.resenderin Standard Stage, a Resender object to timeout
and resend automatically by resender.resend.java.util.HashMap's):
resender_tokens in the Standard Stage (records resender tokens to use to cancel
resending; that is, resender.cancel(token)).
resender.process_queues();
resender.clear(false);
HelloWorldServer receives the HelloWorldLocateMsg it will
print the msg and respond.logger.info*message*/) to print out the msg. logger has be instantiated in Standard Stage.
logger.warn(/*message*/) for warning, and use logger.debug((/*message*/) for debug message. If there is error, use BUG(/*message*/)
req.identifier).req.peer field contains the node guid of the HelloWorldClient.
You will need this to send in the HelloWorldRouteMsg to respond to
the correct node.HelloWorldClient receives the HelloWorldRouteMsg it should_resender_token table,resender.cancel( token )),
Click here to continue with how to run HelloWorld as an experiment.
Click here to go to HelloWorld Exercise step2