-
Notifications
You must be signed in to change notification settings - Fork 25k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement aggregate_metric field mapper (#49830)
Implemented aggregate_metric field type for storing pre-computed aggregates
- Loading branch information
Showing
15 changed files
with
2,011 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...ain/java/org/elasticsearch/xpack/core/aggregatemetric/AggregateMetricFeatureSetUsage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.core.aggregatemetric; | ||
|
||
import org.elasticsearch.common.io.stream.StreamInput; | ||
import org.elasticsearch.xpack.core.XPackFeatureSet; | ||
import org.elasticsearch.xpack.core.XPackField; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
public class AggregateMetricFeatureSetUsage extends XPackFeatureSet.Usage { | ||
|
||
public AggregateMetricFeatureSetUsage(StreamInput input) throws IOException { | ||
super(input); | ||
} | ||
|
||
public AggregateMetricFeatureSetUsage(boolean available, boolean enabled) { | ||
super(XPackField.AGGREGATE_METRIC, available, enabled); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) { | ||
return false; | ||
} | ||
if (getClass() != obj.getClass()) { | ||
return false; | ||
} | ||
AggregateMetricFeatureSetUsage other = (AggregateMetricFeatureSetUsage) obj; | ||
return Objects.equals(available, other.available) && | ||
Objects.equals(enabled, other.enabled); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(available, enabled); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
evaluationDependsOn(xpackModule('core')) | ||
|
||
apply plugin: 'elasticsearch.esplugin' | ||
|
||
esplugin { | ||
name 'x-pack-aggregate-metric' | ||
description 'Module for the aggregate_metric field type, which allows pre-aggregated fields to be stored a single field.' | ||
classname 'org.elasticsearch.xpack.aggregatemetric.AggregateMetricMapperPlugin' | ||
extendedPlugins = ['x-pack-core'] | ||
} | ||
archivesBaseName = 'x-pack-aggregate-metric' | ||
|
||
dependencies { | ||
compileOnly project(path: xpackModule('core'), configuration: 'default') | ||
testCompile project(path: xpackModule('core'), configuration: 'testArtifacts') | ||
} | ||
|
||
integTest.enabled = false |
45 changes: 45 additions & 0 deletions
45
...main/java/org/elasticsearch/xpack/aggregatemetric/AggregateMetricInfoTransportAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.aggregatemetric; | ||
|
||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.license.XPackLicenseState; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.elasticsearch.xpack.core.XPackField; | ||
import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; | ||
import org.elasticsearch.xpack.core.action.XPackInfoFeatureTransportAction; | ||
|
||
public class AggregateMetricInfoTransportAction extends XPackInfoFeatureTransportAction { | ||
|
||
@Inject | ||
public AggregateMetricInfoTransportAction( | ||
TransportService transportService, | ||
ActionFilters actionFilters, | ||
Settings settings, | ||
XPackLicenseState licenseState | ||
) { | ||
super(XPackInfoFeatureAction.AGGREGATE_METRIC.name(), transportService, actionFilters); | ||
} | ||
|
||
@Override | ||
public String name() { | ||
return XPackField.AGGREGATE_METRIC; | ||
} | ||
|
||
@Override | ||
public boolean available() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean enabled() { | ||
return true; | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...ic/src/main/java/org/elasticsearch/xpack/aggregatemetric/AggregateMetricMapperPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.aggregatemetric; | ||
|
||
import org.elasticsearch.action.ActionRequest; | ||
import org.elasticsearch.action.ActionResponse; | ||
import org.elasticsearch.index.mapper.Mapper; | ||
import org.elasticsearch.plugins.ActionPlugin; | ||
import org.elasticsearch.plugins.MapperPlugin; | ||
import org.elasticsearch.plugins.Plugin; | ||
import org.elasticsearch.xpack.aggregatemetric.mapper.AggregateDoubleMetricFieldMapper; | ||
import org.elasticsearch.xpack.core.action.XPackInfoFeatureAction; | ||
import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static java.util.Collections.singletonMap; | ||
|
||
public class AggregateMetricMapperPlugin extends Plugin implements MapperPlugin, ActionPlugin { | ||
|
||
@Override | ||
public Map<String, Mapper.TypeParser> getMappers() { | ||
return singletonMap(AggregateDoubleMetricFieldMapper.CONTENT_TYPE, new AggregateDoubleMetricFieldMapper.TypeParser()); | ||
} | ||
|
||
@Override | ||
public List<ActionHandler<? extends ActionRequest, ? extends ActionResponse>> getActions() { | ||
return Arrays.asList( | ||
new ActionHandler<>(XPackUsageFeatureAction.AGGREGATE_METRIC, AggregateMetricUsageTransportAction.class), | ||
new ActionHandler<>(XPackInfoFeatureAction.AGGREGATE_METRIC, AggregateMetricInfoTransportAction.class) | ||
); | ||
} | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...ain/java/org/elasticsearch/xpack/aggregatemetric/AggregateMetricUsageTransportAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
package org.elasticsearch.xpack.aggregatemetric; | ||
|
||
import org.elasticsearch.action.ActionListener; | ||
import org.elasticsearch.action.support.ActionFilters; | ||
import org.elasticsearch.cluster.ClusterState; | ||
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||
import org.elasticsearch.cluster.service.ClusterService; | ||
import org.elasticsearch.common.inject.Inject; | ||
import org.elasticsearch.common.settings.Settings; | ||
import org.elasticsearch.license.XPackLicenseState; | ||
import org.elasticsearch.protocol.xpack.XPackUsageRequest; | ||
import org.elasticsearch.tasks.Task; | ||
import org.elasticsearch.threadpool.ThreadPool; | ||
import org.elasticsearch.transport.TransportService; | ||
import org.elasticsearch.xpack.core.action.XPackUsageFeatureAction; | ||
import org.elasticsearch.xpack.core.action.XPackUsageFeatureResponse; | ||
import org.elasticsearch.xpack.core.action.XPackUsageFeatureTransportAction; | ||
import org.elasticsearch.xpack.core.aggregatemetric.AggregateMetricFeatureSetUsage; | ||
|
||
public class AggregateMetricUsageTransportAction extends XPackUsageFeatureTransportAction { | ||
|
||
@Inject | ||
public AggregateMetricUsageTransportAction( | ||
TransportService transportService, | ||
ClusterService clusterService, | ||
ThreadPool threadPool, | ||
ActionFilters actionFilters, | ||
IndexNameExpressionResolver indexNameExpressionResolver, | ||
Settings settings, | ||
XPackLicenseState licenseState | ||
) { | ||
super( | ||
XPackUsageFeatureAction.AGGREGATE_METRIC.name(), | ||
transportService, | ||
clusterService, | ||
threadPool, | ||
actionFilters, | ||
indexNameExpressionResolver | ||
); | ||
} | ||
|
||
@Override | ||
protected void masterOperation( | ||
Task task, | ||
XPackUsageRequest request, | ||
ClusterState state, | ||
ActionListener<XPackUsageFeatureResponse> listener | ||
) { | ||
AggregateMetricFeatureSetUsage usage = new AggregateMetricFeatureSetUsage(true, true); | ||
listener.onResponse(new XPackUsageFeatureResponse(usage)); | ||
} | ||
} |
Oops, something went wrong.