mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-23 03:22:59 +00:00
Refactor io.ebean.meta API, method rename with deprecation
This commit is contained in:
@@ -18,22 +18,22 @@ public abstract class AbstractMetricVisitor implements MetricVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReset() {
|
||||
public boolean reset() {
|
||||
return reset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollectTransactionMetrics() {
|
||||
public boolean collectTransactionMetrics() {
|
||||
return collectTransactionMetrics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollectQueryMetrics() {
|
||||
public boolean collectQueryMetrics() {
|
||||
return collectQueryMetrics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCollectL2Metrics() {
|
||||
public boolean collectL2Metrics() {
|
||||
return collectL2Metrics;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,17 +27,17 @@ public class BasicMetricVisitor extends AbstractMetricVisitor implements ServerM
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetaTimedMetric> getTimedMetrics() {
|
||||
public List<MetaTimedMetric> timedMetrics() {
|
||||
return timed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetaQueryMetric> getQueryMetrics() {
|
||||
public List<MetaQueryMetric> queryMetrics() {
|
||||
return query;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetaCountMetric> getCountMetrics() {
|
||||
public List<MetaCountMetric> countMetrics() {
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,13 @@ public interface MetaCountMetric extends MetaMetric {
|
||||
/**
|
||||
* Return the total count.
|
||||
*/
|
||||
long getCount();
|
||||
long count();
|
||||
|
||||
/**
|
||||
* Migrate to count()
|
||||
*/
|
||||
@Deprecated
|
||||
default long getCount() {
|
||||
return count();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,13 @@ public interface MetaMetric {
|
||||
/**
|
||||
* Return the metric name.
|
||||
*/
|
||||
String getName();
|
||||
String name();
|
||||
|
||||
/**
|
||||
* Migrate to name().
|
||||
*/
|
||||
@Deprecated
|
||||
default String getName() {
|
||||
return name();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,21 +8,52 @@ public interface MetaQueryMetric extends MetaTimedMetric {
|
||||
/**
|
||||
* The type of entity or DTO bean.
|
||||
*/
|
||||
Class<?> getType();
|
||||
Class<?> type();
|
||||
|
||||
/**
|
||||
* Migrate to type().
|
||||
*/
|
||||
@Deprecated
|
||||
default Class<?> getType() {
|
||||
return type();
|
||||
}
|
||||
|
||||
/**
|
||||
* The label for the query (can be null).
|
||||
*/
|
||||
String getLabel();
|
||||
String label();
|
||||
|
||||
/**
|
||||
* Migrate to label().
|
||||
*/
|
||||
@Deprecated
|
||||
default String getLabel() {
|
||||
return label();
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual SQL of the query.
|
||||
*/
|
||||
String getSql();
|
||||
String sql();
|
||||
|
||||
/**
|
||||
* Migrate to sql().
|
||||
*/
|
||||
@Deprecated
|
||||
default String getSql() {
|
||||
return sql();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the hash of the sql.
|
||||
*/
|
||||
long getSqlHash();
|
||||
long sqlHash();
|
||||
|
||||
/**
|
||||
* Migrate to sqlHash().
|
||||
*/
|
||||
@Deprecated
|
||||
default long getSqlHash() {
|
||||
return sqlHash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,45 +10,45 @@ public interface MetaQueryPlan {
|
||||
/**
|
||||
* Return the bean type for the query.
|
||||
*/
|
||||
Class<?> getBeanType();
|
||||
Class<?> beanType();
|
||||
|
||||
/**
|
||||
* Return the label of the query.
|
||||
*/
|
||||
String getLabel();
|
||||
String label();
|
||||
|
||||
/**
|
||||
* Return the profile location for the query.
|
||||
*/
|
||||
ProfileLocation getProfileLocation();
|
||||
ProfileLocation profileLocation();
|
||||
|
||||
/**
|
||||
* Return the sql of the query.
|
||||
*/
|
||||
String getSql();
|
||||
String sql();
|
||||
|
||||
/**
|
||||
* Return the hash of the plan.
|
||||
*/
|
||||
long getHash();
|
||||
long sqlHash();
|
||||
|
||||
/**
|
||||
* Return a description of the bind values.
|
||||
*/
|
||||
String getBind();
|
||||
String bind();
|
||||
|
||||
/**
|
||||
* Return the raw plan.
|
||||
*/
|
||||
String getPlan();
|
||||
String plan();
|
||||
|
||||
/**
|
||||
* Return the query execution time associated with the bind values capture.
|
||||
*/
|
||||
long getQueryTimeMicros();
|
||||
long queryTimeMicros();
|
||||
|
||||
/**
|
||||
* Return the total count of times bind capture has occurred.
|
||||
*/
|
||||
long getCaptureCount();
|
||||
long captureCount();
|
||||
}
|
||||
|
||||
@@ -9,27 +9,68 @@ public interface MetaTimedMetric extends MetaMetric {
|
||||
/**
|
||||
* Return the metric location if defined.
|
||||
*/
|
||||
String getLocation();
|
||||
String location();
|
||||
|
||||
/**
|
||||
* Migrate to location()
|
||||
*/
|
||||
@Deprecated
|
||||
default String getLocation() {
|
||||
return location();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total count.
|
||||
*/
|
||||
long getCount();
|
||||
long count();
|
||||
|
||||
/**
|
||||
* Migrate to count()
|
||||
*/
|
||||
@Deprecated
|
||||
default long getCount() {
|
||||
return count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the total execution time in micros.
|
||||
*/
|
||||
long getTotal();
|
||||
long total();
|
||||
|
||||
/**
|
||||
* Migrate to total()
|
||||
*/
|
||||
@Deprecated
|
||||
default long getTotal() {
|
||||
return total();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the max execution time in micros.
|
||||
*/
|
||||
long getMax();
|
||||
long max();
|
||||
|
||||
/**
|
||||
* Migrate to max()
|
||||
*/
|
||||
@Deprecated
|
||||
default long getMax() {
|
||||
return max();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mean execution time in micros.
|
||||
*/
|
||||
long getMean();
|
||||
long mean();
|
||||
|
||||
|
||||
/**
|
||||
* Migrate to mean()
|
||||
*/
|
||||
@Deprecated
|
||||
default long getMean() {
|
||||
return mean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if this is the first metrics collection for this query.
|
||||
|
||||
@@ -8,22 +8,22 @@ public interface MetricVisitor {
|
||||
/**
|
||||
* Return true if the metrics should be reset.
|
||||
*/
|
||||
boolean isReset();
|
||||
boolean reset();
|
||||
|
||||
/**
|
||||
* Return true if we should visit the transaction metrics.
|
||||
*/
|
||||
boolean isCollectTransactionMetrics();
|
||||
boolean collectTransactionMetrics();
|
||||
|
||||
/**
|
||||
* Return true if we should visit the ORM and SQL query metrics.
|
||||
*/
|
||||
boolean isCollectQueryMetrics();
|
||||
boolean collectQueryMetrics();
|
||||
|
||||
/**
|
||||
* Return true if we should visit the L2 cache metrics.
|
||||
*/
|
||||
boolean isCollectL2Metrics();
|
||||
boolean collectL2Metrics();
|
||||
|
||||
/**
|
||||
* Visit has started.
|
||||
|
||||
@@ -32,7 +32,7 @@ public class QueryPlanInit {
|
||||
* Return the query execution time threshold which must be exceeded to initiate
|
||||
* query plan collection.
|
||||
*/
|
||||
public long getThresholdMicros() {
|
||||
public long thresholdMicros() {
|
||||
return thresholdMicros;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class QueryPlanInit {
|
||||
* Set the query execution time threshold which must be exceeded to initiate
|
||||
* query plan collection.
|
||||
*/
|
||||
public void setThresholdMicros(long thresholdMicros) {
|
||||
public void thresholdMicros(long thresholdMicros) {
|
||||
this.thresholdMicros = thresholdMicros;
|
||||
}
|
||||
|
||||
@@ -54,14 +54,14 @@ public class QueryPlanInit {
|
||||
/**
|
||||
* Return the specific hashes that we want to collect query plans on.
|
||||
*/
|
||||
public Set<Long> getHashes() {
|
||||
public Set<Long> sqlHashes() {
|
||||
return hashes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the specific hashes that we want to collect query plans on.
|
||||
*/
|
||||
public void setHashes(Set<Long> hashes) {
|
||||
public void sqlHashes(Set<Long> hashes) {
|
||||
this.hashes = hashes;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class QueryPlanRequest {
|
||||
* have been around for a while (e.g. 5 mins) and so reasonably represent
|
||||
* bind values that match the slowest execution for this query plan.
|
||||
*/
|
||||
public long getSince() {
|
||||
public long since() {
|
||||
return since;
|
||||
}
|
||||
|
||||
@@ -28,14 +28,14 @@ public class QueryPlanRequest {
|
||||
*
|
||||
* @param since The minimum age of the bind values capture.
|
||||
*/
|
||||
public void setSince(long since) {
|
||||
public void since(long since) {
|
||||
this.since = since;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the maximum number of plans to capture.
|
||||
*/
|
||||
public int getMaxCount() {
|
||||
public int maxCount() {
|
||||
return maxCount;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class QueryPlanRequest {
|
||||
* Use this to limit how much query plan capturing is done as query
|
||||
* plan capture is actual database load.
|
||||
*/
|
||||
public void setMaxCount(int maxCount) {
|
||||
public void maxCount(int maxCount) {
|
||||
this.maxCount = maxCount;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class QueryPlanRequest {
|
||||
* <p>
|
||||
* Query plan collection will stop once this time is exceeded.
|
||||
*/
|
||||
public long getMaxTimeMillis() {
|
||||
public long maxTimeMillis() {
|
||||
return maxTimeMillis;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class QueryPlanRequest {
|
||||
* this to ensure the query plan capture does not use excessive amount
|
||||
* of time - put too much load on the database.
|
||||
*/
|
||||
public void setMaxTimeMillis(long maxTimeMillis) {
|
||||
public void maxTimeMillis(long maxTimeMillis) {
|
||||
this.maxTimeMillis = maxTimeMillis;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,16 +10,39 @@ public interface ServerMetrics {
|
||||
/**
|
||||
* Return timed metrics for Transactions, labelled SqlQuery, labelled SqlUpdate.
|
||||
*/
|
||||
List<MetaTimedMetric> getTimedMetrics();
|
||||
List<MetaTimedMetric> timedMetrics();
|
||||
|
||||
/**
|
||||
* Migrate to timedMetrics().
|
||||
*/
|
||||
@Deprecated
|
||||
default List<MetaTimedMetric> getTimedMetrics() {
|
||||
return timedMetrics();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the query metrics.
|
||||
*/
|
||||
List<MetaQueryMetric> getQueryMetrics();
|
||||
List<MetaQueryMetric> queryMetrics();
|
||||
|
||||
/**
|
||||
* Migrate to queryMetrics().
|
||||
*/
|
||||
@Deprecated
|
||||
default List<MetaQueryMetric> getQueryMetrics() {
|
||||
return queryMetrics();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Counter metrics.
|
||||
*/
|
||||
List<MetaCountMetric> getCountMetrics();
|
||||
List<MetaCountMetric> countMetrics();
|
||||
|
||||
/**
|
||||
* Migrate to countMetrics().
|
||||
*/
|
||||
@Deprecated
|
||||
default List<MetaCountMetric> getCountMetrics() {
|
||||
return countMetrics();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ import java.util.Comparator;
|
||||
public interface ServerMetricsAsJson {
|
||||
|
||||
/**
|
||||
* Set to false to exclude profile location and sql.
|
||||
* Set to false in order to exclude profile location and sql.
|
||||
*/
|
||||
ServerMetricsAsJson withExtraAttributes(boolean withLocation);
|
||||
|
||||
/**
|
||||
* Set to false to exclude SQL hash.
|
||||
* Set to false in order to exclude SQL hash.
|
||||
*/
|
||||
ServerMetricsAsJson withHash(boolean withHash);
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class SortMetric {
|
||||
|
||||
@Override
|
||||
public int compare(MetaCountMetric o1, MetaCountMetric o2) {
|
||||
return stringCompare(o1.getName(), o2.getName());
|
||||
return stringCompare(o1.name(), o2.name());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ public class SortMetric {
|
||||
|
||||
@Override
|
||||
public int compare(MetaTimedMetric o1, MetaTimedMetric o2) {
|
||||
int i = stringCompare(o1.getName(), o2.getName());
|
||||
return i != 0 ? i : Long.compare(o1.getCount(), o2.getCount());
|
||||
int i = stringCompare(o1.name(), o2.name());
|
||||
return i != 0 ? i : Long.compare(o1.count(), o2.count());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public class SortMetric {
|
||||
|
||||
@Override
|
||||
public int compare(MetaTimedMetric o1, MetaTimedMetric o2) {
|
||||
return Long.compare(o2.getCount(), o1.getCount());
|
||||
return Long.compare(o2.count(), o1.count());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class SortMetric {
|
||||
|
||||
@Override
|
||||
public int compare(MetaTimedMetric o1, MetaTimedMetric o2) {
|
||||
return Long.compare(o2.getTotal(), o1.getTotal());
|
||||
return Long.compare(o2.total(), o1.total());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class SortMetric {
|
||||
|
||||
@Override
|
||||
public int compare(MetaTimedMetric o1, MetaTimedMetric o2) {
|
||||
return Long.compare(o2.getMean(), o1.getMean());
|
||||
return Long.compare(o2.mean(), o1.mean());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class SortMetric {
|
||||
|
||||
@Override
|
||||
public int compare(MetaTimedMetric o1, MetaTimedMetric o2) {
|
||||
return Long.compare(o2.getMax(), o1.getMax());
|
||||
return Long.compare(o2.max(), o1.max());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ class DefaultQueryPlanListener implements QueryPlanListener {
|
||||
String dbName = capture.getDatabase().getName();
|
||||
for (MetaQueryPlan plan : capture.getPlans()) {
|
||||
log.info("queryPlan db:{} label:{} queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
|
||||
dbName, plan.getLabel(), plan.getQueryTimeMicros(), plan.getProfileLocation(),
|
||||
plan.getSql(), plan.getBind(), plan.getPlan());
|
||||
dbName, plan.label(), plan.queryTimeMicros(), plan.profileLocation(),
|
||||
plan.sql(), plan.bind(), plan.plan());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -416,8 +416,8 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
private void collectQueryPlans() {
|
||||
QueryPlanRequest request = new QueryPlanRequest();
|
||||
request.setMaxCount(config.getQueryPlanCaptureMaxCount());
|
||||
request.setMaxTimeMillis(config.getQueryPlanCaptureMaxTimeMillis());
|
||||
request.maxCount(config.getQueryPlanCaptureMaxCount());
|
||||
request.maxTimeMillis(config.getQueryPlanCaptureMaxTimeMillis());
|
||||
|
||||
// obtains query explain plans ...
|
||||
List<MetaQueryPlan> plans = metaInfoManager.queryPlanCollectNow(request);
|
||||
@@ -2328,13 +2328,13 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
@Override
|
||||
public void visitMetrics(MetricVisitor visitor) {
|
||||
visitor.visitStart();
|
||||
if (visitor.isCollectTransactionMetrics()) {
|
||||
if (visitor.collectTransactionMetrics()) {
|
||||
transactionManager.visitMetrics(visitor);
|
||||
}
|
||||
if (visitor.isCollectL2Metrics()) {
|
||||
if (visitor.collectL2Metrics()) {
|
||||
serverCacheManager.visitMetrics(visitor);
|
||||
}
|
||||
if (visitor.isCollectQueryMetrics()) {
|
||||
if (visitor.collectQueryMetrics()) {
|
||||
beanDescriptorManager.visitMetrics(visitor);
|
||||
dtoBeanManager.visitMetrics(visitor);
|
||||
relationalQueryEngine.visitMetrics(visitor);
|
||||
@@ -2351,7 +2351,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
||||
|
||||
List<MetaQueryPlan> queryPlanInit(QueryPlanInit initRequest) {
|
||||
if (initRequest.isAll()) {
|
||||
queryPlanManager.setDefaultThreshold(initRequest.getThresholdMicros());
|
||||
queryPlanManager.setDefaultThreshold(initRequest.thresholdMicros());
|
||||
}
|
||||
return beanDescriptorManager.queryPlanInit(initRequest);
|
||||
}
|
||||
|
||||
@@ -78,11 +78,11 @@ class DumpMetrics {
|
||||
out("-- Dumping metrics for " + server.getName() + " -- ");
|
||||
ServerMetrics serverMetrics = server.getMetaInfoManager().collectMetrics();
|
||||
|
||||
for (MetaTimedMetric metric : serverMetrics.getTimedMetrics()) {
|
||||
for (MetaTimedMetric metric : serverMetrics.timedMetrics()) {
|
||||
log(metric);
|
||||
}
|
||||
|
||||
List<MetaCountMetric> countMetrics = serverMetrics.getCountMetrics();
|
||||
List<MetaCountMetric> countMetrics = serverMetrics.countMetrics();
|
||||
if (!countMetrics.isEmpty()) {
|
||||
out("\n-- Counters --");
|
||||
countMetrics.sort(SortMetric.COUNT_NAME);
|
||||
@@ -91,7 +91,7 @@ class DumpMetrics {
|
||||
}
|
||||
}
|
||||
|
||||
List<MetaQueryMetric> queryMetrics = serverMetrics.getQueryMetrics();
|
||||
List<MetaQueryMetric> queryMetrics = serverMetrics.queryMetrics();
|
||||
if (!queryMetrics.isEmpty()) {
|
||||
out("\n-- Queries --");
|
||||
queryMetrics.sort(sortBy);
|
||||
@@ -104,8 +104,8 @@ class DumpMetrics {
|
||||
private void logCount(MetaCountMetric metric) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(padNameTimed(metric.getName())).append(" ");
|
||||
sb.append(" count:").append(pad(metric.getCount()));
|
||||
sb.append(padNameTimed(metric.name())).append(" ");
|
||||
sb.append(" count:").append(pad(metric.count()));
|
||||
out(sb.toString());
|
||||
}
|
||||
|
||||
@@ -120,38 +120,38 @@ class DumpMetrics {
|
||||
appendQueryName(metric, sb);
|
||||
appendCounters(metric, sb);
|
||||
if (dumpHash) {
|
||||
sb.append("\n sqlHash:").append(metric.getSqlHash());
|
||||
sb.append("\n sqlHash:").append(metric.sqlHash());
|
||||
}
|
||||
appendProfileAndSql(metric, sb);
|
||||
out(sb.toString());
|
||||
}
|
||||
|
||||
private void appendQueryName(MetaQueryMetric metric, StringBuilder sb) {
|
||||
sb.append("query:").append(padName(metric.getName())).append(" ");
|
||||
sb.append("query:").append(padName(metric.name())).append(" ");
|
||||
}
|
||||
|
||||
private void appendProfileAndSql(MetaQueryMetric metric, StringBuilder sb) {
|
||||
String location = metric.getLocation();
|
||||
String location = metric.location();
|
||||
if (dumpLoc && location != null) {
|
||||
sb.append("\n loc:").append(location);
|
||||
}
|
||||
if (dumpSql) {
|
||||
sb.append(" \n\n sql:").append(metric.getSql()).append("\n\n");
|
||||
sb.append(" \n\n sql:").append(metric.sql()).append("\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
private void log(MetaTimedMetric metric) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(padNameTimed(metric.getName())).append(" ");
|
||||
sb.append(padNameTimed(metric.name())).append(" ");
|
||||
appendCounters(metric, sb);
|
||||
out(sb.toString());
|
||||
}
|
||||
|
||||
private void appendCounters(MetaTimedMetric timedMetric, StringBuilder sb) {
|
||||
sb.append(" count:").append(pad(timedMetric.getCount()))
|
||||
.append(" total:").append(pad(timedMetric.getTotal()))
|
||||
.append(" mean:").append(pad(timedMetric.getMean()))
|
||||
.append(" max:").append(pad(timedMetric.getMax()));
|
||||
sb.append(" count:").append(pad(timedMetric.count()))
|
||||
.append(" total:").append(pad(timedMetric.total()))
|
||||
.append(" mean:").append(pad(timedMetric.mean()))
|
||||
.append(" max:").append(pad(timedMetric.max()));
|
||||
}
|
||||
|
||||
private String padName(String name) {
|
||||
|
||||
@@ -31,9 +31,9 @@ class DumpMetricsData {
|
||||
|
||||
private void collect(ServerMetrics serverMetrics) {
|
||||
|
||||
final List<MetaTimedMetric> timedMetrics = serverMetrics.getTimedMetrics();
|
||||
final List<MetaCountMetric> countMetrics = serverMetrics.getCountMetrics();
|
||||
final List<MetaQueryMetric> queryMetrics = serverMetrics.getQueryMetrics();
|
||||
final List<MetaTimedMetric> timedMetrics = serverMetrics.timedMetrics();
|
||||
final List<MetaCountMetric> countMetrics = serverMetrics.countMetrics();
|
||||
final List<MetaQueryMetric> queryMetrics = serverMetrics.queryMetrics();
|
||||
|
||||
for (MetaTimedMetric metric : timedMetrics) {
|
||||
add(metric);
|
||||
@@ -47,7 +47,7 @@ class DumpMetricsData {
|
||||
}
|
||||
|
||||
private MetricData create(MetaMetric metric) {
|
||||
MetricData data = new MetricData(metric.getName());
|
||||
MetricData data = new MetricData(metric.name());
|
||||
list.add(data);
|
||||
return data;
|
||||
}
|
||||
@@ -55,30 +55,30 @@ class DumpMetricsData {
|
||||
private void add(MetaTimedMetric metric) {
|
||||
final MetricData data = create(metric);
|
||||
appendCounters(data, metric);
|
||||
data.setLoc(metric.getLocation());
|
||||
data.setLoc(metric.location());
|
||||
}
|
||||
|
||||
private void addCount(MetaCountMetric metric) {
|
||||
final MetricData data = create(metric);
|
||||
data.setCount(metric.getCount());
|
||||
data.setCount(metric.count());
|
||||
}
|
||||
|
||||
private void addQuery(MetaQueryMetric metric) {
|
||||
final MetricData data = create(metric);
|
||||
appendCounters(data, metric);
|
||||
appendLocationAndSql(data, metric);
|
||||
data.setSqlHash(metric.getSqlHash());
|
||||
data.setSqlHash(metric.sqlHash());
|
||||
}
|
||||
|
||||
private void appendLocationAndSql(MetricData data, MetaQueryMetric metric) {
|
||||
data.setLoc(metric.getLocation());
|
||||
data.setSql(metric.getSql());
|
||||
data.setLoc(metric.location());
|
||||
data.setSql(metric.sql());
|
||||
}
|
||||
|
||||
private void appendCounters(MetricData data, MetaTimedMetric timedMetric) {
|
||||
data.setCount(timedMetric.getCount());
|
||||
data.setTotal(timedMetric.getTotal());
|
||||
data.setMean(timedMetric.getMean());
|
||||
data.setMax(timedMetric.getMax());
|
||||
data.setCount(timedMetric.count());
|
||||
data.setTotal(timedMetric.total());
|
||||
data.setMean(timedMetric.mean());
|
||||
data.setMax(timedMetric.max());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,11 +84,11 @@ class DumpMetricsJson implements ServerMetricsAsJson {
|
||||
private void collect(ServerMetrics serverMetrics) {
|
||||
try {
|
||||
start();
|
||||
for (MetaTimedMetric metric : serverMetrics.getTimedMetrics()) {
|
||||
for (MetaTimedMetric metric : serverMetrics.timedMetrics()) {
|
||||
logTimed(metric);
|
||||
}
|
||||
|
||||
List<MetaCountMetric> countMetrics = serverMetrics.getCountMetrics();
|
||||
List<MetaCountMetric> countMetrics = serverMetrics.countMetrics();
|
||||
if (!countMetrics.isEmpty()) {
|
||||
if (sortBy != null) {
|
||||
countMetrics.sort(SortMetric.COUNT_NAME);
|
||||
@@ -98,7 +98,7 @@ class DumpMetricsJson implements ServerMetricsAsJson {
|
||||
}
|
||||
}
|
||||
|
||||
List<MetaQueryMetric> queryMetrics = serverMetrics.getQueryMetrics();
|
||||
List<MetaQueryMetric> queryMetrics = serverMetrics.queryMetrics();
|
||||
if (!queryMetrics.isEmpty()) {
|
||||
if (sortBy != null) {
|
||||
queryMetrics.sort(sortBy);
|
||||
@@ -170,7 +170,7 @@ class DumpMetricsJson implements ServerMetricsAsJson {
|
||||
}
|
||||
objStart();
|
||||
key("name");
|
||||
val(metric.getName());
|
||||
val(metric.name());
|
||||
}
|
||||
|
||||
private void metricEnd() throws IOException {
|
||||
@@ -180,7 +180,7 @@ class DumpMetricsJson implements ServerMetricsAsJson {
|
||||
private void logCount(MetaCountMetric metric) throws IOException {
|
||||
metricStart(metric);
|
||||
key("count");
|
||||
val(metric.getCount());
|
||||
val(metric.count());
|
||||
metricEnd();
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ class DumpMetricsJson implements ServerMetricsAsJson {
|
||||
metricStart(metric);
|
||||
appendTiming(metric);
|
||||
if (isIncludeDetail(metric)) {
|
||||
appendExtra("loc", metric.getLocation());
|
||||
appendExtra("loc", metric.location());
|
||||
}
|
||||
metricEnd();
|
||||
}
|
||||
@@ -197,11 +197,11 @@ class DumpMetricsJson implements ServerMetricsAsJson {
|
||||
metricStart(metric);
|
||||
appendTiming(metric);
|
||||
if (withHash) {
|
||||
keyVal("sqlHash", metric.getSqlHash());
|
||||
keyVal("sqlHash", metric.sqlHash());
|
||||
}
|
||||
if (isIncludeDetail(metric)) {
|
||||
appendExtra("loc", metric.getLocation());
|
||||
appendExtra("sql", metric.getSql());
|
||||
appendExtra("loc", metric.location());
|
||||
appendExtra("sql", metric.sql());
|
||||
}
|
||||
metricEnd();
|
||||
}
|
||||
@@ -218,10 +218,10 @@ class DumpMetricsJson implements ServerMetricsAsJson {
|
||||
}
|
||||
|
||||
private void appendTiming(MetaTimedMetric timedMetric) throws IOException {
|
||||
keyVal("count", timedMetric.getCount());
|
||||
keyVal("total", timedMetric.getTotal());
|
||||
keyVal("mean", timedMetric.getMean());
|
||||
keyVal("max", timedMetric.getMax());
|
||||
keyVal("count", timedMetric.count());
|
||||
keyVal("total", timedMetric.total());
|
||||
keyVal("mean", timedMetric.mean());
|
||||
keyVal("max", timedMetric.max());
|
||||
}
|
||||
|
||||
private void keyVal(String key, long value) throws IOException {
|
||||
|
||||
@@ -1559,7 +1559,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
void queryPlanInit(QueryPlanInit request, List<MetaQueryPlan> list) {
|
||||
for (CQueryPlan queryPlan : queryPlanCache.values()) {
|
||||
if (request.includeHash(queryPlan.getSqlHash())) {
|
||||
queryPlan.queryPlanInit(request.getThresholdMicros());
|
||||
queryPlan.queryPlanInit(request.thresholdMicros());
|
||||
list.add(queryPlan.createMeta(null, null));
|
||||
}
|
||||
}
|
||||
@@ -1572,7 +1572,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
|
||||
iudMetrics.visit(visitor);
|
||||
for (CQueryPlan queryPlan : queryPlanCache.values()) {
|
||||
if (!queryPlan.isEmptyStats()) {
|
||||
visitor.visitQuery(queryPlan.getSnapshot(visitor.isReset()));
|
||||
visitor.visitQuery(queryPlan.getSnapshot(visitor.reset()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class DCountMetric implements CountMetric {
|
||||
@Override
|
||||
public void visit(MetricVisitor visitor) {
|
||||
|
||||
long val = visitor.isReset() ? count.sumThenReset() : count.sum();
|
||||
long val = visitor.reset() ? count.sumThenReset() : count.sum();
|
||||
if (val > 0) {
|
||||
visitor.visitCount(new DCountMetricStats(name, val));
|
||||
}
|
||||
@@ -66,12 +66,12 @@ class DCountMetric implements CountMetric {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCount() {
|
||||
public long count() {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class DQueryPlanMetric implements QueryPlanMetric {
|
||||
|
||||
@Override
|
||||
public void visit(MetricVisitor visitor) {
|
||||
TimedMetricStats stats = metric.collect(visitor.isReset());
|
||||
TimedMetricStats stats = metric.collect(visitor.reset());
|
||||
if (stats != null) {
|
||||
visitor.visitQuery(new Stats(meta, stats, collected));
|
||||
collected = true;
|
||||
@@ -45,11 +45,11 @@ class DQueryPlanMetric implements QueryPlanMetric {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return meta + " " + stats + " sql:" + getSql();
|
||||
return meta + " " + stats + " sql:" + sql();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType() {
|
||||
public Class<?> type() {
|
||||
return meta.getType();
|
||||
}
|
||||
|
||||
@@ -59,48 +59,48 @@ class DQueryPlanMetric implements QueryPlanMetric {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSqlHash() {
|
||||
public long sqlHash() {
|
||||
return meta.getSqlHash();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
public String label() {
|
||||
return meta.getLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSql() {
|
||||
public String sql() {
|
||||
return meta.getSql();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return meta.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocation() {
|
||||
public String location() {
|
||||
return meta.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCount() {
|
||||
return stats.getCount();
|
||||
public long count() {
|
||||
return stats.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotal() {
|
||||
return stats.getTotal();
|
||||
public long total() {
|
||||
return stats.total();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMax() {
|
||||
return stats.getMax();
|
||||
public long max() {
|
||||
return stats.max();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMean() {
|
||||
return stats.getMean();
|
||||
public long mean() {
|
||||
return stats.mean();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,12 +60,12 @@ class DTimeMetricStats implements TimedMetricStats {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocation() {
|
||||
public String location() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class DTimeMetricStats implements TimedMetricStats {
|
||||
* Return the count of values collected.
|
||||
*/
|
||||
@Override
|
||||
public long getCount() {
|
||||
public long count() {
|
||||
return count;
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ class DTimeMetricStats implements TimedMetricStats {
|
||||
* Return the total of all the values.
|
||||
*/
|
||||
@Override
|
||||
public long getTotal() {
|
||||
public long total() {
|
||||
return total;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class DTimeMetricStats implements TimedMetricStats {
|
||||
* Return the Max value collected.
|
||||
*/
|
||||
@Override
|
||||
public long getMax() {
|
||||
public long max() {
|
||||
return max;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ class DTimeMetricStats implements TimedMetricStats {
|
||||
* Return the mean value rounded up.
|
||||
*/
|
||||
@Override
|
||||
public long getMean() {
|
||||
public long mean() {
|
||||
return (count < 1) ? 0L : Math.round((double)(total / count));
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ class DTimedMetric implements TimedMetric {
|
||||
|
||||
@Override
|
||||
public void visit(MetricVisitor visitor) {
|
||||
DTimeMetricStats metric = collect(visitor.isReset());
|
||||
DTimeMetricStats metric = collect(visitor.reset());
|
||||
if (metric != null) {
|
||||
visitor.visitTimed(metric);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ class DTimedProfileLocation extends DProfileLocation implements TimedProfileLoca
|
||||
|
||||
@Override
|
||||
public void visit(MetricVisitor visitor) {
|
||||
TimedMetricStats collect = timedMetric.collect(visitor.isReset());
|
||||
TimedMetricStats collect = timedMetric.collect(visitor.reset());
|
||||
if (collect != null) {
|
||||
if (overrideMetricName) {
|
||||
collect.setName(fullName);
|
||||
|
||||
@@ -24,10 +24,10 @@ class CQueryPlanRequest {
|
||||
CQueryPlanRequest(Connection connection, QueryPlanRequest req, Iterator<CQueryBindCapture> iterator) {
|
||||
this.connection = connection;
|
||||
this.iterator = iterator;
|
||||
this.maxCount = req.getMaxCount();
|
||||
long reqSince = req.getSince();
|
||||
this.maxCount = req.maxCount();
|
||||
long reqSince = req.since();
|
||||
this.since = (reqSince == 0) ? Long.MAX_VALUE: reqSince;
|
||||
long maxTimeMillis = req.getMaxTimeMillis();
|
||||
long maxTimeMillis = req.maxTimeMillis();
|
||||
this.maxTime = maxTimeMillis > 0 ? System.currentTimeMillis() + maxTimeMillis : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -83,56 +83,56 @@ public final class CQueryPlanStats {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "label:" + getLabel() + " location:" + getLocation() + " metrics:" + metrics + " sql:" + getSql();
|
||||
return "label:" + label() + " location:" + location() + " metrics:" + metrics + " sql:" + sql();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getType() {
|
||||
public Class<?> type() {
|
||||
return queryPlan.getBeanType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
public String label() {
|
||||
return queryPlan.getLabel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
public String name() {
|
||||
return queryPlan.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocation() {
|
||||
public String location() {
|
||||
return queryPlan.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getCount() {
|
||||
return metrics.getCount();
|
||||
public long count() {
|
||||
return metrics.count();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTotal() {
|
||||
return metrics.getTotal();
|
||||
public long total() {
|
||||
return metrics.total();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMax() {
|
||||
return metrics.getMax();
|
||||
public long max() {
|
||||
return metrics.max();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMean() {
|
||||
return metrics.getMean();
|
||||
public long mean() {
|
||||
return metrics.mean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSqlHash() {
|
||||
public long sqlHash() {
|
||||
return queryPlan.getSqlHash();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSql() {
|
||||
public String sql() {
|
||||
return queryPlan.getSql();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,14 +16,14 @@ class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
private final String sql;
|
||||
private final String bind;
|
||||
private final String plan;
|
||||
private final long hash;
|
||||
private final long sqlHash;
|
||||
private long queryTimeMicros;
|
||||
private long captureCount;
|
||||
|
||||
DQueryPlanOutput(Class<?> beanType, String label, long hash, String sql, ProfileLocation profileLocation, String bind, String plan) {
|
||||
DQueryPlanOutput(Class<?> beanType, String label, long sqlHash, String sql, ProfileLocation profileLocation, String bind, String plan) {
|
||||
this.beanType = beanType;
|
||||
this.label = label;
|
||||
this.hash = hash;
|
||||
this.sqlHash = sqlHash;
|
||||
this.sql = sql;
|
||||
this.profileLocation = profileLocation;
|
||||
this.bind = bind;
|
||||
@@ -31,15 +31,15 @@ class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getHash() {
|
||||
return hash;
|
||||
public long sqlHash() {
|
||||
return sqlHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the associated bean.
|
||||
*/
|
||||
@Override
|
||||
public Class<?> getBeanType() {
|
||||
public Class<?> beanType() {
|
||||
return beanType;
|
||||
}
|
||||
|
||||
@@ -47,12 +47,12 @@ class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
* Return the query label if set.
|
||||
*/
|
||||
@Override
|
||||
public String getLabel() {
|
||||
public String label() {
|
||||
return label;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProfileLocation getProfileLocation() {
|
||||
public ProfileLocation profileLocation() {
|
||||
return profileLocation;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
* Return the sql of query.
|
||||
*/
|
||||
@Override
|
||||
public String getSql() {
|
||||
public String sql() {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
* Return a description of the bind values used.
|
||||
*/
|
||||
@Override
|
||||
public String getBind() {
|
||||
public String bind() {
|
||||
return bind;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
* Return the query plan.
|
||||
*/
|
||||
@Override
|
||||
public String getPlan() {
|
||||
public String plan() {
|
||||
return plan;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
* to build the query plan.
|
||||
*/
|
||||
@Override
|
||||
public long getQueryTimeMicros() {
|
||||
public long queryTimeMicros() {
|
||||
return queryTimeMicros;
|
||||
}
|
||||
|
||||
@@ -93,13 +93,13 @@ class DQueryPlanOutput implements MetaQueryPlan, SpiDbQueryPlan {
|
||||
* Return the total count of times bind capture has occurred.
|
||||
*/
|
||||
@Override
|
||||
public long getCaptureCount() {
|
||||
public long captureCount() {
|
||||
return captureCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return " BeanType:" + ((beanType == null) ? "" : beanType.getSimpleName()) + " planHash:" + hash + " label:" + label + " queryTimeMicros:" + queryTimeMicros + " captureCount:" + captureCount + "\n SQL:" + sql + "\nBIND:" + bind + "\nPLAN:" + plan;
|
||||
return " BeanType:" + ((beanType == null) ? "" : beanType.getSimpleName()) + " planHash:" + sqlHash + " label:" + label + " queryTimeMicros:" + queryTimeMicros + " captureCount:" + captureCount + "\n SQL:" + sql + "\nBIND:" + bind + "\nPLAN:" + plan;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -90,14 +90,14 @@ public abstract class BaseTestCase {
|
||||
}
|
||||
|
||||
protected List<MetaTimedMetric> visitTimedMetrics() {
|
||||
return collectMetrics().getTimedMetrics();
|
||||
return collectMetrics().timedMetrics();
|
||||
}
|
||||
|
||||
protected List<MetaTimedMetric> sqlMetrics() {
|
||||
List<MetaTimedMetric> timedMetrics = visitTimedMetrics();
|
||||
|
||||
return timedMetrics.stream()
|
||||
.filter((it) -> it.getName().startsWith("sql.") || it.getName().startsWith("orm."))
|
||||
.filter((it) -> it.name().startsWith("sql.") || it.name().startsWith("orm."))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -191,13 +191,13 @@ public class DtoQuery2Test extends BaseTestCase {
|
||||
BasicMetricVisitor basic = new BasicMetricVisitor(false, true, true, true);
|
||||
server().getMetaInfoManager().visitMetrics(basic);
|
||||
|
||||
List<MetaQueryMetric> stats = basic.getQueryMetrics();
|
||||
List<MetaQueryMetric> stats = basic.queryMetrics();
|
||||
assertThat(stats).hasSize(1);
|
||||
|
||||
MetaQueryMetric queryMetric = stats.get(0);
|
||||
assertThat(queryMetric.getLabel()).isEqualTo("basic");
|
||||
assertThat(queryMetric.getCount()).isEqualTo(3);
|
||||
assertThat(queryMetric.getName()).isEqualTo("dto.DCust_basic");
|
||||
assertThat(queryMetric.label()).isEqualTo("basic");
|
||||
assertThat(queryMetric.count()).isEqualTo(3);
|
||||
assertThat(queryMetric.name()).isEqualTo("dto.DCust_basic");
|
||||
|
||||
|
||||
server().findDto(DCust.class, "select c4.id, c4.name from o_customer c4 where lower(c4.name) = :name")
|
||||
@@ -207,7 +207,7 @@ public class DtoQuery2Test extends BaseTestCase {
|
||||
|
||||
BasicMetricVisitor metric2 = server().getMetaInfoManager().visitBasic();
|
||||
|
||||
stats = metric2.getQueryMetrics();
|
||||
stats = metric2.queryMetrics();
|
||||
assertThat(stats).hasSize(2);
|
||||
|
||||
log.info("stats " + stats);
|
||||
|
||||
@@ -27,12 +27,12 @@ public class DtoQueryFromOrmTest extends BaseTestCase {
|
||||
@AfterClass
|
||||
public static void reportStats() {
|
||||
ServerMetrics metrics = DB.getDefault().getMetaInfoManager().collectMetrics();
|
||||
for (MetaQueryMetric metric : metrics.getQueryMetrics()) {
|
||||
for (MetaQueryMetric metric : metrics.queryMetrics()) {
|
||||
System.out.println(metric);
|
||||
}
|
||||
|
||||
System.out.println("-- transaction metrics --");
|
||||
for (MetaTimedMetric metric : metrics.getTimedMetrics()) {
|
||||
for (MetaTimedMetric metric : metrics.timedMetrics()) {
|
||||
System.out.println(metric);
|
||||
}
|
||||
}
|
||||
@@ -59,15 +59,15 @@ public class DtoQueryFromOrmTest extends BaseTestCase {
|
||||
|
||||
ServerMetrics metrics = collectMetrics();
|
||||
|
||||
List<MetaQueryMetric> stats = metrics.getQueryMetrics();
|
||||
List<MetaQueryMetric> stats = metrics.queryMetrics();
|
||||
for (MetaQueryMetric stat : stats) {
|
||||
long meanMicros = stat.getMean();
|
||||
long meanMicros = stat.mean();
|
||||
assertThat(meanMicros).isLessThan(900_000);
|
||||
assertThat(stat.getLocation()).isSameAs(loc0.location());
|
||||
assertThat(stat.location()).isSameAs(loc0.location());
|
||||
}
|
||||
|
||||
assertThat(stats).hasSize(1);
|
||||
assertThat(stats.get(0).getCount()).isEqualTo(4);
|
||||
assertThat(stats.get(0).count()).isEqualTo(4);
|
||||
}
|
||||
|
||||
@ForPlatform(Platform.H2)
|
||||
|
||||
@@ -42,14 +42,14 @@ public class DtoQueryTest extends BaseTestCase {
|
||||
|
||||
ServerMetrics metrics = collectMetrics();
|
||||
|
||||
List<MetaQueryMetric> stats = metrics.getQueryMetrics();
|
||||
List<MetaQueryMetric> stats = metrics.queryMetrics();
|
||||
for (MetaQueryMetric stat : stats) {
|
||||
long meanMicros = stat.getMean();
|
||||
long meanMicros = stat.mean();
|
||||
assertThat(meanMicros).isLessThan(900_000);
|
||||
}
|
||||
|
||||
assertThat(stats).hasSize(1);
|
||||
assertThat(stats.get(0).getCount()).isEqualTo(1);
|
||||
assertThat(stats.get(0).count()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -283,13 +283,13 @@ public class DtoQueryTest extends BaseTestCase {
|
||||
BasicMetricVisitor basic = new BasicMetricVisitor(false, true, true, true);
|
||||
server().getMetaInfoManager().visitMetrics(basic);
|
||||
|
||||
List<MetaQueryMetric> stats = basic.getQueryMetrics();
|
||||
List<MetaQueryMetric> stats = basic.queryMetrics();
|
||||
assertThat(stats).hasSize(1);
|
||||
|
||||
MetaQueryMetric queryMetric = stats.get(0);
|
||||
assertThat(queryMetric.getLabel()).isEqualTo("basic");
|
||||
assertThat(queryMetric.getCount()).isEqualTo(3);
|
||||
assertThat(queryMetric.getName()).isEqualTo("dto.DCust_basic");
|
||||
assertThat(queryMetric.label()).isEqualTo("basic");
|
||||
assertThat(queryMetric.count()).isEqualTo(3);
|
||||
assertThat(queryMetric.name()).isEqualTo("dto.DCust_basic");
|
||||
|
||||
|
||||
server().findDto(DCust.class, "select c4.id, c4.name from o_customer c4 where lower(c4.name) = :name")
|
||||
@@ -299,7 +299,7 @@ public class DtoQueryTest extends BaseTestCase {
|
||||
|
||||
ServerMetrics metric2 = server().getMetaInfoManager().collectMetrics();
|
||||
|
||||
stats = metric2.getQueryMetrics();
|
||||
stats = metric2.queryMetrics();
|
||||
assertThat(stats).hasSize(2);
|
||||
|
||||
log.info("stats " + stats);
|
||||
|
||||
@@ -39,10 +39,10 @@ public class UpdateQueryTest extends BaseTestCase {
|
||||
assertSql(query).contains("update o_customer set status=?, updtime=? where status = ? and id > ?");
|
||||
|
||||
ServerMetrics metrics = collectMetrics();
|
||||
List<MetaQueryMetric> ormQueryMetrics = metrics.getQueryMetrics();
|
||||
List<MetaQueryMetric> ormQueryMetrics = metrics.queryMetrics();
|
||||
assertThat(ormQueryMetrics).hasSize(1);
|
||||
assertThat(ormQueryMetrics.get(0).getType()).isEqualTo(Customer.class);
|
||||
assertThat(ormQueryMetrics.get(0).getLabel()).isEqualTo("updateActive");
|
||||
assertThat(ormQueryMetrics.get(0).type()).isEqualTo(Customer.class);
|
||||
assertThat(ormQueryMetrics.get(0).label()).isEqualTo("updateActive");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -69,10 +69,10 @@ public class UpdateQueryTest extends BaseTestCase {
|
||||
assertSql(sql.get(0)).contains("update o_customer set status = status");
|
||||
|
||||
ServerMetrics metrics = collectMetrics();
|
||||
List<MetaQueryMetric> ormQueryMetrics = metrics.getQueryMetrics();
|
||||
List<MetaQueryMetric> ormQueryMetrics = metrics.queryMetrics();
|
||||
assertThat(ormQueryMetrics).hasSize(1);
|
||||
assertThat(ormQueryMetrics.get(0).getType()).isEqualTo(Customer.class);
|
||||
assertThat(ormQueryMetrics.get(0).getLabel()).isEqualTo("updateAll");
|
||||
assertThat(ormQueryMetrics.get(0).type()).isEqualTo(Customer.class);
|
||||
assertThat(ormQueryMetrics.get(0).label()).isEqualTo("updateAll");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -23,11 +23,11 @@ public class BeanIudMetricsTest {
|
||||
BasicMetricVisitor basic = new BasicMetricVisitor();
|
||||
iudMetrics.visit(basic);
|
||||
|
||||
List<MetaTimedMetric> timed = basic.getTimedMetrics();
|
||||
List<MetaTimedMetric> timed = basic.timedMetrics();
|
||||
assertThat(timed).hasSize(1);
|
||||
|
||||
assertThat(timed.get(0).getCount()).isEqualTo(4);
|
||||
assertThat(timed.get(0).getName()).isEqualTo("iud.one.insertBatch");
|
||||
assertThat(timed.get(0).count()).isEqualTo(4);
|
||||
assertThat(timed.get(0).name()).isEqualTo("iud.one.insertBatch");
|
||||
|
||||
iudMetrics.addBatch(PersistRequest.Type.UPDATE, startNanos, 1);
|
||||
iudMetrics.addBatch(PersistRequest.Type.DELETE_SOFT, startNanos, 2);
|
||||
@@ -37,15 +37,15 @@ public class BeanIudMetricsTest {
|
||||
|
||||
basic = new BasicMetricVisitor();
|
||||
iudMetrics.visit(basic);
|
||||
timed = basic.getTimedMetrics();
|
||||
timed = basic.timedMetrics();
|
||||
assertThat(timed).hasSize(3);
|
||||
|
||||
assertThat(timed.get(0).getCount()).isEqualTo(16);
|
||||
assertThat(timed.get(0).getName()).isEqualTo("iud.one.insertBatch");
|
||||
assertThat(timed.get(1).getCount()).isEqualTo(3);
|
||||
assertThat(timed.get(1).getName()).isEqualTo("iud.one.updateBatch");
|
||||
assertThat(timed.get(2).getCount()).isEqualTo(12);
|
||||
assertThat(timed.get(2).getName()).isEqualTo("iud.one.deleteBatch");
|
||||
assertThat(timed.get(0).count()).isEqualTo(16);
|
||||
assertThat(timed.get(0).name()).isEqualTo("iud.one.insertBatch");
|
||||
assertThat(timed.get(1).count()).isEqualTo(3);
|
||||
assertThat(timed.get(1).name()).isEqualTo("iud.one.updateBatch");
|
||||
assertThat(timed.get(2).count()).isEqualTo(12);
|
||||
assertThat(timed.get(2).name()).isEqualTo("iud.one.deleteBatch");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -63,15 +63,15 @@ public class BeanIudMetricsTest {
|
||||
BasicMetricVisitor basic = new BasicMetricVisitor();
|
||||
iudMetrics.visit(basic);
|
||||
|
||||
List<MetaTimedMetric> timed = basic.getTimedMetrics();
|
||||
List<MetaTimedMetric> timed = basic.timedMetrics();
|
||||
assertThat(timed).hasSize(3);
|
||||
|
||||
assertThat(timed.get(0).getCount()).isEqualTo(1);
|
||||
assertThat(timed.get(0).getName()).isEqualTo("iud.one.insert");
|
||||
assertThat(timed.get(1).getCount()).isEqualTo(2);
|
||||
assertThat(timed.get(1).getName()).isEqualTo("iud.one.update");
|
||||
assertThat(timed.get(2).getCount()).isEqualTo(2);
|
||||
assertThat(timed.get(2).getName()).isEqualTo("iud.one.delete");
|
||||
assertThat(timed.get(0).count()).isEqualTo(1);
|
||||
assertThat(timed.get(0).name()).isEqualTo("iud.one.insert");
|
||||
assertThat(timed.get(1).count()).isEqualTo(2);
|
||||
assertThat(timed.get(1).name()).isEqualTo("iud.one.update");
|
||||
assertThat(timed.get(2).count()).isEqualTo(2);
|
||||
assertThat(timed.get(2).name()).isEqualTo("iud.one.delete");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,17 +21,17 @@ public class DTimedMetricMapTest {
|
||||
BasicMetricVisitor visitor = new BasicMetricVisitor();
|
||||
metricMap.visit(visitor);
|
||||
|
||||
MetaTimedMetric timedMetric = visitor.getTimedMetrics().get(0);
|
||||
assertThat(timedMetric.getCount()).isEqualTo(1);
|
||||
assertThat(timedMetric.getTotal()).isGreaterThan(10);
|
||||
MetaTimedMetric timedMetric = visitor.timedMetrics().get(0);
|
||||
assertThat(timedMetric.count()).isEqualTo(1);
|
||||
assertThat(timedMetric.total()).isGreaterThan(10);
|
||||
|
||||
metricMap.addSinceNanos("some", nanos);
|
||||
|
||||
visitor = new BasicMetricVisitor();
|
||||
metricMap.visit(visitor);
|
||||
|
||||
timedMetric = visitor.getTimedMetrics().get(0);
|
||||
assertThat(timedMetric.getCount()).isEqualTo(1);
|
||||
assertThat(timedMetric.getTotal()).isGreaterThan(10);
|
||||
timedMetric = visitor.timedMetrics().get(0);
|
||||
assertThat(timedMetric.count()).isEqualTo(1);
|
||||
assertThat(timedMetric.total()).isGreaterThan(10);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,16 +17,16 @@ public class DTimedMetricTest {
|
||||
metric.addSinceNanos(start);
|
||||
|
||||
DTimeMetricStats stats = metric.collect(true);
|
||||
assertThat(stats.getCount()).isEqualTo(1);
|
||||
assertThat(stats.getTotal()).isGreaterThan(10);
|
||||
assertThat(stats.getMax()).isEqualTo(stats.getTotal());
|
||||
assertThat(stats.count()).isEqualTo(1);
|
||||
assertThat(stats.total()).isGreaterThan(10);
|
||||
assertThat(stats.max()).isEqualTo(stats.total());
|
||||
|
||||
metric.addSinceNanos(start);
|
||||
|
||||
stats = metric.collect(true);
|
||||
assertThat(stats.getCount()).isEqualTo(1);
|
||||
assertThat(stats.getTotal()).isGreaterThan(10);
|
||||
assertThat(stats.getMax()).isEqualTo(stats.getTotal());
|
||||
assertThat(stats.count()).isEqualTo(1);
|
||||
assertThat(stats.total()).isGreaterThan(10);
|
||||
assertThat(stats.max()).isEqualTo(stats.total());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -40,16 +40,16 @@ public class DTimedMetricTest {
|
||||
metric.addBatchSince(start, 5);
|
||||
|
||||
DTimeMetricStats stats = metric.collect(true);
|
||||
assertThat(stats.getCount()).isEqualTo(5);
|
||||
assertThat(stats.getTotal()).isGreaterThan(10000);
|
||||
assertThat(stats.getMax()).isEqualTo(stats.getTotal() / 5);
|
||||
assertThat(stats.getMax()).isGreaterThan(10000 / 5);
|
||||
assertThat(stats.count()).isEqualTo(5);
|
||||
assertThat(stats.total()).isGreaterThan(10000);
|
||||
assertThat(stats.max()).isEqualTo(stats.total() / 5);
|
||||
assertThat(stats.max()).isGreaterThan(10000 / 5);
|
||||
|
||||
metric.addBatchSince(start, 2);
|
||||
|
||||
stats = metric.collect(true);
|
||||
assertThat(stats.getCount()).isEqualTo(2);
|
||||
assertThat(stats.getTotal()).isGreaterThan(10000);
|
||||
assertThat(stats.getMax()).isEqualTo(stats.getTotal() / 2);
|
||||
assertThat(stats.count()).isEqualTo(2);
|
||||
assertThat(stats.total()).isGreaterThan(10000);
|
||||
assertThat(stats.max()).isEqualTo(stats.total() / 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class SortMetricTest {
|
||||
list.add(create("a"));
|
||||
list.sort(sortMetric);
|
||||
|
||||
String names = list.stream().map(DTimeMetricStats::getName).collect(Collectors.joining());
|
||||
String names = list.stream().map(DTimeMetricStats::name).collect(Collectors.joining());
|
||||
|
||||
assertEquals("nullabcd", names);
|
||||
}
|
||||
|
||||
@@ -80,15 +80,15 @@ public class TestBatchInsertFlush extends BaseTestCase {
|
||||
}
|
||||
|
||||
ServerMetrics metrics = collectMetrics();
|
||||
List<MetaTimedMetric> txnStats = metrics.getTimedMetrics();
|
||||
List<MetaTimedMetric> txnStats = metrics.timedMetrics();
|
||||
for (MetaTimedMetric txnMetric : txnStats) {
|
||||
System.out.println(txnMetric);
|
||||
}
|
||||
assertThat(txnStats).hasSize(4);
|
||||
assertThat(txnStats.get(0).getName()).isEqualTo("txn.main");
|
||||
assertThat(txnStats.get(1).getName()).isEqualTo("txn.named.TestBatchInsertFlush.no_cascade");
|
||||
assertThat(txnStats.get(2).getName()).isEqualTo("iud.TSDetail.insertBatch");
|
||||
assertThat(txnStats.get(3).getName()).isEqualTo("iud.TSMaster.insertBatch");
|
||||
assertThat(txnStats.get(0).name()).isEqualTo("txn.main");
|
||||
assertThat(txnStats.get(1).name()).isEqualTo("txn.named.TestBatchInsertFlush.no_cascade");
|
||||
assertThat(txnStats.get(2).name()).isEqualTo("iud.TSDetail.insertBatch");
|
||||
assertThat(txnStats.get(3).name()).isEqualTo("iud.TSMaster.insertBatch");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -28,7 +28,7 @@ public class TestM2mDeleteObject extends BaseTestCase {
|
||||
|
||||
List<MetaTimedMetric> sqlMetrics = sqlMetrics();
|
||||
assertThat(sqlMetrics).hasSize(1);
|
||||
assertThat(sqlMetrics.get(0).getName()).isEqualTo("orm.update.deleteAllPermissions");
|
||||
assertThat(sqlMetrics.get(0).name()).isEqualTo("orm.update.deleteAllPermissions");
|
||||
|
||||
Tenant t = new Tenant("tenant");
|
||||
|
||||
|
||||
@@ -176,7 +176,7 @@ public class TestCustomerFinder extends BaseTestCase {
|
||||
// change default collect query plan threshold to 200 micros
|
||||
QueryPlanInit init0 = new QueryPlanInit();
|
||||
init0.setAll(true);
|
||||
init0.setThresholdMicros(2);
|
||||
init0.thresholdMicros(2);
|
||||
final List<MetaQueryPlan> plans = server().getMetaInfoManager().queryPlanInit(init0);
|
||||
assertThat(plans.size()).isGreaterThan(1);
|
||||
|
||||
@@ -186,7 +186,7 @@ public class TestCustomerFinder extends BaseTestCase {
|
||||
// change query plan threshold to 100 micros
|
||||
QueryPlanInit init = new QueryPlanInit();
|
||||
init.setAll(true);
|
||||
init.setThresholdMicros(1);
|
||||
init.thresholdMicros(1);
|
||||
final List<MetaQueryPlan> appliedToPlans = server().getMetaInfoManager().queryPlanInit(init);
|
||||
assertThat(appliedToPlans.size()).isGreaterThan(4);
|
||||
|
||||
@@ -195,30 +195,30 @@ public class TestCustomerFinder extends BaseTestCase {
|
||||
|
||||
ServerMetrics metrics = DB.getDefault().getMetaInfoManager().collectMetrics();
|
||||
|
||||
List<MetaQueryMetric> planStats = metrics.getQueryMetrics();
|
||||
List<MetaQueryMetric> planStats = metrics.queryMetrics();
|
||||
assertThat(planStats.size()).isGreaterThan(4);
|
||||
|
||||
for (MetaQueryMetric planStat : planStats) {
|
||||
System.out.println(planStat);
|
||||
}
|
||||
|
||||
for (MetaTimedMetric txnTimed : metrics.getTimedMetrics()) {
|
||||
for (MetaTimedMetric txnTimed : metrics.timedMetrics()) {
|
||||
System.out.println(txnTimed);
|
||||
}
|
||||
|
||||
// obtains db query plans ...
|
||||
QueryPlanRequest request = new QueryPlanRequest();
|
||||
// collect max 1000 plans (use something more like 10)
|
||||
request.setMaxCount(1_000);
|
||||
request.maxCount(1_000);
|
||||
// don't collect any more plans if used 10 secs
|
||||
request.setMaxTimeMillis(10_000);
|
||||
request.maxTimeMillis(10_000);
|
||||
List<MetaQueryPlan> plans0 = server().getMetaInfoManager().queryPlanCollectNow(request);
|
||||
assertThat(plans0).isNotEmpty();
|
||||
|
||||
for (MetaQueryPlan plan : plans) {
|
||||
logger.info("queryPlan label:{}, queryTimeMicros:{} loc:{} sql:{} bind:{} plan:{}",
|
||||
plan.getLabel(), plan.getQueryTimeMicros(), plan.getProfileLocation(),
|
||||
plan.getSql(), plan.getBind(), plan.getPlan());
|
||||
plan.label(), plan.queryTimeMicros(), plan.profileLocation(),
|
||||
plan.sql(), plan.bind(), plan.plan());
|
||||
System.out.println(plan);
|
||||
}
|
||||
|
||||
|
||||
@@ -407,7 +407,7 @@ public class SqlQueryTests extends BaseTestCase {
|
||||
|
||||
List<MetaTimedMetric> sqlMetrics = sqlMetrics();
|
||||
assertThat(sqlMetrics).hasSize(1);
|
||||
assertThat(sqlMetrics.get(0).getName()).isEqualTo("sql.query.findEach-Max10Rows");
|
||||
assertThat(sqlMetrics.get(0).name()).isEqualTo("sql.query.findEach-Max10Rows");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TestNestedMandatory extends BaseTestCase {
|
||||
}
|
||||
|
||||
assertThat(txnMetrics).hasSize(2);
|
||||
assertThat(txnMetrics.get(1).getName()).isEqualTo("txn.named.outer");
|
||||
assertThat(txnMetrics.get(1).name()).isEqualTo("txn.named.outer");
|
||||
}
|
||||
|
||||
class Outer {
|
||||
|
||||
@@ -20,9 +20,9 @@ public class TestTransactionalReadOnly extends BaseTestCase {
|
||||
resetAllMetrics();
|
||||
executeTransactionalUsingReadOnlyDataSource();
|
||||
|
||||
final List<MetaTimedMetric> timedMetrics = collectMetrics().getTimedMetrics();
|
||||
final List<MetaTimedMetric> timedMetrics = collectMetrics().timedMetrics();
|
||||
final Optional<MetaTimedMetric> txnReadOnly = metric(timedMetrics, "txn.readonly");
|
||||
assertThat(txnReadOnly.get().getCount()).isEqualTo(1);
|
||||
assertThat(txnReadOnly.get().count()).isEqualTo(1);
|
||||
assertThat(metric(timedMetrics, "txn")).isEmpty();
|
||||
}
|
||||
|
||||
@@ -32,15 +32,15 @@ public class TestTransactionalReadOnly extends BaseTestCase {
|
||||
resetAllMetrics();
|
||||
executeTransactionalUsingMainDataSource();
|
||||
|
||||
final List<MetaTimedMetric> timedMetrics = collectMetrics().getTimedMetrics();
|
||||
final List<MetaTimedMetric> timedMetrics = collectMetrics().timedMetrics();
|
||||
final Optional<MetaTimedMetric> txnMain = metric(timedMetrics, "txn.main");
|
||||
assertThat(txnMain.get().getCount()).isEqualTo(1);
|
||||
assertThat(txnMain.get().count()).isEqualTo(1);
|
||||
assertThat(metric(timedMetrics, "txn.readonly")).isEmpty();
|
||||
}
|
||||
|
||||
private Optional<MetaTimedMetric> metric(List<MetaTimedMetric> timedMetrics, String name) {
|
||||
return timedMetrics.stream()
|
||||
.filter(metaTimedMetric -> metaTimedMetric.getName().equals(name))
|
||||
.filter(metaTimedMetric -> metaTimedMetric.name().equals(name))
|
||||
.findFirst();
|
||||
}
|
||||
|
||||
|
||||
@@ -126,8 +126,8 @@ public class TestSqlUpdateInTxn extends BaseTestCase {
|
||||
|
||||
List<MetaTimedMetric> sqlMetrics = sqlMetrics();
|
||||
assertThat(sqlMetrics).hasSize(1);
|
||||
assertThat(sqlMetrics.get(0).getName()).isEqualTo("sql.update.auditLargeUpdate");
|
||||
assertThat(sqlMetrics.get(0).getCount()).isEqualTo(1);
|
||||
assertThat(sqlMetrics.get(0).name()).isEqualTo("sql.update.auditLargeUpdate");
|
||||
assertThat(sqlMetrics.get(0).count()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -8,9 +8,7 @@ import io.ebean.meta.MetaTimedMetric;
|
||||
import io.ebean.meta.ServerMetrics;
|
||||
import io.ebean.util.StringHelper;
|
||||
import io.ebeaninternal.api.SpiEbeanServer;
|
||||
import io.ebeaninternal.api.SpiQuery;
|
||||
import io.ebeaninternal.api.SpiTransaction;
|
||||
import io.ebeaninternal.server.core.OrmQueryRequest;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import io.ebeaninternal.server.expression.platform.DbExpressionHandler;
|
||||
import io.ebeaninternal.server.expression.platform.DbExpressionHandlerFactory;
|
||||
@@ -88,14 +86,14 @@ public abstract class BaseTestCase {
|
||||
}
|
||||
|
||||
protected List<MetaTimedMetric> visitTimedMetrics() {
|
||||
return collectMetrics().getTimedMetrics();
|
||||
return collectMetrics().timedMetrics();
|
||||
}
|
||||
|
||||
protected List<MetaTimedMetric> sqlMetrics() {
|
||||
List<MetaTimedMetric> timedMetrics = visitTimedMetrics();
|
||||
|
||||
return timedMetrics.stream()
|
||||
.filter((it) -> it.getName().startsWith("sql.") || it.getName().startsWith("orm."))
|
||||
.filter((it) -> it.name().startsWith("sql.") || it.name().startsWith("orm."))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
@@ -255,14 +255,13 @@ class RedisCache implements ServerCache {
|
||||
|
||||
@Override
|
||||
public ServerCacheStatistics getStatistics(boolean reset) {
|
||||
|
||||
ServerCacheStatistics cacheStats = new ServerCacheStatistics();
|
||||
cacheStats.setCacheName(cacheKey);
|
||||
cacheStats.setHitCount(hitCount.get(reset));
|
||||
cacheStats.setMissCount(missCount.get(reset));
|
||||
cacheStats.setPutCount(metricPut.collect(reset).getCount());
|
||||
cacheStats.setRemoveCount(metricRemove.collect(reset).getCount());
|
||||
cacheStats.setClearCount(metricClear.collect(reset).getCount());
|
||||
cacheStats.setPutCount(metricPut.collect(reset).count());
|
||||
cacheStats.setRemoveCount(metricRemove.collect(reset).count());
|
||||
cacheStats.setClearCount(metricClear.collect(reset).count());
|
||||
return cacheStats;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user