(mOSAIC) Platform tutorial -- Testing cloudlets on PTC
Contents
PTC
Prerequisites
- read the tutorial on the wiki:
- Virtual Box emulator and extension pack,
tested on 4.2.x (4.2.6);
- mOSAIC testbed:
tested on 0.12;
- Firefox:
tested on 18.0.1;
- PuTTY:
Installation
- Virtual Box:
download the emulator and extension pack executables: https://www.virtualbox.org/wiki/Downloads (tested with 4.2.6);
- install the Virtual Box emulator;
- install the Virtual Box extension pack;
ensure that the installation folder is in the PATH environment variable:
- for Windows 8:
right click on Computer;
choose Properties from the menu;
select the Advanced System Settings option;
go to the Advanced tab;
click the Environment Variables... button;
in System Variables group edit the PATH variable and prepend to it the installation folder C:\Program Files\Oracle\VirtualBox or %VBOX_INSTALL_PATH% (if such a variable is defined);
- log out and log back in;
- for Windows XP:
right click on My Computer;
choose Properties from the menu;
follow the same as above starting from the "go to the Advanced tab;
- for Linux it should work out-of-the-box without any other intervention;
- for Windows 8:
- testbed:
download the testbed zip: http://ftp.info.uvt.ro/mosaic/ptc (tested with 0.11.1);
- unzip;
- configure the testbed:
on Windows follow closely the tutorial on the wiki: PTC Installation on Windows;
be sure to apply the initial VirtualBox configuration (see alert box in the link above for details);
testbed_init.bat; this will take some time;
testbed_start.bat; don't close this window;
on Linux follow closely the tutorial on the wiki: PTC Installation on Linux;
be sure to apply the initial VirtualBox configuration (see alert box in the link above for details);
./testbed.sh -i;
./testbed.sh -s;
- test the testbed:
open in Firefox (or Chromium): http://192.168.178.10/;
follow closely the tutorial on the wiki: PTC Web Console;
Usage
open in Firefox (or Chromium): http://192.168.178.10/;
- configure the VM user-data:
select the user data tab;
- for the simple use case:
#!pkg:tazpkg:mosaic-node-boot=0.6.0:run:bin/run
the token #!pkg specifies that when mOS starts it should install the given package;
the token tazpkg specifies that the package should be installed by using the tazpkg package manager, and should be available either in the official mOS repository, or the official Slitaz repository;
the token 0.6.0 specifies that the package should have exactly that version;
the token run:bin/run specifies that after the package was installed, the executable bin/run in the package's root folder should be started; (the packages root is usually /opt/<<package-name>>-<<package-version>>;)
- for the advanced use case (i.e. multiple applications at the same time, etc.):
#!app:<<application-id>>:mosaic-node-boot=0.6.0
the token #!app is similar with the #!pkg variant, except the following,
the token <<application-id>> specifies that the VM's started should be registered in the mOSAIC official DNS domain as <<application-id>>.apps.mosaic.ieat.ro;
it asserts the usage of tazpkg packages (see above);
it asserts the execution of the bin/run executable (see above);
click the submit changes button;
- start the VM's:
select the vbox control tab;
click the add nodes button once for each VM;
- query the VM's;
select the cluster nodes tab;
- wait until the nodes appear in the list;
wait until the ping and ssh columns become green; (at this moment the VM with mOS is preparing, i.e. the customization package and its dependencies are downloaded and installed;)
wait until the CMC becomes green; (at this moment the customized package was installed and started;)
(the UI refreshes automatically once a minute, but you can force it by clicking the refresh now button;)
to skip re-installing the package each time a VM restarts (which implies downloading all dependencies from the network):
- start the VM's;
- wait for the VM's to install the package;
wait for the VM's to start the package; (i.e. the CMC column becomes green;)
- click on each VM's name, and a dialog box should pop-out;
click on the button change(no) corresponding to the clean parameter until it is set no no;
click the ok button;
Cloudlets
Prerequisites
- PTC as described above;
- Java:
tested with 1.7.x (1.7.0u11);
- Eclipse:
tested with 4.2.x (4.2.1);
http://eclipse.org/downloads (the "Classic" or "IDE for Java Developers" variants should do);
Installation
- Java:
download the run-time: https://www.java.com/en/download/manual.jsp;
- install;
- Eclipse:
download the IDE: http://eclipse.org/downloads (the "Classic" or "IDE for Java Developers" variants should do);
- unzip;
Hello cloudlet
Preparation phase
download and unzip the template project: https://bitbucket.org/mosaic/mosaic-java-platform/downloads/template-cloudlets-v3.zip;
the resulting source code is available at: https://bitbucket.org/mosaic/mosaic-java-platform/downloads/hello-cloudlets-v3.zip;
copy the template project template-cloudles under the name hello-cloudlets;
- import in Eclipse:
select the File menu;
select the Import... option;
expand the Maven section;
choose the Existing Maven Projects option;
click the Next button;
click the Browse... button;
choose the copied project (i.e. hello-cloudlets);
check that the /pom.xml is selected;
click the Finish button;
wait until the Maven plugin downloads all dependencies; ( this will take some time; check the Progress view);
if after the import Eclipse complains about missing dependencies, try forcing a Maven dependency update:
right click the project in the Package Explorer;
select the Maven menu;
select the Update Project... option;
- check that the project is selected;
select the Force Update of Snapshots / Releases option;
check that the Update project configuration from pom.xml is selected;
check that the Clean Projects is selected;
check that the Offline is not selected;
click the OK button;
- configure the project:
- configure the Maven artifact:
select the project's pom.xml file in the Package Explorer;
- open it by double click; (a multi-tabbed editor should open;)
select the Overview tab;
change the value of the Artifact Id input to the name hello-cloudlets;
rename the project to hello-cloudlets:
right click the project in the Package Explorer;
select the Refactor menu;
select the Rename... option;
enter the name hello-cloudlets;
check that the Update references is selected;
click the OK button;
rename the Java packages to eu.mosaic_cloud.hello:
right click the eu.mosaic_cloud.examples.template.cloudlets package, in the Package Explorer, inside the src/main/java sub-folder;
select the Refactor menu;
select the Rename... option;
enter the name eu.mosaic_cloud.hello;
select the Rename subpackages option;
select the Update textual occurrences in comments and strings option;
select the Update fully qualified names in non-Java text files option;
check that the Update references is selected;
check that the File name patterns is *;
click the Preview button;
click the OK button;
rename the Java class to HelloCloudlet:
right click the TemplateCloudlet class, in the Package Explorer, inside the src/main/java and eu.mosaic_cloud.hello sub-folders;
apply the same operation as in the previous step to give it the name HelloCloudlet;
- rename the Java resources:
right click the template-cloudlet.properties file, in the Package Explorer, inside the src/main/resources/eu/mosaic_cloud/examples/template/cloudlets sub-folder;
select the Refactor menu;
select the Move... option;
select the src/main/resources sub-folder;
right click the template-cloudlet.properties file like above;
select the Refactor menu;
select the Rename... option;
enter the name hello-cloudlet.properties;
click the OK button;
remove the unneeded and empty folder eu;
- configure the Maven artifact:
Development phase
update the HelloCloudlet class to log the "Hello world text" inside the initializedSucceeded callback:
open the HelloCloudlet class, in the Package Explorer, inside the src/main/java sub-folder;
select the Source menu;
select the Override / Implement Methods... option;
check the initializeSucceeded(...) option;
click the OK button;
- instead of the method body write:
this.logger.info("hello world!"); return ICallback.SUCCESS;
- save the file;
- update the cloudlet properties file:
open the hello-cloudlet.properties file, in the Package Explorer, inside the src/main/resources sub-folder;
- check that the body contains the following (/!\ usually the last two entries are not updated by Eclipse during refactorings):
cloudlet.main_class=eu.mosaic_cloud.hello.HelloCloudlet cloudlet.context_class=eu.mosaic_cloud.hello.HelloCloudlet$Context cloudlet.resource_file=hello-cloudlet.properties
- save the file;
Packaging phase
- package the cloudlet Jar:
right click the hello-cloudlets project, in the Package Explorer;
select the Run As menu;
select the Maven build... option;
enter package inside the Goals field;
click the Run button;
any further package can be simply executed from the Run menu and then Run History;
the cloudlet Jar should be named hello-cloudlets-0.6.0-jar-with-dependencies.jar;
the cloudlet Jar should be inside the target folder inside the project's folder;
the cloudlet Jar named without the suffix -jar-with-dependencies will work for this simple example, but will break for other ones that have dependencies on other Java code;
- upload the cloudlet Jar:
- ...;
to deploy the cloudlet in another cloud provider you must upload it to a server where it will be accessible via HTTP; for example you could upload it on:
BitBucket, in the project's Downloads section; when using the URL be careful to use http protocol, and not https;
- S3, but you must make it publicly accessible;
Deployment phase
- open in Firefox (or Chromium) the mOSAIC WebUI from one of the VM's;
this URL should be something like http://<<ip-address-or-DNS-name>>:31810/;
if you are using PTC you can click the CMC cell for one of the started VM's, from inside the cluster nodes tab;
- create the cloudlet:
select the mOSAIC Cloudlet option from the menu on the left;
inside the Configuration text area enter something similar to:
[ "hello-cloudlet.properties", "http://192.168.178.10/store/hello-cloudlets-0.6.0-jar-with-dependencies.jar" ]
[ "hello-cloudlet.properties", "http://cdn.bitbucket.org/mosaic/mosaic-java-platform/downloads/hello-cloudlets-0.6.0-jar-with-dependencies.jar" ]
be careful to use the http protocol, and not https;
click the Create button;
- inspect the cloudlet:
select the List option from the menu on the left;
click the Log button for the desired cloudlet;
look inside the log for the Hello world! text;
- stop the cloudlet:
select the List option from the menu on the left;
click the Stop button for the desired cloudlet;
Simple cloudlets
the source code is available at: https://bitbucket.org/mosaic/mosaic-java-platform/downloads/simple-cloudlets-v3.zip;
- start the following components in this order:
mOSAIC RabbitMQ;
mOSAIC Riak KV;
mOSAIC HTTP Gateway;
mOSAIC AMQP driver;
mOSAIC Riak driver;
for each new test stop the drivers and start new ones (the last two components);
- just like in the deployment of the hello cloudlet, for each example, create the following cloudlets and the check the log for each started cloudlet:
- hello example:
[ "hello-cloudlet.properties", "http://cdn.bitbucket.org/mosaic/mosaic-java-platform/downloads/hello-cloudlets-0.6.0-jar-with-dependencies.jar" ]
- ping-pong example:
- pong cloudlet:
[ "pong-cloudlet.properties", "http://cdn.bitbucket.org/mosaic/mosaic-java-platform/downloads/simple-cloudlets-0.6.0-jar-with-dependencies.jar" ]
- ping cloudlet:
[ "ping-cloudlet.properties", "http://cdn.bitbucket.org/mosaic/mosaic-java-platform/downloads/simple-cloudlets-0.6.0-jar-with-dependencies.jar" ]
- pong cloudlet:
- publisher-consumer example:
- consumer cloudlet:
[ "consumer-cloudlet.properties", "http://cdn.bitbucket.org/mosaic/mosaic-java-platform/downloads/simple-cloudlets-0.6.0-jar-with-dependencies.jar" ]
- publisher cloudlet:
[ "publisher-cloudlet.properties", "http://cdn.bitbucket.org/mosaic/mosaic-java-platform/downloads/simple-cloudlets-0.6.0-jar-with-dependencies.jar" ]
- consumer cloudlet:
- hello example: