PK ]>
c build.xml
PK X>hA A commands.py# Here you can create play commands that are specific to the module, and extend existing commands
MODULE = 'hazelcast'
# Commands that are specific to your module
COMMANDS = ['hazelcast:hello']
def execute(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "hazelcast:hello":
print "~ Hello"
# This will be executed before any command (new, run...)
def before(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
# This will be executed after any command (new, run...)
def after(**kargs):
command = kargs.get("command")
app = kargs.get("app")
args = kargs.get("args")
env = kargs.get("env")
if command == "new":
pass
PK b>YD commands.pyc
{Mc @ s. d Z d g Z d Z d Z d Z d S( t hazelcasts hazelcast:helloc K sV | i d } | i d } | i d } | i d } | d j o d GHn d S( Nt commandt appt argst envs hazelcast:hellos ~ Hello( t get( t kargsR R R R ( ( s= /Users/marcus/Developments/play_modules/hazelcast/commands.pyt execute s
c K s@ | i d } | i d } | i d } | i d } d S( NR R R R ( R ( R R R R R ( ( s= /Users/marcus/Developments/play_modules/hazelcast/commands.pyt before s c K sQ | i d } | i d } | i d } | i d } | d j o n d S( NR R R R t new( R ( R R R R R ( ( s= /Users/marcus/Developments/play_modules/hazelcast/commands.pyt after s
N( t MODULEt COMMANDSR R R
( ( ( s= /Users/marcus/Developments/play_modules/hazelcast/commands.pyt s PK E>Mi" " manifestversion=0.1
frameworkVersions=1.2
PK 䰴>eq
README.textileh1. Documentation for the Hazelcast module
bq. This module is a @dropin@ replacement for EhCacheImpl or MemcachedImpl from Play.
It allow your application to have a clustered cache when you can't install a memcached server on your platform.
It's also a great free open source *In-Memory Data Grid*
See "Hazelcast Documentation":http://www.hazelcast.com/documentation.jsp for more details.
h2. Installing Hazelcast Module
p. To install Hazelcast Plugin module, you do like every other Play Modules:
bc. play install hazelcast[-version]
h2. Using Hazelcast Module in your application (Dependency management)
h3. There is two way to use the module
* The Play 1.x way (*in application.conf*)
bc. module.hazelcast=${play.path}/modules/hazelcast-[version]
* The Play 1.2.x way (*in dependencies.yml*)
bc.. require:
- play -> hazelcast [version]
h2. Using standard Play! Framework Cache Mechanisms
p. All the standard Play annotations or methods work seamlessly with Hazelcast instead of EhCache or Memcached.
* @@CacheFor("1h")@
* @Cache.xxx()@
* Etc...
bq. See "Play Framework Cache Documentation":/@documentation/cache for *@@CacheFor@* and provided Play! *@Cache.xxx()@* usage.
h2. Using features from Hazelcast
h3. Using @Inject to inject an instance of Hazelcast in your controller
bc. @Inject private static HazelcastInstance hazel;
h3. Injecting the default ExecutorService
bc. @Inject private static ExecutorService executor;
h3. Using @Named to inject a named resource
bc. @Named("MyQueue") private static Queue myQueue;
h2. Hazelcast clustered services
* Distributed Queues (Entries are consumed by one and only one JVM)
* Distributed Topics (Entries are consumed by all JVM)
* Distributed Events
* Distributed AtomicNumber provider
* Distributed ExecutorService
* Distributed ID Generator (_ID are UNIQUE in all cluster nodes_)
* Distributed List (to share a list in the cluster between many JVM)
* Distributed Lock (_to apply a lock on an object and share between JVM_)
* Distributed Set
* Distributed Map/MultiMap (_Maps are shared between JMV, MultiMap allow for multiple values for the same key_)
* Distributed Transaction (_affect transactions on clustered objects, not database!_)
h3. Configuration file *hazelcast.xml*
You can modify *hazelcast.xml* to your need to create more Queues or Map and modify the default ExecutorService parameters. Just copy the hazelcast.xml file from the module _conf_ directory to your application _conf_ directory.
h3. Hazelcast Object type that can be retreived via @@Named@ annotation
* Queue
* Topic
* AtomicNumber
* ExecutorService
* Set
* Map
* MultiMap
* IdGenerator
h3. Hazelcast Object type that can by retreived via @@Inject@ annotation
* Transaction
* ExecutorService
* PartitionService
* Event
h3. Method directly accessible on @HazelcastPlugin@ class
* @HazelcastPlugin.getTransaction()@ [1]
* @HazelcastPlugin.getLock(Object o)@ [2]
* @HazelcastPlugin.getHazel()@ [3]
fn1. Use this to get a Transaction object then you can @begin()@ or @commit()@ or @rollback()@ operations on cluster.
fn2. Use this to lock an object across the cluster.
fn3. Use this if you absolutly _NEED_ to directly get the Default Hazelcast instance.
h2. Roadmap
p. I'd like to see some basic Play! features use Hazel capabilities:
* Play! Jobs could use Hazelcast ExecutorService automaticaly
* Integrating Hazelcast with my other upcoming module "Camel":http://myuri.me/3VAE for "EIP":http://myuri.me/3Vh8
* Etc...
PK > ) app/controllers/HazelcastApplication.javapackage controllers;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.inject.Inject;
import play.Logger;
import play.cache.Cache;
import play.data.validation.Required;
import play.mvc.Controller;
import com.hazelcast.config.ExecutorConfig;
import com.hazelcast.config.MapConfig;
import com.hazelcast.config.QueueConfig;
import com.hazelcast.config.TopicConfig;
import com.hazelcast.core.HazelcastInstance;
public class HazelcastApplication extends Controller {
@Inject
private static HazelcastInstance hazel;
public static void index() {
Logger.info("Compteur: %s", hazel.getAtomicNumber("test").addAndGet(1));
String implementation = Cache.cacheImpl.getClass().getName();
String name = hazel.getName();
String port = "" + hazel.getConfig().getPort();
hazel.getList("myList");
hazel.getQueue("myQueue");
hazel.getMap("myMap");
hazel.getTopic("myTopic");
hazel.getAtomicNumber("myAtomicNumber");
hazel.getExecutorService("myExecutorService");
hazel.getIdGenerator("myIdGenerator");
hazel.getMultiMap("myMultiMap");
hazel.getSet("mySet");
List maps = new ArrayList(hazel.getConfig().getMapConfigs().values());
List executors = new ArrayList(hazel.getConfig().getExecutorConfigs());
List queues = new ArrayList(hazel.getConfig().getQConfigs().values());
List topics = new ArrayList(hazel.getConfig().getTopicConfigs().values());
render(implementation, name, port, maps, executors, queues, topics);
}
public static void viewMap(@Required String name){
Map map = hazel.getMap(name);
Set keys = map.keySet();
render(name, keys, map);
}
}
PK N>l3 ) app/views/HazelcastApplication/index.html#{extends "HazelcastApplication/main.html" /}
#{set title:'Home' /}
PK <>1 conf/application.confapplication.name=hazelcast
PK >3&Z Z conf/dependencies.ymlself: play -> hazelcast 0.1
require:
- play
- com.hazelcast -> hazelcast-all 1.9.2:
exclude:
- junit-addons -> junit-addons 1.4
- xerces -> xercesImpl 2.6.2
- xerces -> xmlParserAPIs 2.6.2
- org.mockito -> mockito-all 1.8.2
- com.hazelcast -> hazelcast-hibernate 1.9.2
PK K>/n| | conf/hazelcast.xml
devdev-pass5701224.2.2.354327127.0.0.110.10.1.*PBEWithMD5AndDESthesaltthepass19RSA/NONE/PKCS1PADDINGthekeypasslocalJKSthestorepasskeystore166460PK X>r
conf/messages# Default hazelcast messages
# You can specialize this file for each language.
# For exemple, for french create a messages.fr file
#hazelcast.name=hazelcastPK Z>Ad$$ $ conf/routes# This file defines all module routes (Higher priority routes first)
#
# import these routes in the main app as :
# * / module:hazelcast
#
# ~~~~
#GET /? HazelcastApplication.index
GET /play-hazelcast/ staticDir:public-hazelcastPK 갴>eq
! documentation/manual/home.textileh1. Documentation for the Hazelcast module
bq. This module is a @dropin@ replacement for EhCacheImpl or MemcachedImpl from Play.
It allow your application to have a clustered cache when you can't install a memcached server on your platform.
It's also a great free open source *In-Memory Data Grid*
See "Hazelcast Documentation":http://www.hazelcast.com/documentation.jsp for more details.
h2. Installing Hazelcast Module
p. To install Hazelcast Plugin module, you do like every other Play Modules:
bc. play install hazelcast[-version]
h2. Using Hazelcast Module in your application (Dependency management)
h3. There is two way to use the module
* The Play 1.x way (*in application.conf*)
bc. module.hazelcast=${play.path}/modules/hazelcast-[version]
* The Play 1.2.x way (*in dependencies.yml*)
bc.. require:
- play -> hazelcast [version]
h2. Using standard Play! Framework Cache Mechanisms
p. All the standard Play annotations or methods work seamlessly with Hazelcast instead of EhCache or Memcached.
* @@CacheFor("1h")@
* @Cache.xxx()@
* Etc...
bq. See "Play Framework Cache Documentation":/@documentation/cache for *@@CacheFor@* and provided Play! *@Cache.xxx()@* usage.
h2. Using features from Hazelcast
h3. Using @Inject to inject an instance of Hazelcast in your controller
bc. @Inject private static HazelcastInstance hazel;
h3. Injecting the default ExecutorService
bc. @Inject private static ExecutorService executor;
h3. Using @Named to inject a named resource
bc. @Named("MyQueue") private static Queue myQueue;
h2. Hazelcast clustered services
* Distributed Queues (Entries are consumed by one and only one JVM)
* Distributed Topics (Entries are consumed by all JVM)
* Distributed Events
* Distributed AtomicNumber provider
* Distributed ExecutorService
* Distributed ID Generator (_ID are UNIQUE in all cluster nodes_)
* Distributed List (to share a list in the cluster between many JVM)
* Distributed Lock (_to apply a lock on an object and share between JVM_)
* Distributed Set
* Distributed Map/MultiMap (_Maps are shared between JMV, MultiMap allow for multiple values for the same key_)
* Distributed Transaction (_affect transactions on clustered objects, not database!_)
h3. Configuration file *hazelcast.xml*
You can modify *hazelcast.xml* to your need to create more Queues or Map and modify the default ExecutorService parameters. Just copy the hazelcast.xml file from the module _conf_ directory to your application _conf_ directory.
h3. Hazelcast Object type that can be retreived via @@Named@ annotation
* Queue
* Topic
* AtomicNumber
* ExecutorService
* Set
* Map
* MultiMap
* IdGenerator
h3. Hazelcast Object type that can by retreived via @@Inject@ annotation
* Transaction
* ExecutorService
* PartitionService
* Event
h3. Method directly accessible on @HazelcastPlugin@ class
* @HazelcastPlugin.getTransaction()@ [1]
* @HazelcastPlugin.getLock(Object o)@ [2]
* @HazelcastPlugin.getHazel()@ [3]
fn1. Use this to get a Transaction object then you can @begin()@ or @commit()@ or @rollback()@ operations on cluster.
fn2. Use this to lock an object across the cluster.
fn3. Use this if you absolutly _NEED_ to directly get the Default Hazelcast instance.
h2. Roadmap
p. I'd like to see some basic Play! features use Hazel capabilities:
* Play! Jobs could use Hazelcast ExecutorService automaticaly
* Integrating Hazelcast with my other upcoming module "Camel":http://myuri.me/3VAE for "EIP":http://myuri.me/3Vh8
* Etc...
PK 0m>?#q\ q\ lib/hazelcast-1.9.2.jarPK
oK> META-INF/PK
nK>M META-INF/MANIFEST.MFTMo@#fRRD9TVe8v x3潙آON]dMYGFbɃEX"k0+:M[! Ec^}kʿUuKJ:\q^Qrpaس3Jb^ >#3#'
T#tS5`%GXΌٟU^i͓biCS- s
iڣG&Tt\r]u5
apΨ4Ic,('BqފzYI6j=/*76Vv1@<w?{x>|:/