Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Create concurrent and distributed applications isn't a easy task, the Akka Tookit was created to bring the Actors power to JVM, currently SCALA or JAVA can be used as development language. Akka is responsible for delivery the  infrastructure for concurrent, distributed and fault tolerant event driven applications, Akka emphasizes the asynchronous model, Akka can be deployed on servlet container, so it fits on SAP HANA Cloud, to complement the Akka toolkit, another tookit focused on REST services on top of Akka was created (Spray), with this is possible to expose the Akka Actors as Rest services for consumption. To demonstrate how we can use Scala + Akka + Spray on SAP HANA Cloud, I've created a simple application that implements a classical Word Count using Map/Reduce using Akka Actors.

The project can be cloned from my Github account: https://github.com/isaias/spray-hana

The build of project is based on SBT, for a simple definition it is like MAVEN and Ant.

To publish a WAR for deploy on SAP HANA Cloud just use the SBT Task package it will generate a WAR that can be deployed directly.

Some attention points:

  • The application.conf must be specificy the root path
  • You will need Console Client

Brief explanation about the Akka Actors of project:

  • MasterActor, it acts like a coordinator of the process, it will receive the chunks of Strings that will be passed for Map Actor.
  • MapActor, this actor receive a String, splits it in words and process the occurrences of each word, after execution MapActor returns the result for MasterActor.
  • ReduceActor, it will consolidate the mapped data that will be used to generate a final reduced list on next Actor, the Aggregator.
  • AggregatorActor, it will create the final Map end decrease a CountDownLatch that is used to indicate that all process was finished.

A CountDownLatch was used to indicate when all words was reduced and are ready to get final result.

To run it using Jetty just use the task container:start at SBT, after open your  browser and call http://localhost:8080 to get a index or http://localhost:8080/wordcount to get a result of a processing using Akka Actors. After executing wordcount we will get a output like bellow:

{

  "youthful": 1,

  "rage": 1,

  "looks": 2,

  "buriest": 1,

  "decrease,": 1,

  "ordering;": 1,

  "sweet": 8,

  "liquid": 1,

  "used": 1,

  "eye": 2,

  "evident:": 1,

  "spring,": 1,

  "silvered": 1,

  "joy:": 1,

  "lend,": 1,

  "comment.": 1,

  "perfection": 1,

  "plants": 1,

  "widow": 2,

}


Final considerations:

  • To use Eclipse as IDE for Scala development try the Scala IDE plugin (http://scala-ide.org/), there is a plugin that puts a eclipse task on SBT to generate eclipse files (https://github.com/typesafehub/sbteclipse).
  • The Akka documentation is excellent, the quality of both (JAVA and SCALA) are the same
  • For developers of another languages (JAVA, ABAP, Ruby) developing using SCALA can be a great opportunity to get new skills on Functional Programming
  • The Spray documentation isn't complete like Akka but you can get some help on Google Groups

Spray is also a great option to provide REST services for SAP UI5. For this application spray-routing was used because it is on top of spray-servlet that is indicated to run a Servlet Container.

What do you think about the use of another languages on SAP HANA Cloud?

7 Comments
Labels in this area