Discussion:
[jade-develop] running multi-platfrom from an external java application
Ali Abdulaziz
2014-08-03 12:20:50 UTC
Permalink
Dear founders of JADE and all,

I posting this after visiting all possibly related posts to my issue and
could not find an exact solution.

I employing Jade in my master degree research project. That is, I would like
to create Intra-platforms from an external java application. by revising
all documents in the website especially "administration" one, this would be
similar to the scenario of launching several platforms using Command-line in
Windows environment as the following using windows :

--------------------------------
First platform

open a CMD

type : java jade.Boot -gui -platform-id Platform

this will initiate a platform named Platform, in which, its AMS would be
reached in this address AMS at Platform

------------------------------

Second platform

open a "new" another CMD

type : java jade.Boot -gui -platform-id Platform -local-port 1111

this will initiate a platform named Platform, in which , its AMS would be
reached in this address AMS at Platform2

---------------------------------

and so on.

now this would work perfectly using the command line, as we can see
different platforms with different IDs and ports can be launched such that
Agents that live in them can communicate with other agents in the same
platform or in remote platform.

however, I tried doing the same launching using external java application
and could not succeed in doing so.

it only succeed in initiating the first platform, but it would not in the
rest platforms.
this is my code

#####################################################################

Profile p1 = new ProfileImpl(true);
p1.setParameter(ProfileImpl.PLATFORM_ID, "platform"+ID); // ID range from 1
to 10
p1.setParameter(Profile.LOCAL_PORT, Integer.toString(port)); // available
port
Runtime.instance().setCloseVM(true)
ContainerController mc = Runtime.instance().createMainContainer(p1); // I
need to have a main container for each platform
#####################################################################



then I get this error

####################################################################

Aug 03, 2014 9:42:26 PM jade.imtp.leap.LEAPIMTPManager initialize
INFO: Listening for intra-platform commands on address:
- jicp://10.1.1.5:1024
- jicp://10.1.1.5:1025

Aug 03, 2014 9:42:26 PM jade.core.AgentContainerImpl joinPlatform
SEVERE: Some problem occurred while joining agent platform.
jade.core.ProfileException: Can't get a proxy to the Platform Manager -
Caused by: Wrong platform name platform1. It should be platform2
at jade.core.ProfileImpl.createPlatformManager(ProfileImpl.java:529)
at jade.core.ProfileImpl.getPlatformManager(ProfileImpl.java:442)
at jade.core.ProfileImpl.getServiceManager(ProfileImpl.java:456)
at jade.core.AgentContainerImpl.init(AgentContainerImpl.java:346)
at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:492)
at jade.core.Runtime.createMainContainer(Runtime.java:166)
at intiator.intiatePlatform(intiator.java:49)
at MainLauncher.main(MainLauncher.java:69)
Nested Exception:
jade.core.IMTPException: Wrong platform name platform1. It should be
platform2
at
jade.imtp.leap.CommandDispatcher.setPlatformManager(CommandDispatcher.java:231)
at
jade.imtp.leap.CommandDispatcher.registerSkeleton(CommandDispatcher.java:736)
at
jade.imtp.leap.LEAPIMTPManager.exportPlatformManager(LEAPIMTPManager.java:198)
at jade.core.ProfileImpl.createPlatformManager(ProfileImpl.java:518)
at jade.core.ProfileImpl.getPlatformManager(ProfileImpl.java:442)
at jade.core.ProfileImpl.getServiceManager(ProfileImpl.java:456)
at jade.core.AgentContainerImpl.init(AgentContainerImpl.java:346)
at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:492)
at jade.core.Runtime.createMainContainer(Runtime.java:166)
at intiator.intiatePlatform(intiator.java:49)
at MainLauncher.main(MainLauncher.java:69)
Exception in thread "main" java.lang.NullPointerException
at intiator.intiatePlatform(intiator.java:58)
at MainLauncher.main(MainLauncher.java:69)

#####################################################################

So I would like to make it successfully using code as it would be using
Command-line

Thank you




--
View this message in context: http://jade.17737.x6.nabble.com/running-multi-platfrom-from-an-external-java-application-tp5002672.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
Caire Giovanni
2014-08-03 21:48:21 UTC
Permalink
Hi,

You cannot launch 2 different Main Containers (2 platforms) in the same JVM.

Bye,

Giovanni

-----Messaggio originale-----
Da: jade-develop [mailto:jade-develop-bounces at avalon.tilab.com] Per conto di Ali Abdulaziz
Inviato: domenica 3 agosto 2014 14:21
A: jade-develop at avalon.tilab.com
Oggetto: [jade-develop] running multi-platfrom from an external java application

