My personal views, thoughts and opinions.

Sunday, June 30, 2013

Running existing applications on SAP HANA Cloud



In my recent blog I mentioned that I gave up on running my own server and now I'm entirely dependent on services provided via Internet in some cloud. 

Since I'm working for SAP and developing the HANA Cloud thingie I intend to start a series of blogs about my experience with the clouds and in particular the PaaS I'm working on. Not really a complete surprise I guess, so to catch up I'll try to post stuff that's nowhere to be found :) 

Having said all the above I want to make the statement that I'm expressing just my opinion. You probably noticed that this is not an official SAP site, I'm neither SAP spokesman nor my blog is the official SAP documentation.

So here it comes my first blog for SAP HANA Cloud ...


Isn't this already available in the documentation?

Well not exactly ...

Developing and deploying an application on SAP HANA Cloud is described in numerous blogs, articles and tutorials. But most of the stuff out there ignores the fact that there are cloud users that want to run an existing application on the platform. 

Some of them need to check if their application written for standalone servers will require modification (or will it run at all), and some of them just want to see how all this cloud stuff behaves without going through all the development hustle and pain. 

And what is this blog about then?

It turns out that if one wants to step into the shoes of an operator, administrator (or whatever it is called in your organization) then you're out of luck. There are bits and pieces scattered in various places so it becomes quite difficult to get a decent overview.

While my target is not to gather such an overview and provide it at once in the next year or so, I want to assemble some guidelines on how you can use HANA Cloud and where you can get the operator's information.

Get an account

To be able to use SAP HANA Cloud for free you'll need to create a developer account. It gives you access to the trial landscape for an unlimited period. 
The access to the trial landscape allows you to:
  • deploy and run your own application
  • get access to the Cloud Cockpit to do some operator's tasks

Download and configure the SDK

Go to the tools page and download the latest SDK. Extract the downloaded ZIP somewhere and then check the official documentation on how the console client can be configured to use proxy.

To try-out if everything works ok go to the directory where you extracted the SDK and start a console/terminal/command line.

Now use:
cd tools
neo
You should see a list with commands available with the SDK:


C:\neo-sdk-javaweb-1.30.8\tools>neo

SAP HANA Cloud Console Client

No arguments specified


Usage: neo [group:]command [parameters] [properties file]

Available commands:

 --- connectivity ---
  delete-destination
        Deletes destination or JKS file from SAP HANA Cloud
  get-destination
        Downloads destination or JKS file to local file system
  put-destination
        Uploads destination or JKS file to SAP HANA Cloud

 --- deploy ---
  deploy
        Deploys WARs or installable units
... <output trimmed> ...

Now let's try if your account works correctly. Go to <SDK root>/tools/samples/deploy_war/example_war.properties and open it with your favourite text editor. Change the first four keys in the properties file like this:

# Your account name
account=i024099trial

# Application name
application=test

# User for login to hana.ondemand.com.
user=i024099

# URL of the landscape admin server. Optional. Defaults to hana.ondemand.com.
host=hanatrial.ondemand.com
Please note that you'll have to use your own account and user names.

Save the changes in the properties file and check if the account works ok using the following command line:
C:\neo-sdk-javaweb-1.30.8\tools>neo deploy samples\deploy_war\example_war.properties
Enter your password when prompted and if everything works fine you should see:

SAP HANA Cloud Console Client


Requesting deployment for:
   application    : test
   account        : i024099trial
   source         : samples/deploy_war/example.war
   elasticity data: [1 .. 1]
   severity       : error
   host           : https://hanatrial.ondemand.com
   SDK version    : 1.30.8
   user           : i024099

Password for your user:

[Sat Jun 29 18:30:51 FET 2013] Deployment started......
[Sat Jun 29 18:31:01 FET 2013] Deployment finished successfully
What does "landscape" mean? Isn't the cloud a single and somehow lonely place?

If you haven't noticed I mentioned registering a "trial" account in "trial" landscape with some URL. I'm not sure adding "trial" to the URL will make the things better. Then the URL for SDK download was not really with the subdomain of the trial landscape. This perhaps means we have more than one landscape?

The answer is yes - we have two landscapes which can be used for different purposes:
  • trial landscape - for experimenting and writing blogs :)
  • factory landscape - for running business applications and making money out of it

The SAP HANA Cloud is supposed to be singular, but as we can see we have two clouds with the same name. So what's the difference?

To put it in a simple way - the trial landscape is not the big thing. Yes you can do a lot of things with it but you don't get all the bells and whistles of the real product. For example you don't get support (and the sweet support SLAs).

And ... you don't get to pay for it. So we'll continue using the trial in this blog.
 
Does "latest SDK" ring a bell? 

You probably noticed the "download the latest SDK" part above. This in practice means that we update the SDK once in a while. 

So if you want to use the latest and greatest you need to download it every 2 weeks. And yes - we try to keep it compatible.

The blog is indeed targeted more at operators, so why should you bother to download the SDK every 2 weeks then? The answer is that the SDK contains not only development stuff (APIs, local runtime, samples, ...) but the client part tools as well.

So even if you have an application you don't want to modify you may still want to download the latest SDK to get all the improvements poured inside on a bi-weekly base.

