Hazelcast is a clustering and highly scalable data distribution platform for Java. Hazelcast helps architects and developers to easily design and develop faster, highly scalable and reliable applications for their businesses.
Hazelcast 2.0
Document Link:http://www.hazelcast.com/docs/2.0/manual/single_html/
API Overview: http://www.hazelcast.com/javadoc/overview-summary.html
Code Examples: http://code.google.com/p/hazelcast/source/browse/trunk/hazelcast/src/main/java/com/hazelcast/examples/
List of Tables
import com.hazelcast.core.ITopic
import com.hazelcast.core.Hazelcast
import com.hazelcast.core.MessageListener
import com.hazelcast.core.InstanceListener
import com.hazelcast.core.InstanceEvent
class SampleMessage extends MessageListener[String] {
def onMessage(msg: String): Unit = {
System.out.println("Message received = " + msg)
}
}
class SampleInstance extends InstanceListener {
def instanceCreated(event: InstanceEvent): Unit = {
val instance = event.getInstance()
System.out.println("Created " + instance.getInstanceType() + "," + instance.getId())
}
def instanceDestroyed(event: InstanceEvent): Unit = {
val instance = event.getInstance()
System.out.println("Destroyed " + instance.getInstanceType() + "," + instance.getId())
}
}
object Sample {
def main(args : Array[String]) : Unit = {
import scala.collection.JavaConversions._
// test case for MessageListener
val sampleMessage = new SampleMessage()
val topic = Hazelcast.getTopic[String]("default")
topic.addMessageListener(sampleMessage)
topic.publish ("my-message-object")
// test case for InstanceListener
val sampleInstance = new SampleInstance()
Hazelcast.addInstanceListener(sampleInstance)
val instances = Hazelcast.getInstances().toList
System.out.println("The length of instances is: " + instances.length)
instances.foreach(instance => {
System.out.println(instance.getInstanceType() + "," + instance.getId())
})
}
}