<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeroen van Grondelle &#187; Cloud</title>
	<atom:link href="http://www.vangrondelle.com/tag/cloud/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vangrondelle.com</link>
	<description></description>
	<lastBuildDate>Thu, 11 Aug 2011 21:21:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>OSGi in the Cloud</title>
		<link>http://www.vangrondelle.com/2009/12/osgi-in-de-cloud/</link>
		<comments>http://www.vangrondelle.com/2009/12/osgi-in-de-cloud/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 14:20:57 +0000</pubDate>
		<dc:creator>Jeroen</dc:creator>
				<category><![CDATA[How to]]></category>
		<category><![CDATA[Cloud]]></category>
		<category><![CDATA[OSGi]]></category>

		<guid isPermaLink="false">http://www.vangrondelle.com/?p=74</guid>
		<description><![CDATA[Running an OSGi container in a public cloud service, such as]]></description>
			<content:encoded><![CDATA[<p>Running an OSGi container in a public cloud service, such as <a href="http://aws.amazon.com/ec2/>&#8220;Amazon&#8217;s EC2</a> or <a href="http://www.gogrid.com/" onclick="pageTracker._trackPageview('/outgoing/www.gogrid.com/?referer=');">GoGrid.com</a>, is the ultimate proof of the Scale Invariance promised in our <a href="http://www.vangrondelle.com/2009/11/beyond-osgi-software-achitecture/">Beyond Software Architecture presentation</a>. Reason enough for <a href="http://www.twitter.com/m4rr5" onclick="pageTracker._trackPageview('/outgoing/www.twitter.com/m4rr5?referer=');">Marcel Offermans</a> and myself to give it a try and deploy our software on EC2.</p>
<p>Our goal is to us a standard EC2 image and run Java and an OSGi framework on it, through the use of <a href="http://paxrunner.ops4j.org/space/Pax+Runner" onclick="pageTracker._trackPageview('/outgoing/paxrunner.ops4j.org/space/Pax+Runner?referer=');">PAXRunner</a>. We will install software bundles onto the instance later, by a provisioning mechanism.</p>
<h3>Subscribing</h3>
<p>Go through the standard subscription process at aws.amazon.com and create an EC2 account. When completed, do three things.<br />
- Add SSH port 22 to the default security group;<br />
- Create a Private/Public Keypair;<br />
- Download your Private Key, as you&#8217;ll need it to connect to your images</p>
<h3>Choosing an AMI</h3>
<p>At this stage, we are using a standard <a href="https://wiki.ubuntu.com/JauntyJackalope" onclick="pageTracker._trackPageview('/outgoing/wiki.ubuntu.com/JauntyJackalope?referer=');">Ubuntu 9.04</a> AMI, provided by <a href="http://alestic.com/" onclick="pageTracker._trackPageview('/outgoing/alestic.com/?referer=');">alestic.com</a> (AMI ID: ami-ccf615a5).</p>
<p>Launch an instance and connect to it using SSH:</p>

<div class="wp_codebox"><table><tr id="p748"><td class="code" id="p74code8"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">local</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-i</span> EC2.pem root<span style="color: #000000; font-weight: bold;">@</span>ec2-a-b-c-d.amazonaws.com</pre></td></tr></table></div>

<p>Enable multiverse repositories by editing /etc/apt/sources.list. Add these four lines at the end (for EC2&#8242;s US-EAST cloud).</p>

<div class="wp_codebox"><table><tr id="p749"><td class="code" id="p74code9"><pre class="bash" style="font-family:monospace;">deb http:<span style="color: #000000; font-weight: bold;">//</span>us.ec2.archive.ubuntu.com<span style="color: #000000; font-weight: bold;">/</span>ubuntu<span style="color: #000000; font-weight: bold;">/</span> jaunty main multiverse
deb-src http:<span style="color: #000000; font-weight: bold;">//</span>us.ec2.archive.ubuntu.com<span style="color: #000000; font-weight: bold;">/</span>ubuntu<span style="color: #000000; font-weight: bold;">/</span> jaunty main multiverse
deb http:<span style="color: #000000; font-weight: bold;">//</span>us.ec2.archive.ubuntu.com<span style="color: #000000; font-weight: bold;">/</span>ubuntu<span style="color: #000000; font-weight: bold;">/</span> jaunty-updates main multiverse
deb-src http:<span style="color: #000000; font-weight: bold;">//</span>us.ec2.archive.ubuntu.com<span style="color: #000000; font-weight: bold;">/</span>ubuntu<span style="color: #000000; font-weight: bold;">/</span> jaunty-updates main multiverse</pre></td></tr></table></div>

<p>Update the <a href="http://en.wikipedia.org/wiki/Advanced_Packaging_Tool" onclick="pageTracker._trackPageview('/outgoing/en.wikipedia.org/wiki/Advanced_Packaging_Tool?referer=');">APT</a> database:</p>

<div class="wp_codebox"><table><tr id="p7410"><td class="code" id="p74code10"><pre class="bash" style="font-family:monospace;">ec2<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> update</pre></td></tr></table></div>

<h3>Install java</h3>
<p>Install Sun&#8217;s Java 6 JDK using APT:</p>

<div class="wp_codebox"><table><tr id="p7411"><td class="code" id="p74code11"><pre class="bash" style="font-family:monospace;">ec2<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> sun-java6-jdk</pre></td></tr></table></div>

<h3>Run an OSGi Framework using Pax Runner</h3>
<p>A great way of installing and running an OSGi framework is using PAX Runner. PAX Runner transparently downloads and runs for you all major OSGi implementations.</p>
<p>Download and unarchive PAX Runner.</p>

<div class="wp_codebox"><table><tr id="p7412"><td class="code" id="p74code12"><pre class="bash" style="font-family:monospace;">ec2<span style="color: #000000; font-weight: bold;">&gt;</span> curl http:<span style="color: #000000; font-weight: bold;">//</span>repo1.maven.org<span style="color: #000000; font-weight: bold;">/</span>maven2<span style="color: #000000; font-weight: bold;">/</span>org<span style="color: #000000; font-weight: bold;">/</span>ops4j<span style="color: #000000; font-weight: bold;">/</span>pax<span style="color: #000000; font-weight: bold;">/</span>runner<span style="color: #000000; font-weight: bold;">/</span>pax-runner-assembly<span style="color: #000000; font-weight: bold;">/</span>1.3.0<span style="color: #000000; font-weight: bold;">/</span>pax-runner-assembly-1.3.0-jdk15.tar.gz <span style="color: #000000; font-weight: bold;">&gt;</span> pax-runner-assembly-1.3.0-jdk15.tar.gz
ec2<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">tar</span> xzf pax-runner-assembly-1.3.0-jdk15.tar.gz</pre></td></tr></table></div>

<p>
Installing and starting an OSGi Framework can be done by running PAX Runners shell script. By adding the URL of a bundle as a parameter, this bundle will be downloaded and started.</p>

<div class="wp_codebox"><table><tr id="p7413"><td class="code" id="p74code13"><pre class="bash" style="font-family:monospace;">ec2<span style="color: #000000; font-weight: bold;">&gt;</span> .<span style="color: #000000; font-weight: bold;">/</span>pax-runner-1.3.0<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pax-run.sh http:<span style="color: #000000; font-weight: bold;">//</span>www.vangrondelle.com<span style="color: #000000; font-weight: bold;">/</span>code<span style="color: #000000; font-weight: bold;">/</span>hellocloud_1.0.0.jar
__________                 __________                                 
\______   \_____  ___  ___ \______   \__ __  ____   ____   ___________
<span style="color: #000000; font-weight: bold;">|</span>     ___<span style="color: #000000; font-weight: bold;">/</span>\__  \ \  \<span style="color: #000000; font-weight: bold;">/</span>  <span style="color: #000000; font-weight: bold;">/</span>  <span style="color: #000000; font-weight: bold;">|</span>       _<span style="color: #000000; font-weight: bold;">/</span>  <span style="color: #000000; font-weight: bold;">|</span>  \<span style="color: #000000; font-weight: bold;">/</span>    \ <span style="color: #000000; font-weight: bold;">/</span>    \_<span style="color: #000000; font-weight: bold;">/</span> __ \_  __ \
<span style="color: #000000; font-weight: bold;">|</span>    <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">/</span> __ \_<span style="color: #000000; font-weight: bold;">&gt;</span>    <span style="color: #000000; font-weight: bold;">&lt;</span>   <span style="color: #000000; font-weight: bold;">|</span>    <span style="color: #000000; font-weight: bold;">|</span>   \  <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">/</span>   <span style="color: #000000; font-weight: bold;">|</span>  \   <span style="color: #000000; font-weight: bold;">|</span>  \  ___<span style="color: #000000; font-weight: bold;">/|</span>  <span style="color: #000000; font-weight: bold;">|</span> \<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #000000; font-weight: bold;">|</span>____<span style="color: #000000; font-weight: bold;">|</span>    <span style="color: #7a0874; font-weight: bold;">&#40;</span>____  <span style="color: #000000; font-weight: bold;">/</span>__<span style="color: #000000; font-weight: bold;">/</span>\_ \  <span style="color: #000000; font-weight: bold;">|</span>____<span style="color: #000000; font-weight: bold;">|</span>_  <span style="color: #000000; font-weight: bold;">/</span>____<span style="color: #000000; font-weight: bold;">/|</span>___<span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">/</span>___<span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">/</span>\___  <span style="color: #000000; font-weight: bold;">&gt;</span>__<span style="color: #000000; font-weight: bold;">|</span>   
               \<span style="color: #000000; font-weight: bold;">/</span>      \<span style="color: #000000; font-weight: bold;">/</span>         \<span style="color: #000000; font-weight: bold;">/</span>           \<span style="color: #000000; font-weight: bold;">/</span>     \<span style="color: #000000; font-weight: bold;">/</span>     \<span style="color: #000000; font-weight: bold;">/</span>       
&nbsp;
Pax Runner <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.3.0<span style="color: #7a0874; font-weight: bold;">&#41;</span> from OPS4J - http:<span style="color: #000000; font-weight: bold;">//</span>www.ops4j.org
<span style="color: #660033;">----------------------------------------------------</span>
&nbsp;
 -<span style="color: #000000; font-weight: bold;">&gt;</span> Using config <span style="color: #7a0874; font-weight: bold;">&#91;</span>classpath:META-INF<span style="color: #000000; font-weight: bold;">/</span>runner.properties<span style="color: #7a0874; font-weight: bold;">&#93;</span>
 -<span style="color: #000000; font-weight: bold;">&gt;</span> Using only arguments from <span style="color: #7a0874; font-weight: bold;">command</span> line
 -<span style="color: #000000; font-weight: bold;">&gt;</span> Scan bundles from <span style="color: #7a0874; font-weight: bold;">&#91;</span>http:<span style="color: #000000; font-weight: bold;">//</span>www.vangrondelle.com<span style="color: #000000; font-weight: bold;">/</span>code<span style="color: #000000; font-weight: bold;">/</span>hellocloud_1.0.0.jar<span style="color: #7a0874; font-weight: bold;">&#93;</span>
 -<span style="color: #000000; font-weight: bold;">&gt;</span> Scan bundles from <span style="color: #7a0874; font-weight: bold;">&#91;</span>scan-bundle:http:<span style="color: #000000; font-weight: bold;">//</span>www.vangrondelle.com<span style="color: #000000; font-weight: bold;">/</span>code<span style="color: #000000; font-weight: bold;">/</span>hellocloud_1.0.0.jar<span style="color: #7a0874; font-weight: bold;">&#93;</span>
 -<span style="color: #000000; font-weight: bold;">&gt;</span> Provision bundle <span style="color: #7a0874; font-weight: bold;">&#91;</span>http:<span style="color: #000000; font-weight: bold;">//</span>www.vangrondelle.com<span style="color: #000000; font-weight: bold;">/</span>code<span style="color: #000000; font-weight: bold;">/</span>hellocloud_1.0.0.jar, at default start level, bundle will be started, bundle will be loaded from the cache<span style="color: #7a0874; font-weight: bold;">&#93;</span>
 -<span style="color: #000000; font-weight: bold;">&gt;</span> Preparing framework <span style="color: #7a0874; font-weight: bold;">&#91;</span>Felix 2.0.1<span style="color: #7a0874; font-weight: bold;">&#93;</span>
 -<span style="color: #000000; font-weight: bold;">&gt;</span> Downloading bundles...
 -<span style="color: #000000; font-weight: bold;">&gt;</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.vangrondelle.com<span style="color: #000000; font-weight: bold;">/</span>code<span style="color: #000000; font-weight: bold;">/</span>hellocloud_1.0.0.jar : <span style="color: #000000;">1078</span> bytes <span style="color: #000000; font-weight: bold;">@</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> 359kBps <span style="color: #7a0874; font-weight: bold;">&#93;</span>
 -<span style="color: #000000; font-weight: bold;">&gt;</span> Using execution environment <span style="color: #7a0874; font-weight: bold;">&#91;</span>J2SE-<span style="color: #000000;">1.6</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
 -<span style="color: #000000; font-weight: bold;">&gt;</span> Runner has successfully finished his job<span style="color: #000000; font-weight: bold;">!</span>
&nbsp;
&nbsp;
Welcome to Felix
================
&nbsp;
Hello Cloud<span style="color: #000000; font-weight: bold;">!</span>
-<span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>As you see, Felix is installed by default. Different OSGi implementations can be run by adding the <code>--platform equinox|knopflerfish</code> flag. Even the version to be installed can be specified.</p>
<h3>Turning all this into a bootstrap script</h3>
<p>For easy launching, you could add all this into a <a href="http://www.vangrondelle.com/code/bootstrap.sh">bootstrap script</a> that turns a default Ubuntu image into an OSGi server with a single command.</p>
<p>Turning the Java installation into a silent install requires some additional scripting.</p>
<p>You can now install and run a bundle using the following command.</p>

<div class="wp_codebox"><table><tr id="p7414"><td class="code" id="p74code14"><pre class="bash" style="font-family:monospace;">ec2<span style="color: #000000; font-weight: bold;">&gt;</span> curl www.vangrondelle.com<span style="color: #000000; font-weight: bold;">/</span>code<span style="color: #000000; font-weight: bold;">/</span>bootstrap.sh <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sh</span></pre></td></tr></table></div>

<p>This script needs some enhancements: Multiverse repositories are added everytime its run for now. Script might detect EC2 Zone and add appropriate repositories.<br />
<script type="text/javascript">var dzone_url = 'http://www.vangrondelle.com/2009/12/osgi-in-de-cloud/';</script><br />
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.vangrondelle.com/2009/12/osgi-in-de-cloud/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