Dear founders of JADE and all,

I posting this after visiting all possibly related posts to my issue and could not find an exact solution.

I employing Jade in my master degree research project. That is, I would like to create Intra-platforms from an external java application. by revising all documents in the website especially "administration" one, this would be similar to the scenario of launching several platforms using Command-line in Windows environment as the following using windows :

--------------------------------
First platform

open a CMD

type : java jade.Boot -gui -platform-id Platform

this will initiate a platform named Platform, in which, its AMS would be reached in this address AMS at Platform

------------------------------

Second platform

open a "new" another CMD

type : java jade.Boot -gui -platform-id Platform -local-port 1111

this will initiate a platform named Platform, in which , its AMS would be reached in this address AMS at Platform2

---------------------------------

and so on.

now this would work perfectly using the command line, as we can see different platforms with different IDs and ports can be launched such that Agents that live in them can communicate with other agents in the same platform or in remote platform.

however, I tried doing the same launching using external java application and could not succeed in doing so.

it only succeed in initiating the first platform, but it would not in the rest platforms.
this is my code

#####################################################################

Profile p1 = new ProfileImpl(true);
p1.setParameter(ProfileImpl.PLATFORM_ID, "platform"+ID); // ID range from 1 to 10 p1.setParameter(Profile.LOCAL_PORT, Integer.toString(port)); // available port
Runtime.instance().setCloseVM(true)
ContainerController mc = Runtime.instance().createMainContainer(p1); // I
need to have a main container for each platform
#####################################################################



then I get this error

####################################################################

Aug 03, 2014 9:42:26 PM jade.imtp.leap.LEAPIMTPManager initialize
INFO: Listening for intra-platform commands on address:
- jicp://10.1.1.5:1024
- jicp://10.1.1.5:1025

Aug 03, 2014 9:42:26 PM jade.core.AgentContainerImpl joinPlatform
SEVERE: Some problem occurred while joining agent platform.
jade.core.ProfileException: Can't get a proxy to the Platform Manager -
Caused by: Wrong platform name platform1. It should be platform2
at jade.core.ProfileImpl.createPlatformManager(ProfileImpl.java:529)
at jade.core.ProfileImpl.getPlatformManager(ProfileImpl.java:442)
at jade.core.ProfileImpl.getServiceManager(ProfileImpl.java:456)
at jade.core.AgentContainerImpl.init(AgentContainerImpl.java:346)
at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:492)
at jade.core.Runtime.createMainContainer(Runtime.java:166)
at intiator.intiatePlatform(intiator.java:49)
at MainLauncher.main(MainLauncher.java:69)
Nested Exception:
jade.core.IMTPException: Wrong platform name platform1. It should be
platform2
at
jade.imtp.leap.CommandDispatcher.setPlatformManager(CommandDispatcher.java:231)
at
jade.imtp.leap.CommandDispatcher.registerSkeleton(CommandDispatcher.java:736)
at
jade.imtp.leap.LEAPIMTPManager.exportPlatformManager(LEAPIMTPManager.java:198)
at jade.core.ProfileImpl.createPlatformManager(ProfileImpl.java:518)
at jade.core.ProfileImpl.getPlatformManager(ProfileImpl.java:442)
at jade.core.ProfileImpl.getServiceManager(ProfileImpl.java:456)
at jade.core.AgentContainerImpl.init(AgentContainerImpl.java:346)
at jade.core.AgentContainerImpl.joinPlatform(AgentContainerImpl.java:492)
at jade.core.Runtime.createMainContainer(Runtime.java:166)
at intiator.intiatePlatform(intiator.java:49)
at MainLauncher.main(MainLauncher.java:69)
Exception in thread "main" java.lang.NullPointerException
at intiator.intiatePlatform(intiator.java:58)
at MainLauncher.main(MainLauncher.java:69)

#####################################################################

So I would like to make it successfully using code as it would be using
Command-line

Thank you




--
View this message in context: http://jade.17737.x6.nabble.com/running-multi-platfrom-from-an-external-java-application-tp5002672.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
_______________________________________________
jade-develop mailing list
jade-develop at avalon.tilab.com
http://jade.tilab.com/mailman/listinfo/jade-develop
UNSUBSCRIBE INSTRUCTIONS AT
http://jade.tilab.com/community-mailinglist.htm
Ali Abdulaziz
2014-08-03 21:53:08 UTC
Permalink
but way it works using command-line in the same machine, while would not work
using external application.

by opening several CMD windows, I can launch several platforms in the same
machine. I need to do the same from an external java application.

