Defining BYON locations on application descriptor

46 views
Skip to first unread message

migue...@gmail.com

unread,
Apr 3, 2014, 3:58:39 PM4/3/14
to brookly...@googlegroups.com
Hi everyone,

I'm trying to define an application which has several application servers (i.e. JBoss7Server) each of them running on different locations.

I already made it work using a YAML plan and BYON locations for each server without any difficulties, but now I need to add some more functionality to it, such as defininig new sensors, and I can't find the proper way to define BYON locations in the java application descriptor.

I already tried with this for a single server:

JBoss7Server server = addChild(EntitySpec
.create(JBoss7Server.class)
.configure("httpPort", "8080+")
.configure("name", "Server")
.configure("war", "WAR_PATH")
.location(byonLocationResolver.newLocationFromString(
Maps.newHashMap(),
"byon:(hosts='10.0.1.1')",
getManagementContext().getLocationRegistry())));

But i'm getting this error:

2014-04-03 18:05:54,855 WARN Failed to create entity using spec EntitySpec{type=interface brooklyn.entity.Application} (rethrowing)
java.lang.IllegalStateException: Entity MyApplication{id=eIfSgB8c} (in null) requires a single SshMachineLocation, but has []
at brooklyn.entity.effector.EffectorTasks.getSshMachine(EffectorTasks.java:160) ~[brooklyn-core-0.7.0-SNAPSHOT.jar:na]
Caused by: java.lang.IllegalStateException: Optional.get() cannot be called on an absent value
at com.google.common.base.Absent.get(Absent.java:42) ~[guava-15.0.jar:na]

Any ideas?

Miguel

Aled Sage

unread,
Apr 3, 2014, 5:42:57 PM4/3/14
to brookly...@googlegroups.com
Hi Miguel,

Could you post your whole app class as a gist [1] or equivalent please, and also let us know how you are running the app?

I'd be really interested in hearing more about your use-case.

---
Your error says that MyApplication was passed zero locations, rather than it being about Jboss7Server not getting its location by the looks of it.

If you look in the brooklyn.debug.log file (most likely in the working dir where you launched brooklyn) then you'll see the full exception stack trace.

---
A common pattern is to define the locations outside of the actual application blueprint (thus making it location-agnostic).

For example, you could start your app with a MachineProvisioningLocation (e.g. using byon for a pool of machines), and let each app-server obtain a machine, by passing the pool to the server.start() method (or in the Jboss7Server's entitySpec.location() method).

Or your app could take multiple locations, and could create a DynamicRegionsFabric - for each location passed to the fabric it creates an entity; you could tell it to create a cluster of AS7 servers.

---
Instead of calling the byonLocationResolver directly, it's normal to just do one of:
  1. start booklyn with something like:
    brooklyn launch --app <yourapp> --location "byon:(hosts='10.0.1.1')"
  2. define a named location in brooklyn.properties, that you can then reference, e.g.
    brooklyn.location.named.my-hosts=byon:(hosts='10.0.1.1')
  3. managementContext.getLocationRegistry().resolve("byon:(hosts='10.0.1.1'))
Note that the ByonLocationResolver is automatically registered with the LocationRegistry using the java ServiceLoader [2].

Aled

[1] https://gist.github.com/
[2] https://github.com/brooklyncentral/brooklyn/blob/master/core/src/main/java/brooklyn/location/basic/BasicLocationRegistry.java#L66-69

Miguel Barrientos Fernández

unread,
Apr 4, 2014, 12:54:08 PM4/4/14
to brookly...@googlegroups.com
Thanks a lot Aled!

The app i'm trying to configurate is a distributed implementation of a CPU intensive algorithm (BLAST algorithm) and I want to replicate the processing node in several locations, so I would have one frontend server and several backend (workers) ones. The Java code i'm trying to deploy YAML I was trying to translate to Java code are here:


Since that YAML was just a test to proof that I could run different locations for each entity I followed your suggestion of creating a DynamicRegionsFabric and passing a range of BYON locations, but I would like to specify different locations parameters for every other entity, such as the frontend server. 

I'm not getting any error now but i'm getting wrong locations. I've located the problem and it seems like I can't override the location configuration on the dashboard (I'm loading the application by specifying it at catalog.xml). If I select a range of byon's (specified at brooklyn.properties) at the dashboard launching the app, it will asign one node to each server and ignore the configuration done at the java code with .location() methods on EntitySpec, and if I select "localhost" i'll get everything deployed locally.

Miguel.

Miguel Barrientos Fernández

unread,
Apr 9, 2014, 10:05:36 AM4/9/14
to brookly...@googlegroups.com
Hi again, 

I still haven't find a proper way to assign a specific location to every child, in the same way YAML does it. I have been reading the code and tried to understand how the web client parses YAML to start the entities in different locations but I get lost easily :(

Can you guys give me some hint about it? 

Thanks!

Miguel

martin...@cloudsoftcorp.com

unread,
Apr 10, 2014, 5:49:08 AM4/10/14
to brookly...@googlegroups.com
Hi Miguel,

When creating an application from YAML, brooklyn first passes the YAML to a CAMP platform to create an AssemblyTemplate, which is then instantiated - you can see this here: [1]. This uses the camp-server project, which is a generic implementation of the CAMP spec, and is not brooklyn-specific - you can see that project here: [2]

The part that I think may be of interest to you is where brooklyn takes the generic CAMP AssemblyTemplate and creates a brooklyn Application (line 228 in [1]). This is all done by the BrooklynAssemblyTemplateInstantiator [3]

The BrooklynAssemblyTemplateInstantiator then builds the entity hierarchy using a BrooklynComponentTemplateResolver ([3] lines 195-207). This then resolves the spec and adds the locations [4]

There were also some changes made to the way locations are picked up when an entity starts - see [5]. In particular AbstractApplication line 107. This was merged 9 days ago, so you may need to get the latest version of brooklyn to see this change

Hope this helps,

Martin Harris
Lead Software Engineer
Cloudsoft Corporation Ltd
www.cloudsoftcorp.com

[1] https://github.com/brooklyncentral/brooklyn/blob/master/usage/rest-server/src/main/java/brooklyn/rest/resources/ApplicationResource.java#L214-L250

[2] https://github.com/brooklyncentral/camp-server/tree/master/camp-base/src/main/java/io/brooklyn/camp

[3] https://github.com/brooklyncentral/brooklyn/blob/master/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynAssemblyTemplateInstantiator.java

[4] https://github.com/brooklyncentral/brooklyn/blob/master/usage/camp/src/main/java/io/brooklyn/camp/brooklyn/spi/creation/BrooklynComponentTemplateResolver.java#L168-L210

[5]
https://github.com/brooklyncentral/brooklyn/pull/1298
Reply all
Reply to author
Forward
0 new messages