wiki:IpaacaQuickStart

Ipaaca Quickstart

Requirements

Spread: ( http://www.spread.org/), already installed on netboot machines.

Quickstart

Ipaaca requires that spread is running:

spread -n localhost &

In the simplest (but often used) usecase, Ipaaca is used to submit some incremental unit containing one or more strings from an outputbuffer in one program to the inputbuffer of another program.

To do this on the sending side

Inititialization:

  1. Create an outputbuffer (may be reused later on)

Sending the message:

  1. Create an messageiu
  2. Set the category of the message iu
  3. Set the payload of the message iu: this is a set of (key, item) pairs with key and item both strings
  4. Add the IU to the outputbuffer

To do this on the receiving side

Initialization:

  1. Create an inputbuffer that is registered for the ius your are sending
  2. Register an handler that is registered for the category your are sending and IUEventType MESSAGE

Receiving the message:

  1. The handler is called whenever a message iu from the sender arrives.

In C++

sending side

Initialization:

ipaaca::OutputBuffer output_buffer = ipaaca::OutputBuffer::create("idofoutputbuffer");

sending the message:

ipaaca::Message::ptr msg = ipaaca::Message::create("categoryid");
msg->payload()["key"] = "value";
output_buffer->add(msg);

receiving side

Initialization:

input_buffer = ipaaca::InputBuffer::create("idofbuffer", "categoryid");
input_buffer->register_handler(boost::bind(&MyClass::handle_iu_event, this, _1, _2, _3));

With

void MyClass::handle_iu_event(ipaaca::IUInterface::ptr iu, ipaaca::IUEventType event_type, bool local)
{
std::string value = iu->payload()["key"];
}

as handler function.

In Java

sending side

Initialization:

Initializer.initializeIpaacaRsb();
OutputBuffer outBuffer = new OutputBuffer("component1");

sending the message:

LocalMessageIU localIU = new LocalMessageIU();
localIU.setCategory("category1");
localIU.getPayload().put("key", "value");
outBuffer.add(localIU);

receiving side

Initialization:

Initializer.initializeIpaacaRsb();
Set<String> categories = new ImmutableSet.Builder<String>().add("category1").build();
inBuffer = new InputBuffer("component2", categories);
EnumSet<IUEventType> types = EnumSet.of(IUEventType.ADDED, IUEventType.COMMITTED, IUEventType.UPDATED, IUEventType.MESSAGE);
inBuffer.registerHandler(new IUEventHandler(new MyEventHandler(), types, categories));

With

final class MyEventHandler implements HandlerFunctor
{
  @Override
  public void handle(AbstractIU iu, IUEventType type, boolean local)
  {
    String value = iu.getPayload().get("key");
  }
}

In Python

import ipaaca

sending side

Initialization:

out_buffer = ipaaca.OutputBuffer('myArtibtraryComponentName');

sending the message:

msg_iu = ipaaca.Message('category1');
msg_iu.payload['key'] = 'value'
out_buffer.add(msg_iu);

receiving side

Initialization:

def my_first_iu_handler(iu, event_type, local):
	print( u'Received payload: ' + unicode(iu.payload) )

my_category_interests = ['category1']
in_buffer = ipaaca.InputBuffer("myArtibtraryComponentName", my_category_interests);
in_buffer.register_handler(my_first_iu_handler)