Issues getting Reef Application up and running

11 views
Skip to first unread message

Adam Todorski

unread,
Feb 11, 2012, 9:59:10 AM2/11/12
to Reef Users Group
I'm trying to make a Reef application in Java and am running into some
issues and have two questions. One: I do not appear to be registering
the app correctly as my heartbeats are rejected with a
BadRequestException "Heartbeat failed - Cannot create heartbeat
status, register application first. ". Here is how I'm trying to
register it:

ApplicationService applicationService =
client.getService(ApplicationService.class);

NodeSettings settings = new NodeSettings("nodename", "location",
"network");
List<String> capabilities = new ArrayList<String>();

// no capabilities are added, is this my problem?
//capabilities.add("");

appConfig = applicationService.registerApplication(settings,
"applicationName", capabilities);

The registerApplication call is successful but when I subsequently try
to send a heartbeat using the resulting ApplicationConfig, it fails
with the aforementioned exception:

StatusSnapshot.Builder
snapshot = StatusSnapshot.newBuilder();

snapshot.setInstanceName(appConfig.getInstanceName());
snapshot.setOnline(true);
snapshot.setProcessId(appConfig.getProcessId());
snapshot.setTime(Calendar.getInstance().getTimeInMillis());

// boom! it blows up on this call
applicationService.sendHeartbeat(snapshot.build());

I feel like I'm missing a step in registering the application, but
can't figure out what.

Secondly, I'm trying to implement a new protocol. I created an OSGi
bundle which includes a class that implements Protocol and that
attempts to register it in the OSGi BundleActivator like so:

private MyProtocol protocol = new MyProtocol();

@Override
public void start(BundleContext context) throws Exception {

// config for reef
Dictionary<String, String> config = new Hashtable<String,
String>();
config.put("protocol", "myprotocolname");

// Instantiate our protocol
context.registerService(
MyProtocol.class.getName(), protocol, config);

Any insight would be much appreciated!

Thank you,
Adam

Adam Todorski

unread,
Feb 11, 2012, 10:05:48 AM2/11/12
to Reef Users Group
I forgot to include the actual question in the second part: the bundle
registers just fine but endpoints using the protocol never transition
to the COMMS_UP state, nor do the addChannel and addEndpoint methods
get called in my protocol class.

Adam Todorski

unread,
Feb 12, 2012, 10:12:55 AM2/12/12
to Reef Users Group
I've solved the problem with registration of my protocol: the OSGi
service registration needs to be told that I'm registering a
org.totalgrid.reef.protocol.api.Protocol and not my implementation
thereof else the Reef FEP manager won't see my class as something that
it needs to do something with. This is obvious in retrospect as there
is no way for the FEP manager to know that the class I registered
implements Protocol, but it was challenging to debug.

I also added my protocol to the org.totalgrid.reef.node.cfg
configuration file (org.totalgrid.reef.protocols), but I'm not sure if
that is strictly necessary.

Sam Hendley

unread,
Feb 16, 2012, 10:14:36 AM2/16/12
to reef-...@googlegroups.com
Hey Adam, glad you were able to work that out on your own. We are actually in the process of writing a comprehensive guide on implementing a protocol which ill be sure to forward to you when its complete.

You didn't need to include the protocol name in the org.totalgrid.reef.standalone.cfg file. That is used only during testing to launch a simplified system that doesn't depend on OSGi (and hence needs a list telling it what protocols to load. 

If your curious the code is here:

Let us know if you encounter any more problems, we are usually much more responsive on weekdays.

Sam

Adam Todorski

unread,
Feb 16, 2012, 8:19:56 PM2/16/12
to reef-...@googlegroups.com
Thank you, Sam.  I am new to scala, but it is very concise and expressive so reading some of the source in the core to figure out how to make my plugin really wasn't that bad.

Adam
Reply all
Reply to author
Forward
0 new messages