Some of my next blogs for HANA Cloud will shed some light on the tooling in the SDK.

I don't have an existing application. Now what?

Here are some places where you can find applications to try out:

The rules here are that the application:
  • does not require modification in Tomcat scripts, OS resources (plain WAR), native executables to do their job
  • is DB vendor neutral (no DB exotics)

Let's start. Or is it rather deploy and start?

If you've read this far you should have:
  • downloaded and configured SDK tools (so far only proxy settings)
  • application to run on SAP HANA Cloud

Running your application is actually a two phase process with HANA Cloud:
  • uploading the application (we call this deployment) 
  • starting an application process with the uploaded binaries

Let's start with the upload part for JPetstore:
  1. Download JPetstore
  2. Extract the mybatis-jpetstore-6.0.0.war
  3. Rename it to ROOT.war
  4. Copy the ROOT.war to <SDK root>/tools/samples/deploy_war
  5. Modify the example_war.properties file and change:

    source=samples/deploy_war/example.war 

    to 

    source=samples/deploy_war/ROOT.war

  6. Deploy the application using:
C:\neo-sdk-javaweb-1.30.8\tools>neo deploy samples\deploy_war\example_war.properties
SAP HANA Cloud Console Client


Requesting deployment for:
   application    : test
   account        : i024099trial
   source         : samples/deploy_war/ROOT.war
   elasticity data: [1 .. 1]
   severity       : error
   host           : https://hanatrial.ondemand.com
   SDK version    : 1.30.8
   user           : i024099


[Sat Jun 29 23:38:56 FET 2013] Deployment started...............................
........
[Sat Jun 29 23:40:45 FET 2013] Deployment finished successfully

Now we have the binaries uploaded it is time to start the application with the following command:
C:\neo-sdk-javaweb-1.30.8\tools>neo start samples\deploy_war\example_war.properties

SAP HANA Cloud Console Client


Requesting start for:
   application: test
   account    : i024099trial
   host       : https://hanatrial.ondemand.com
   synchronous: false
   SDK version: 1.30.8
   user       : i024099

Password for your user:

Start request performed successfully.

Triggered start of application processes.
Component status: STARTING
You may noticed that the command is actually asynchronous and just triggers the start process. To check the status of the application we've just attempted to start you may use the status command. Once the application is started we'll get the access points:

C:\neo-sdk-javaweb-1.30.8\tools>neo status samples\deploy_war\example_war.properties

SAP HANA Cloud Console Client


Requesting status for:
   application: test
   account    : i024099trial
   host       : https://hanatrial.ondemand.com
   SDK version: 1.30.8
   user       : i024099

Status: STARTED

URL: https://testi024099trial.hanatrial.ondemand.com

Access points:
  https://testi024099trial.hanatrial.ondemand.com

Let's try to access the provided URL. And voilà we have the JPetstore running.

Trying the same with a GWT sample:
  1. Go to gwt-2.5.1/samples/Showcase/war
  2. ZIP the content into ROOT.war
  3. Copy and overwrite the JPetstore 
  4. Deploy and start the application


What's in the next blog?
  • Why command line?
  • Scaling your application
  • Start/Stop/Restart
  • Managing multiple applications
  • Undeploy

Tuesday, June 04, 2013

Replacing a server with free services

I have had a server with:
  • Apache Tomcat
  • Git and SVN servers
  • Gallery (Apache, PHP, MySQL)
  • IP Cam Motion
Recently I found out that all of this can be easily migrated to free internet services. What do I gain? Well ... a lot of things but amongst them:
  • silence in my living room
  • reduced electricity costs
  • data protection in case a thunder storm comes close
If you are interested what I used to replace all of the above, below is the breakout with some pros and cons.

Image hosting

I had concerns that my photos are far too big to fit any of the offerings on the web, but I replaced my self-hosted Gallery instance with Flickr since they offer a free terabyte of storage.

Pros:
  • access from my mobile 
  • I don't have to backup the data from my server
  • great groupping in Flickr (sets and collections)
  • social elements

Cons - clumsy Uploadr that:
  • does not understand some camera rotation exif info 
  • does not allow me to upload more than 200 photos no matter that I have 1 TB free in Flickr and 30 GB RAM for its JavaScript

Source code

GitHub would have been my choice but ... I needed a private repository for some of my code. So I had to go with BitBucket that offers Git hosting for teams and 5 private repos.

IP Cam

I used to run Motion to capture photos and video of my home IP Cam. I found out that I can simply mail the photos to a dedicated GMail account and make use of several GB storage they offer.

Instead of my custom web interface (simple HTML page) I now use the camera's web interface with guest access (no rotation or settings change).

The hardest part was to create a rule/filter that deletes motion detect events older than several days. After I googled on the topic I found out that this is easily achieved with Google Apps Scripts.

Tomcat

A good Tomcat hosting is not easy to find. I experimented a bit with Amazon's Free Tier but I cannot recommend it since:
  • it is not really free (once you go out of the tier usage limits)
  • it does not provide enough storage for big projects (MySQL would cost you a lot)
Torrents

I used my server to download torrents since Apple does not allow such software in the AppStore for iOS (and therefore for my iPad). I can use my Android phone to do this but this is not really reliable or cost-effective.

No real replacement I can recommend so far.

Google+ Followers