Commit 9a48355b authored by Matija Obreza's avatar Matija Obreza

Hazelcast upgrade to 3.4 and admin cache stats overview (note the Hazelcast group name change!)

parent 47a282b5
......@@ -61,6 +61,7 @@
<org.springframework.social-google-version>1.0.0.M3</org.springframework.social-google-version>
<mysql.version>5.1.31</mysql.version>
<hazelcast.version>3.4</hazelcast.version>
<oval.version>1.81</oval.version>
<jackson.version>2.2.1</jackson.version>
......@@ -384,17 +385,22 @@
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-spring</artifactId>
<version>3.1.7</version>
<version>${hazelcast.version}</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-cloud</artifactId>
<version>3.1.7</version>
<version>${hazelcast.version}</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-hibernate4</artifactId>
<version>${hazelcast.version}</version>
</dependency>
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast-wm</artifactId>
<version>3.1.7</version>
<version>${hazelcast.version}</version>
</dependency>
<dependency>
......
This diff is collapsed.
......@@ -57,7 +57,11 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.hazelcast.core.DistributedObject;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IMap;
import com.hazelcast.monitor.LocalMapStats;
@Controller
@RequestMapping("/admin")
......@@ -387,4 +391,76 @@ public class AdminController {
return "redirect:/admin/";
}
@RequestMapping("/cache")
public String cacheStats(Model model) {
List<CacheStats> cacheMaps = new ArrayList<CacheStats>();
List<Object> cacheOther = new ArrayList<Object>();
Set<HazelcastInstance> instances = Hazelcast.getAllHazelcastInstances();
for (HazelcastInstance hz : instances) {
if (LOG.isDebugEnabled())
LOG.debug("\n\nCache stats Instance: " + hz.getName());
for (DistributedObject o : hz.getDistributedObjects()) {
if (o instanceof IMap) {
IMap imap = (IMap) o;
cacheMaps.add(new CacheStats(imap));
// System.out.println(imap.getServiceName() + ": " +
// imap.getName() + " " + imap.getPartitionKey());
// LocalMapStats localMapStats = imap.getLocalMapStats();
// System.out.println("created: " +
// localMapStats.getCreationTime());
// System.out.println("owned entries: " +
// localMapStats.getOwnedEntryCount());
// System.out.println("backup entries: " +
// localMapStats.getBackupEntryCount());
// System.out.println("locked entries: " +
// localMapStats.getLockedEntryCount());
// System.out.println("dirty entries: " +
// localMapStats.getDirtyEntryCount());
// System.out.println("hits: " + localMapStats.getHits());
// System.out.println("puts: " +
// localMapStats.getPutOperationCount());
// System.out.println("last update: " +
// localMapStats.getLastUpdateTime());
// System.out.println("last access:" +
// localMapStats.getLastAccessTime());
} else {
if (LOG.isDebugEnabled())
LOG.debug(o.getClass() + " " + o);
cacheOther.add(o);
}
}
}
model.addAttribute("cacheMaps", cacheMaps);
model.addAttribute("cacheOther", cacheOther);
return "/admin/cache";
}
public static final class CacheStats {
private String serviceName;
private String name;
private LocalMapStats mapStats;
public CacheStats(IMap<?, ?> imap) {
this.serviceName = imap.getServiceName();
this.name = imap.getName();
this.mapStats = imap.getLocalMapStats();
}
public String getServiceName() {
return serviceName;
}
public String getName() {
return name;
}
public LocalMapStats getMapStats() {
return mapStats;
}
}
}
......@@ -22,7 +22,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import com.hazelcast.config.MapConfig.EvictionPolicy;
import com.hazelcast.config.EvictionPolicy;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.ILock;
import com.hazelcast.core.ManagedContext;
......
......@@ -564,4 +564,11 @@ data-overview.otherCount=Other
data-overview.missingCount=Not specified
data-overview.totalCount=Total
data-overview.donorCode=FAO WIEWS code of donor institute
data-overview.mlsStatus=Available for distribution under the MLS
\ No newline at end of file
data-overview.mlsStatus=Available for distribution under the MLS
admin.cache.page.title=Application Cache Overview
cache.stat.map.ownedEntryCount=Owned cache entries
cache.stat.map.lockedEntryCount=Locked cache entries
cache.stat.map.puts=Number of writes to cache
cache.stat.map.hits=Number of cache hits
......@@ -95,8 +95,8 @@ executor.queue.capacity=100
scheduler.max.pool.size=16
# Hazelcast
hazelcast.instanceName=genesys
hazelcast.name=genesys
hazelcast.instanceName=hz-genesys
hazelcast.name=genesys-hz-3.5
hazelcast.password=hazelcasts
hazelcast.port=5701
......
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>
<html>
<head>
<title><spring:message code="admin.cache.page.title" /></title>
</head>
<body>
<h1>
<spring:message code="admin.cache.page.title" />
</h1>
<c:forEach items="${cacheMaps}" var="cacheMap">
<h3><c:out value="${cacheMap.serviceName}" /> <c:out value="${cacheMap.name}" /></h3>
<c:set value="${cacheMap.mapStats}" var="mapStat" />
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.ownedEntryCount" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.ownedEntryCount}" />
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.lockedEntryCount" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.lockedEntryCount}" />
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.puts" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.putOperationCount}" />
</div>
</div>
<div class="row">
<div class="col-xs-6 col-sm-4">
<spring:message code="cache.stat.map.hits" />
</div>
<div class="col-xs-6 col-sm-8">
<c:out value="${mapStat.hits}" />
</div>
</div>
</c:forEach>
<c:forEach items="${cacheOthers}" var="cacheOther">
<h3><c:out value="${cacheOther.class.name}" /> <c:out value="${cacheOther}" /></h3>
</c:forEach>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment