%--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
--%>
<%@page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@page import="org.apache.syncope.client.SyncopeConstants"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="org.apache.openjpa.datacache.CacheStatisticsImpl"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%@page import="org.apache.openjpa.persistence.OpenJPAPersistence"%>
<%@page import="org.apache.openjpa.persistence.OpenJPAEntityManagerFactory"%>
<%@page import="org.springframework.context.ConfigurableApplicationContext"%>
<%@page import="org.apache.openjpa.datacache.QueryKey"%>
<%@page import="org.apache.openjpa.kernel.QueryStatistics"%>
<%@page import="org.apache.openjpa.persistence.QueryResultCacheImpl"%>
<%@page import="org.apache.syncope.core.util.ApplicationContextProvider"%>
Cache Statistics
<%
ConfigurableApplicationContext context = ApplicationContextProvider.getApplicationContext();
EntityManagerFactory emf = context.getBean(
EntityManagerFactory.class);
OpenJPAEntityManagerFactory oemf = OpenJPAPersistence.cast(emf);
QueryStatistics queryStatistics =
((QueryResultCacheImpl) oemf.getQueryResultCache()).getDelegate().getStatistics();
CacheStatisticsImpl statistics = (CacheStatisticsImpl) oemf.getStoreCache().getStatistics();
String action = request.getParameter("do");
StringBuilder info = new StringBuilder(512);
if ("activate".equals(action)
&& !statistics.isEnabled()) {
statistics.enable();
info.append("Statistics enabled\n");
} else if ("deactivate".equals(action)
&& !statistics.isEnabled()) {
statistics.disable();
info.append("Statistics disabled\n");
} else if ("clear".equals(action)) {
queryStatistics.reset();
statistics.reset();
info.append("Statistics cleared\n");
}
SimpleDateFormat sdf = new SimpleDateFormat(
SyncopeConstants.DEFAULT_DATE_PATTERN);
if (info.length() > 0) {
%>
<% }%>
Reload
">
<%=(statistics.isEnabled()
? "DEACTIVATE" : "ACTIVATE")%>
CLEAR
Last update: <%=sdf.format(statistics.since())%>
Activation: <%=sdf.format(statistics.start())%>
Hits |
<%=statistics.getHitCount()%> |
Reads |
<%=statistics.getReadCount()%> |
Writes |
<%=statistics.getWriteCount()%> |
Query Hits |
<%=queryStatistics.getHitCount()%> |
Query Executions |
<%=queryStatistics.getExecutionCount()%> |
Query Evictions |
<%=queryStatistics.getEvictionCount()%> |
Query statistics |
Query |
Hits |
Executions |
<%
boolean odd = true;
for (QueryKey key : queryStatistics.keys()) {
%>
">
<%=key%> |
<%=queryStatistics.getHitCount(key)%> |
<%=queryStatistics.getExecutionCount(key)%> |
<%
odd = !odd;
}
%>
2nd level cache statistics |
Region |
Hits |
Reads |
Writes |
<%
odd = true;
for (String className : statistics.classNames()) {
%>
">
<%=className%> |
<%=statistics.getHitCount(className)%> |
<%=statistics.getReadCount(className)%> |
<%=statistics.getWriteCount(className)%> |
<%
odd = !odd;
}
%>