Hi guys,
the last days I found myself playing with the Google AppEngine, a very easy to use and powerful cloud-hosting service powered by Google. I felt the need to code the server-side using Scala which resulted in some very neat and small code. (Special thanks to the superb XML-parsing and collection-framework in Scala)
Recently I enjoy playing a game called Heroes Of Newerth that is the successor of the famous Dota. This game as a public XML-API that I daily pull stats from - of user that 'registered' at my site:
So I parse the XML-data using Scala, make it persistent saving Java Data Objects (JDO) to the Datastore of the AppEngine. Users than can get the Data visualized using a combination of the Google Web Toolkit (GWT 2.0) and the Google Visualization API. I could create a pretty rich user-experience writing only about 1.000 Lines of Code Java/Scala code and a hand full of HTML and CSS.
Best Regards,
Nicolas
Posts mit dem Label Scala werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Scala werden angezeigt. Alle Posts anzeigen
Sonntag, 7. Februar 2010
Hi guys,
the last days I found myself playing with the Google AppEngine, a very easy to use and powerful cloud-hosting service powered by Google. I felt the need to code the server-side using Scala which resulted in some very neat and small code. (Special thanks to the superb XML-parsing and collection-framework in Scala)
Recently I enjoy playing a game called Heroes Of Newerth that is the successor of the famous Dota. This game as a public XML-API that I daily pull stats from - of user that 'registered' at my site:
So I parse the XML-data using Scala, make it persistent saving Java Data Objects (JDO) to the Datastore of the AppEngine. Users than can get the Data visualized using a combination of the Google Web Toolkit (GWT 2.0) and the Google Visualization API. I could create a pretty rich user-experience writing only about 1.000 Lines of Code Java/Scala code and a hand full of HTML and CSS.
Best Regards,
Nicolas
the last days I found myself playing with the Google AppEngine, a very easy to use and powerful cloud-hosting service powered by Google. I felt the need to code the server-side using Scala which resulted in some very neat and small code. (Special thanks to the superb XML-parsing and collection-framework in Scala)
Recently I enjoy playing a game called Heroes Of Newerth that is the successor of the famous Dota. This game as a public XML-API that I daily pull stats from - of user that 'registered' at my site:
So I parse the XML-data using Scala, make it persistent saving Java Data Objects (JDO) to the Datastore of the AppEngine. Users than can get the Data visualized using a combination of the Google Web Toolkit (GWT 2.0) and the Google Visualization API. I could create a pretty rich user-experience writing only about 1.000 Lines of Code Java/Scala code and a hand full of HTML and CSS.
Best Regards,
Nicolas
AppEngine + Scala + JDO + GWT + Google Visualization API
AppEngine + Scala + JDO + GWT + Google Visualization API
Montag, 25. Januar 2010
Recently I stumbled upon GridGain, which seems to be a highly interesing Grid-Framework written in Java. Due to the fact it is written in Java it is supposed to be working with Scala, my upcoming favorite JVM language (Sorry Java!).
Having watched the screencasts by Nikita Ivanov I was kind of forced to give a try! You should watch them to, they explain every single step to take when using GridGain with Java.
This is the specific setup I was using:
This is the specific setup I was using:
- Eclipse: 3.5.1 build 20090920-1017
- GridGain: 2.2.1
- Scala: Scala Library version 2.8.0.r20638-b20100123020158
- JUnit: 4.5.0.v20090824
To give you an idea of what GridGain (in Java) is like and how to make code run in the cloud with basically just one annotation:
@Gridify
public int superHeavyMethod(int x, double y){
// ...
}
Oh yeah, we do like that =)So as you now have watched the screencasts, I show you how to do the same in Scala. For this example, I chose to execute a function f with a single parameter in the cloud. To do so I defined the @Gridify -ed method myCloudExecutionMethod, which takes such a function and such a parameter.
package org.anddev.scala.gridgain
import org.gridgain.grid._
import org.gridgain.grid.gridify._
object MyGridifyApp {
def main (args : Array[String]) : Unit = {
GridFactory.start()
try {
def f = (x:Int) => {println(">>> Executing f(x)=x*x ..."); x*x}
println(">>> f(5)=" + myCloudExecutionMethod(f, 5))
}
finally GridFactory.stop(true)
}
@Gridify
def myCloudExecutionMethod(f: Int => Int, x: Int): Int = {
println(">>> myCloudExecutionMethod ...")
f(x)
}
}This is how the whole project with all resources looks like (Note: MyGridApp, MyGridJob and MyGridTask are not used in this example):
When running the app you might need to create/modify the Run-Configuration, as the current Scala-Eclipse Plugin pretty much fails on creating one for you. (You'll probably have to enter the 'Main class' in the 'Main'-tab)
When running the app you might need to create/modify the Run-Configuration, as the current Scala-Eclipse Plugin pretty much fails on creating one for you. (You'll probably have to enter the 'Main class' in the 'Main'-tab)
This is how the run configuration looks like, when you have set up your project correctly (See the screencasts on how to add what and where) :
So to actually run this awesome code on the grid, you'd start some grid-nodes (from sth. like: C:\Program Files (x86)\gridgain-2.1.1\bin ) then sth like this will be logged to your Eclipse Console view:
_____ _ _ _____ _We can see that the result was actually printed in our application, just as we expected. And if you now have a look to the nodes you had started, you'll find the following in one of them:
/ ____| (_) | |/ ____| (_)
| | __ _ __ _ __| | | __ __ _ _ _ __
| | |_ | '__| |/ _` | | |_ |/ _` | | '_ \
| |__| | | | | (_| | |__| | (_| | | | | |
\_____|_| |_|\__,_|\_____|\__,_|_|_| |_|
>>> GridGain ver. 2.1.1-26022009
>>> Copyright (C) 2005-2009 GridGain Systems.
.....
>>> -------------------
>>> Discovery Snapshot.
>>> -------------------
>>> Number of nodes: 3
...
>>> Total number of CPUs: 2
...
>>> --------------------------------------------------
>>> GridGain ver. 2.1.1-26022009 STARTED OK in 8466ms.
>>> --------------------------------------------------
...
>>> f(5)=25
....
>>> ------------------------------------------------
>>> GridGain ver. 2.1.1-26022009 STOPPED OK in 19ms.
>>> ------------------------------------------------
>>> Optional instance name: null
>>> Grid up time: 00:00:01:256
>>> myCloudExecutionMethod ...
>>> Executing f(x)=x*x ...
Think about this for a moment.... BAZINGA! - You've just successfully executed your first Grid-enabled application.
As you also have seen, the screencasts show off some JUnit-love on GridGain and this is how you do it with Scala. Note: You'll have all the same buildpath-setup as above!
Basically we will have two TestCases and one of the will throw an Exception on purpose, so we can see that we can even view the proper stacktrace of a Exception that was thrown somewhere in the grid!!! (Both TestCases are wrapped in a TestSuite)
package org.anddev.scala.gridgain
import java.lang.management._
import junit.framework._
class MyGridAppTestA extends TestCase {
def testA() : Unit = {
throw new RuntimeException("Exception in test A on " + ManagementFactory.getRuntimeMXBean().getName())
}
}package org.anddev.scala.gridgain
import java.lang.management._
import junit.framework._
class MyGridAppTestB extends TestCase {
def testB() : Unit = {
println("Executing test B on: " + ManagementFactory.getRuntimeMXBean().getName())
}
}package org.anddev.scala.gridgain import junit.framework._ import org.junit.runner.RunWith import org.junit.runners.Suite import org.gridgain.grid.test._ import org.gridgain.grid.test.junit4._ @GridifyTest @RunWith(classOf[GridJunit4Suite]) @Suite.SuiteClasses(Array(classOf[MyGridAppTestA], classOf[MyGridAppTestB])) class MyGridAppTestSuite
In this case the Eclipse JUnit Runner could successfully pick up the TestSuite and I didn't even have to create a Run Configuration manually!
This is what we expected and what you will get:
As I said WIN ! GridGain rocks!
Scala + GridGain (+ Eclipse + JUnit) = WIN
Scala + GridGain (+ Eclipse + JUnit) = WIN
Recently I stumbled upon GridGain, which seems to be a highly interesing Grid-Framework written in Java. Due to the fact it is written in Java it is supposed to be working with Scala, my upcoming favorite JVM language (Sorry Java!).
Having watched the screencasts by Nikita Ivanov I was kind of forced to give a try! You should watch them to, they explain every single step to take when using GridGain with Java.
This is the specific setup I was using:
This is the specific setup I was using:
- Eclipse: 3.5.1 build 20090920-1017
- GridGain: 2.2.1
- Scala: Scala Library version 2.8.0.r20638-b20100123020158
- JUnit: 4.5.0.v20090824
To give you an idea of what GridGain (in Java) is like and how to make code run in the cloud with basically just one annotation:
@Gridify
public int superHeavyMethod(int x, double y){
// ...
}
Oh yeah, we do like that =)So as you now have watched the screencasts, I show you how to do the same in Scala. For this example, I chose to execute a function f with a single parameter in the cloud. To do so I defined the @Gridify -ed method myCloudExecutionMethod, which takes such a function and such a parameter.
package org.anddev.scala.gridgain
import org.gridgain.grid._
import org.gridgain.grid.gridify._
object MyGridifyApp {
def main (args : Array[String]) : Unit = {
GridFactory.start()
try {
def f = (x:Int) => {println(">>> Executing f(x)=x*x ..."); x*x}
println(">>> f(5)=" + myCloudExecutionMethod(f, 5))
}
finally GridFactory.stop(true)
}
@Gridify
def myCloudExecutionMethod(f: Int => Int, x: Int): Int = {
println(">>> myCloudExecutionMethod ...")
f(x)
}
}This is how the whole project with all resources looks like (Note: MyGridApp, MyGridJob and MyGridTask are not used in this example):
When running the app you might need to create/modify the Run-Configuration, as the current Scala-Eclipse Plugin pretty much fails on creating one for you. (You'll probably have to enter the 'Main class' in the 'Main'-tab)
When running the app you might need to create/modify the Run-Configuration, as the current Scala-Eclipse Plugin pretty much fails on creating one for you. (You'll probably have to enter the 'Main class' in the 'Main'-tab)
This is how the run configuration looks like, when you have set up your project correctly (See the screencasts on how to add what and where) :
So to actually run this awesome code on the grid, you'd start some grid-nodes (from sth. like: C:\Program Files (x86)\gridgain-2.1.1\bin ) then sth like this will be logged to your Eclipse Console view:
_____ _ _ _____ _We can see that the result was actually printed in our application, just as we expected. And if you now have a look to the nodes you had started, you'll find the following in one of them:
/ ____| (_) | |/ ____| (_)
| | __ _ __ _ __| | | __ __ _ _ _ __
| | |_ | '__| |/ _` | | |_ |/ _` | | '_ \
| |__| | | | | (_| | |__| | (_| | | | | |
\_____|_| |_|\__,_|\_____|\__,_|_|_| |_|
>>> GridGain ver. 2.1.1-26022009
>>> Copyright (C) 2005-2009 GridGain Systems.
.....
>>> -------------------
>>> Discovery Snapshot.
>>> -------------------
>>> Number of nodes: 3
...
>>> Total number of CPUs: 2
...
>>> --------------------------------------------------
>>> GridGain ver. 2.1.1-26022009 STARTED OK in 8466ms.
>>> --------------------------------------------------
...
>>> f(5)=25
....
>>> ------------------------------------------------
>>> GridGain ver. 2.1.1-26022009 STOPPED OK in 19ms.
>>> ------------------------------------------------
>>> Optional instance name: null
>>> Grid up time: 00:00:01:256
>>> myCloudExecutionMethod ...
>>> Executing f(x)=x*x ...
Think about this for a moment.... BAZINGA! - You've just successfully executed your first Grid-enabled application.
As you also have seen, the screencasts show off some JUnit-love on GridGain and this is how you do it with Scala. Note: You'll have all the same buildpath-setup as above!
Basically we will have two TestCases and one of the will throw an Exception on purpose, so we can see that we can even view the proper stacktrace of a Exception that was thrown somewhere in the grid!!! (Both TestCases are wrapped in a TestSuite)
package org.anddev.scala.gridgain
import java.lang.management._
import junit.framework._
class MyGridAppTestA extends TestCase {
def testA() : Unit = {
throw new RuntimeException("Exception in test A on " + ManagementFactory.getRuntimeMXBean().getName())
}
}package org.anddev.scala.gridgain
import java.lang.management._
import junit.framework._
class MyGridAppTestB extends TestCase {
def testB() : Unit = {
println("Executing test B on: " + ManagementFactory.getRuntimeMXBean().getName())
}
}package org.anddev.scala.gridgain import junit.framework._ import org.junit.runner.RunWith import org.junit.runners.Suite import org.gridgain.grid.test._ import org.gridgain.grid.test.junit4._ @GridifyTest @RunWith(classOf[GridJunit4Suite]) @Suite.SuiteClasses(Array(classOf[MyGridAppTestA], classOf[MyGridAppTestB])) class MyGridAppTestSuite
In this case the Eclipse JUnit Runner could successfully pick up the TestSuite and I didn't even have to create a Run Configuration manually!
This is what we expected and what you will get:
As I said WIN ! GridGain rocks!
Abonnieren
Posts (Atom)