my code basically for each platform launch, it instantiate a new runtime.
nevertheless, it does not work.

what could be a fix for this?

could please indicate what I shall be doing?

thank you



--
View this message in context: http://jade.17737.x6.nabble.com/running-multi-platfrom-from-an-external-java-application-tp5002672p5002678.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
Caire Giovanni
2014-08-09 21:53:22 UTC
Permalink
Hi,

The problem, as I said, is related to having 2 different platforms (Main Containers) inside the same JVM. The JADE in-process interface that you use to launch JADE from an existing program works "in process": that is in the same process.

To achieve what you need you should
- Get the TestSuite Add-on from the Add-ons area of the Jade web site
- Add the testSuite.jar file to your compile path and classpath
- Use a code similar to that below to launch different JADE instances in different processes.

JadeController jc = TestUtility.launchJadeInstance("Platform-name", null, "startup arguments as in the command line", null);

Bye,

Giovanni

-----Messaggio originale-----
Da: jade-develop [mailto:jade-develop-bounces at avalon.tilab.com] Per conto di Ali Abdulaziz
Inviato: domenica 3 agosto 2014 23:53
A: jade-develop at avalon.tilab.com
Oggetto: Re: [jade-develop] R: running multi-platfrom from an external java application

but way it works using command-line in the same machine, while would not work using external application.

by opening several CMD windows, I can launch several platforms in the same machine. I need to do the same from an external java application.

my code basically for each platform launch, it instantiate a new runtime.
nevertheless, it does not work.

what could be a fix for this?

could please indicate what I shall be doing?

thank you



--
View this message in context: http://jade.17737.x6.nabble.com/running-multi-platfrom-from-an-external-java-application-tp5002672p5002678.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
_______________________________________________
jade-develop mailing list
jade-develop at avalon.tilab.com
http://jade.tilab.com/mailman/listinfo/jade-develop
UNSUBSCRIBE INSTRUCTIONS AT
http://jade.tilab.com/community-mailinglist.htm
Ali Abdulaziz
2014-08-10 08:34:46 UTC
Permalink
Hi,

yes it works as I wanted Exactly.

this leads to the following, how I can get ContainerController of each
platform ? because I want to initiate some agents and so on.

Thank you very much




--
View this message in context: http://jade.17737.x6.nabble.com/running-multi-platfrom-from-an-external-java-application-tp5002672p5002687.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
Caire Giovanni
2014-08-15 12:52:39 UTC
Permalink
Hi,

The ContainerController is just a "wrapper" of the real container --> You can have a ContainerController only if you are in the same JVM of the container you want to control. This is not your case unforyunately.

In general however you can create and kill agents on whatever container (local or remote) by interacting with the AMS.
More in details to create an agent you should REQUEST to the AMS the CreateAgent action of the JADEManagementOntology.
You can look at the GetAvailableLocationsBehaviour class (examples.mobile package) included in the JADE examples distribution for an example of how to interact with the AMS. Furthermore a detailed description about how to interact with the AMS is included in chapter 5 of the book Developing Multi Agent Systems with JADE.

Bye,

Giovanni

-----Messaggio originale-----
Da: jade-develop [mailto:jade-develop-bounces at avalon.tilab.com] Per conto di Ali Abdulaziz
Inviato: domenica 10 agosto 2014 10:35
A: jade-develop at avalon.tilab.com
Oggetto: Re: [jade-develop] R: R: running multi-platfrom from an external java application

Hi,

yes it works as I wanted Exactly.

this leads to the following, how I can get ContainerController of each platform ? because I want to initiate some agents and so on.

Thank you very much




--
View this message in context: http://jade.17737.x6.nabble.com/running-multi-platfrom-from-an-external-java-application-tp5002672p5002687.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
_______________________________________________
jade-develop mailing list
jade-develop at avalon.tilab.com
http://jade.tilab.com/mailman/listinfo/jade-develop
UNSUBSCRIBE INSTRUCTIONS AT
http://jade.tilab.com/community-mailinglist.htm
Ali Abdulaziz
2014-08-18 12:26:56 UTC
Permalink
Thank you for all your help.
I have another related question, and for clarification and also for
documenting purposes, I am writing the following for other jade users, as
giving back what I've learnt to the community.

Now, as you know , with the solution of test-suite you provided, now I am
able to do the following:
1- I can start different platforms such that p1,p2, ... Pn on one machine,
each platform has its own main-container as follows

