diff options
56 files changed, 1 insertions, 4628 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index c0f68a1c0b7..53e10410dc6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -121,7 +121,6 @@ add_subdirectory(slobrok) add_subdirectory(standalone-container) add_subdirectory(storage) add_subdirectory(storageserver) -add_subdirectory(statistics) add_subdirectory(streamingvisitors) add_subdirectory(tenant-cd-api) add_subdirectory(vbench) diff --git a/cloud-tenant-base-dependencies-enforcer/pom.xml b/cloud-tenant-base-dependencies-enforcer/pom.xml index 99bef1e22e6..400c01abb78 100644 --- a/cloud-tenant-base-dependencies-enforcer/pom.xml +++ b/cloud-tenant-base-dependencies-enforcer/pom.xml @@ -174,7 +174,6 @@ <include>com.yahoo.vespa:searchcore:*:jar:provided</include> <include>com.yahoo.vespa:searchlib:*:jar:provided</include> <include>com.yahoo.vespa:security-utils:*:jar:provided</include> - <include>com.yahoo.vespa:statistics:*:jar:provided</include> <include>com.yahoo.vespa:vdslib:*:jar:provided</include> <include>com.yahoo.vespa:vespa-http-client:*:jar:provided</include> <include>com.yahoo.vespa:vespa_jersey2:*:pom:provided</include> diff --git a/config-model/pom.xml b/config-model/pom.xml index e50c1177e7e..23464171aa1 100644 --- a/config-model/pom.xml +++ b/config-model/pom.xml @@ -201,12 +201,6 @@ </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> - <artifactId>statistics</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> <artifactId>container-messagebus</artifactId> <version>${project.version}</version> <scope>provided</scope> diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java index 7f7e608aa19..17983553071 100755 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java @@ -47,7 +47,6 @@ import com.yahoo.vespa.model.container.component.DiscBindingsConfigGenerator; import com.yahoo.vespa.model.container.component.FileStatusHandlerComponent; import com.yahoo.vespa.model.container.component.Handler; import com.yahoo.vespa.model.container.component.SimpleComponent; -import com.yahoo.vespa.model.container.component.StatisticsComponent; import com.yahoo.vespa.model.container.component.SystemBindingPattern; import com.yahoo.vespa.model.container.component.chain.ProcessingHandler; import com.yahoo.vespa.model.container.configserver.ConfigserverCluster; @@ -179,7 +178,6 @@ public abstract class ContainerCluster<CONTAINER extends Container> // (ThreadedHttpRequestHandler.Context is source compatible.) addSimpleComponent("com.yahoo.container.jdisc.LoggingRequestHandler$Context"); - addComponent(new StatisticsComponent()); addSimpleComponent(AccessLog.class); addComponent(new DefaultThreadpoolProvider(this, defaultPoolNumThreads)); addSimpleComponent(com.yahoo.concurrent.classlock.ClassLocking.class); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java b/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java index 8a489ea9de4..da49969ebf8 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/PlatformBundles.java @@ -125,8 +125,6 @@ public class PlatformBundles { "com.yahoo.search.searchchain.ForkingSearcher", "com.yahoo.search.searchchain.example.ExampleSearcher", "com.yahoo.search.searchers.CacheControlSearcher", - "com.yahoo.search.statistics.PeakQpsSearcher", - "com.yahoo.search.statistics.TimingSearcher", "com.yahoo.vespa.streamingvisitors.MetricsSearcher", "com.yahoo.vespa.streamingvisitors.VdsStreamingSearcher" ); diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/component/StatisticsComponent.java b/config-model/src/main/java/com/yahoo/vespa/model/container/component/StatisticsComponent.java deleted file mode 100644 index 2236d30083b..00000000000 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/component/StatisticsComponent.java +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.model.container.component; - -import com.yahoo.vespa.model.admin.monitoring.Monitoring; -import com.yahoo.container.StatisticsConfig; - -/** - * @author Tony Vaagenes - */ -public class StatisticsComponent extends SimpleComponent implements StatisticsConfig.Producer { - - public StatisticsComponent() { - super("com.yahoo.statistics.StatisticsImpl"); - } - - @Override - public void getConfig(StatisticsConfig.Builder builder) { - Monitoring monitoring = getMonitoringService(); - if (monitoring != null) { - builder. - collectionintervalsec(monitoring.getIntervalSeconds().doubleValue()). - loggingintervalsec(monitoring.getIntervalSeconds().doubleValue()); - } - builder.values(new StatisticsConfig.Values.Builder(). - name("query_latency"). - operations(new StatisticsConfig.Values.Operations.Builder(). - name(StatisticsConfig.Values.Operations.Name.REGULAR). - arguments(new StatisticsConfig.Values.Operations.Arguments.Builder(). - key("limits"). - value("25,50,100,500")))); - - } -} diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/configserver/ConfigserverCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/configserver/ConfigserverCluster.java index 413c6f07efd..bbccdaa9453 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/container/configserver/ConfigserverCluster.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/container/configserver/ConfigserverCluster.java @@ -9,7 +9,6 @@ import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.SystemName; import com.yahoo.config.provision.Zone; -import com.yahoo.container.StatisticsConfig; import com.yahoo.container.core.VipStatusConfig; import com.yahoo.container.jdisc.config.HealthMonitorConfig; import com.yahoo.net.HostName; @@ -31,7 +30,6 @@ public class ConfigserverCluster extends AbstractConfigProducer ConfigserverConfig.Producer, CuratorConfig.Producer, HealthMonitorConfig.Producer, - StatisticsConfig.Producer, VipStatusConfig.Producer, ZookeeperServerConfig.Producer { @@ -173,12 +171,6 @@ public class ConfigserverCluster extends AbstractConfigProducer } @Override - public void getConfig(StatisticsConfig.Builder builder) { - builder.collectionintervalsec(60.0); - builder.loggingintervalsec(60.0); - } - - @Override public void getConfig(HealthMonitorConfig.Builder builder) { builder.snapshot_interval(60.0); } diff --git a/container-core/pom.xml b/container-core/pom.xml index 4b47cfde122..294f6c0a585 100644 --- a/container-core/pom.xml +++ b/container-core/pom.xml @@ -104,21 +104,6 @@ </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> - <artifactId>statistics</artifactId> - <version>${project.version}</version> - <exclusions> - <exclusion> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - </exclusion> - <exclusion> - <groupId>com.yahoo.vespa</groupId> - <artifactId>config</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> <artifactId>vdslib</artifactId> <version>${project.version}</version> </dependency> diff --git a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java index decb0513e26..8aee2d43187 100644 --- a/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java +++ b/container-core/src/main/java/com/yahoo/container/core/config/HandlersConfigurerDi.java @@ -20,7 +20,6 @@ import com.yahoo.jdisc.service.ClientProvider; import com.yahoo.jdisc.service.ServerProvider; import com.yahoo.osgi.OsgiImpl; import com.yahoo.osgi.OsgiWrapper; -import com.yahoo.statistics.Statistics; import org.osgi.framework.Bundle; import java.util.ArrayList; @@ -118,7 +117,6 @@ public class HandlersConfigurerDi { return result.oldComponentsCleanupTask(); } - @SuppressWarnings("deprecation") private Injector createFallbackInjector(com.yahoo.container.Container vespaContainer, Injector discInjector) { return discInjector.createChildInjector(new AbstractModule() { @Override @@ -126,7 +124,6 @@ public class HandlersConfigurerDi { // Provide a singleton instance for all component fallbacks, // otherwise fallback injection may lead to a cascade of components requiring reconstruction. bind(com.yahoo.container.Container.class).toInstance(vespaContainer); - bind(com.yahoo.statistics.Statistics.class).toInstance(Statistics.nullImplementation); bind(AccessLog.class).toInstance(AccessLog.NONE_INSTANCE); bind(Executor.class).toInstance(fallbackExecutor); if (vespaContainer.getFileAcquirer() != null) diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json index d4aadb11ba0..ff89cf432c2 100644 --- a/container-search/abi-spec.json +++ b/container-search/abi-spec.json @@ -4395,13 +4395,6 @@ ], "methods": [ "public void <init>(com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.component.provider.ComponentRegistry, com.yahoo.search.searchchain.ExecutionFactory, ai.vespa.cloud.ZoneInfo)", - "public void <init>(com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.language.process.Embedder, com.yahoo.search.searchchain.ExecutionFactory)", - "public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.language.process.Embedder, com.yahoo.search.searchchain.ExecutionFactory)", - "public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, com.yahoo.container.handler.threadpool.ContainerThreadPool, com.yahoo.container.logging.AccessLog, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.search.searchchain.ExecutionFactory)", - "public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, java.util.concurrent.Executor, com.yahoo.container.logging.AccessLog, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.search.searchchain.ExecutionFactory)", - "public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, java.util.concurrent.Executor, com.yahoo.container.logging.AccessLog, com.yahoo.search.query.profile.config.QueryProfilesConfig, com.yahoo.container.core.ContainerHttpConfig, com.yahoo.search.searchchain.ExecutionFactory)", - "public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric, java.util.concurrent.Executor, com.yahoo.container.logging.AccessLog, com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry, com.yahoo.search.searchchain.ExecutionFactory, java.util.Optional)", - "public void <init>(com.yahoo.container.core.ChainsConfig, com.yahoo.search.config.IndexInfoConfig, com.yahoo.container.QrSearchersConfig, com.yahoo.vespa.configdefinition.SpecialtokensConfig, com.yahoo.statistics.Statistics, com.yahoo.language.Linguistics, com.yahoo.jdisc.Metric, com.yahoo.component.provider.ComponentRegistry, java.util.concurrent.Executor, com.yahoo.container.logging.AccessLog, com.yahoo.search.query.profile.config.QueryProfilesConfig, com.yahoo.component.provider.ComponentRegistry, com.yahoo.container.core.ContainerHttpConfig)", "public final com.yahoo.container.jdisc.HttpResponse handle(com.yahoo.container.jdisc.HttpRequest)", "public java.util.Optional getRequestType()", "public com.yahoo.search.Result searchAndFill(com.yahoo.search.Query, com.yahoo.component.chain.Chain)", @@ -8521,132 +8514,6 @@ ], "fields": [] }, - "com.yahoo.search.statistics.MeasureQpsConfig$Builder": { - "superClass": "java.lang.Object", - "interfaces": [ - "com.yahoo.config.ConfigInstance$Builder" - ], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>()", - "public void <init>(com.yahoo.search.statistics.MeasureQpsConfig)", - "public com.yahoo.search.statistics.MeasureQpsConfig$Builder outputmethod(com.yahoo.search.statistics.MeasureQpsConfig$Outputmethod$Enum)", - "public com.yahoo.search.statistics.MeasureQpsConfig$Builder queryproperty(java.lang.String)", - "public com.yahoo.search.statistics.MeasureQpsConfig$Builder eventname(java.lang.String)", - "public final boolean dispatchGetConfig(com.yahoo.config.ConfigInstance$Producer)", - "public final java.lang.String getDefMd5()", - "public final java.lang.String getDefName()", - "public final java.lang.String getDefNamespace()", - "public final boolean getApplyOnRestart()", - "public final void setApplyOnRestart(boolean)", - "public com.yahoo.search.statistics.MeasureQpsConfig build()" - ], - "fields": [] - }, - "com.yahoo.search.statistics.MeasureQpsConfig$Outputmethod$Enum": { - "superClass": "java.lang.Enum", - "interfaces": [], - "attributes": [ - "public", - "final", - "enum" - ], - "methods": [ - "public static com.yahoo.search.statistics.MeasureQpsConfig$Outputmethod$Enum[] values()", - "public static com.yahoo.search.statistics.MeasureQpsConfig$Outputmethod$Enum valueOf(java.lang.String)" - ], - "fields": [ - "public static final enum com.yahoo.search.statistics.MeasureQpsConfig$Outputmethod$Enum STATISTICS", - "public static final enum com.yahoo.search.statistics.MeasureQpsConfig$Outputmethod$Enum METAHIT" - ] - }, - "com.yahoo.search.statistics.MeasureQpsConfig$Outputmethod": { - "superClass": "com.yahoo.config.EnumNode", - "interfaces": [], - "attributes": [ - "public", - "final" - ], - "methods": [ - "public void <init>()", - "public void <init>(com.yahoo.search.statistics.MeasureQpsConfig$Outputmethod$Enum)" - ], - "fields": [ - "public static final com.yahoo.search.statistics.MeasureQpsConfig$Outputmethod$Enum STATISTICS", - "public static final com.yahoo.search.statistics.MeasureQpsConfig$Outputmethod$Enum METAHIT" - ] - }, - "com.yahoo.search.statistics.MeasureQpsConfig$Producer": { - "superClass": "java.lang.Object", - "interfaces": [ - "com.yahoo.config.ConfigInstance$Producer" - ], - "attributes": [ - "public", - "interface", - "abstract" - ], - "methods": [ - "public abstract void getConfig(com.yahoo.search.statistics.MeasureQpsConfig$Builder)" - ], - "fields": [] - }, - "com.yahoo.search.statistics.MeasureQpsConfig": { - "superClass": "com.yahoo.config.ConfigInstance", - "interfaces": [], - "attributes": [ - "public", - "final" - ], - "methods": [ - "public static java.lang.String getDefMd5()", - "public static java.lang.String getDefName()", - "public static java.lang.String getDefNamespace()", - "public static java.lang.String getDefVersion()", - "public void <init>(com.yahoo.search.statistics.MeasureQpsConfig$Builder)", - "public com.yahoo.search.statistics.MeasureQpsConfig$Outputmethod$Enum outputmethod()", - "public java.lang.String queryproperty()", - "public java.lang.String eventname()" - ], - "fields": [ - "public static final java.lang.String CONFIG_DEF_MD5", - "public static final java.lang.String CONFIG_DEF_NAME", - "public static final java.lang.String CONFIG_DEF_NAMESPACE", - "public static final java.lang.String CONFIG_DEF_VERSION", - "public static final java.lang.String[] CONFIG_DEF_SCHEMA" - ] - }, - "com.yahoo.search.statistics.PeakQpsSearcher$QpsHit": { - "superClass": "com.yahoo.search.result.Hit", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>(java.lang.Integer, java.lang.Double)", - "public boolean isMeta()", - "public java.lang.String toString()" - ], - "fields": [ - "public static final java.lang.String MEAN_QPS", - "public static final java.lang.String PEAK_QPS", - "public static final java.lang.String SCHEME" - ] - }, - "com.yahoo.search.statistics.PeakQpsSearcher": { - "superClass": "com.yahoo.search.Searcher", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>(com.yahoo.search.statistics.MeasureQpsConfig, com.yahoo.statistics.Statistics)", - "public com.yahoo.search.Result search(com.yahoo.search.Query, com.yahoo.search.searchchain.Execution)" - ], - "fields": [] - }, "com.yahoo.search.statistics.TimeTracker$Activity": { "superClass": "java.lang.Enum", "interfaces": [], @@ -8691,166 +8558,6 @@ ], "fields": [] }, - "com.yahoo.search.statistics.TimingSearcher$Parameters": { - "superClass": "java.lang.Object", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>(java.lang.String, com.yahoo.search.statistics.TimeTracker$Activity)" - ], - "fields": [] - }, - "com.yahoo.search.statistics.TimingSearcher": { - "superClass": "com.yahoo.search.cluster.PingableSearcher", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>(com.yahoo.component.ComponentId, com.yahoo.search.statistics.TimingSearcherConfig, com.yahoo.statistics.Statistics)", - "public void fill(com.yahoo.search.Result, java.lang.String, com.yahoo.search.searchchain.Execution)", - "public com.yahoo.prelude.Pong ping(com.yahoo.prelude.Ping, com.yahoo.search.searchchain.Execution)", - "public com.yahoo.search.Result search(com.yahoo.search.Query, com.yahoo.search.searchchain.Execution)", - "public void setMeasurements(com.yahoo.statistics.Value)", - "public void deconstruct()" - ], - "fields": [] - }, - "com.yahoo.search.statistics.TimingSearcherConfig$Builder": { - "superClass": "java.lang.Object", - "interfaces": [ - "com.yahoo.config.ConfigInstance$Builder" - ], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>()", - "public void <init>(com.yahoo.search.statistics.TimingSearcherConfig)", - "public com.yahoo.search.statistics.TimingSearcherConfig$Builder timer(com.yahoo.search.statistics.TimingSearcherConfig$Timer$Builder)", - "public com.yahoo.search.statistics.TimingSearcherConfig$Builder timer(java.util.function.Consumer)", - "public com.yahoo.search.statistics.TimingSearcherConfig$Builder timer(java.util.List)", - "public final boolean dispatchGetConfig(com.yahoo.config.ConfigInstance$Producer)", - "public final java.lang.String getDefMd5()", - "public final java.lang.String getDefName()", - "public final java.lang.String getDefNamespace()", - "public final boolean getApplyOnRestart()", - "public final void setApplyOnRestart(boolean)", - "public com.yahoo.search.statistics.TimingSearcherConfig build()" - ], - "fields": [ - "public java.util.List timer" - ] - }, - "com.yahoo.search.statistics.TimingSearcherConfig$Producer": { - "superClass": "java.lang.Object", - "interfaces": [ - "com.yahoo.config.ConfigInstance$Producer" - ], - "attributes": [ - "public", - "interface", - "abstract" - ], - "methods": [ - "public abstract void getConfig(com.yahoo.search.statistics.TimingSearcherConfig$Builder)" - ], - "fields": [] - }, - "com.yahoo.search.statistics.TimingSearcherConfig$Timer$Builder": { - "superClass": "java.lang.Object", - "interfaces": [ - "com.yahoo.config.ConfigBuilder" - ], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>()", - "public void <init>(com.yahoo.search.statistics.TimingSearcherConfig$Timer)", - "public com.yahoo.search.statistics.TimingSearcherConfig$Timer$Builder name(java.lang.String)", - "public com.yahoo.search.statistics.TimingSearcherConfig$Timer$Builder eventname(java.lang.String)", - "public com.yahoo.search.statistics.TimingSearcherConfig$Timer$Builder measure(com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum)", - "public com.yahoo.search.statistics.TimingSearcherConfig$Timer build()" - ], - "fields": [] - }, - "com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum": { - "superClass": "java.lang.Enum", - "interfaces": [], - "attributes": [ - "public", - "final", - "enum" - ], - "methods": [ - "public static com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum[] values()", - "public static com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum valueOf(java.lang.String)" - ], - "fields": [ - "public static final enum com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum FILL", - "public static final enum com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum PING", - "public static final enum com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum SEARCH" - ] - }, - "com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure": { - "superClass": "com.yahoo.config.EnumNode", - "interfaces": [], - "attributes": [ - "public", - "final" - ], - "methods": [ - "public void <init>()", - "public void <init>(com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum)" - ], - "fields": [ - "public static final com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum FILL", - "public static final com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum PING", - "public static final com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum SEARCH" - ] - }, - "com.yahoo.search.statistics.TimingSearcherConfig$Timer": { - "superClass": "com.yahoo.config.InnerNode", - "interfaces": [], - "attributes": [ - "public", - "final" - ], - "methods": [ - "public void <init>(com.yahoo.search.statistics.TimingSearcherConfig$Timer$Builder)", - "public java.lang.String name()", - "public java.lang.String eventname()", - "public com.yahoo.search.statistics.TimingSearcherConfig$Timer$Measure$Enum measure()" - ], - "fields": [] - }, - "com.yahoo.search.statistics.TimingSearcherConfig": { - "superClass": "com.yahoo.config.ConfigInstance", - "interfaces": [], - "attributes": [ - "public", - "final" - ], - "methods": [ - "public static java.lang.String getDefMd5()", - "public static java.lang.String getDefName()", - "public static java.lang.String getDefNamespace()", - "public static java.lang.String getDefVersion()", - "public void <init>(com.yahoo.search.statistics.TimingSearcherConfig$Builder)", - "public java.util.List timer()", - "public com.yahoo.search.statistics.TimingSearcherConfig$Timer timer(int)" - ], - "fields": [ - "public static final java.lang.String CONFIG_DEF_MD5", - "public static final java.lang.String CONFIG_DEF_NAME", - "public static final java.lang.String CONFIG_DEF_NAMESPACE", - "public static final java.lang.String CONFIG_DEF_VERSION", - "public static final java.lang.String[] CONFIG_DEF_SCHEMA" - ] - }, "com.yahoo.text.interpretation.AnnotationClass": { "superClass": "java.lang.Object", "interfaces": [], diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java index 3eadf29489e..2c26a302ece 100644 --- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java +++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java @@ -3,14 +3,11 @@ package com.yahoo.search.handler; import ai.vespa.cloud.ZoneInfo; import com.yahoo.collections.Tuple2; -import com.yahoo.component.ComponentId; import com.yahoo.component.ComponentSpecification; import com.yahoo.component.Vtag; import com.yahoo.component.annotation.Inject; import com.yahoo.component.chain.Chain; import com.yahoo.component.provider.ComponentRegistry; -import com.yahoo.container.QrSearchersConfig; -import com.yahoo.container.core.ChainsConfig; import com.yahoo.container.core.ContainerHttpConfig; import com.yahoo.container.handler.threadpool.ContainerThreadPool; import com.yahoo.container.jdisc.AclMapping; @@ -20,11 +17,9 @@ import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.jdisc.LoggingRequestHandler; import com.yahoo.container.jdisc.RequestHandlerSpec; import com.yahoo.container.jdisc.VespaHeaders; -import com.yahoo.container.logging.AccessLog; import com.yahoo.io.IOUtils; import com.yahoo.jdisc.Metric; import com.yahoo.jdisc.Request; -import com.yahoo.language.Linguistics; import com.yahoo.language.process.Embedder; import com.yahoo.language.provider.DefaultEmbedderProvider; import com.yahoo.net.HostName; @@ -36,12 +31,9 @@ import com.yahoo.processing.request.CompoundName; import com.yahoo.search.Query; import com.yahoo.search.Result; import com.yahoo.search.Searcher; -import com.yahoo.search.config.IndexInfoConfig; import com.yahoo.search.query.context.QueryContext; import com.yahoo.search.query.profile.compiled.CompiledQueryProfile; import com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry; -import com.yahoo.search.query.profile.config.QueryProfileConfigurer; -import com.yahoo.search.query.profile.config.QueryProfilesConfig; import com.yahoo.search.query.properties.DefaultProperties; import com.yahoo.search.query.ranking.SoftTimeout; import com.yahoo.search.result.ErrorMessage; @@ -52,8 +44,6 @@ import com.yahoo.search.statistics.ElapsedTime; import com.yahoo.slime.Inspector; import com.yahoo.slime.ObjectTraverser; import com.yahoo.slime.SlimeUtils; -import com.yahoo.statistics.Statistics; -import com.yahoo.vespa.configdefinition.SpecialtokensConfig; import com.yahoo.yolean.Exceptions; import com.yahoo.yolean.trace.TraceNode; @@ -130,119 +120,6 @@ public class SearchHandler extends LoggingRequestHandler { zoneInfo); } - /** - * @deprecated Use the @Inject annotated constructor instead. - */ - @Deprecated // Vespa 8 - public SearchHandler(Metric metric, - ContainerThreadPool threadpool, - CompiledQueryProfileRegistry queryProfileRegistry, - ContainerHttpConfig config, - Embedder embedder, - ExecutionFactory executionFactory) { - this(metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory, - config.numQueriesToTraceOnDebugAfterConstruction(), - config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey()), - ZoneInfo.defaultInfo()); - } - - /** - * @deprecated Use the @Inject annotated constructor instead. - */ - @Deprecated // Vespa 8 - public SearchHandler(Statistics statistics, - Metric metric, - ContainerThreadPool threadpool, - CompiledQueryProfileRegistry queryProfileRegistry, - ContainerHttpConfig config, - Embedder embedder, - ExecutionFactory executionFactory) { - this(metric, threadpool.executor(), queryProfileRegistry, embedder, executionFactory, - config.numQueriesToTraceOnDebugAfterConstruction(), - config.hostResponseHeaderKey().equals("") ? Optional.empty() : Optional.of(config.hostResponseHeaderKey()), - ZoneInfo.defaultInfo()); - } - - /** - * @deprecated Use the @Inject annotated constructor instead. - */ - @Deprecated // Vespa 8 - public SearchHandler(Statistics statistics, - Metric metric, - ContainerThreadPool threadpool, - AccessLog ignored, - CompiledQueryProfileRegistry queryProfileRegistry, - ContainerHttpConfig config, - ExecutionFactory executionFactory) { - this(statistics, metric, threadpool.executor(), ignored, queryProfileRegistry, config, executionFactory); - } - - /** - * @deprecated Use the @Inject annotated constructor instead. - */ - @Deprecated // Vespa 8 - public SearchHandler(Statistics statistics, - Metric metric, - Executor executor, - AccessLog ignored, - CompiledQueryProfileRegistry queryProfileRegistry, - ContainerHttpConfig containerHttpConfig, - ExecutionFactory executionFactory) { - this(metric, executor, queryProfileRegistry, Embedder.throwsOnUse, executionFactory, - containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(), - containerHttpConfig.hostResponseHeaderKey().equals("") ? Optional.empty() - : Optional.of(containerHttpConfig.hostResponseHeaderKey()), - ZoneInfo.defaultInfo()); - } - - /** - * @deprecated Use the @Inject annotated constructor instead. - */ - @Deprecated // Vespa 8 - public SearchHandler(Statistics statistics, - Metric metric, - Executor executor, - AccessLog ignored, - QueryProfilesConfig queryProfileConfig, - ContainerHttpConfig containerHttpConfig, - ExecutionFactory executionFactory) { - this(metric, executor, QueryProfileConfigurer.createFromConfig(queryProfileConfig).compile(), - Embedder.throwsOnUse, executionFactory, - containerHttpConfig.numQueriesToTraceOnDebugAfterConstruction(), - containerHttpConfig.hostResponseHeaderKey().equals("") ? Optional.empty() - : Optional.of( containerHttpConfig.hostResponseHeaderKey()), - ZoneInfo.defaultInfo()); - } - - /** - * @deprecated Use the @Inject annotated constructor instead. - */ - @Deprecated // Vespa 8 - public SearchHandler(Statistics statistics, - Metric metric, - Executor executor, - AccessLog ignored, - CompiledQueryProfileRegistry queryProfileRegistry, - ExecutionFactory executionFactory, - Optional<String> hostResponseHeaderKey) { - this(metric, executor, queryProfileRegistry, toRegistry(Embedder.throwsOnUse), - executionFactory, 0, hostResponseHeaderKey, - ZoneInfo.defaultInfo()); - } - - private SearchHandler(Metric metric, - Executor executor, - CompiledQueryProfileRegistry queryProfileRegistry, - Embedder embedder, - ExecutionFactory executionFactory, - long numQueriesToTraceOnDebugAfterStartup, - Optional<String> hostResponseHeaderKey, - ZoneInfo zoneInfo) { - this(metric, executor, queryProfileRegistry, toRegistry(embedder), - executionFactory, numQueriesToTraceOnDebugAfterStartup, hostResponseHeaderKey, - ZoneInfo.defaultInfo()); - } - private SearchHandler(Metric metric, Executor executor, CompiledQueryProfileRegistry queryProfileRegistry, @@ -266,30 +143,6 @@ public class SearchHandler extends LoggingRequestHandler { this.zoneInfo = zoneInfo; } - /** @deprecated use the other constructor */ - @Deprecated // TODO: Remove on Vespa 8 - public SearchHandler(ChainsConfig chainsConfig, - IndexInfoConfig indexInfo, - QrSearchersConfig clusters, - SpecialtokensConfig specialtokens, - Statistics statistics, - Linguistics linguistics, - Metric metric, - ComponentRegistry<Renderer> renderers, - Executor executor, - AccessLog accessLog, - QueryProfilesConfig queryProfileConfig, - ComponentRegistry<Searcher> searchers, - ContainerHttpConfig containerHttpConfig) { - this(statistics, - metric, - executor, - accessLog, - queryProfileConfig, - containerHttpConfig, - new ExecutionFactory(chainsConfig, indexInfo, clusters, searchers, specialtokens, linguistics, renderers, executor)); - } - Metric metric() { return metric; } private static int examineExecutor(Executor executor) { @@ -716,12 +569,6 @@ public class SearchHandler extends LoggingRequestHandler { return Collections.unmodifiableMap(map); } - private static ComponentRegistry<Embedder> toRegistry(Embedder embedder) { - ComponentRegistry<Embedder> emb = new ComponentRegistry<>(); - emb.register(new ComponentId(Embedder.defaultEmbedderId), embedder); - return emb; - } - } diff --git a/container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java b/container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java deleted file mode 100644 index 2823a7d74e1..00000000000 --- a/container-search/src/main/java/com/yahoo/search/statistics/PeakQpsSearcher.java +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.search.statistics; - -import com.yahoo.collections.Tuple2; -import com.yahoo.concurrent.ThreadLocalDirectory; -import com.yahoo.search.Query; -import com.yahoo.search.Result; -import com.yahoo.search.Searcher; -import com.yahoo.processing.request.CompoundName; -import com.yahoo.search.result.Hit; -import com.yahoo.search.searchchain.Execution; -import com.yahoo.statistics.Callback; -import com.yahoo.statistics.Handle; -import com.yahoo.statistics.Statistics; -import com.yahoo.statistics.Value; - -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Deque; -import java.util.List; -import java.util.ListIterator; - -/** - * Aggregate peak qps and expose through meta hits and/or log events. - * - * @author Steinar Knutsen - * @deprecated Will be removed on Vespa 8 - */ -@Deprecated -public class PeakQpsSearcher extends Searcher { - - private final ThreadLocalDirectory<Deque<QueryRatePerSecond>, Long> directory; - private final Value qpsStatistics; - private final CompoundName propertyName; - private final boolean useMetaHit; - - /** - * Meta hit which carries the peak qps and mean qps since the last time this - * data was requested. The URI is always "meta:qps". The data is stored as - * Number subclasses in the fields named by the fields PEAK_QPS and MEAN_QPS - * in the QpsHit class. - */ - public static class QpsHit extends Hit { - - /** The name of the field containing mean QPS since the last measurement. */ - public static final String MEAN_QPS = "mean_qps"; - - /** The name of the field containing peak QPS since the last measurement. */ - public static final String PEAK_QPS = "peak_qps"; - public static final String SCHEME = "meta"; - - public QpsHit(Integer peakQps, Double meanQps) { - super(SCHEME + ":qps"); - setField(PEAK_QPS, peakQps); - setField(MEAN_QPS, meanQps); - } - - public boolean isMeta() { - return true; - } - - @Override - public String toString() { - return "QPS hit: Peak QPS " + getField(PEAK_QPS) + ", mean QPS " + getField(MEAN_QPS) + "."; - } - - } - - static class QueryRatePerSecond { - long when; - int howMany; - - QueryRatePerSecond(long when) { - this.when = when; - this.howMany = 0; - } - - void add(int x) { - howMany += x; - } - - void increment() { - howMany += 1; - } - - @Override - public String toString() { - return "QueryRatePerSecond(" + when + ": " + howMany + ")"; - } - } - - static class QueryRate implements - ThreadLocalDirectory.Updater<Deque<QueryRatePerSecond>, Long> { - @Override - public Deque<QueryRatePerSecond> update(Deque<QueryRatePerSecond> current, Long when) { - QueryRatePerSecond last = current.peekLast(); - if (last == null || last.when != when) { - last = new QueryRatePerSecond(when); - current.addLast(last); - } - last.increment(); - return current; - } - - @Override - public Deque<QueryRatePerSecond> createGenerationInstance(Deque<QueryRatePerSecond> previous) { - if (previous == null) { - return new ArrayDeque<>(); - } else { - return new ArrayDeque<>(previous.size()); - } - } - } - - private class Fetcher implements Callback { - @Override - public void run(Handle h, boolean firstRun) { - List<Deque<QueryRatePerSecond>> data = directory.fetch(); - List<QueryRatePerSecond> chewed = merge(data); - for (QueryRatePerSecond qps : chewed) { - qpsStatistics.put(qps.howMany); - } - } - } - - public PeakQpsSearcher(MeasureQpsConfig config, Statistics manager) { - directory = createDirectory(); - MeasureQpsConfig.Outputmethod.Enum method = config.outputmethod(); - if (method == MeasureQpsConfig.Outputmethod.METAHIT) { - useMetaHit = true; - propertyName = new CompoundName(config.queryproperty()); - qpsStatistics = null; - } else if (method == MeasureQpsConfig.Outputmethod.STATISTICS) { - String event = config.eventname(); - if (event == null || event.isEmpty()) { - event = getId().getName(); - event = event.replace('.', '_'); - } - qpsStatistics = new Value(event, manager, new Value.Parameters() - .setAppendChar('_').setLogMax(true).setLogMean(true) - .setLogMin(false).setLogRaw(false).setNameExtension(true) - .setCallback(new Fetcher())); - useMetaHit = false; - propertyName = null; - } else { - throw new IllegalStateException("Config definition out of sync with implementation." + - " No way to create output for method " + method + "."); - } - } - - static ThreadLocalDirectory<Deque<QueryRatePerSecond>, Long> createDirectory() { - return new ThreadLocalDirectory<>(new QueryRate()); - } - - static List<QueryRatePerSecond> merge(List<Deque<QueryRatePerSecond>> measurements) { - List<QueryRatePerSecond> rates = new ArrayList<>(); - while (measurements.size() > 0) { - Deque<Deque<QueryRatePerSecond>> consumeFrom = new ArrayDeque<>(measurements.size()); - long current = Long.MAX_VALUE; - for (ListIterator<Deque<QueryRatePerSecond>> i = measurements.listIterator(); i.hasNext();) { - Deque<QueryRatePerSecond> deck = i.next(); - if (deck.size() == 0) { - i.remove(); - continue; - } - QueryRatePerSecond threadData = deck.peekFirst(); - if (threadData.when < current) { - consumeFrom.clear(); - current = threadData.when; - consumeFrom.add(deck); - } else if (threadData.when == current) { - consumeFrom.add(deck); - } - } - if (consumeFrom.size() > 0) { - rates.add(consume(consumeFrom)); - } - } - return rates; - } - - private static QueryRatePerSecond consume(Deque<Deque<QueryRatePerSecond>> consumeFrom) { - Deque<QueryRatePerSecond> valueQueue = consumeFrom.pop(); - QueryRatePerSecond value = valueQueue.pop(); - QueryRatePerSecond thisSecond = new QueryRatePerSecond(value.when); - thisSecond.add(value.howMany); - while (consumeFrom.size() > 0) { - valueQueue = consumeFrom.pop(); - value = valueQueue.pop(); - thisSecond.add(value.howMany); - } - return thisSecond; - - } - - @Override - public Result search(Query query, Execution execution) { - Result r; - long when = query.getStartTime() / 1000L; - Hit meta = null; - directory.update(when); - if (useMetaHit) { - if (query.properties().getBoolean(propertyName, false)) { - List<QueryRatePerSecond> l = merge(directory.fetch()); - Tuple2<Integer, Double> maxAndMean = maxAndMean(l); - meta = new QpsHit(maxAndMean.first, maxAndMean.second); - } - } - r = execution.search(query); - if (meta != null) { - r.hits().add(meta); - } - return r; - } - - private Tuple2<Integer, Double> maxAndMean(List<QueryRatePerSecond> l) { - int max = Integer.MIN_VALUE; - double sum = 0.0d; - if (l.size() == 0) { - return new Tuple2<>(0, 0.0); - } - for (QueryRatePerSecond qps : l) { - sum += qps.howMany; - if (qps.howMany > max) { - max = qps.howMany; - } - } - return new Tuple2<>(max, sum / (double) l.size()); - } - -} diff --git a/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java b/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java deleted file mode 100644 index 5d036b8fa20..00000000000 --- a/container-search/src/main/java/com/yahoo/search/statistics/TimingSearcher.java +++ /dev/null @@ -1,144 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.search.statistics; - -import com.yahoo.component.ComponentId; -import com.yahoo.component.chain.dependencies.Before; -import com.yahoo.search.statistics.TimingSearcherConfig.Timer; -import com.yahoo.prelude.Ping; -import com.yahoo.prelude.Pong; -import com.yahoo.search.Query; -import com.yahoo.search.Result; -import com.yahoo.search.cluster.PingableSearcher; -import com.yahoo.search.searchchain.Execution; -import com.yahoo.search.statistics.TimeTracker.Activity; -import com.yahoo.statistics.Statistics; -import com.yahoo.statistics.Value; - -/** - * A searcher which is intended to be useful as a general probe for - * measuring time consumption a search chain. - * - * @author Steinar Knutsen - * @deprecated Will be removed on Vespa 8 - */ -@Before("rawQuery") -@Deprecated -public class TimingSearcher extends PingableSearcher { - - private Value measurements; - private final boolean measurePing; - private final boolean measureSearch; - private final boolean measureFill; - private static final Parameters defaultParameters = new Parameters(null, Activity.SEARCH); - - public static class Parameters { - final String eventName; - final Activity pathToSample; - - public Parameters(String eventName, Activity pathToSample) { - super(); - this.eventName = eventName; - this.pathToSample = pathToSample; - } - } - - TimingSearcher(ComponentId id, Parameters setUp, Statistics manager) { - super(id); - if (setUp == null) { - setUp = defaultParameters; - } - String eventName = setUp.eventName; - if (eventName == null || "".equals(eventName)) { - eventName = id.getName(); - } - measurements = new Value(eventName, manager, new Value.Parameters() - .setNameExtension(true).setLogMax(true).setLogMin(true) - .setLogMean(true).setLogSum(true).setLogInsertions(true) - .setAppendChar('_')); - - measurePing = setUp.pathToSample == Activity.PING; - measureSearch = setUp.pathToSample == Activity.SEARCH; - measureFill = setUp.pathToSample == Activity.FILL; - } - - public TimingSearcher(ComponentId id, TimingSearcherConfig config, Statistics manager) { - this(id, buildParameters(config, id.getName()), manager); - } - - private static Parameters buildParameters( - TimingSearcherConfig config, String searcherName) { - for (int i = 0; i < config.timer().size(); ++i) { - Timer t = config.timer(i); - if (t.name().equals(searcherName)) { - return buildParameters(t); - } - } - return null; - } - - private static Parameters buildParameters(Timer t) { - Activity m; - Timer.Measure.Enum toSample = t.measure(); - if (toSample == Timer.Measure.FILL) { - m = Activity.FILL; - } else if (toSample == Timer.Measure.PING) { - m = Activity.PING; - } else { - m = Activity.SEARCH; - } - return new Parameters(t.eventname(), m); - } - - private long preMeasure(boolean doIt) { - if (doIt) { - return System.currentTimeMillis(); - } else { - return 0L; - } - } - - private void postMeasure(boolean doIt, long start) { - if (doIt) { - long elapsed = System.currentTimeMillis() - start; - measurements.put(elapsed); - } - } - - @Override - public void fill(Result result, String summaryClass, Execution execution) { - long start = preMeasure(measureFill); - super.fill(result, summaryClass, execution); - postMeasure(measureFill, start); - } - - @Override - public Pong ping(Ping ping, Execution execution) { - long start = preMeasure(measurePing); - Pong pong = execution.ping(ping); - postMeasure(measurePing, start); - return pong; - } - - @Override - public Result search(Query query, Execution execution) { - long start = preMeasure(measureSearch); - Result result = execution.search(query); - postMeasure(measureSearch, start); - return result; - } - - /** - * This method is only included for testing. - */ - public void setMeasurements(Value measurements) { - this.measurements = measurements; - } - - @Override - public void deconstruct() { - // avoid dangling, duplicate loggers - measurements.cancel(); - super.deconstruct(); - } - -} diff --git a/container-search/src/main/resources/configdefinitions/search.statistics.measure-qps.def b/container-search/src/main/resources/configdefinitions/search.statistics.measure-qps.def deleted file mode 100644 index 0cc615d0601..00000000000 --- a/container-search/src/main/resources/configdefinitions/search.statistics.measure-qps.def +++ /dev/null @@ -1,16 +0,0 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -namespace=search.statistics - -## Configure measurements of peak QPS rates. - -## Control whether com.yahoo.search.statistics.PeakQpsSearcher -## should emit data through statistics framework or as a meta hit. -outputmethod enum { STATISTICS, METAHIT } default=STATISTICS - -## If using meta hits, which query property should trigger sampling -queryproperty string default="fetchpeakqps" - -## The base name for the statistics event. Default is the component name -## of the searcher, as defined in vespa-services, with dots replaced by -## underscore. -eventname string default="" diff --git a/container-search/src/main/resources/configdefinitions/search.statistics.timing-searcher.def b/container-search/src/main/resources/configdefinitions/search.statistics.timing-searcher.def deleted file mode 100644 index 16f83e31013..00000000000 --- a/container-search/src/main/resources/configdefinitions/search.statistics.timing-searcher.def +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -namespace=search.statistics - -timer[].name string -timer[].eventname string -timer[].measure enum { FILL, PING, SEARCH } default=SEARCH - diff --git a/docproc/abi-spec.json b/docproc/abi-spec.json index 5ad2c6d454d..bb7177783de 100644 --- a/docproc/abi-spec.json +++ b/docproc/abi-spec.json @@ -80,8 +80,6 @@ "methods": [ "public void <init>(com.yahoo.docproc.DocumentProcessor)", "public void <init>(com.yahoo.docproc.DocumentProcessor, com.yahoo.jdisc.Metric)", - "public void <init>(com.yahoo.docproc.DocumentProcessor, com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric)", - "public void <init>(com.yahoo.docproc.DocumentProcessor, java.lang.String, com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric)", "public void <init>(com.yahoo.docproc.DocumentProcessor, java.lang.String, com.yahoo.jdisc.Metric)", "public java.lang.Object clone()", "public com.yahoo.docproc.DocumentProcessor getDocumentProcessor()", @@ -102,12 +100,9 @@ "public void <init>()", "public void <init>(java.lang.String)", "public void <init>(com.yahoo.jdisc.Metric)", - "public void <init>(com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric)", - "public void <init>(java.lang.String, com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric)", "public void <init>(java.lang.String, com.yahoo.jdisc.Metric)", "public void <init>(com.yahoo.docproc.CallStack)", "public void <init>(java.lang.String, java.util.Collection, com.yahoo.jdisc.Metric)", - "public void <init>(java.lang.String, java.util.Collection, com.yahoo.statistics.Statistics, com.yahoo.jdisc.Metric)", "public java.lang.String getName()", "public void setName(java.lang.String)", "public com.yahoo.docproc.CallStack addNext(com.yahoo.docproc.Call)", @@ -133,7 +128,6 @@ "public java.util.ListIterator iterator()", "public int size()", "public java.lang.String toString()", - "public com.yahoo.statistics.Statistics getStatistics()", "public com.yahoo.jdisc.Metric getMetric()" ], "fields": [] diff --git a/docproc/pom.xml b/docproc/pom.xml index f3202973abc..d758606f8b7 100644 --- a/docproc/pom.xml +++ b/docproc/pom.xml @@ -78,12 +78,6 @@ </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> - <artifactId>statistics</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> <artifactId>vespajlib</artifactId> <version>${project.version}</version> <scope>provided</scope> diff --git a/docproc/src/main/java/com/yahoo/docproc/Call.java b/docproc/src/main/java/com/yahoo/docproc/Call.java index bb277e5ebfe..75670badf91 100644 --- a/docproc/src/main/java/com/yahoo/docproc/Call.java +++ b/docproc/src/main/java/com/yahoo/docproc/Call.java @@ -11,7 +11,6 @@ import com.yahoo.document.DocumentPut; import com.yahoo.document.DocumentUpdate; import com.yahoo.jdisc.Metric; import com.yahoo.concurrent.SystemTimer; -import com.yahoo.statistics.Statistics; import java.util.List; @@ -40,14 +39,6 @@ public class Call implements Cloneable { public Call(DocumentProcessor processor, Metric metric) { this(processor, "", metric); } - @Deprecated - public Call(DocumentProcessor processor, Statistics manager, Metric metric) { - this(processor, "", metric); - } - @Deprecated - public Call(DocumentProcessor processor, String chainName, Statistics manager, Metric metric) { - this(processor, chainName, metric); - } public Call(DocumentProcessor processor, String chainName, Metric metric) { this.processor = processor; @@ -64,8 +55,7 @@ public class Call implements Cloneable { @Override public Object clone() { try { - Call clone = (Call) super.clone(); - return clone; + return super.clone(); } catch (CloneNotSupportedException e) { throw new RuntimeException("Will not happen"); } diff --git a/docproc/src/main/java/com/yahoo/docproc/CallStack.java b/docproc/src/main/java/com/yahoo/docproc/CallStack.java index 9f59d9e869b..9c7251ee54e 100644 --- a/docproc/src/main/java/com/yahoo/docproc/CallStack.java +++ b/docproc/src/main/java/com/yahoo/docproc/CallStack.java @@ -4,7 +4,6 @@ package com.yahoo.docproc; import com.yahoo.component.ComponentId; import com.yahoo.docproc.jdisc.metric.NullMetric; import com.yahoo.jdisc.Metric; -import com.yahoo.statistics.Statistics; import java.util.Collection; import java.util.Iterator; @@ -47,14 +46,6 @@ public class CallStack { this.name = null; this.metric = metric; } - @Deprecated - public CallStack(Statistics statistics, Metric metric) { - this(metric); - } - @Deprecated - public CallStack(String name, Statistics manager, Metric metric) { - this(name, metric); - } /** Creates an empty stack with a name */ public CallStack(String name, Metric metric) { this.name = name; @@ -87,10 +78,6 @@ public class CallStack { addLast(docproc); } } - @Deprecated - public CallStack(String name, Collection<DocumentProcessor> docprocs, Statistics manager, Metric metric) { - this(name, docprocs, metric); - } /** Returns the name of this stack, or null if it is not named */ public String getName() { @@ -384,11 +371,6 @@ public class CallStack { return b.toString(); } - @Deprecated - public Statistics getStatistics() { - return null; - } - public Metric getMetric() { return metric; } diff --git a/fat-model-dependencies/pom.xml b/fat-model-dependencies/pom.xml index 97e37aa2192..5c489662842 100644 --- a/fat-model-dependencies/pom.xml +++ b/fat-model-dependencies/pom.xml @@ -131,11 +131,6 @@ </dependency> <dependency> <groupId>com.yahoo.vespa</groupId> - <artifactId>statistics</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> <artifactId>container-messagebus</artifactId> <version>${project.version}</version> </dependency> @@ -119,7 +119,6 @@ <module>service-monitor</module> <module>socket_test</module> <module>standalone-container</module> - <module>statistics</module> <module>storage</module> <module>streamingvisitors</module> <module>tenant-base</module> diff --git a/statistics/.gitignore b/statistics/.gitignore deleted file mode 100644 index 324d6034fd1..00000000000 --- a/statistics/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -statistics.iml -archive -build -log -target -.settings -.classpath -.project -/pom.xml.build diff --git a/statistics/CMakeLists.txt b/statistics/CMakeLists.txt deleted file mode 100644 index f8d34754c41..00000000000 --- a/statistics/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -install_config_definitions() diff --git a/statistics/OWNERS b/statistics/OWNERS deleted file mode 100644 index 67cd2820bb8..00000000000 --- a/statistics/OWNERS +++ /dev/null @@ -1 +0,0 @@ -arnej27959 diff --git a/statistics/README b/statistics/README deleted file mode 100644 index 0b90b092125..00000000000 --- a/statistics/README +++ /dev/null @@ -1,2 +0,0 @@ -Old metrics gathering and aggregation. -To be replaced with simplemetrics where possible. diff --git a/statistics/abi-spec.json b/statistics/abi-spec.json deleted file mode 100644 index b2ffb43d9cc..00000000000 --- a/statistics/abi-spec.json +++ /dev/null @@ -1,241 +0,0 @@ -{ - "com.yahoo.statistics.Callback": { - "superClass": "java.lang.Object", - "interfaces": [], - "attributes": [ - "public", - "interface", - "abstract" - ], - "methods": [ - "public abstract void run(com.yahoo.statistics.Handle, boolean)" - ], - "fields": [] - }, - "com.yahoo.statistics.Counter": { - "superClass": "com.yahoo.statistics.Handle", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>(java.lang.String, com.yahoo.statistics.Statistics, boolean)", - "public void <init>(java.lang.String, com.yahoo.statistics.Statistics, boolean, com.yahoo.statistics.Callback, boolean)", - "public void increment()", - "public void increment(long)", - "public long get()", - "public boolean getResetCounter()", - "public void reset()", - "public void runHandle()", - "public java.lang.String toString()", - "public boolean equals(java.lang.Object)", - "public int hashCode()" - ], - "fields": [] - }, - "com.yahoo.statistics.CounterGroup": { - "superClass": "com.yahoo.statistics.Group", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>(java.lang.String, com.yahoo.statistics.Statistics)", - "public void <init>(java.lang.String, com.yahoo.statistics.Statistics, boolean)", - "public void <init>(java.lang.String, com.yahoo.statistics.Statistics, boolean, com.yahoo.statistics.Callback, boolean)", - "public void increment(java.lang.String)", - "public void increment(java.lang.String, long)", - "public void runHandle()", - "public boolean equals(java.lang.Object)", - "public int hashCode()" - ], - "fields": [] - }, - "com.yahoo.statistics.Handle": { - "superClass": "java.lang.Object", - "interfaces": [], - "attributes": [ - "public", - "abstract" - ], - "methods": [ - "public final void runCallback()", - "public final void run()", - "public abstract void runHandle()", - "public final boolean cancel()", - "public final boolean isCancelled()", - "public abstract boolean equals(java.lang.Object)", - "public abstract int hashCode()" - ], - "fields": [] - }, - "com.yahoo.statistics.Histogram": { - "superClass": "java.lang.Object", - "interfaces": [ - "com.yahoo.statistics.Bucket" - ], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>(com.yahoo.statistics.Limits)", - "public synchronized void put(double[])", - "public void put(double[], int)", - "public java.lang.String toString()", - "public void reset()", - "public double lowerLimit()", - "public double upperLimit()", - "public java.util.List getBuckets()", - "public long getSum()", - "public boolean isLeaf()", - "public void add(long)" - ], - "fields": [] - }, - "com.yahoo.statistics.HistogramType": { - "superClass": "java.lang.Object", - "interfaces": [], - "attributes": [ - "public", - "final" - ], - "methods": [ - "public java.lang.String toString()" - ], - "fields": [ - "public static final com.yahoo.statistics.HistogramType REGULAR", - "public static final com.yahoo.statistics.HistogramType CUMULATIVE", - "public static final com.yahoo.statistics.HistogramType REVERSE_CUMULATIVE" - ] - }, - "com.yahoo.statistics.Limits": { - "superClass": "java.lang.Object", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>()", - "public void <init>(double[])", - "public void addAxis(java.lang.String, double[])", - "public void freeze()", - "public boolean isFrozen()" - ], - "fields": [] - }, - "com.yahoo.statistics.Statistics$NullImplementation": { - "superClass": "java.lang.Object", - "interfaces": [ - "com.yahoo.statistics.Statistics" - ], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>()", - "public void register(com.yahoo.statistics.Handle)", - "public void remove(java.lang.String)", - "public com.yahoo.container.StatisticsConfig getConfig()", - "public int purge()" - ], - "fields": [] - }, - "com.yahoo.statistics.Statistics": { - "superClass": "java.lang.Object", - "interfaces": [], - "attributes": [ - "public", - "interface", - "abstract" - ], - "methods": [ - "public abstract void register(com.yahoo.statistics.Handle)", - "public abstract void remove(java.lang.String)", - "public abstract com.yahoo.container.StatisticsConfig getConfig()", - "public abstract int purge()" - ], - "fields": [ - "public static final com.yahoo.statistics.Statistics nullImplementation" - ] - }, - "com.yahoo.statistics.StatisticsImpl": { - "superClass": "com.yahoo.component.AbstractComponent", - "interfaces": [ - "com.yahoo.statistics.Statistics" - ], - "attributes": [ - "public", - "final" - ], - "methods": [ - "public void <init>(com.yahoo.container.StatisticsConfig)", - "public void deconstruct()", - "public void register(com.yahoo.statistics.Handle)", - "public void remove(java.lang.String)", - "public com.yahoo.container.StatisticsConfig getConfig()", - "public int purge()" - ], - "fields": [] - }, - "com.yahoo.statistics.Value$Parameters": { - "superClass": "java.lang.Object", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>()", - "public com.yahoo.statistics.Value$Parameters setLogRaw(java.lang.Boolean)", - "public com.yahoo.statistics.Value$Parameters setLogSum(java.lang.Boolean)", - "public com.yahoo.statistics.Value$Parameters setLogMean(java.lang.Boolean)", - "public com.yahoo.statistics.Value$Parameters setLogMax(java.lang.Boolean)", - "public com.yahoo.statistics.Value$Parameters setLogMin(java.lang.Boolean)", - "public com.yahoo.statistics.Value$Parameters setLogInsertions(java.lang.Boolean)", - "public com.yahoo.statistics.Value$Parameters setNameExtension(java.lang.Boolean)", - "public com.yahoo.statistics.Value$Parameters setLogHistogram(java.lang.Boolean)", - "public com.yahoo.statistics.Value$Parameters setHistogramId(com.yahoo.statistics.HistogramType)", - "public com.yahoo.statistics.Value$Parameters setLimits(com.yahoo.statistics.Limits)", - "public com.yahoo.statistics.Value$Parameters setAppendChar(java.lang.Character)", - "public com.yahoo.statistics.Value$Parameters setCallback(com.yahoo.statistics.Callback)" - ], - "fields": [] - }, - "com.yahoo.statistics.Value": { - "superClass": "com.yahoo.statistics.Handle", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>(java.lang.String, com.yahoo.statistics.Statistics, com.yahoo.statistics.Value$Parameters)", - "public static com.yahoo.statistics.Value buildValue(java.lang.String, com.yahoo.statistics.Statistics, com.yahoo.statistics.Value$Parameters)", - "public void put(double)", - "public double getMean()", - "public double getMin()", - "public double getMax()", - "public double get()", - "public void reset()", - "public void runHandle()", - "public java.lang.String toString()", - "public boolean equals(java.lang.Object)", - "public int hashCode()" - ], - "fields": [] - }, - "com.yahoo.statistics.ValueGroup": { - "superClass": "com.yahoo.statistics.Group", - "interfaces": [], - "attributes": [ - "public" - ], - "methods": [ - "public void <init>(java.lang.String, com.yahoo.statistics.Statistics)", - "public void <init>(java.lang.String, com.yahoo.statistics.Statistics, com.yahoo.statistics.Callback)", - "public void put(java.lang.String, double)", - "public void runHandle()", - "public boolean equals(java.lang.Object)", - "public int hashCode()" - ], - "fields": [] - } -}
\ No newline at end of file diff --git a/statistics/pom.xml b/statistics/pom.xml deleted file mode 100644 index c32b42ad5be..00000000000 --- a/statistics/pom.xml +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0"?> -<!-- Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 - http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.yahoo.vespa</groupId> - <artifactId>parent</artifactId> - <version>7-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> - </parent> - <artifactId>statistics</artifactId> - <version>7-SNAPSHOT</version> - <packaging>jar</packaging> - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-library</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>vespalog</artifactId> - <version>${project.version}</version> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>annotations</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>config-bundle</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>config</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>component</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>com.yahoo.vespa</groupId> - <artifactId>config-class-plugin</artifactId> - <version>${project.version}</version> - <executions> - <execution> - <id>config-gen</id> - <goals> - <goal>config-gen</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>com.yahoo.vespa</groupId> - <artifactId>abi-check-plugin</artifactId> - </plugin> - </plugins> - </build> -</project> diff --git a/statistics/src/main/java/com/yahoo/statistics/Axis.java b/statistics/src/main/java/com/yahoo/statistics/Axis.java deleted file mode 100644 index f0daff92d00..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Axis.java +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import java.util.Arrays; - - -/** - * A wrapper class for representing a single axis of an n-dimensional - * histogram. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -class Axis { - private final double[] limits; - private final String name; - - Axis(String name, double[] limits) { - this.limits = Arrays.copyOf(limits, limits.length); - this.name = name; - } - - double[] getLimits() { - return limits; - } - - String getName() { - return name; - } - -} diff --git a/statistics/src/main/java/com/yahoo/statistics/Bucket.java b/statistics/src/main/java/com/yahoo/statistics/Bucket.java deleted file mode 100644 index fd69f202d2b..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Bucket.java +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import java.util.List; - - -/** - * A bucket in a multidimensional histogram. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -interface Bucket { - void put(double[] value, int dim); - void reset(); - double lowerLimit(); - double upperLimit(); - boolean isLeaf(); - List<Bucket> getBuckets(); - long getSum(); - void add(long n); -} diff --git a/statistics/src/main/java/com/yahoo/statistics/Callback.java b/statistics/src/main/java/com/yahoo/statistics/Callback.java deleted file mode 100644 index fad86d38fd7..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Callback.java +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -/** - * Definition of the callback interface for the statistics API. It is a common - * use case to need a reference to the Handle (e.g. Value or Counter) which a - * callback is related to. Since everything in a Handle since 5.1.4 is fully - * initialized from the constructor, it became cumbersome to use Runnable for - * the callback and this interface came into use. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - * @since 5.1.4 - */ -@Deprecated -public interface Callback { - /** - * Invoked each logging cycle right before the events for a Handle are - * emitted to the log. - * - * @param h - * the handle which invoked this callback - * @param firstTime - * true the first time the method is invoked from h, false later - */ - public void run(Handle h, boolean firstTime); -} diff --git a/statistics/src/main/java/com/yahoo/statistics/Counter.java b/statistics/src/main/java/com/yahoo/statistics/Counter.java deleted file mode 100644 index 1425c2a4375..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Counter.java +++ /dev/null @@ -1,203 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import java.util.concurrent.atomic.AtomicLong; - -import com.yahoo.container.StatisticsConfig; - - -/** - * A single integer value which can be incremented. - * - * @author Steinar Knutsen - */ -@Deprecated -public class Counter extends Handle { - // The current value of this counter - private AtomicLong current = new AtomicLong(0L); - - // Whether or not this counter shall be reset between each logging - // interval - private final boolean resetCounter; - - /** - * A monotonically increasing 64 bit integer value. - * - * @param name - * The name of this counter, for use in logging. - * @param manager - * the statistics manager acquired by injection - * @param fetchParametersFromConfig - * Whether or not this counter should be initialized from config. - */ - public Counter(String name, Statistics manager, boolean fetchParametersFromConfig) { - this(name, manager, fetchParametersFromConfig, null, false, true); - } - - /** - * A monotonically increasing 64 bit integer value. - * - * @param name - * The name of this counter, for use in logging. - * @param manager - * the statistics manager acquired by injection - * @param fetchParametersFromConfig - * Whether or not this counter should be initialized from config. - * @param callback - * will be invoked each time this counter is written to the log - * @param resetCounter - * Control for if this Counter should be reset between each - * logging interval. - */ - public Counter(String name, Statistics manager, - boolean fetchParametersFromConfig, Callback callback, boolean resetCounter) { - this(name, manager, fetchParametersFromConfig, callback, - resetCounter, true); - } - - /** - * A monotonically increasing 64 bit integer value. Do not make this - * constructor public, it is used for creating unregistered counters. - * - * @param name - * The name of this counter, for use in logging. - * @param manager - * the statistics manager acquired by injection - * @param fetchParametersFromConfig - * Whether or not this counter should be initialized from config. - * @param callback - * will be invoked each time this counter is written to the log - * @param resetCounter - * Control for if this Counter should be reset between each - * logging interval. - * @param register - * Whether to register the counter in the statistics manager - */ - private Counter(String name, Statistics manager, - boolean fetchParametersFromConfig, Callback callback, - boolean resetCounter, boolean register) { - super(name, manager, callback); - if (fetchParametersFromConfig) { - StatisticsConfig config = manager.getConfig(); - this.resetCounter = getResetCounter(name, config); - } else { - this.resetCounter = resetCounter; - } - if (register) { - manager.register(this); - } - } - - - /** - * Get a Counter instance not registered in the statistics manager. This is - * used by CounterGroup and should not be made public. - * - * @param name - * The name of this counter, for use in logging. - * @param resetCounter - * Control for if this Counter should be reset between each - * logging interval. - */ - static Counter intializeUnregisteredCounter(String name, - boolean resetCounter) { - return new Counter(name, null, false, null, resetCounter, false); - } - - /** - * If this Counter is set up to read config, configure it - * according to the config given. - */ - private static boolean getResetCounter(String name, StatisticsConfig config) { - for (int i = 0; i < config.counterresets().size(); i++) { - String configName = config.counterresets(i).name(); - if (configName.equals(name)) { - return true; - } - } - return false; - } - - /** - * Increment by 1. - */ - public void increment() { - current.incrementAndGet(); - } - - /** - * Increment by n. - */ - public void increment(long n) { - current.addAndGet(n); - } - - /** - * @return current value of this counter - */ - public long get() { - return current.get(); - } - - /** - * The reset counter is true if this is counter is reset to 0 between each - * logging interval. - * - * @return whether this counter is reset between each logging interval. - */ - public boolean getResetCounter() { - return resetCounter; - } - - /** - * If this counter should be set to 0 between each logging interval, - * do that. - */ - public void reset() { - if (resetCounter) { - current.set(0L); - } - } - - /** - * Log current state and reset. - */ - @Override - public void runHandle() { - boolean resetState = getResetCounter(); - - if (resetState) { - current.set(0L); - } - } - - @Override - public String toString() { - return super.toString() + " " + getName() + " " + current; - } - - CounterProxy getProxyAndReset() { - CounterProxy c = new CounterProxy(getName()); - if (getResetCounter()) { - c.setRaw(current.getAndSet(0L)); - } else { - c.setRaw(current.get()); - } - return c; - } - - @Override - public boolean equals(Object o) { - if (o.getClass() != this.getClass()) { - return false; - } - Counter other = (Counter) o; - return getName().equals(other.getName()); - } - - @Override - public int hashCode() { - return getName().hashCode() + 31 * "Counter".hashCode(); - } - -} diff --git a/statistics/src/main/java/com/yahoo/statistics/CounterGroup.java b/statistics/src/main/java/com/yahoo/statistics/CounterGroup.java deleted file mode 100644 index 08b700dbe3c..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/CounterGroup.java +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -import com.yahoo.container.StatisticsConfig; -import com.yahoo.log.event.Event; - -import java.util.Map; -import java.util.HashMap; -import java.util.Iterator; - - -/** - * A set of associated counters. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@SuppressWarnings("removal") // TODO Vespa 8: remove (com.yahoo.log.event) -@Deprecated -public class CounterGroup extends Group { - private final boolean resetCounter; - - // A map for names of subevents and Value instances - private Map<String, Counter> subEvents = new HashMap<>(); - - /** - * @param name The symbolic name of this group of counters. - */ - public CounterGroup(String name, Statistics manager) { - this(name, manager, true); - } - - /** - * Create a basic group of counter which may or may not depend on config. - * - * @param name - * The symbolic name of this group of counters. - * @param manager - * the statistics manager acquired by injection - * @param fetchParametersFromConfig - * Whether this Group should be configured from config. - */ - public CounterGroup(String name, Statistics manager, - boolean fetchParametersFromConfig) { - this(name, manager, fetchParametersFromConfig, null, false); - } - - /** - * Create a group of counters with a callback included. - * - * @param name - * The symbolic name of this group of counters. - * @param manager - * the statistics manager acquired by injection - * @param fetchParametersFromConfig - * Whether this Group should be configured from config. - * @param callback - * will be invoked each time data is written to the log - * @param resetCounter - * Control for if this group should be reset between each - * logging interval. - */ - public CounterGroup(String name, Statistics manager, - boolean fetchParametersFromConfig, Callback callback, boolean resetCounter) { - - super(name, manager, callback); - if (fetchParametersFromConfig) { - StatisticsConfig config = manager.getConfig(); - this.resetCounter = getResetCounter(name, config); - } else { - this.resetCounter = resetCounter; - } - manager.register(this); - } - - private static boolean getResetCounter(String name, StatisticsConfig config) { - for (int i = 0; i < config.counterresets().size(); i++) { - String configName = config.counterresets(i).name(); - if (configName.equals(name)) { - return true; - } - } - return false; - } - - - /** - * Increment named contained counter by 1. - */ - public void increment(String name) { - Counter c = getCounter(name); - c.increment(); - } - - /** - * Increment named contained counter by n. - */ - public void increment(String name, long n) { - Counter c = getCounter(name); - c.increment(n); - } - - /** - * Get a counter with a given name, creates a new counter if no - * counter with the name given exists. - */ - synchronized Counter getCounter(String name) { - Counter c = subEvents.get(name); - if (c == null) { - c = getNewCounter(name); - } - return c; - } - - private Counter getNewCounter(String subName) { - Counter c = Counter.intializeUnregisteredCounter(subName, resetCounter); - subEvents.put(subName, c); - return c; - } - - /** - * Dump contained counters to log and reset. - */ - @Override - public void runHandle() { - StringBuilder multi = new StringBuilder(); - CounterProxy[] proxies; - int i = 0; - - // this is to make sure the number of events does not change while logging - synchronized (this) { - proxies = new CounterProxy[subEvents.size()]; - i = 0; - for (Iterator<Counter> j = subEvents.values().iterator(); j - .hasNext();) { - Counter c = j.next(); - proxies[i] = c.getProxyAndReset(); - i++; - } - } - - while (i > 0) { - i--; - if (multi.length() > 0) { - multi.append(", "); - } - multi.append(proxies[i].getName()); - multi.append("="); - multi.append(proxies[i].getRaw()); - } - - Event.countGroup(getName(), multi.toString()); - } - - @Override - public boolean equals(Object o) { - if (o.getClass() != this.getClass()) { - return false; - } - CounterGroup other = (CounterGroup) o; - return getName().equals(other.getName()); - } - - @Override - public int hashCode() { - return getName().hashCode() + 31 * "CounterGroup".hashCode(); - } -} - diff --git a/statistics/src/main/java/com/yahoo/statistics/CounterProxy.java b/statistics/src/main/java/com/yahoo/statistics/CounterProxy.java deleted file mode 100644 index da8a029982a..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/CounterProxy.java +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -/** - * To be able to cache events concerning Counters internally, group them - * together and similar. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -class CounterProxy extends Proxy { - private long raw; - private boolean hasRaw = false; - - CounterProxy(String name) { - super(name); - } - - boolean hasRaw() { - return hasRaw; - } - long getRaw() { - return raw; - } - void setRaw(long raw) { - hasRaw = true; - this.raw = raw; - } - -} - diff --git a/statistics/src/main/java/com/yahoo/statistics/Group.java b/statistics/src/main/java/com/yahoo/statistics/Group.java deleted file mode 100644 index 2935521b1e0..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Group.java +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -/** - * The base class for groups of counters and values. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -abstract class Group extends Handle { - Group(String name, Statistics manager, Callback parametrizedCallback) { - super(name, manager, parametrizedCallback); - } -} diff --git a/statistics/src/main/java/com/yahoo/statistics/Handle.java b/statistics/src/main/java/com/yahoo/statistics/Handle.java deleted file mode 100644 index d1ad0e26f40..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Handle.java +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import java.util.TimerTask; - -/** - * Base class for the interface to the statistics framework. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -public abstract class Handle { - - private TimerTask task; - - private final String name; - private boolean cancelled; - private final Statistics manager; - private final Callback parametrizedCallback; - private boolean firstTime; - - Handle(String name, Statistics manager, Callback parametrizedCallback) { - this.name = name; - this.manager = manager; - this.parametrizedCallback = parametrizedCallback; - firstTime = true; - } - - String getName() { - return name; - } - - TimerTask makeTask() { - final Handle self = this; - synchronized (self) { - if (task != null) { - task.cancel(); - } - task = new TimerTask() { - public void run() { - self.run(); - } - }; - return task; - } - } - - /** - * Run the callback object. - * - * This will happen at the start of each invocation of a Handle's - * run() method. The callback is presumed to be exception safe. - * If no callback is set, this is a no-op. The callback will need - * to handle any necessary synchronization itself. - */ - public final void runCallback() { - if (parametrizedCallback == null) { - return; - } - parametrizedCallback.run(this, firstTime); - firstTime = false; - } - - /** - * Run the callback object first, then invoke runHandle(). - */ - public final void run() { - runCallback(); - runHandle(); - } - - /** - * Invoke an action to be performed periodically for a statistics Handle. - * - * <p>Synchronization has to be handled by the method itself. - */ - public abstract void runHandle(); - - /** - * Cancel this Handle and remove it from internal state in Statistics. - * - * @return value of java.util.TimerTask.cancel() - */ - public final boolean cancel() { - boolean ok = (task == null ? false : task.cancel()); - cancelled = true; - manager.purge(); - return ok; - } - - /** - * Returns whether this object has been cancelled or not. - * - * @return true if cancelled - */ - public final boolean isCancelled() { - return cancelled; - } - - @Override - public abstract boolean equals(Object o); - - @Override - public abstract int hashCode(); -} diff --git a/statistics/src/main/java/com/yahoo/statistics/Histogram.java b/statistics/src/main/java/com/yahoo/statistics/Histogram.java deleted file mode 100644 index 98330e80efc..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Histogram.java +++ /dev/null @@ -1,240 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -import java.util.ArrayDeque; -import java.util.Deque; -import java.util.Iterator; -import java.util.List; -import java.util.ArrayList; - -/** - * A set of sums or other histograms. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -public class Histogram implements Bucket { - // The upper and lower limit for the bucket in another histogram - // this histogram represents. The "outermost" histogram in a - // multidimensional histogram will effectively ignore this, but set - // them to -Inf and Inf for consistency. - private final double lower; - private final double upper; - - // The names of all the axes, only used in "outermost" histogram in - // multi dimensional histogram. - private String axes = null; - - private List<Bucket> buckets = new ArrayList<>(); - - /** - * Build a new histogram using bucket limits from the given Limits - * object. - */ - public Histogram(Limits limits) { - // lower and upper will never be used here, - // but it's nicer with defined values - this(limits, 0, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY); - - // generate axis names, but only if there is more than one - int guard = limits.getDimensions(); - if (guard == 1) { - return; - } - StringBuffer names = new StringBuffer(); - int i = 0; - while (i < guard) { - names.append(limits.getAxis(i).getName()); - i++; - if (i < guard) { - names.append(","); - } - } - axes = names.toString(); - } - - private Histogram(Limits limits, int dim, double lower, double upper) { - this.lower = lower; - this.upper = upper; - // last axis, create sum objects instead of histograms - boolean lastAxis = dim == (limits.getDimensions() - 1); - Axis next = limits.getAxis(dim); - double[] delimiters = next.getLimits(); - int i = 0; - double previousBucket = Double.NEGATIVE_INFINITY; - dim++; - while (i < delimiters.length) { - if (lastAxis) { - buckets.add(new Sum(previousBucket, delimiters[i])); - } else { - buckets.add(new Histogram(limits, dim, - previousBucket, delimiters[i])); - } - previousBucket = delimiters[i]; - i++; - } - if (lastAxis) { - buckets.add(new Sum(previousBucket, Double.POSITIVE_INFINITY)); - } else { - buckets.add(new Histogram(limits, dim, - previousBucket, - Double.POSITIVE_INFINITY)); - } - - } - - /** - * Increment the corresponding bucket for this data point by 1. - */ - public synchronized void put(double[] value) { - put(value, 0); - } - - /** - * Increment the corresponding bucket for this data point by 1. - * - * @param dim the index of the first value to consider in value array - */ - @Override - public void put(double[] value, int dim) { - Bucket bucket = findBucket(0, buckets.size(), value[dim]); - bucket.put(value, ++dim); - } - - private Bucket findBucket(int offset, int limit, double value) { - int index = offset + (limit - offset) / 2; - Bucket bucket = buckets.get(index); - if (bucket.lowerLimit() <= value && value < bucket.upperLimit()) { - return bucket; - } else if (bucket.upperLimit() <= value) { - return findBucket(index + 1, limit, value); - } else { // value < bucket.lowerLimit() - return findBucket(offset, index, value); - } - } - - @Override - public String toString() { - StringBuffer s; - int i, t; - - s = new StringBuffer(); - if (axes != null) { - s.append(axes).append(" "); - } - s.append("("); - s.append(buckets.get(0).toString()); - s.append(")"); - - t = buckets.size(); - i = 1; - while (i < t) { - Bucket b = buckets.get(i); - s.append(" < "); - s.append(b.lowerLimit()); - s.append(" ("); - s.append(b.toString()); - s.append(")"); - i += 1; - } - - return s.toString(); - } - - /** - * Reset all contained buckets. - */ - @Override - public void reset() { - for (Iterator<Bucket> i = buckets.iterator(); i.hasNext(); ) { - i.next().reset(); - } - } - - /** - * The lower limit for the bucket this histogram represents. - * - * @return the lower limit for the bucket this histogram represents - */ - @Override - public double lowerLimit() { - return lower; - } - - /** - * The upper limit for the bucket this histogram represents. - * - * @return the upper limit for the bucket this histogram represents - */ - @Override - public double upperLimit() { - return upper; - } - - @Override - public List<Bucket> getBuckets() { - return buckets; - } - - private List<Bucket> getLeaves() { - final class Bookmark { - final int i; - final List<Bucket> buckets; - Bookmark(int i, List<Bucket> buckets) { - this.i = i; - this.buckets = buckets; - } - } - List<Bucket> sums = new ArrayList<>(); - Deque<Bookmark> stack = new ArrayDeque<>(); - List<Bucket> current; - int i = 0; - stack.addFirst(new Bookmark(i, buckets)); - while (stack.size() > 0) { - Bookmark currentMark = stack.removeFirst(); - i = currentMark.i; - current = currentMark.buckets; - while (i < current.size()) { - Bucket b = current.get(i++); - if (b.isLeaf()) { - sums.add(b); - } else { - Bookmark marker = new Bookmark(i, current); - stack.addFirst(marker); - i = 0; - current = b.getBuckets(); - } - } - } - return sums; - } - - void merge(Histogram source) { - List<Bucket> src = source.getLeaves(); - List<Bucket> dst = getLeaves(); - if (dst.size() != src.size()) { - throw new IllegalStateException( - "Number of buckets in destination and source not equal. (Source " - + src.size() + ", destination " + dst.size() + "."); - } - for (int i = 0; i < dst.size(); ++i) { - dst.get(i).add(src.get(i).getSum()); - } - } - - @Override - public long getSum() { - throw new RuntimeException("Not implemented."); - } - - @Override - public boolean isLeaf() { - return false; - } - - @Override - public void add(long n) { - throw new IllegalStateException("Can not add directly to a Histogram instance."); - } -} diff --git a/statistics/src/main/java/com/yahoo/statistics/HistogramType.java b/statistics/src/main/java/com/yahoo/statistics/HistogramType.java deleted file mode 100644 index cc7ca04dbbf..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/HistogramType.java +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -/** - * Enumeration of how a histogram should be represented from - * admin server. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -public final class HistogramType { - private final String representation; - - private HistogramType(String representation) { - this.representation = representation; - } - - public String toString() { return representation; } - - /** - * Basic histograms, each bucket is count representing the bucket's - * defined interval. - */ - public static final HistogramType REGULAR = new HistogramType("REGULAR"); - - /** - * Cumulative histograms, that is, a given bucket contains the count - * for values corresponding to "itself" and all preceding buckets. - */ - public static final HistogramType CUMULATIVE = - new HistogramType("CUMULATIVE"); - - - /** - * Reverse cumulative histograms, that is, a given bucket contains - * the count for values corresponding to "itself" and all following - * buckets. - */ - public static final HistogramType REVERSE_CUMULATIVE = - new HistogramType("REVERSE_CUMULATIVE"); - -} diff --git a/statistics/src/main/java/com/yahoo/statistics/Limits.java b/statistics/src/main/java/com/yahoo/statistics/Limits.java deleted file mode 100644 index fc79fd00d19..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Limits.java +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -import java.util.List; -import java.util.ArrayList; - - -/** - * Limits for a histogram, this is only a wrapper for initializing - * a histogram. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -public class Limits { - private final List<Axis> axes = new ArrayList<>(1); - private boolean frozen = false; - - /** - * Create an empty Limits instance. - */ - public Limits() { - } - - /** - * Create a Limits instance suitable for use in a Value.Parameters instance. - * The instance will be frozen. - */ - public Limits(double[] limits) { - addAxis(null, limits); - freeze(); - } - - /** - * @param name the name of the variable for this axis - * @param limits the bucket limits for this axis - */ - public void addAxis(String name, double[] limits) { - if (frozen) { - throw new IllegalStateException("Can not add more axes to a frozen Limits instance."); - } - axes.add(new Axis(name, limits)); - } - - int getDimensions() { - return axes.size(); - } - - Axis getAxis(int i) { - return axes.get(i); - } - - /** - * Prevent adding any mores axes. - */ - public void freeze() { - this.frozen = true; - } - - /** - * True if further change is not permitted. - * - * @return whether this object now should be considered immutable - */ - public boolean isFrozen() { - return frozen; - } - -} diff --git a/statistics/src/main/java/com/yahoo/statistics/Proxy.java b/statistics/src/main/java/com/yahoo/statistics/Proxy.java deleted file mode 100644 index c4146f4dbf8..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Proxy.java +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -/** - * Base class for event proxies, which are used to cache and group - * events internally. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -abstract class Proxy { - private long timestamp; - private String name; - - Proxy(String name) { - this(name, System.currentTimeMillis()); - } - - Proxy(String name, long timestamp) { - this.timestamp = timestamp; - this.name = name; - } - - long getTimestamp() { - return timestamp; - } - - String getName() { - return name; - } -} diff --git a/statistics/src/main/java/com/yahoo/statistics/SampleDirectory.java b/statistics/src/main/java/com/yahoo/statistics/SampleDirectory.java deleted file mode 100644 index bac08fe17b6..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/SampleDirectory.java +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import java.util.ArrayList; -import java.util.List; - -/** - * Book-keeping class to know which SampleSet instances have unlogged data. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -final class SampleDirectory { - private final Object directoryLock = new Object(); - private List<SampleSet> directory = new ArrayList<>(200); - - void put(SampleSet s) { - synchronized (directoryLock) { - directory.add(s); - s.setRegisteredForLogging(true); - } - } - - /** - * Get a view of the current generation of data and instantiate a new - * generation. This does the memory barrier two-step for the - * client. - */ - SampleSet.Sampling[] fetchValues() { - SampleSet.Sampling[] copyToReturn; - synchronized (directoryLock) { - List<SampleSet> tmpDir = directory; - copyToReturn = new SampleSet.Sampling[tmpDir.size()]; - List<SampleSet> newDir = new ArrayList<>(200); - for (int i = 0; i < copyToReturn.length; ++i) { - copyToReturn[i] = tmpDir.get(i).getAndReset(); - } - directory = newDir; - } - return copyToReturn; - } - - /** - * Return a view of the current generation of data. This does the memory - * barrier two-step for the client. - */ - SampleSet.Sampling[] viewValues() { - SampleSet.Sampling[] copy; - synchronized (directoryLock) { - copy = new SampleSet.Sampling[directory.size()]; - for (int i = 0; i < copy.length; ++i) { - copy[i] = directory.get(i).values; - } - } - return copy; - } - -} diff --git a/statistics/src/main/java/com/yahoo/statistics/SampleSet.java b/statistics/src/main/java/com/yahoo/statistics/SampleSet.java deleted file mode 100644 index 768ae1433ea..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/SampleSet.java +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -/** - * A running set of samples for a Value instance. It is - * used only in a very specific context between the sampling threads (each instance - * is only used by on sampling thread) and the single logging thread. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -final class SampleSet { - Sampling values; - final Limits histogramLimits; - private boolean isRegisteredForLogging = false; - - SampleSet(Limits histogramLimits) { - this.histogramLimits = histogramLimits; - values = new Sampling(0.0d, 0L, 0.0d, 0.0d, histogramLimits); - } - - static final class Sampling { - final double sum; - final long insertions; - final double max; - final double min; - final Histogram histogram; - - Sampling(double sum, long insertions, double max, double min, Limits histogramLimits) { - if (histogramLimits != null) { - this.histogram = new Histogram(histogramLimits); - } else { - this.histogram = null; - } - this.sum = sum; - this.insertions = insertions; - this.max = max; - this.min = min; - } - - Sampling(double sum, long insertions, double max, double min, Histogram histogram) { - this.histogram = histogram; - this.sum = sum; - this.insertions = insertions; - this.max = max; - this.min = min; - } - } - - - private Sampling createSampling(double x, Sampling previous) { - double sum = previous.sum; - long insertions = previous.insertions; - double max = previous.max; - double min = previous.min; - - sum += x; - if (insertions == 0) { - max = x; - min = x; - } else { - max = Math.max(x, max); - min = Math.min(x, min); - } - insertions++; - return new Sampling(sum, insertions, max, min, previous.histogram); - } - - /** - * Insert x, do all pertinent operations. (Update histogram, update - * insertion count for calculating mean, etc.) - * - * @return whether this is registered for logging - */ - synchronized boolean put(double x) { - Sampling previous = values; - Histogram histogram = previous.histogram; - if (histogram != null) { - histogram.put(new double[] {x}); - } - values = createSampling(x, previous); - return isRegisteredForLogging; - } - - /** - * Get state and reset it. - */ - synchronized Sampling getAndReset() { - Sampling previous = values; - values = new Sampling(0.0d, 0L, 0.0d, 0.0d, histogramLimits); - setRegisteredForLogging(false); - return previous; - } - - // Setting this state is protected by SampleDirectory.directoryLock. It is - // either set from the logging thread (protected by directoryLock and using - // "this" as a memory barrier through getAndReset()), or from the sampling - // thread protected by directoryLock and without a mem barrier. - void setRegisteredForLogging(boolean isRegisteredForLogging) { - this.isRegisteredForLogging = isRegisteredForLogging; - } - -} diff --git a/statistics/src/main/java/com/yahoo/statistics/Statistics.java b/statistics/src/main/java/com/yahoo/statistics/Statistics.java deleted file mode 100644 index 92d320e0647..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Statistics.java +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import com.yahoo.container.StatisticsConfig; - -/** - * Interface used for registering statistics values and counters for logging. - * - * @author steinar - * @author Tony Vaagenes - * @deprecated Will be removed on Vespa 8. If required by a method, there exists an alternative to be used instead. - */ -@Deprecated -public interface Statistics { - /** - * Add a new handle to be scheduled for periodic logging. If a handle - * already exists with the same name, it will be cancelled and removed from - * the internal state of this object. - */ - void register(Handle h); - - /** - * Remove a named handler from the set of working handlers. - */ - void remove(String name); - - /** - * Get current config used. This may be a null reference, depending on how - * the instance was constructed. - */ - StatisticsConfig getConfig(); - - /** - * Purges all cancelled Handles from internal Map and Timer. - * - * @return return value from java.util.Timer.purge() - */ - int purge(); - - /** A null implementation which ignores all calls and returns the default config */ - public static Statistics nullImplementation=new NullImplementation(); - - static class NullImplementation implements Statistics { - - private StatisticsConfig nullConfig=new StatisticsConfig(new StatisticsConfig.Builder()); - - @Override - public void register(Handle h) { } - - @Override - public void remove(String name) { } - - @Override - public StatisticsConfig getConfig() { return nullConfig; } - - @Override - public int purge() { return 0; } - - } - -} diff --git a/statistics/src/main/java/com/yahoo/statistics/StatisticsImpl.java b/statistics/src/main/java/com/yahoo/statistics/StatisticsImpl.java deleted file mode 100644 index f3a0b23a551..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/StatisticsImpl.java +++ /dev/null @@ -1,154 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Timer; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.yahoo.component.AbstractComponent; -import com.yahoo.container.StatisticsConfig; - -/** - * Centralized book keeping for statistics module. Times logging and reads - * config. It is normally obtained through injection, but may be initialized - * manually for testing or when an injection mechanism is unavailable. Logging - * will be disabled by initializing the Statistics class with a null config - * object. - * - * @author Steinar Knutsen - */ -@SuppressWarnings("deprecation") -public final class StatisticsImpl extends AbstractComponent implements Statistics { - - private final Timer worker; - private final StatisticsConfig config; - private static final Logger log = Logger.getLogger(StatisticsImpl.class.getName()); - private final int collectioninterval; - private final int logginginterval; - // default access for testing only - final Map<String, Handle> handles = new HashMap<>(); - - /** - * Build a statistics manager based on the given config values. Use a config - * builder for testing if logging is necessary, set the config argument to - * the constructor to null is logging is not necessary. - * - * @since 5.1.4 - * @param config - * settings for logging interval and configured events. Setting - * it to null disables logging. - * @throws IllegalArgumentException - * if logging interval is smaller than collection interval, or - * collection interval is not a multiplum of logging interval - */ - public StatisticsImpl(StatisticsConfig config) { - int l = (int) config.loggingintervalsec(); - int c = (int) config.collectionintervalsec(); - - if (l != 0 && l < c) { - throw new IllegalArgumentException( - "Logging interval (" + l + ") smaller than collection interval (" + c + ")." - + " New config ignored."); - } - if ((l % c) != 0) { - throw new IllegalArgumentException( - "Collection interval (" + c + ") not multiplum of logging interval (" + l + ")." - + " New config ignored."); - } - this.logginginterval = l; - this.collectioninterval = c; - this.config = config; - this.worker = new Timer(true); - } - - /** - * Cancel internal worker thread and do any other necessary cleanup. The - * internal worker thread is a daemon thread, so not calling this will not - * hamper a clean exit from the VM. - */ - @Override - public void deconstruct() { - worker.cancel(); - } - - private void schedule(Handle h) { - if (logginginterval != 0) { - h.run(); - // We use the rather creative assumption that there is - // exactly 24h pr day+night. - final Date d = new Date(); - final long ms = collectioninterval * 1000L; - final long delay = ms - (d.getTime() % (ms)); - worker.scheduleAtFixedRate(h.makeTask(), delay, ms); - } - } - - /** - * Add a new handle to be scheduled for periodic logging. If a handle - * already exists with the same name, it will be cancelled and removed from - * the internal state of this object. - */ - @Override - public void register(Handle h) { - synchronized (handles) { - Handle oldHandle = handles.get(h.getName()); - if (oldHandle == h) { - log.log(Level.WARNING, "Handle [" + h + "] already registered"); - return; - } - if (oldHandle != null) { - oldHandle.cancel(); - } - handles.put(h.getName(), h); - if (worker != null) { - schedule(h); - } - } - } - - /** - * Remove a named handler from the set of working handlers. - */ - @Override - public void remove(String name) { - synchronized (handles) { - Handle oldHandle = handles.remove(name); - if (oldHandle != null) { - oldHandle.cancel(); - } - } - } - - /** - * Get current config used. This may be a null reference, depending on how - * the instance was constructed. - */ - @Override - public StatisticsConfig getConfig() { - return config; - } - - /** - * Purges all cancelled Handles from internal Map and Timer. - * - * @return return value from java.util.Timer.purge() - */ - @Override - public int purge() { - synchronized (handles) { - Iterator<Handle> it = handles.values().iterator(); - while (it.hasNext()) { - final Handle h = it.next(); - if (h.isCancelled()) { - it.remove(); - } - } - return worker == null ? 0 : worker.purge(); - } - } - -} diff --git a/statistics/src/main/java/com/yahoo/statistics/Sum.java b/statistics/src/main/java/com/yahoo/statistics/Sum.java deleted file mode 100644 index 5661e82cf1b..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Sum.java +++ /dev/null @@ -1,75 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import java.util.List; - - -/** - * The innermost part of a histogram, a bucket which only contains a - * counter. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -class Sum implements Bucket { - private long sum = 0L; - private double lower; - private double upper; - - Sum(double lower, double upper) { - this.lower = lower; - this.upper = upper; - } - - /** - * Increment this bucket. - */ - public void put(double[] value, int dim) { - sum += 1; - } - - /** - * Set this bucket's count to 0. - */ - public void reset() { - sum = 0L; - } - - /** - * The lower limit for values counted by this bucket. - */ - public double lowerLimit() { - return lower; - } - - /** - * The upper limit for values counted by this bucket. - */ - public double upperLimit() { - return upper; - } - - public String toString() { - return Long.toString(sum); - } - - @Override - public List<Bucket> getBuckets() { - return null; - } - - @Override - public boolean isLeaf() { - return true; - } - - @Override - public long getSum() { - return sum; - } - - @Override - public void add(long n) { - sum += n; - } -} diff --git a/statistics/src/main/java/com/yahoo/statistics/Value.java b/statistics/src/main/java/com/yahoo/statistics/Value.java deleted file mode 100644 index 9b41f526f13..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/Value.java +++ /dev/null @@ -1,765 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import java.util.HashMap; -import java.util.List; -import java.util.logging.Logger; - -import com.yahoo.container.StatisticsConfig; -import com.yahoo.container.StatisticsConfig.Values.Operations; -import java.util.logging.Level; - -/** - * A statistical variable, typically representing a sampling of an - * arbitrarily changing parameter. - * - * @author Steinar Knutsen - */ -@Deprecated -public class Value extends Handle { - - // For accumulated values, SampleSet instances are mem barriers between {n - // sampling threads} and {logging thread}. - - // lastValue is a memory barrier between {n sampling threads} and {n - // sampling threads, logging thread}. - - // Therefore, the logging thread first locks SampleDirectory.directoryLock, - // then locks each SampleSet, one by one. The sampling threads _either_ lock - // a single SampleSet _or_ lock SampleDirectory.directoryLock. - - // It is necessary to create a memory relationship between the logging - // threads to ensure the newest sample ends up in the log for logRaw = true. - - private final ThreadLocal<SampleSet> sample = new ThreadLocal<>(); - private final SampleDirectory directory = new SampleDirectory(); - - // This must _only_ be touched if logRaw is true - private volatile double lastValue = 0.0d; - - private final boolean logRaw; - private final boolean logMean; - private final boolean logSum; - private final boolean logInsertions; - private final boolean logMax; - private final boolean logMin; - private final boolean logHistogram; - - private final Limits histogram; - final HistogramType histogramId; - - private static final Logger log = Logger.getLogger(Value.class.getName()); - static final String HISTOGRAM_TYPE_WARNING = "Histogram types other than REGULAR currently not supported." - +" Reverting to regular histogram for statistics event"; - - /** - * Parameters for building Value instances. All settings are classes instead - * of primitive types to allow tri-state logic (true, false, unset). - */ - public static class Parameters { - /** - * Log raw values. Raw values are basically the last value logged. - */ - Boolean logRaw; - /** - * Log the sum of all data points for each interval. - */ - Boolean logSum; - /** - * Log the mean value for each interval. - */ - Boolean logMean; - /** - * Log the maximal value observed for each interval. - */ - Boolean logMax; - /** - * Log the minimal value observed for each interval. - */ - Boolean logMin; - /** - * Log the number of observations for each interval. - */ - Boolean logInsertions; - /** - * Whether or not to add an identifying extension (like mean) to event - * names when logging derived values. - * - * It is useful to disable extensions if a only a single dervied value, - * e.g. the mean, is the only thing to be logged. The default is to use - * extensions. - * - * If extensions are disabled, the ability to log more than one of raw - * value, min, max, mean (i.e. the raw value and derived values of the - * same type) is disabled to avoid confusion. Since histograms are not - * Value events, these never have a name extension and are always - * available. - */ - Boolean nameExtension; - /** - * Log a data histogram. - */ - Boolean logHistogram; - /** - * What kind of histogram to log. - * - * @see HistogramType - */ - HistogramType histogramId; - /** - * The limits to use if logging as a histogram. The Limits instance must - * be frozen before using the Parameters instance in a Value constructor - * call. - * - * @see Limits - */ - Limits limits; - /** - * Separator character to use between event name and type of - * nameExtension is set to true. - */ - Character appendChar; - - /** - * This is invoked each time a value is dumped to the log. - * - * @see Handle#runCallback() - */ - Callback callback; - - /** - * Whether to register in the Statistics manager. This is not touched by - * merge and also has no undefined state. In general, a Value should - * always register and not doing so explicitly should not be part of the - * public API. - */ - private boolean register = true; - - /** - * Get a fresh Parameters instance with all features turned/unset. - * Parameters instances may be recycled for construction multiple Value - * instances, but do note any Limits instance added must be frozen. - */ - public Parameters() { - } - - /** - * (De-)Activate logging of raw values. Raw values are basically the - * last value logged. - * - * @return "this" for call chaining - */ - public Parameters setLogRaw(Boolean logRaw) { - this.logRaw = logRaw; - return this; - } - - /** - * (De-)Activate logging the sum of all data points for each interval. - * - * @return "this" for call chaining - */ - public Parameters setLogSum(Boolean logSum) { - this.logSum = logSum; - return this; - } - - /** - * (De)-activate loging the mean value for each interval. - * - * @return "this" for call chaining - */ - public Parameters setLogMean(Boolean logMean) { - this.logMean = logMean; - return this; - } - - /** - * (De-)Activate logging the maximal value observed for each interval. - * - * @return "this" for call chaining - */ - public Parameters setLogMax(Boolean logMax) { - this.logMax = logMax; - return this; - } - - /** - * (De-)Activate logging the minimal value observed for each interval. - * - * @return "this" for call chaining - */ - public Parameters setLogMin(Boolean logMin) { - this.logMin = logMin; - return this; - } - - /** - * (De-)Activate loging the number of observations for each interval. - * - * @return "this" for call chaining - */ - public Parameters setLogInsertions(Boolean logInsertions) { - this.logInsertions = logInsertions; - return this; - } - - /** - * Whether or not to add an identifying extension (like mean) to event - * names when logging derived values. - * - * It is useful to disable extensions if a only a single dervied value, - * e.g. the mean, is the only thing to be logged. The default is to use - * extensions. - * - * If extensions are disabled, the ability to log more than one of raw - * value, min, max, mean (i.e. the raw value and derived values of the - * same type) is disabled to avoid confusion. Since histograms are not - * Value events, these never have a name extension and are always - * available. - * - * @return "this" for call chaining - */ - public Parameters setNameExtension(Boolean nameExtension) { - this.nameExtension = nameExtension; - return this; - } - - /** - * (De-)Activate logging a data histogram. - * - * @return "this" for call chaining - */ - public Parameters setLogHistogram(Boolean logHistogram) { - this.logHistogram = logHistogram; - return this; - } - - /** - * What kind of histogram to log. - * - * @see HistogramType - * - * @return "this" for call chaining - */ - public Parameters setHistogramId(HistogramType histogramId) { - this.histogramId = histogramId; - return this; - } - - /** - * The limits to use if logging as a histogram. The Limits instance must - * be frozen before using the Parameters instance in a Value constructor - * call. - * - * @return "this" for call chaining* - * @see Limits - */ - public Parameters setLimits(Limits limits) { - this.limits = limits; - return this; - } - - /** - * Separator character to use between event name and type of - * nameExtension is set to true. The default is '.'. - * - * @return "this" for call chaining - */ - public Parameters setAppendChar(Character appendChar) { - this.appendChar = appendChar; - return this; - } - - /** - * Set a callback to be invoked each time this Value is written to the - * log. - * - * @param callback - * to be invoked each time the Value is written to the log - * @return "this" for call chaining - */ - public Parameters setCallback(Callback callback) { - this.callback = callback; - return this; - } - - /** - * Set whether to register in the statistics manager. Do note the - * package private access for this method opposed to all the other - * setters. - * - * @param register - * set to false to avoid registering - * @return "this" for call chaining - */ - private Parameters setRegister(boolean register) { - this.register = register; - return this; - } - - /** - * If a member is not set in this, add it from defaults. Do note, this - * applies for both true and false settings, in other words, the default - * may also be used to turn off something if it is undefined in this. - */ - void merge(Parameters defaults) { - if (defaults == null) { - return; - } - this.logRaw = this.logRaw == null ? defaults.logRaw : this.logRaw; - this.logSum = this.logSum == null ? defaults.logSum : this.logSum; - this.logMean = this.logMean == null ? defaults.logMean - : this.logMean; - this.logMax = this.logMax == null ? defaults.logMax : this.logMax; - this.logMin = this.logMin == null ? defaults.logMin : this.logMin; - this.logInsertions = this.logInsertions == null ? defaults.logInsertions - : this.logInsertions; - this.nameExtension = this.nameExtension == null ? defaults.nameExtension - : this.nameExtension; - this.logHistogram = this.logHistogram == null ? defaults.logHistogram - : this.logHistogram; - this.histogramId = this.histogramId == null ? defaults.histogramId - : this.histogramId; - this.limits = this.limits == null ? defaults.limits : this.limits; - this.appendChar = this.appendChar == null ? defaults.appendChar - : this.appendChar; - this.callback = this.callback == null ? defaults.callback - : this.callback; - } - - } - - /** - * Configure a Value instance fully, no raw config access. - * - * @param name - * tag for logging - * @param manager - * the statistics manager acquired by injection - * @param parameters - * all the parameters necessary for initializing a Value - * @throws IllegalStateException - * if Parameters.limits exists and is not frozen - */ - public Value(String name, Statistics manager, Parameters parameters) { - super(name, manager, parameters.callback); - this.logHistogram = isTrue(parameters.logHistogram); - this.logMax = isTrue(parameters.logMax); - this.logMean = isTrue(parameters.logMean); - this.logMin = isTrue(parameters.logMin); - this.logRaw = isTrue(parameters.logRaw); - this.logSum = isTrue(parameters.logSum); - this.logInsertions = isTrue(parameters.logInsertions); - if (logHistogram) { - if (!parameters.limits.isFrozen()) { - throw new IllegalStateException("The Limits instance must be frozen."); - } - if (parameters.histogramId != HistogramType.REGULAR) { - log.log(Level.WARNING, HISTOGRAM_TYPE_WARNING + " '" + name + "'"); - } - this.histogramId = HistogramType.REGULAR; - this.histogram = parameters.limits; - } else { - this.histogram = null; - this.histogramId = HistogramType.REGULAR; - } - - if (parameters.register) { - manager.register(this); - } - } - - private static boolean isTrue(Boolean b) { - return b != null && b; - } - - /** - * Build a Value which should be initialized from config. - * - * @param name - * the name of the event in the log - * @param manager - * the current Statistics manager, acquired by injection - * @param defaults - * defaults for values not defined by config, this may be null - */ - public static Value buildValue(String name, Statistics manager, Parameters defaults) { - return new Value(name, manager, buildParameters(name, manager, defaults)); - } - - /** - * Get a Value instance not registered in the statistics manager. This is - * used by ValueGroup and should not be made public. - * - * @param name - * The name of this counter, for use in logging. - * @param parameters - * setting for the new Value - */ - static Value initializeUnregisteredValue(String name, Parameters parameters) { - return new Value(name, null, parameters.setRegister(false)); - } - - private static Parameters buildParameters(String name, Statistics manager, Parameters defaults) { - Parameters p = null; - StatisticsConfig config = manager.getConfig(); - if (config != null) { - for (int i = 0; i < config.values().size(); i++) { - String configName = config.values(i).name(); - if (configName.equals(name)) { - p = parametersFromConfig(config.values(i).operations()); - break; - } - } - } - if (p == null) { - if (defaults == null) { - p = defaultParameters(); - } else { - p = defaults; - } - } else { - p.merge(defaults); - } - return p; - } - - static Parameters defaultParameters() { - return new Parameters().setLogRaw(true).setNameExtension(true); - } - - private static Parameters parametersFromConfig(List<Operations> o) { - Parameters p = new Parameters().setNameExtension(true); - - for (Operations operation : o) { - Operations.Name.Enum opName = operation.name(); - - HashMap<String, String> args = new HashMap<>(); - for (int j = 0; j < operation.arguments().size(); j++) { - args.put(operation.arguments(j).key(), operation.arguments(j).value()); - } - - if (opName == Operations.Name.MEAN) { - p.setLogMean(true); - } else if (opName == Operations.Name.MAX) { - p.setLogMax(true); - } else if (opName == Operations.Name.MIN) { - p.setLogMin(true); - } else if (opName == Operations.Name.RAW) { - p.setLogRaw(true); - } else if (opName == Operations.Name.SUM) { - p.setLogSum(true); - } else if (opName == Operations.Name.INSERTIONS) { - p.setLogInsertions(true); - } else if (opName == Operations.Name.REGULAR) { - p.setLogHistogram(true); - p.setHistogramId(HistogramType.REGULAR); - p.setLimits(initHistogram(args.get("axes"), args.get("limits"))); - } else if (opName == Operations.Name.CUMULATIVE) { - p.setLogHistogram(true); - p.setHistogramId(HistogramType.CUMULATIVE); - p.setLimits(initHistogram(args.get("axes"), args.get("limits"))); - } else if (opName == Operations.Name.REVERSE_CUMULATIVE) { - p.setLogHistogram(true); - p.setHistogramId(HistogramType.REVERSE_CUMULATIVE); - p.setLimits(initHistogram(args.get("axes"),args.get("limits"))); - } - } - return p; - } - - private static Limits initHistogram(String axes, String limits) { - String[] borders; - double[] vanillaLimits; - Limits l = new Limits(); - int i = 0; - - if (axes != null) { - throw new RuntimeException("Config of multidimensional histograms not yet implemented."); - } - if (limits == null) { - throw new RuntimeException("Config of histograms needs a list of limits."); - } - borders = limits.split(","); - vanillaLimits = new double[borders.length]; - while (i < vanillaLimits.length) { - vanillaLimits[i] = Double.parseDouble(borders[i].trim()); - ++i; - } - l.addAxis(null, vanillaLimits); - l.freeze(); - return l; - } - - private SampleSet getSample() { - SampleSet s = sample.get(); - if (s == null) { - s = new SampleSet(histogram); - sample.set(s); - } - return s; - } - - private void putComposite(double x) { - SampleSet s = getSample(); - boolean isInDir = s.put(x); - if (!isInDir) { - directory.put(s); - } - } - - /** - * Insert x, do all pertinent operations. (Update histogram, update - * insertion count for calculating mean, etc.) - */ - public void put(double x) { - if (logComposite()) { - putComposite(x); - } - if (logRaw) { - lastValue = x; - } - } - - private boolean logComposite() { - return logMean || logMin || logMax || logSum || logInsertions || logHistogram; - } - - /** - * Get mean value since last reset. - */ - public double getMean() { - SampleSet.Sampling[] values = directory.viewValues(); - long insertions = 0L; - double sum = 0.0d; - for (var x : values) { - insertions += x.insertions; - sum += x.sum; - } - if (insertions == 0) { - return 0.0d; - } - return sum/insertions; - } - - /** - * Get minimal value logged since last reset. - */ - public double getMin() { - SampleSet.Sampling[] values = directory.viewValues(); - long insertions = 0L; - double min = 0.0d; - for (var x : values) { - if (x.insertions == 0) { - continue; - } - if (insertions == 0) { - min = x.min; - } else { - min = Math.min(x.min, min); - } - insertions += x.insertions; - } - return min; - } - - /** - * Get maximum value logged since last reset. - */ - public double getMax() { - SampleSet.Sampling[] values = directory.viewValues(); - long insertions = 0L; - double max = 0.0d; - for (var x : values) { - if (x.insertions == 0) { - continue; - } - if (insertions == 0) { - max = x.max; - } else { - max = Math.max(x.max, max); - } - insertions += x.insertions; - } - return max; - } - - private Histogram getHistogram() { - if (histogram == null) { - return null; - } else { - SampleSet.Sampling[] values = directory.viewValues(); - Histogram merged = new Histogram(histogram); - for (var s : values) { - merged.merge(s.histogram); - } - return merged; - } - } - - /** - * Get last value logged, 0 if nothing logged since reset. - */ - public double get() { - return lastValue; - } - - /** - * Set last value logged container to 0, reset histogram and set all - * counters and derived statistics to 0. - */ - public void reset() { - if (logComposite()) { - directory.fetchValues(); - } - if (logRaw) { - lastValue = 0.0d; - } - } - - /** - * Dump state to log and reset. - */ - @Override - public void runHandle() { - getAndSetCurrentState(); - } - - public String toString() { - if (histogram == null) { - return super.toString() + " " + getName(); - } else { - return super.toString() + " " + getName() + " " + getHistogram().toString(); - } - } - - @Override - public boolean equals(Object o) { - if (o.getClass() != this.getClass()) { - return false; - } - Value other = (Value) o; - return getName().equals(other.getName()); - } - - @Override - public int hashCode() { - return getName().hashCode() + 31 * "Value".hashCode(); - } - - static class Snapshot { - double insertions; - double max; - double min; - double mean; - double sum; - double raw; - Histogram histogram = null; - - Snapshot insertions(double lastInsertions) { - this.insertions = lastInsertions; - return this; - } - - Snapshot max(double lastMax) { - this.max = lastMax; - return this; - } - - Snapshot min(double lastMin) { - this.min = lastMin; - return this; - } - - Snapshot mean(double lastMean) { - this.mean = lastMean; - return this; - } - - Snapshot sum(double lastSum) { - this.sum = lastSum; - return this; - } - - Snapshot raw(double lastRaw) { - this.raw = lastRaw; - return this; - } - - Snapshot histogram(Histogram mergedHistogram) { - this.histogram = mergedHistogram; - return this; - } - } - - private Snapshot getAndSetCurrentState() { - double lastInsertions = 0L; - double lastMax = 0.0d; - double lastMin = 0.0d; - double lastMean = 0.0d; - double lastSum = 0.0d; - double lastRaw = 0.0d; - Histogram mergedHistogram = null; - - if (logRaw) { - lastRaw = lastValue; - } - if (logComposite()) { - SampleSet.Sampling[] lastInterval = directory.fetchValues(); - if (histogram != null) { - mergedHistogram = new Histogram(histogram); - } - for (var threadData : lastInterval) { - if (threadData.insertions == 0) { - continue; - } - if (lastInsertions == 0L) { - lastMax = threadData.max; - lastMin = threadData.min; - } else { - lastMax = Math.max(threadData.max, lastMax); - lastMin = Math.min(threadData.min, lastMin); - } - lastSum += threadData.sum; - if (mergedHistogram != null) { - mergedHistogram.merge(threadData.histogram); - } - lastInsertions += threadData.insertions; - } - if (lastInsertions == 0L) { - lastMean = 0.0d; - } else { - lastMean = lastSum / lastInsertions; - } - } - return new Snapshot().insertions(lastInsertions) - .max(lastMax).mean(lastMean).min(lastMin) - .raw(lastRaw).sum(lastSum) - .histogram(mergedHistogram); - } - - ValueProxy getProxyAndReset() { - ValueProxy p = new ValueProxy(getName()); - Snapshot now = getAndSetCurrentState(); - - if (logRaw) { - p.setRaw(now.raw); - } - if (logMean) { - p.setMean(now.mean); - } - if (logMin) { - p.setMin(now.min); - } - if (logMax) { - p.setMax(now.max); - } - if (logHistogram) { - p.setHistogram(now.histogram); - } - - return p; - } -} - diff --git a/statistics/src/main/java/com/yahoo/statistics/ValueGroup.java b/statistics/src/main/java/com/yahoo/statistics/ValueGroup.java deleted file mode 100644 index ea12c1e4c89..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/ValueGroup.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -import com.yahoo.log.event.Event; - -import java.util.Iterator; -import java.util.Map; -import java.util.HashMap; - -/** - * A set of related values which should be logged together. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@SuppressWarnings("removal") // TODO Vespa 8: remove (com.yahoo.log.event) -@Deprecated -public class ValueGroup extends Group { - // A map for names of subevents and Value instances - private Map<String, Value> subEvents = new HashMap<>(); - - /** - * Create a ValueGroup. - * - * @param name - * The symbolic name of this group of values - * @param manager - * the statistics manager acquired by injection - */ - public ValueGroup(String name, Statistics manager) { - this(name, manager, null); - } - - /** - * Create a ValueGroup. - * - * @param name - * The symbolic name of this group of values - * @param manager - * the statistics manager acquired by injection - * @param callback - * will be invoked each time data is written to the log - */ - public ValueGroup(String name, Statistics manager, Callback callback) { - super(name, manager, callback); - manager.register(this); - } - - /** - * Put a value into the named value in the group. - */ - public void put(String name, double x) { - Value v = getValue(name); - v.put(x); - } - - /** - * Get a value with a given name, creates a new value if no - * value with the name given exists. - * - */ - synchronized Value getValue(String name) { - Value v = subEvents.get(name); - if (v == null) { - v = getNewValue(name); - } - return v; - } - - private Value getNewValue(String subName) { - Value v = Value.initializeUnregisteredValue(subName, new Value.Parameters().setLogRaw(true)); - subEvents.put(subName, v); - return v; - } - - /** - * Dump state to log and reset. - */ - @Override - public void runHandle() { - StringBuilder multi = new StringBuilder(); - ValueProxy[] proxies; - int i = 0; - - synchronized (this) { - proxies = new ValueProxy[subEvents.size()]; - i = 0; - for (Iterator<Value> j = subEvents.values().iterator(); j.hasNext();) { - Value v = j.next(); - proxies[i] = v.getProxyAndReset(); - i++; - } - } - - while (i > 0) { - i--; - if (multi.length() > 0) { - multi.append(", "); - } - multi.append(proxies[i].getName()); - multi.append("="); - multi.append(proxies[i].getRaw()); - } - - Event.valueGroup(getName(), multi.toString()); - } - - @Override - public boolean equals(Object o) { - if (o.getClass() != this.getClass()) { - return false; - } - ValueGroup other = (ValueGroup) o; - return getName().equals(other.getName()); - } - - @Override - public int hashCode() { - return getName().hashCode() + 31 * "ValueGroup".hashCode(); - } -} diff --git a/statistics/src/main/java/com/yahoo/statistics/ValueProxy.java b/statistics/src/main/java/com/yahoo/statistics/ValueProxy.java deleted file mode 100644 index 3146dc7d2d7..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/ValueProxy.java +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -/** - * To be able to cache events concerning Values internally, group them - * together and similar. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@Deprecated -class ValueProxy extends Proxy { - private double raw; - private boolean hasRaw = false; - private double min; - private boolean hasMin = false; - private double mean; - private boolean hasMean = false; - private double max; - private boolean hasMax = false; - private Histogram histogram; - private boolean hasHistogram; - - ValueProxy(String name) { - super(name); - } - - boolean hasRaw() { - return hasRaw; - } - double getRaw() { - return raw; - } - void setRaw(double raw) { - hasRaw = true; - this.raw = raw; - } - - boolean hasMin() { - return hasMin; - } - double getMin() { - return min; - } - void setMin(double min) { - hasMin = true; - this.min = min; - } - - boolean hasMean() { - return hasMean; - } - double getMean() { - return mean; - } - void setMean(double mean) { - hasMean = true; - this.mean = mean; - } - - boolean hasMax() { - return hasMax; - } - double getMax() { - return max; - } - void setMax(double max) { - hasMax = true; - this.max = max; - } - - boolean hasHistogram() { - return hasHistogram; - } - Histogram getHistogram() { - return histogram; - } - void setHistogram(Histogram histogram) { - hasHistogram = true; - this.histogram = histogram; - } - -} - diff --git a/statistics/src/main/java/com/yahoo/statistics/package-info.java b/statistics/src/main/java/com/yahoo/statistics/package-info.java deleted file mode 100644 index bb861889d44..00000000000 --- a/statistics/src/main/java/com/yahoo/statistics/package-info.java +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -@ExportPackage -@PublicApi -package com.yahoo.statistics; - -import com.yahoo.api.annotations.PublicApi; -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/statistics/src/main/resources/configdefinitions/container.statistics.def b/statistics/src/main/resources/configdefinitions/container.statistics.def deleted file mode 100644 index 5f540241e35..00000000000 --- a/statistics/src/main/resources/configdefinitions/container.statistics.def +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -namespace=container - -## Interval between internal sample points measured in seconds -collectionintervalsec double default=300.0 - -## Interval between each dump to log measured in seconds -loggingintervalsec double default=300.0 - -## Configuration for measured values -values[].name string - -## An array of what operations should be performed on gathered data -values[].operations[].name enum { RAW, MEAN, MIN, MAX, REGULAR, CUMULATIVE, REVERSE_CUMULATIVE, SUM, INSERTIONS } default=RAW - -## Arguments for the operations, typically limits for arrays. -values[].operations[].arguments[].key string -values[].operations[].arguments[].value string - -## The counters which should be reset between each collection interval, -## and therefore be logged as values. -counterresets[].name string diff --git a/statistics/src/test/java/com/yahoo/statistics/CounterGroupTestCase.java b/statistics/src/test/java/com/yahoo/statistics/CounterGroupTestCase.java deleted file mode 100644 index c1899aa7e94..00000000000 --- a/statistics/src/test/java/com/yahoo/statistics/CounterGroupTestCase.java +++ /dev/null @@ -1,141 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -import java.util.Arrays; -import java.util.logging.Handler; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -import com.yahoo.container.StatisticsConfig; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -/** - * Test set for groups of counters. - * - * @author Steinar Knutsen - */ -@SuppressWarnings({"deprecation","removal"}) // TODO Vespa 8: remove -public class CounterGroupTestCase { - - private volatile boolean gotRecord = false; - - private class CounterGroupHandler extends Handler { - // This is for testing CounterProxy - @Override - public void publish(LogRecord record) { - com.yahoo.log.event.CountGroup msg = (com.yahoo.log.event.CountGroup) record.getParameters()[0]; - assertEquals("test", msg.getValue("name")); - String values = msg.getValue("values"); - assertFalse("Unexpected value for a.", values.indexOf("a=500") == -1); - assertFalse("Unexpected value for b.", values.indexOf("b=1") == -1); - assertFalse("Unexpected value for c.", values.indexOf("c=0") == -1); - gotRecord = true; - - } - - @Override - public void flush() { - } - - @Override - public void close() throws SecurityException { - } - } - - @Test - public void testBasic() { - Logger logger = Logger.getLogger(CounterGroup.class.getName()); - boolean initUseParentHandlers = logger.getUseParentHandlers(); - Handler logChecker = new CounterGroupHandler(); - logger.setUseParentHandlers(false); - CounterGroup c = new CounterGroup("test", Statistics.nullImplementation, false); - Counter n; - c.increment("a"); - c.increment("b"); - c.increment("a", 499); - n = c.getCounter("a"); - assertEquals(500, n.get()); - n = c.getCounter("b"); - assertEquals(1, n.get()); - n = c.getCounter("c"); - assertEquals(0, n.get()); - logger.addHandler(logChecker); - c.run(); - assertFalse("The logging handler did not really run.", gotRecord == false); - // cleanup: - logger.removeHandler(logChecker); - logger.setUseParentHandlers(initUseParentHandlers); - } - - @Test - public void testObjectContracts() { - CounterGroup c = new CounterGroup("test", Statistics.nullImplementation, false); - CounterGroup c2 = new CounterGroup("test", Statistics.nullImplementation, false); - c2.increment("nalle"); - assertEquals(c, c2); - assertEquals(c.hashCode(), c2.hashCode()); - c2 = new CounterGroup("nalle", Statistics.nullImplementation, false); - assertFalse("Different names should lead to different hashcodes", - c.hashCode() == c2.hashCode()); - assertFalse("Different names should lead to equals() return false", - c.equals(c2)); - } - - @Test - public void testConfigStuff() { - Logger logger = Logger.getLogger(CounterGroup.class.getName()); - boolean initUseParentHandlers = logger.getUseParentHandlers(); - logger.setUseParentHandlers(false); - MockStatistics m = new MockStatistics(); - final String joppe = "joppe"; - StatisticsConfig config = new StatisticsConfig( - new StatisticsConfig.Builder().counterresets(Arrays - .asList(new StatisticsConfig.Counterresets.Builder[] { - new StatisticsConfig.Counterresets.Builder().name(joppe) }))); - m.config = config; - CounterGroup c = new CounterGroup("nalle", m); - CounterGroup c2 = new CounterGroup(joppe, m); - final String bamse = "bamse"; - c.increment(bamse); - c2.increment(bamse); - assertEquals(1L, c.getCounter(bamse).get()); - assertEquals(1L, c2.getCounter(bamse).get()); - c2.increment(bamse); - assertEquals(1L, c.getCounter(bamse).get()); - assertEquals(2L, c2.getCounter(bamse).get()); - c.run(); - c2.run(); - assertEquals(1L, c.getCounter(bamse).get()); - assertEquals(0L, c2.getCounter(bamse).get()); - logger.setUseParentHandlers(initUseParentHandlers); - } - - public class MockStatistics implements Statistics { - public StatisticsConfig config = null; - public int registerCount = 0; - - @Override - public void register(Handle h) { - registerCount += 1; - } - - @Override - public void remove(String name) { - } - - @Override - public StatisticsConfig getConfig() { - return config; - } - - @Override - public int purge() { - return 0; - } - } - -} diff --git a/statistics/src/test/java/com/yahoo/statistics/CounterTestCase.java b/statistics/src/test/java/com/yahoo/statistics/CounterTestCase.java deleted file mode 100644 index 8c17fd936a0..00000000000 --- a/statistics/src/test/java/com/yahoo/statistics/CounterTestCase.java +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import java.util.Arrays; -import java.util.logging.Logger; - -import com.yahoo.container.StatisticsConfig; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; - -/** - * Check counters work. - * - * @author Steinar Knutsen - */ -@SuppressWarnings("deprecation") -public class CounterTestCase { - - @Test - public void testBasic() { - Counter c = new Counter("test", Statistics.nullImplementation, false); - c.increment(); - assertEquals(1, c.get()); - c.increment(499); - assertEquals(500, c.get()); - c.reset(); - assertEquals(500, c.get()); - c = new Counter("test", Statistics.nullImplementation, false, null, true); - c.increment(); - assertEquals(1, c.get()); - c.increment(499); - assertEquals(500, c.get()); - c.reset(); - assertEquals(0, c.get()); - } - - @Test - public void testObjectContracts() { - final String counterName = "test"; - Counter c = new Counter(counterName, Statistics.nullImplementation, false); - Counter c2 = new Counter(counterName, Statistics.nullImplementation, false); - c2.increment(); - assertEquals(c, c2); - assertEquals(c.hashCode(), c2.hashCode()); - c2 = new Counter("nalle", Statistics.nullImplementation, false); - assertFalse("Different names should lead to different hashcodes", - c.hashCode() == c2.hashCode()); - assertFalse("Different names should lead to equals() return false", - c.equals(c2)); - String prefix = "com.yahoo.statistics.Counter"; - String suffix = counterName + " 0"; - String image = c.toString(); - assertEquals(suffix, image.substring(image.length() - suffix.length())); - assertEquals(prefix, image.substring(0, prefix.length())); - } - - @Test - public void testConfigStuff() { - Logger logger = Logger.getLogger(Counter.class.getName()); - boolean initUseParentHandlers = logger.getUseParentHandlers(); - logger.setUseParentHandlers(false); - MockStatistics m = new MockStatistics(); - final String joppe = "joppe"; - StatisticsConfig config = new StatisticsConfig( - new StatisticsConfig.Builder().counterresets(Arrays - .asList(new StatisticsConfig.Counterresets.Builder[] { new StatisticsConfig.Counterresets.Builder() - .name(joppe) }))); - m.config = config; - Counter c = new Counter("nalle", m, true); - Counter c2 = new Counter(joppe, m, true); - c.increment(); - c2.increment(); - assertEquals(1L, c.get()); - assertEquals(1L, c2.get()); - c.run(); - c2.run(); - assertEquals(1L, c.get()); - assertEquals(0L, c2.get()); - logger.setUseParentHandlers(initUseParentHandlers); - - } - - public class MockStatistics implements Statistics { - public StatisticsConfig config = null; - public int registerCount = 0; - - @Override - public void register(Handle h) { - registerCount += 1; - } - - @Override - public void remove(String name) { - } - - @Override - public StatisticsConfig getConfig() { - return config; - } - - @Override - public int purge() { - return 0; - } - } - -} diff --git a/statistics/src/test/java/com/yahoo/statistics/HistogramTestCase.java b/statistics/src/test/java/com/yahoo/statistics/HistogramTestCase.java deleted file mode 100644 index 517de9b4ef1..00000000000 --- a/statistics/src/test/java/com/yahoo/statistics/HistogramTestCase.java +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -/** - * Some low level checking of the histograms. - * - * @author Steinar Knutsen - */ -@SuppressWarnings("deprecation") -public class HistogramTestCase { - - @Test - public void testFindBucket() { - Limits l = new Limits(); - double[] thresholds = {.5, 1.0, 5.0}; - double[] value = {.5, .5}; - l.addAxis("latency", thresholds); - thresholds = new double[] {500.0, 1000.0, 5000.0}; - l.addAxis("size", thresholds); - Histogram h = new Histogram(l); - assertEquals("latency,size ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 0.5 ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 1.0 ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 5.0 ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0))", - h.toString()); - h.put(value); - assertEquals("latency,size ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 0.5 ((1) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 1.0 ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 5.0 ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0))", - h.toString()); - - } - - @Test - public void testMerge() { - Limits l = new Limits(); - double[] thresholds = {.5, 1.0, 5.0}; - double[] value = {.75}; - l.addAxis("latency", thresholds); - Histogram h = new Histogram(l); - Histogram h2 = new Histogram(l); - h.put(value); - h.put(value); - h2.put(value); - h2.merge(h); - assertEquals("(0) < 0.5 (3) < 1.0 (0) < 5.0 (0)", h2.toString()); - } - - @Test - public void testMultiDimensionalMerge() { - Limits l = new Limits(); - double[] thresholds = {.5, 1.0, 5.0}; - double[] value = {.5, .5}; - l.addAxis("latency", thresholds); - thresholds = new double[] {500.0, 1000.0, 5000.0}; - l.addAxis("size", thresholds); - Histogram h = new Histogram(l); - Histogram h2 = new Histogram(l); - h.put(value); - assertEquals("latency,size ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 0.5 ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 1.0 ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 5.0 ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0))", - h2.toString()); - h2.merge(h); - assertEquals("latency,size ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 0.5 ((1) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 1.0 ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0)) < 5.0 ((0) < 500.0 (0) < 1000.0 (0) < 5000.0 (0))", - h.toString()); - } - - @Test - public void testEmptyHistogram() { - try { - new Histogram(new Limits()); - } catch (IndexOutOfBoundsException e) { - return; - } - fail("Got no exception when trying to create an empty histogram."); - } - -} diff --git a/statistics/src/test/java/com/yahoo/statistics/ProxyTestCase.java b/statistics/src/test/java/com/yahoo/statistics/ProxyTestCase.java deleted file mode 100644 index 8eaee5d8ce8..00000000000 --- a/statistics/src/test/java/com/yahoo/statistics/ProxyTestCase.java +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * Tabular checking of statistics proxies. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@SuppressWarnings("deprecation") -public class ProxyTestCase { - private static final double MAX = 2.0d; - private static final double MEAN = 1.0d; - private static final double MIN = -1.0d; - private static final double RAW = 0.5d; - private static final long C_RAW = 3; - ValueProxy vp; - CounterProxy cp; - Histogram h = new Histogram(new Limits(new double[] { 1.0d })); - - @Before - public void setUp() throws Exception { - vp = new ValueProxy("nalle"); - vp.setRaw(RAW); - vp.setMin(MIN); - vp.setMean(MEAN); - vp.setMax(MAX); - vp.setHistogram(h); - cp = new CounterProxy("nalle"); - cp.setRaw(C_RAW); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public final void test() { - assertFalse(vp.hasHistogram() == false); - assertFalse(vp.hasRaw() == false); - assertFalse(vp.hasMin() == false); - assertFalse(vp.hasMean() == false); - assertFalse(vp.hasMax() == false); - assertFalse(cp.hasRaw() == false); - assertEquals(C_RAW, cp.getRaw()); - assertEquals(MAX, vp.getMax(), 1e-9); - assertEquals(MEAN, vp.getMean(), 1e-9); - assertEquals(MIN, vp.getMin(), 1e-9); - assertEquals(RAW, vp.getRaw(), 1e-9); - assertSame(h, vp.getHistogram()); - - final long t = 11L; - Proxy p = new Proxy("nalle", t) { - }; - assertEquals(t, p.getTimestamp()); - } - -} diff --git a/statistics/src/test/java/com/yahoo/statistics/StatisticsImplTestCase.java b/statistics/src/test/java/com/yahoo/statistics/StatisticsImplTestCase.java deleted file mode 100644 index 1ae8725ffe2..00000000000 --- a/statistics/src/test/java/com/yahoo/statistics/StatisticsImplTestCase.java +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; - -import java.util.logging.Logger; - -import org.junit.Test; - -import com.yahoo.container.StatisticsConfig; - -/** - * Check register/remove semantics. - * - * @author <a href="mailto:steinar@yahoo-inc.com">Steinar Knutsen</a> - */ -@SuppressWarnings("deprecation") -public class StatisticsImplTestCase { - private static class TestHandle extends Handle { - - TestHandle(final String name, final Statistics manager, - final Callback parametrizedCallback) { - super(name, manager, parametrizedCallback); - } - - @Override - public void runHandle() { - } - - @Override - public boolean equals(final Object o) { - if (o == this) { - return true; - } else { - return false; - } - } - - @Override - public int hashCode() { - return getName().hashCode(); - } - - } - - @Test - public final void testRegister() { - final StatisticsConfig config = new StatisticsConfig( - new StatisticsConfig.Builder().collectionintervalsec(31e9) - .loggingintervalsec(31e9)); - final StatisticsImpl s = new StatisticsImpl(config); - final Logger logger = Logger.getLogger(TestHandle.class.getName()); - final boolean initUseParentHandlers = logger.getUseParentHandlers(); - logger.setUseParentHandlers(false); - final String firstHandle = "a"; - final Handle a = new TestHandle(firstHandle, s, null); - final Handle a2 = new TestHandle(firstHandle, s, null); - final String secondHandle = "b"; - final Handle b = new TestHandle(secondHandle, s, null); - s.register(a); - s.register(a2); - assertFalse("Old handle should be cancelled.", a.isCancelled() == false); - assertFalse("New handle should not be cancelled.", a2.isCancelled()); - assertEquals("Internal handles map semantics have been changed?", 1, - s.handles.size()); - s.register(b); - s.remove(secondHandle); - assertFalse("Removed handle should be cancelled.", - b.isCancelled() == false); - a2.cancel(); - s.purge(); - assertEquals("Cancelled tasks should be removed.", 0, s.handles.size()); - s.deconstruct(); - assertSame(config, s.getConfig()); - logger.setUseParentHandlers(initUseParentHandlers); - } - - @Test - public void freezeNullImplementationBehavior() { - Statistics s = Statistics.nullImplementation; - assertEquals(0, s.purge()); - // invoke s.register - Handle h = new Handle("nalle", s, null) { - @Override - public void runHandle() { - } - - @Override - public boolean equals(Object o) { - return true; - } - - @Override - public int hashCode() { - return 0; - } - - }; - assertEquals(0, s.purge()); - s.register(h); - s.remove("nalle"); - s.register(h); - h.cancel(); - assertEquals(0, s.purge()); - } - -} diff --git a/statistics/src/test/java/com/yahoo/statistics/ValueGroupTestCase.java b/statistics/src/test/java/com/yahoo/statistics/ValueGroupTestCase.java deleted file mode 100644 index f57fff8c312..00000000000 --- a/statistics/src/test/java/com/yahoo/statistics/ValueGroupTestCase.java +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - - -import java.util.logging.Handler; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -import com.yahoo.container.StatisticsConfig; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -/** - * Test set for groups of values. - * - * @author Steinar Knutsen - */ -@SuppressWarnings({"deprecation","removal"}) // TODO Vespa 8: remove -public class ValueGroupTestCase { - - private volatile boolean gotRecord = false; - - private class ValueGroupHandler extends Handler { - // this is for testing ValueProxy - - @Override - public void publish(LogRecord record) { - com.yahoo.log.event.ValueGroup msg = (com.yahoo.log.event.ValueGroup) record.getParameters()[0]; - assertEquals("test", msg.getValue("name")); - String values = msg.getValue("values"); - assertFalse("Unexpected value for a.", values.indexOf("a=-50.0") == -1); - assertFalse("Unexpected value for b.", values.indexOf("b=40.0") == -1); - assertFalse("Unexpected value for c.", values.indexOf("c=0.0") == -1); - gotRecord = true; - } - - @Override - public void flush() { - } - - @Override - public void close() throws SecurityException { - } - } - - @Test - public void testBasic() { - Logger logger = Logger.getLogger(ValueGroup.class.getName()); - boolean initUseParentHandlers = logger.getUseParentHandlers(); - Handler logChecker = new ValueGroupHandler(); - logger.setUseParentHandlers(false); - final MockStatistics manager = new MockStatistics(); - ValueGroup v = new ValueGroup("test", manager); - v.put("a", 50.0); - v.put("b", 40.0); - v.put("a", -50.0); - assertTrue("Last value inserted to a was -50", - -50.0 == v.getValue("a").get()); - assertTrue("Last value inserted to b was 40.", - 40.0 == v.getValue("b").get()); - assertTrue("c has not been used yet", - 0.0 == v.getValue("c").get()); - logger.addHandler(logChecker); - v.run(); - assertFalse("The logging handler did not really run.", gotRecord == false); - assertEquals(1, manager.registerCount); - // cleanup: - logger.removeHandler(logChecker); - logger.setUseParentHandlers(initUseParentHandlers); - } - - @Test - public void testOverlappingSubnames() { - final MockStatistics manager = new MockStatistics(); - ValueGroup v = new ValueGroup("jappe", manager); - ValueGroup v2 = new ValueGroup("nalle", manager); - final String name = "mobil"; - v.put(name, 50.0); - v2.put(name, 40.0); - assertEquals(50.0, v.getValue(name).get(), 1e-9); - assertEquals(40.0, v2.getValue(name).get(), 1e-9); - assertEquals(2, manager.registerCount); - } - - @Test - public void testObjectContracts() { - ValueGroup v = new ValueGroup("test", new MockStatistics()); - ValueGroup v2 = new ValueGroup("test", new MockStatistics()); - v2.put("nalle", 2.0); - assertEquals(v, v2); - assertEquals(v.hashCode(), v2.hashCode()); - v2 = new ValueGroup("nalle", new MockStatistics()); - assertFalse("Different names should lead to different hashcodes", - v.hashCode() == v2.hashCode()); - assertFalse("Different names should lead to equals() return false", - v.equals(v2)); - } - - public class MockStatistics implements Statistics { - public StatisticsConfig config = null; - public int registerCount = 0; - - @Override - public void register(Handle h) { - registerCount += 1; - } - - @Override - public void remove(String name) { - } - - @Override - public StatisticsConfig getConfig() { - return config; - } - - @Override - public int purge() { - return 0; - } - } - -} diff --git a/statistics/src/test/java/com/yahoo/statistics/ValueTestCase.java b/statistics/src/test/java/com/yahoo/statistics/ValueTestCase.java deleted file mode 100644 index b7f0d9ca8c4..00000000000 --- a/statistics/src/test/java/com/yahoo/statistics/ValueTestCase.java +++ /dev/null @@ -1,268 +0,0 @@ -// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.statistics; - -import java.util.Arrays; -import java.util.List; -import java.util.logging.Handler; -import java.util.logging.LogRecord; -import java.util.logging.Logger; - -import com.yahoo.container.StatisticsConfig; -import static com.yahoo.container.StatisticsConfig.Values.Operations; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; - -/** - * Check correct statistics are generated for basic values. - * - * @author Steinar Knutsen - */ -@SuppressWarnings({"deprecation","removal"}) // TODO Vespa 8: remove -public class ValueTestCase { - - private static final double delta = 0.0000000001; - - private static final String NALLE = "nalle"; - private static final double SECOND = 43.0d; - private static final double FIRST = 42.0d; - - private static class TrivialCallback implements Callback { - - @Override - public void run(Handle h, boolean firstRun) { - Value v = (Value) h; - if (firstRun) { - v.put(FIRST); - } else { - v.put(SECOND); - } - } - - } - - @Test - public void testMean() { - Value v = new Value("thingie", Statistics.nullImplementation, new Value.Parameters().setLogMean(true)); - v.put(1.0); - v.put(2.0); - v.put(4.0); - v.put(-1.0); - assertTrue("Mean should be 1.5", 1.5 == v.getMean()); - ValueProxy vp = v.getProxyAndReset(); - assertTrue("Proxy mean should be 1.5", 1.5 == vp.getMean()); - assertTrue("Value should have been reset.", 0.0d == v.getMean()); - } - - @Test - public void testMin() { - Value v = new Value("thingie", Statistics.nullImplementation, new Value.Parameters().setLogMin(true)); - v.put(2.0); - assertTrue("Min should be 2.0", 2.0 == v.getMin()); - v.put(1.0); - assertTrue("Min should be 1.0", 1.0 == v.getMin()); - v.put(-1.0); - v.put(4.0); - assertTrue("Min should be -1.0", -1.0 == v.getMin()); - } - - @Test - public void testMax() { - Value v = new Value("thingie", Statistics.nullImplementation, new Value.Parameters().setLogMax(true)); - v.put(-1.0); - assertTrue("Max should be -1.0", -1.0 == v.getMax()); - v.put(1.0); - v.put(2.0); - assertTrue("Max should be 2.0", 2.0 == v.getMax()); - v.put(4.0); - v.put(-1.0); - assertTrue("Max should be 4.0", 4.0 == v.getMax()); - } - - @Test - public void testHistogram() { - Value v = new Value("thingie", Statistics.nullImplementation, new Value.Parameters() - .setLogHistogram(true).setHistogramId(HistogramType.REGULAR) - .setLimits(new Limits(new double[] { 0.0, 1.0, 2.0 }))); - v.put(-1.0); - v.put(0.0); - v.put(1.0); - v.put(2.0); - v.put(3.0); - assertTrue(v.toString().endsWith( - " thingie (1) < 0.0 (1) < 1.0 (1) < 2.0 (2)")); - } - - @Test - public void testCallback() { - Logger logger = Logger.getLogger(Value.class.getName()); - boolean initUseParentHandlers = logger.getUseParentHandlers(); - logger.setUseParentHandlers(false); - Value v = new Value("thingie", Statistics.nullImplementation, new Value.Parameters() - .setLogRaw(true).setCallback(new TrivialCallback())); - v.run(); - assertEquals(FIRST, v.get(), delta); - v.run(); - assertEquals(SECOND, v.get(), delta); - v.run(); - assertEquals(SECOND, v.get(), delta); - logger.setUseParentHandlers(initUseParentHandlers); - } - - @Test - public void testParameter() { - Value.Parameters p = new Value.Parameters().setLogInsertions(true) - .setNameExtension(true).setAppendChar('_'); - Value.Parameters p2 = new Value.Parameters().setLogSum(true); - assertNull(p2.appendChar); - assertNull(p.logSum); - p2.merge(p); - assertEquals(Character.valueOf('_'), p2.appendChar); - assertNull(p2.logMax); - assertEquals(Boolean.TRUE, p2.logSum); - } - - private class CheckHistogram extends Handler { - volatile boolean gotRecord = false; - volatile boolean gotWarning = false; - final String histogram; - final String representation; - - public CheckHistogram(String histogram, String representation) { - this.histogram = histogram; - this.representation = representation; - } - - @Override - public void publish(LogRecord record) { - if (record.getParameters() == null) { - assertEquals(Value.HISTOGRAM_TYPE_WARNING + " '" + NALLE + "'", record.getMessage()); - gotWarning = true; - return; - } - if (!(record.getParameters()[0] instanceof com.yahoo.log.event.Histogram)) { - return; - } - com.yahoo.log.event.Histogram msg = (com.yahoo.log.event.Histogram) record.getParameters()[0]; - assertEquals(NALLE, msg.getValue("name")); - assertEquals(histogram, msg.getValue("counts")); - assertEquals(representation, msg.getValue("representation")); - gotRecord = true; - } - - @Override - public void flush() { - } - - @Override - public void close() throws SecurityException { - } - } - - @Test - public void testParameterFromConfig() { - Logger logger = Logger.getLogger(Value.class.getName()); - boolean initUseParentHandlers = logger.getUseParentHandlers(); - logger.setUseParentHandlers(false); - CheckHistogram h = new CheckHistogram("(0) < 0.0 (0) < 1.0 (0) < 2.0 (1)", "REGULAR"); - logger.addHandler(h); - List<Operations.Arguments.Builder> histogram = Arrays.asList(new Operations.Arguments.Builder[] { - new Operations.Arguments.Builder().key("limits").value("0, 1, 2")}); - List<Operations.Builder> ops = Arrays.asList(new Operations.Builder[] { - new Operations.Builder().name(Operations.Name.Enum.MEAN), - new Operations.Builder().name(Operations.Name.Enum.MIN), - new Operations.Builder().name(Operations.Name.Enum.MAX), - new Operations.Builder().name(Operations.Name.Enum.RAW), - new Operations.Builder().name(Operations.Name.Enum.INSERTIONS), - new Operations.Builder().name(Operations.Name.Enum.REGULAR).arguments(histogram), - new Operations.Builder().name(Operations.Name.Enum.SUM) }); - StatisticsConfig c = new StatisticsConfig( - new StatisticsConfig.Builder() - .values(new StatisticsConfig.Values.Builder().name( - NALLE).operations(ops))); - MockStatistics m = new MockStatistics(); - m.config = c; - Value v = Value.buildValue(NALLE, m, null); - final double x = 79.0d; - v.put(x); - assertEquals(x, v.getMean(), delta); - v.run(); - logger.removeHandler(h); - logger.setUseParentHandlers(initUseParentHandlers); - } - - @Test - public void testReverseHistogram() { - Logger logger = Logger.getLogger(Value.class.getName()); - boolean initUseParentHandlers = logger.getUseParentHandlers(); - logger.setUseParentHandlers(false); - CheckHistogram h = new CheckHistogram("(0) < 0.0 (2) < 1.0 (2) < 2.0 (0)", "REGULAR"); - logger.addHandler(h); - List<Operations.Arguments.Builder> histogram = Arrays.asList(new Operations.Arguments.Builder[] { - new Operations.Arguments.Builder().key("limits").value("0, 1, 2")}); - List<Operations.Builder> ops = Arrays.asList(new Operations.Builder[] { - new Operations.Builder().name(Operations.Name.Enum.REVERSE_CUMULATIVE).arguments(histogram) }); - StatisticsConfig c = new StatisticsConfig( - new StatisticsConfig.Builder() - .values(new StatisticsConfig.Values.Builder().name( - NALLE).operations(ops))); - MockStatistics m = new MockStatistics(); - m.config = c; - Value v = Value.buildValue(NALLE, m, null); - assertEquals(HistogramType.REGULAR.toString(), v.histogramId.toString()); - v.put(.5d); - v.put(.5d); - v.put(1.5d); - v.put(1.5d); - v.run(); - logger.removeHandler(h); - logger.setUseParentHandlers(initUseParentHandlers); - } - - @Test - public void testObjectContracts() { - final String valueName = "test"; - Value v = new Value(valueName, Statistics.nullImplementation, Value.defaultParameters()); - Value v2 = new Value(valueName, Statistics.nullImplementation, Value.defaultParameters()); - v2.put(1.0); - assertEquals(v, v2); - assertEquals(v.hashCode(), v2.hashCode()); - v2 = new Value("nalle", Statistics.nullImplementation, Value.defaultParameters()); - assertFalse("Different names should lead to different hashcodes", - v.hashCode() == v2.hashCode()); - assertFalse("Different names should lead to equals() return false", - v.equals(v2)); - String image = v.toString(); - String prefix = "com.yahoo.statistics.Value"; - assertEquals(prefix, image.substring(0, prefix.length())); - assertEquals(valueName, image.substring(image.length() - valueName.length())); - } - - public class MockStatistics implements Statistics { - public StatisticsConfig config = null; - public int registerCount = 0; - - @Override - public void register(Handle h) { - registerCount += 1; - } - - @Override - public void remove(String name) { - } - - @Override - public StatisticsConfig getConfig() { - return config; - } - - @Override - public int purge() { - return 0; - } - } - -} |