Discussion:
[jade-develop] Running containers on multiple jade platforms on one machine from java code
Eike Lüders
2013-12-04 18:06:41 UTC
Permalink
Hey,

I have a problem regarding to the use of multiple jade platforms on a single machine.
I use MacOS X 10.9 and Jade 4.3.0

I started two jade instances with different ports on the local computer (I also tried with -local-port).
java jade.Boot -gui -port 2010
java jade.Boot -gui -port 2011

Now I try to start the containers from a java program with the following code.
The code runs in a loop and should create one container on each jade platform that is specified with the port.
(Here i also tried with Profile.LOCAL_PORT)
({PORT} stands for either 2010 or 2011)

Runtime jadeRuntime = Runtime.instance();
ProfileImpl profile = new ProfileImpl();
profile.setParameter(Profile.CONTAINER_NAME, "Container_" + i);
profile.setParameter(Profile.MAIN_HOST, "localhost");
profile.setParameter(Profile.MAIN_PORT, {PORT} + "");
AgentContainer container = jadeRuntime.createAgentContainer(profile);

The problem that occurs is that jade starts all containers always on the same jade platform and does not
create them on the platform that is specified by the port.

If I try to start the containers via cmd it works correctly:
java jade.Boot -gui -local-port 2010
java jade.Boot -gui -local-port 2011

Any suggestions? Thanks!

/Eike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://avalon.cselt.it/pipermail/jade-develop/attachments/20131204/2b6a8954/attachment.html>
Caire Giovanni
2013-12-06 11:54:50 UTC
Permalink
Hi,

The point is that you are launching in the same JVM 2 containers belonging to 2 different platforms. This is possible, BUT you are required to explicitly specify the Platform ID each container is connecting to -->

When starting the Main Containers use add the -platform-id option as below
java jade.Boot -gui -port 2010 -platform-id P1
java jade.Boot -gui -port 2011 -platform-id P2

Similarly when starting the containers from code add the Profile.PLATFORM_ID option as below
Runtime jadeRuntime = Runtime.instance();
ProfileImpl profile = new ProfileImpl();
profile.setParameter(Profile.CONTAINER_NAME, "Container_" + i);
profile.setParameter(Profile.MAIN_HOST, "localhost");
profile.setParameter(Profile.MAIN_PORT, {PORT} + "");
profile.setParameter(Profile.PLATFORM_ID, "P1"); // P2 at the second round
AgentContainer container = jadeRuntime.createAgentContainer(profile);

Bye,

Giovanni

Da: jade-develop-bounces at avalon.tilab.com [mailto:jade-develop-bounces at avalon.tilab.com] Per conto di Eike L?ders
Inviato: mercoled? 4 dicembre 2013 19:07
A: jade-develop at avalon.tilab.com
Oggetto: [jade-develop] Running containers on multiple jade platforms on one machine from java code


Hey,

I have a problem regarding to the use of multiple jade platforms on a single machine.
I use MacOS X 10.9 and Jade 4.3.0

I started two jade instances with different ports on the local computer (I also tried with -local-port).
java jade.Boot -gui -port 2010
java jade.Boot -gui -port 2011

Now I try to start the containers from a java program with the following code.
The code runs in a loop and should create one container on each jade platform that is specified with the port.
(Here i also tried with Profile.LOCAL_PORT)
({PORT} stands for either 2010 or 2011)

Runtime jadeRuntime = Runtime.instance();
ProfileImpl profile = new ProfileImpl();
profile.setParameter(Profile.CONTAINER_NAME, "Container_" + i);
profile.setParameter(Profile.MAIN_HOST, "localhost");
profile.setParameter(Profile.MAIN_PORT, {PORT} + "");
AgentContainer container = jadeRuntime.createAgentContainer(profile);

The problem that occurs is that jade starts all containers always on the same jade platform and does not
create them on the platform that is specified by the port.

If I try to start the containers via cmd it works correctly:
java jade.Boot -gui -local-port 2010
java jade.Boot -gui -local-port 2011

Any suggestions? Thanks!

/Eike

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://avalon.cselt.it/pipermail/jade-develop/attachments/20131206/358b96b8/attachment.html>
Caire Giovanni
2013-12-09 22:16:21 UTC
Permalink
Hi,

The two Main Container MUST be launched in different JVMs. Note in fact that while you can have peripheral containers belonging to different platforms in the same JVM, this is not the case for Main Containers. If you launch a Main Container in a JVM any other container running in the same JVM will belong to the same platform.