jc = TestUtility.launchJadeInstance("Machine"+ID, null, "-gui -platform-id
Platform"+ID+" -local-port "+port+" -agents ServiceAgent:ServiceAgent",
null); // ID =1,2,3,....etc. // Port = 1111,1112, ... etc.

2- I did a test on 2 different nodes (computers) connected to one router,
such that I want to create one main-container on the node A, and peripheral
containers on other nodes (B,c, ...) in which they are connected the
main-container that resides in node A.

I managed to do it as the following

jc= TestUtility.launchJadeInstance("Machine"+ID, null, "-gui -container
-host //node B,C,.. IP addresses// -port 1099 -agents
ServiceAgent:ServiceAgent", null); // remote

However, it would not work unless by starting a jade on nodes B,C,D, .. from
the command line by typing
java jade.Boot // supposing that you set jade lib in the class-path

now , if you run that command jc = .... , it will work and you can see the
containers in RMA GUI in Node A
and you can see what is behind the scene in the other nodes' command line.

As you can see this very costy if I have several nodes B,C,D, ...... which I
will be faced with.
it is not reliable to be present at each node and start a jade on each one
of them , in order for that command (jc = ... ) to work.

I mean , I would like to start containers on all nodes from the node A using
external application , what else needed besides their IP Addresses ?

thank you.





--
View this message in context: http://jade.17737.x6.nabble.com/running-multi-platfrom-from-an-external-java-application-tp5002672p5002700.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
Caire Giovanni
2014-08-20 14:57:08 UTC
Permalink
Hi,

The TestSuite add-on also contains a daemon (TSDaemon) that must be started (once for all) in each host where you want to launch JADE containers.
Having done that you can create containers remotely by means of the overloaded version of the launchJadeInstance() method that gets a RemoteManager as first parameter. The createRemoteManager(host, port, "TSDaemon") method of the TestUtility class allows you to get a RemoteManager object "pointing" to a given host where the TSDaemon is running.

More in general however I would suggest migrating from "vanilla" JADE to WADE. WADE is a sort of enterprise version of JADE and provides, among others, a number of additional features that facilitate the administration of a distributed WADE-based system. Starting a complete platform typically distributed on several hosts from a single central point is one of the basic features that WADE adds to JADE.

Bye,

Giovanni

-----Messaggio originale-----
Da: jade-develop [mailto:jade-develop-bounces at avalon.tilab.com] Per conto di Ali Abdulaziz
Inviato: lunedì 18 agosto 2014 14:27
A: jade-develop at avalon.tilab.com
Oggetto: Re: [jade-develop] R: R: R: running multi-platfrom from an external java application

Thank you for all your help.
I have another related question, and for clarification and also for documenting purposes, I am writing the following for other jade users, as giving back what I've learnt to the community.

Now, as you know , with the solution of test-suite you provided, now I am able to do the following:
1- I can start different platforms such that p1,p2, ... Pn on one machine, each platform has its own main-container as follows

jc = TestUtility.launchJadeInstance("Machine"+ID, null, "-gui -platform-id Platform"+ID+" -local-port "+port+" -agents ServiceAgent:ServiceAgent",
null); // ID =1,2,3,....etc. // Port = 1111,1112, ... etc.

2- I did a test on 2 different nodes (computers) connected to one router, such that I want to create one main-container on the node A, and peripheral containers on other nodes (B,c, ...) in which they are connected the main-container that resides in node A.

I managed to do it as the following

jc= TestUtility.launchJadeInstance("Machine"+ID, null, "-gui -container -host //node B,C,.. IP addresses// -port 1099 -agents ServiceAgent:ServiceAgent", null); // remote

However, it would not work unless by starting a jade on nodes B,C,D, .. from the command line by typing java jade.Boot // supposing that you set jade lib in the class-path

now , if you run that command jc = .... , it will work and you can see the containers in RMA GUI in Node A and you can see what is behind the scene in the other nodes' command line.

As you can see this very costy if I have several nodes B,C,D, ...... which I will be faced with.
it is not reliable to be present at each node and start a jade on each one of them , in order for that command (jc = ... ) to work.

I mean , I would like to start containers on all nodes from the node A using external application , what else needed besides their IP Addresses ?

thank you.





--
View this message in context: http://jade.17737.x6.nabble.com/running-multi-platfrom-from-an-external-java-application-tp5002672p5002700.html
Sent from the JADE - Dev mailing list archive at Nabble.com.
_______________________________________________
jade-develop mailing list
jade-develop at avalon.tilab.com
http://jade.tilab.com/mailman/listinfo/jade-develop
UNSUBSCRIBE INSTRUCTIONS AT
http://jade.tilab.com/community-mailinglist.htm

Loading...