Commit 72b5807b authored by Matija Obreza's avatar Matija Obreza Committed by Artem Hrybeniuk
Browse files

Admin MVC: Dump cache contents to log

parent df1e2f75
......@@ -78,6 +78,24 @@ public class CacheController {
return "redirect:/admin/cache/";
}
@RequestMapping(method = RequestMethod.POST, value = "/dump")
public String dumpCache(@RequestParam(required = true, value = "name") String cacheName) {
final Cache cache = cacheManager.getCache(cacheName);
if (cache != null) {
LOG.warn("Inspecting cache {} of type {}", cacheName, cache.getNativeCache().getClass());
var nativeCache = cache.getNativeCache();
if (nativeCache instanceof IMap<?,?>) {
var hzMap = (IMap<?,?>) nativeCache;
hzMap.forEach((key, value) -> {
LOG.warn("Key={} [{}]: [{}]\n\t={}", key, key.getClass(), value.getClass(), value);
});
}
} else {
LOG.info("No such cache: {}", cacheName);
}
return "redirect:/admin/cache/";
}
@RequestMapping("/")
public String cacheStats(Model model) {
List<CacheStats> cacheMaps = new ArrayList<CacheStats>();
......
......@@ -32,7 +32,7 @@
<td style="text-align: right;">
Efficiency
</td>
<td class="col-sm-1 col-xs-2">
<td class="col-xs-1">
<form class="form-inline" method="post"
action="<c:url value="/admin/cache/clearCache" />">
<button type="submit" name="clearAll" class="btn btn-warning">Zap!</button>
......@@ -80,8 +80,8 @@
</p>
</c:if>
</td>
<td class="col-sm-1 col-xs-2">
<td class="col-xs-1">
<form method="post"
action="<c:url value="/admin/cache/clearCache" />">
<input type="hidden" name="name" value="${cacheMap.name}" />
......@@ -91,6 +91,17 @@
value="${_csrf.token}" />
</form>
</td>
<td class="col-xs-1">
<form method="post"
action="<c:url value="/admin/cache/dump" />">
<input type="hidden" name="name" value="${cacheMap.name}" />
<button type="submit" class="btn btn-default btn-sm">Dump</button>
<!-- CSRF protection -->
<input type="hidden" name="${_csrf.parameterName}"
value="${_csrf.token}" />
</form>
</td>
</tr>
</c:forEach>
</tbody>
......
Supports Markdown
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