Bye,

Giovanni

Da: Eike L?ders [mailto:eiklud-3 at student.ltu.se]
Inviato: venerd? 6 dicembre 2013 13:50
A: Caire Giovanni
Oggetto: Re: [jade-develop] Running containers on multiple jade platforms on one machine from java code


Hi Giovanni,

thanks for your reply. I tried your suggestions but I still have the same problem.
The containers are always launched on the jade platform that was started last.

For example if I start P1 on port 2010 after P2 on port 2011 the containers are launched in P1.
If I start P2 after P1 the containers are launched on P2. No matter what I specify as PLATFORM_ID.

Do you have any other suggestions?

BR
Eike


Am 06.12.2013 um 12:54 schrieb Caire Giovanni <giovanni.caire at telecomitalia.it<mailto:giovanni.caire at telecomitalia.it>>:


Hi,

The point is that you are launching in the same JVM 2 containers belonging to 2 different platforms. This is possible, BUT you are required to explicitly specify the Platform ID each container is connecting to -->

When starting the Main Containers use add the -platform-id option as below
java jade.Boot -gui -port 2010 -platform-id P1
java jade.Boot -gui -port 2011 -platform-id P2

Similarly when starting the containers from code add the Profile.PLATFORM_ID option as below
Runtime jadeRuntime = Runtime.instance();
ProfileImpl profile = new ProfileImpl();
profile.setParameter(Profile.CONTAINER_NAME, "Container_" + i);
profile.setParameter(Profile.MAIN_HOST, "localhost");
profile.setParameter(Profile.MAIN_PORT, {PORT} + "");
profile.setParameter(Profile.PLATFORM_ID, "P1"); // P2 at the second round
AgentContainer container = jadeRuntime.createAgentContainer(profile);

Bye,

Giovanni

Da: jade-develop-bounces at avalon.tilab.com<http://avalon.tilab.com> [mailto:jade-develop-bounces at avalon.tilab.com] Per conto di Eike L?ders
Inviato: mercoled? 4 dicembre 2013 19:07
A: jade-develop at avalon.tilab.com<mailto:jade-develop at avalon.tilab.com>
Oggetto: [jade-develop] Running containers on multiple jade platforms on one machine from java code


Hey,

I have a problem regarding to the use of multiple jade platforms on a single machine.
I use MacOS X 10.9 and Jade 4.3.0

I started two jade instances with different ports on the local computer (I also tried with -local-port).
java jade.Boot -gui -port 2010
java jade.Boot -gui -port 2011

Now I try to start the containers from a java program with the following code.
The code runs in a loop and should create one container on each jade platform that is specified with the port.
(Here i also tried with Profile.LOCAL_PORT)
({PORT} stands for either 2010 or 2011)

Runtime jadeRuntime = Runtime.instance();
ProfileImpl profile = new ProfileImpl();
profile.setParameter(Profile.CONTAINER_NAME, "Container_" + i);
profile.setParameter(Profile.MAIN_HOST, "localhost");
profile.setParameter(Profile.MAIN_PORT, {PORT} + "");
AgentContainer container = jadeRuntime.createAgentContainer(profile);

The problem that occurs is that jade starts all containers always on the same jade platform and does not
create them on the platform that is specified by the port.

If I try to start the containers via cmd it works correctly:
java jade.Boot -gui -local-port 2010
java jade.Boot -gui -local-port 2011

Any suggestions? Thanks!

/Eike

Questo messaggio e i suoi allegati sono indirizzati esclusivamente alle persone indicate. La diffusione, copia o qualsiasi altra azione derivante dalla conoscenza di queste informazioni sono rigorosamente vietate. Qualora abbiate ricevuto questo documento per errore siete cortesemente pregati di darne immediata comunicazione al mittente e di provvedere alla sua distruzione, Grazie.

This e-mail and any attachments is confidential and may contain privileged information intended for the addressee(s) only. Dissemination, copying, printing or use by anybody else is unauthorised. If you are not the intended recipient, please delete this message and any attachments and advise the sender by return e-mail, Thanks.
<logo Ambiente_foglia2.jpg>Rispetta l'ambiente. Non stampare questa mail se non ? necessario.

<logo Ambiente_foglia2.jpg>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://avalon.cselt.it/pipermail/jade-develop/attachments/20131209/55af0619/attachment.html>
Loading...