Intro
This was suppose to be the first part, but ended up being the third. I should have showed this presentation as well, by Kylin Soon.
Deployment
The tests are failing for now, so let’s skip them.
[fdemeloj@fdemeloj target]$ mvn clean install -Dmaven.test.skip=true
Same approach copy to /standalone/deployments
INFO [org.jboss.as.server] (DeploymentScanner-threads – 1) WFLYSRV0010: Deployed “jboss-helloworld-jdg.war” (runtime-name : “jboss-helloworld-jdg.war”)
Core Part
Well, as expected the core part is the cache, which has the following configurations:
public DefaultCacheManager getCacheManager() {
if (manager == null) {GlobalConfiguration glob = new GlobalConfigurationBuilder().clusteredDefault() // Builds a default clustered
.transport().addProperty(“configurationFile”, “jgroups-udp.xml”)
.globalJmxStatistics().allowDuplicateDomains(true).enable()
.build();
Configuration loc = new ConfigurationBuilder().jmxStatistics().enable() // Enable JMX statistics
.clustering().cacheMode(CacheMode.DIST_SYNC) /
.hash().numOwners(2)
.expiration().lifespan(ENTRY_LIFESPAN)
.build();
manager = new DefaultCacheManager(glob, loc, true);
}
Meaning
.expiration().lifespan(ENTRY_LIFESPAN) time to expire the data in the cache.
Lifespan property is pretty cool
jgroups-udp.xml
Differently than the other three, this one uses a specific jdg configuration file that set’s multicast – UDP properties, instead of TCP. Some recommendations for this file here.
<UDP
bind_addr=”${jgroups.bind_addr:127.0.0.1}”
mcast_addr=”${jgroups.udp.mcast_addr:228.6.7.8}”
mcast_port=”${jgroups.udp.mcast_port:46655}”
tos=”8″
ucast_recv_buf_size=”20000000″
ucast_send_buf_size=”640000″
mcast_recv_buf_size=”25000000″
mcast_send_buf_size=”640000″
max_bundle_size=”64000″
ip_ttl=”${jgroups.udp.ip_ttl:2}”
enable_diagnostics=”false”thread_naming_pattern=”pl”
thread_pool.enabled=”true”
thread_pool.min_threads=”2″
thread_pool.max_threads=”30″
thread_pool.keep_alive_time=”5000″
/><PING />
<MERGE3 max_interval=”30000″ min_interval=”10000″/>
<FD_SOCK/>
<FD_ALL/>
<BARRIER />
<pbcast.NAKACK2 use_mcast_xmit=”true” discard_delivered_msgs=”true”/>
<UNICAST3/>
<pbcast.STABLE stability_delay=”1000″ desired_avg_gossip=”50000″ max_bytes=”1000000″/>
<pbcast.GMS print_local_addr=”false” join_timeout=”3000″ view_bundling=”true”/>
<UFC max_credits=”500000″ min_threshold=”0.20″/>
<MFC max_credits=”500000″ min_threshold=”0.20″/>
<FRAG2 frag_size=”60000″ />
Adding value
Pretty much standard, as before, get the (default) cache manager and put the value.
INFO [org.jboss.as.quickstarts.datagrid.helloworld.PutController] (default task-1) put: jdg 8
Interesting parts
- The Security Manager
- double lines when creating the default cache manager and the configuration file
- Lifespan and UDP were the best part