mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-12 22:41:35 +00:00
#2346 - Rename Database.getMetaInfoManager() to metaInfo() with deprecation
This commit is contained in:
1 parent
4557bdfa6f
commit
7fba9adc43
13 files changed
+38
-30
No files matched your search
@@ -187,7 +187,15 @@ public interface Database {
|
|||||||
* Return the MetaInfoManager which is used to get meta data from the Database
|
* Return the MetaInfoManager which is used to get meta data from the Database
|
||||||
* such as query execution statistics.
|
* such as query execution statistics.
|
||||||
*/
|
*/
|
||||||
MetaInfoManager getMetaInfoManager();
|
MetaInfoManager metaInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deprecated migrate to metaInfo().
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
default MetaInfoManager getMetaInfoManager() {
|
||||||
|
return metaInfo();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the platform used for this database instance.
|
* Return the platform used for this database instance.
|
||||||
|
|||||||
@@ -325,7 +325,7 @@ public final class DefaultServer implements SpiServer, SpiEbeanServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MetaInfoManager getMetaInfoManager() {
|
public MetaInfoManager metaInfo() {
|
||||||
return metaInfoManager;
|
return metaInfoManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ final class DumpMetrics {
|
|||||||
void dump() {
|
void dump() {
|
||||||
|
|
||||||
out("-- Dumping metrics for " + server.name() + " -- ");
|
out("-- Dumping metrics for " + server.name() + " -- ");
|
||||||
ServerMetrics serverMetrics = server.getMetaInfoManager().collectMetrics();
|
ServerMetrics serverMetrics = server.metaInfo().collectMetrics();
|
||||||
|
|
||||||
for (MetaTimedMetric metric : serverMetrics.timedMetrics()) {
|
for (MetaTimedMetric metric : serverMetrics.timedMetrics()) {
|
||||||
log(metric);
|
log(metric);
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ final class DumpMetricsData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<MetricData> data() {
|
List<MetricData> data() {
|
||||||
collect(database.getMetaInfoManager().collectMetrics());
|
collect(database.metaInfo().collectMetrics());
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,14 +66,14 @@ final class DumpMetricsJson implements ServerMetricsAsJson {
|
|||||||
@Override
|
@Override
|
||||||
public String json() {
|
public String json() {
|
||||||
writer = new StringWriter();
|
writer = new StringWriter();
|
||||||
collect(database.getMetaInfoManager().collectMetrics());
|
collect(database.metaInfo().collectMetrics());
|
||||||
return writer.toString();
|
return writer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(Appendable buffer) {
|
public void write(Appendable buffer) {
|
||||||
writer = buffer;
|
writer = buffer;
|
||||||
collect(database.getMetaInfoManager().collectMetrics());
|
collect(database.metaInfo().collectMetrics());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collect(ServerMetrics serverMetrics) {
|
private void collect(ServerMetrics serverMetrics) {
|
||||||
|
|||||||
@@ -82,11 +82,11 @@ public abstract class BaseTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void resetAllMetrics() {
|
protected void resetAllMetrics() {
|
||||||
server().getMetaInfoManager().resetAllMetrics();
|
server().metaInfo().resetAllMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ServerMetrics collectMetrics() {
|
protected ServerMetrics collectMetrics() {
|
||||||
return server().getMetaInfoManager().collectMetrics();
|
return server().metaInfo().collectMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<MetaTimedMetric> visitTimedMetrics() {
|
protected List<MetaTimedMetric> visitTimedMetrics() {
|
||||||
|
|||||||
@@ -189,7 +189,7 @@ public class DtoQuery2Test extends BaseTestCase {
|
|||||||
|
|
||||||
// collect without reset
|
// collect without reset
|
||||||
BasicMetricVisitor basic = new BasicMetricVisitor(false, true, true, true);
|
BasicMetricVisitor basic = new BasicMetricVisitor(false, true, true, true);
|
||||||
server().getMetaInfoManager().visitMetrics(basic);
|
server().metaInfo().visitMetrics(basic);
|
||||||
|
|
||||||
List<MetaQueryMetric> stats = basic.queryMetrics();
|
List<MetaQueryMetric> stats = basic.queryMetrics();
|
||||||
assertThat(stats).hasSize(1);
|
assertThat(stats).hasSize(1);
|
||||||
@@ -205,7 +205,7 @@ public class DtoQuery2Test extends BaseTestCase {
|
|||||||
.setParameter("name", "rob")
|
.setParameter("name", "rob")
|
||||||
.findList();
|
.findList();
|
||||||
|
|
||||||
BasicMetricVisitor metric2 = server().getMetaInfoManager().visitBasic();
|
BasicMetricVisitor metric2 = server().metaInfo().visitBasic();
|
||||||
|
|
||||||
stats = metric2.queryMetrics();
|
stats = metric2.queryMetrics();
|
||||||
assertThat(stats).hasSize(2);
|
assertThat(stats).hasSize(2);
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ public class DtoQueryFromOrmTest extends BaseTestCase {
|
|||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void resetStats() {
|
public static void resetStats() {
|
||||||
DB.getDefault().getMetaInfoManager().resetAllMetrics();
|
DB.getDefault().metaInfo().resetAllMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterClass
|
@AfterClass
|
||||||
public static void reportStats() {
|
public static void reportStats() {
|
||||||
ServerMetrics metrics = DB.getDefault().getMetaInfoManager().collectMetrics();
|
ServerMetrics metrics = DB.getDefault().metaInfo().collectMetrics();
|
||||||
for (MetaQueryMetric metric : metrics.queryMetrics()) {
|
for (MetaQueryMetric metric : metrics.queryMetrics()) {
|
||||||
System.out.println(metric);
|
System.out.println(metric);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ public class DtoQueryTest extends BaseTestCase {
|
|||||||
|
|
||||||
// collect without reset
|
// collect without reset
|
||||||
BasicMetricVisitor basic = new BasicMetricVisitor(false, true, true, true);
|
BasicMetricVisitor basic = new BasicMetricVisitor(false, true, true, true);
|
||||||
server().getMetaInfoManager().visitMetrics(basic);
|
server().metaInfo().visitMetrics(basic);
|
||||||
|
|
||||||
List<MetaQueryMetric> stats = basic.queryMetrics();
|
List<MetaQueryMetric> stats = basic.queryMetrics();
|
||||||
assertThat(stats).hasSize(1);
|
assertThat(stats).hasSize(1);
|
||||||
@@ -297,7 +297,7 @@ public class DtoQueryTest extends BaseTestCase {
|
|||||||
.setParameter("name", "rob")
|
.setParameter("name", "rob")
|
||||||
.findList();
|
.findList();
|
||||||
|
|
||||||
ServerMetrics metric2 = server().getMetaInfoManager().collectMetrics();
|
ServerMetrics metric2 = server().metaInfo().collectMetrics();
|
||||||
|
|
||||||
stats = metric2.queryMetrics();
|
stats = metric2.queryMetrics();
|
||||||
assertThat(stats).hasSize(2);
|
assertThat(stats).hasSize(2);
|
||||||
|
|||||||
@@ -358,7 +358,7 @@ public class TDSpiEbeanServer implements SpiEbeanServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MetaInfoManager getMetaInfoManager() {
|
public MetaInfoManager metaInfo() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class TestCustomerFinder extends BaseTestCase {
|
|||||||
runQueries();
|
runQueries();
|
||||||
|
|
||||||
StringBuilder buffer0 = new StringBuilder();
|
StringBuilder buffer0 = new StringBuilder();
|
||||||
DB.getDefault().getMetaInfoManager()
|
DB.getDefault().metaInfo()
|
||||||
.collectMetricsAsJson()
|
.collectMetricsAsJson()
|
||||||
.withHeader(false)
|
.withHeader(false)
|
||||||
.write(buffer0);
|
.write(buffer0);
|
||||||
@@ -45,7 +45,7 @@ public class TestCustomerFinder extends BaseTestCase {
|
|||||||
runQueries();
|
runQueries();
|
||||||
|
|
||||||
StringBuilder buffer1 = new StringBuilder();
|
StringBuilder buffer1 = new StringBuilder();
|
||||||
DB.getDefault().getMetaInfoManager()
|
DB.getDefault().metaInfo()
|
||||||
.collectMetricsAsJson()
|
.collectMetricsAsJson()
|
||||||
.withHeader(false)
|
.withHeader(false)
|
||||||
.write(buffer1);
|
.write(buffer1);
|
||||||
@@ -177,7 +177,7 @@ public class TestCustomerFinder extends BaseTestCase {
|
|||||||
QueryPlanInit init0 = new QueryPlanInit();
|
QueryPlanInit init0 = new QueryPlanInit();
|
||||||
init0.setAll(true);
|
init0.setAll(true);
|
||||||
init0.thresholdMicros(2);
|
init0.thresholdMicros(2);
|
||||||
final List<MetaQueryPlan> plans = server().getMetaInfoManager().queryPlanInit(init0);
|
final List<MetaQueryPlan> plans = server().metaInfo().queryPlanInit(init0);
|
||||||
assertThat(plans.size()).isGreaterThan(1);
|
assertThat(plans.size()).isGreaterThan(1);
|
||||||
|
|
||||||
// the server has some plans
|
// the server has some plans
|
||||||
@@ -187,13 +187,13 @@ public class TestCustomerFinder extends BaseTestCase {
|
|||||||
QueryPlanInit init = new QueryPlanInit();
|
QueryPlanInit init = new QueryPlanInit();
|
||||||
init.setAll(true);
|
init.setAll(true);
|
||||||
init.thresholdMicros(1);
|
init.thresholdMicros(1);
|
||||||
final List<MetaQueryPlan> appliedToPlans = server().getMetaInfoManager().queryPlanInit(init);
|
final List<MetaQueryPlan> appliedToPlans = server().metaInfo().queryPlanInit(init);
|
||||||
assertThat(appliedToPlans.size()).isGreaterThan(4);
|
assertThat(appliedToPlans.size()).isGreaterThan(4);
|
||||||
|
|
||||||
// run queries again
|
// run queries again
|
||||||
runQueries();
|
runQueries();
|
||||||
|
|
||||||
ServerMetrics metrics = DB.getDefault().getMetaInfoManager().collectMetrics();
|
ServerMetrics metrics = DB.getDefault().metaInfo().collectMetrics();
|
||||||
|
|
||||||
List<MetaQueryMetric> planStats = metrics.queryMetrics();
|
List<MetaQueryMetric> planStats = metrics.queryMetrics();
|
||||||
assertThat(planStats.size()).isGreaterThan(4);
|
assertThat(planStats.size()).isGreaterThan(4);
|
||||||
@@ -212,7 +212,7 @@ public class TestCustomerFinder extends BaseTestCase {
|
|||||||
request.maxCount(1_000);
|
request.maxCount(1_000);
|
||||||
// don't collect any more plans if used 10 secs
|
// don't collect any more plans if used 10 secs
|
||||||
request.maxTimeMillis(10_000);
|
request.maxTimeMillis(10_000);
|
||||||
List<MetaQueryPlan> plans0 = server().getMetaInfoManager().queryPlanCollectNow(request);
|
List<MetaQueryPlan> plans0 = server().metaInfo().queryPlanCollectNow(request);
|
||||||
assertThat(plans0).isNotEmpty();
|
assertThat(plans0).isNotEmpty();
|
||||||
|
|
||||||
for (MetaQueryPlan plan : plans) {
|
for (MetaQueryPlan plan : plans) {
|
||||||
@@ -232,7 +232,7 @@ public class TestCustomerFinder extends BaseTestCase {
|
|||||||
|
|
||||||
runQueries();
|
runQueries();
|
||||||
|
|
||||||
String metricsJson = server().getMetaInfoManager()
|
String metricsJson = server().metaInfo()
|
||||||
.collectMetricsAsJson()
|
.collectMetricsAsJson()
|
||||||
.withHash(true)
|
.withHash(true)
|
||||||
.withExtraAttributes(true)
|
.withExtraAttributes(true)
|
||||||
@@ -256,7 +256,7 @@ public class TestCustomerFinder extends BaseTestCase {
|
|||||||
|
|
||||||
runQueries();
|
runQueries();
|
||||||
|
|
||||||
String metricsJson = server().getMetaInfoManager()
|
String metricsJson = server().metaInfo()
|
||||||
.collectMetricsAsJson()
|
.collectMetricsAsJson()
|
||||||
.withHash(false)
|
.withHash(false)
|
||||||
.withExtraAttributes(false)
|
.withExtraAttributes(false)
|
||||||
@@ -279,7 +279,7 @@ public class TestCustomerFinder extends BaseTestCase {
|
|||||||
runQueries();
|
runQueries();
|
||||||
|
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
server().getMetaInfoManager()
|
server().metaInfo()
|
||||||
.collectMetricsAsJson()
|
.collectMetricsAsJson()
|
||||||
.withHeader(false)
|
.withHeader(false)
|
||||||
.write(buffer);
|
.write(buffer);
|
||||||
@@ -297,7 +297,7 @@ public class TestCustomerFinder extends BaseTestCase {
|
|||||||
runQueries();
|
runQueries();
|
||||||
|
|
||||||
StringBuilder buffer = new StringBuilder();
|
StringBuilder buffer = new StringBuilder();
|
||||||
server().getMetaInfoManager()
|
server().metaInfo()
|
||||||
.collectMetricsAsJson()
|
.collectMetricsAsJson()
|
||||||
.withHeader(true)
|
.withHeader(true)
|
||||||
.write(buffer);
|
.write(buffer);
|
||||||
|
|||||||
@@ -78,11 +78,11 @@ public abstract class BaseTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void resetAllMetrics() {
|
protected void resetAllMetrics() {
|
||||||
server().getMetaInfoManager().resetAllMetrics();
|
server().metaInfo().resetAllMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ServerMetrics collectMetrics() {
|
protected ServerMetrics collectMetrics() {
|
||||||
return server().getMetaInfoManager().collectMetrics();
|
return server().metaInfo().collectMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<MetaTimedMetric> visitTimedMetrics() {
|
protected List<MetaTimedMetric> visitTimedMetrics() {
|
||||||
|
|||||||
@@ -40,8 +40,8 @@ public class ClusterTest {
|
|||||||
foo.save();
|
foo.save();
|
||||||
|
|
||||||
DB.getServerCacheManager().clearAll();
|
DB.getServerCacheManager().clearAll();
|
||||||
DB.getDefault().getMetaInfoManager().resetAllMetrics();
|
DB.getDefault().metaInfo().resetAllMetrics();
|
||||||
other.getMetaInfoManager().resetAllMetrics();
|
other.metaInfo().resetAllMetrics();
|
||||||
|
|
||||||
Person fooA = DB.find(Person.class, foo.getId());
|
Person fooA = DB.find(Person.class, foo.getId());
|
||||||
Person fooB = other.find(Person.class, foo.getId());
|
Person fooB = other.find(Person.class, foo.getId());
|
||||||
@@ -70,7 +70,7 @@ public class ClusterTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
other.getServerCacheManager().clearAll();
|
other.getServerCacheManager().clearAll();
|
||||||
other.getMetaInfoManager().resetAllMetrics();
|
other.metaInfo().resetAllMetrics();
|
||||||
|
|
||||||
DuelCache dualCache = (DuelCache) other.getServerCacheManager().getBeanCache(Person.class);
|
DuelCache dualCache = (DuelCache) other.getServerCacheManager().getBeanCache(Person.class);
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user