Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Odfe 1.4.0 (#43)
Browse files Browse the repository at this point in the history
build against ES7.4
  • Loading branch information
jngz-es authored Feb 20, 2020
1 parent fc2c568 commit 040b2f3
Show file tree
Hide file tree
Showing 56 changed files with 179 additions and 283 deletions.
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {
ext {
es_mv = '7.2'
es_group = "org.elasticsearch"
es_version = '7.2.1'
es_version = '7.4.2'
es_distribution = 'oss-zip'
}
repositories {
Expand All @@ -43,11 +43,11 @@ repositories {
}

ext {
opendistroVersion = '1.2.1'
opendistroVersion = '1.4.0'
isSnapshot = "true" == System.getProperty("build.snapshot", "true")
}

version = "${opendistroVersion}.0-alpha"
version = "${opendistroVersion}.0"

apply plugin: 'java'
apply plugin: 'idea'
Expand Down Expand Up @@ -258,6 +258,9 @@ List<String> jacocoExclusions = [
'com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorRequest',
'com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorResponse',
'com.amazon.opendistroforelasticsearch.ad.transport.StopDetectorTransportAction',
'com.amazon.opendistroforelasticsearch.ad.transport.ADStatsAction',
'com.amazon.opendistroforelasticsearch.ad.transport.CronRequest',
'com.amazon.opendistroforelasticsearch.ad.transport.DeleteDetectorAction',
'com.amazon.opendistroforelasticsearch.ad.util.ParseUtils'
]

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public List<RestHandler> getRestHandlers(
IndexNameExpressionResolver indexNameExpressionResolver,
Supplier<DiscoveryNodes> nodesInCluster
) {
RestGetAnomalyDetectorAction restGetAnomalyDetectorAction = new RestGetAnomalyDetectorAction(settings, restController);
RestGetAnomalyDetectorAction restGetAnomalyDetectorAction = new RestGetAnomalyDetectorAction(restController);
RestIndexAnomalyDetectorAction restIndexAnomalyDetectorAction = new RestIndexAnomalyDetectorAction(
settings,
restController,
Expand All @@ -157,18 +157,14 @@ public List<RestHandler> getRestHandlers(
);
RestSearchAnomalyDetectorAction searchAnomalyDetectorAction = new RestSearchAnomalyDetectorAction(settings, restController);
RestSearchAnomalyResultAction searchAnomalyResultAction = new RestSearchAnomalyResultAction(settings, restController);
RestDeleteAnomalyDetectorAction deleteAnomalyDetectorAction = new RestDeleteAnomalyDetectorAction(
settings,
restController,
clusterService
);
RestDeleteAnomalyDetectorAction deleteAnomalyDetectorAction = new RestDeleteAnomalyDetectorAction(restController, clusterService);
RestExecuteAnomalyDetectorAction executeAnomalyDetectorAction = new RestExecuteAnomalyDetectorAction(
settings,
restController,
clusterService,
anomalyDetectorRunner
);
RestStatsAnomalyDetectorAction statsAnomalyDetectorAction = new RestStatsAnomalyDetectorAction(settings, restController, adStats);
RestStatsAnomalyDetectorAction statsAnomalyDetectorAction = new RestStatsAnomalyDetectorAction(restController, adStats);

return ImmutableList
.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.ToXContentObject;
import org.elasticsearch.common.xcontent.XContentBuilder;
Expand Down Expand Up @@ -56,8 +55,7 @@ public abstract class AbstractSearchAction<T extends ToXContentObject> extends B

private final Logger logger = LogManager.getLogger(AbstractSearchAction.class);

public AbstractSearchAction(Settings settings, RestController controller, String urlPath, String index, Class<T> clazz) {
super(settings);
public AbstractSearchAction(RestController controller, String urlPath, String index, Class<T> clazz) {
this.index = index;
this.clazz = clazz;
controller.registerHandler(RestRequest.Method.POST, urlPath, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.action.support.WriteRequest;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestChannel;
Expand All @@ -55,8 +54,7 @@ public class RestDeleteAnomalyDetectorAction extends BaseRestHandler {
private final ClusterService clusterService;
private final AnomalyDetectorActionHandler handler = new AnomalyDetectorActionHandler();

public RestDeleteAnomalyDetectorAction(Settings settings, RestController controller, ClusterService clusterService) {
super(settings);
public RestDeleteAnomalyDetectorAction(RestController controller, ClusterService clusterService) {
this.clusterService = clusterService;
// delete anomaly detector document
controller
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ public RestExecuteAnomalyDetectorAction(
ClusterService clusterService,
AnomalyDetectorRunner anomalyDetectorRunner
) {
super(settings);

this.anomalyDetectorRunner = anomalyDetectorRunner;
this.requestTimeout = REQUEST_TIMEOUT.get(settings);
clusterService.getClusterSettings().addSettingsUpdateConsumer(REQUEST_TIMEOUT, it -> requestTimeout = it);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentHelper;
Expand Down Expand Up @@ -55,8 +54,7 @@ public class RestGetAnomalyDetectorAction extends BaseRestHandler {
private static final String GET_ANOMALY_DETECTOR_ACTION = "get_anomaly_detector";
private static final Logger logger = LogManager.getLogger(RestGetAnomalyDetectorAction.class);

public RestGetAnomalyDetectorAction(Settings settings, RestController controller) {
super(settings);
public RestGetAnomalyDetectorAction(RestController controller) {
String path = String.format(Locale.ROOT, "%s/{%s}", AnomalyDetectorPlugin.AD_BASE_DETECTORS_URI, DETECTOR_ID);
controller.registerHandler(RestRequest.Method.GET, path, this);
controller.registerHandler(RestRequest.Method.HEAD, path, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ public RestIndexAnomalyDetectorAction(
ClusterService clusterService,
AnomalyDetectionIndices anomalyDetectionIndices
) {
super(settings);
controller.registerHandler(RestRequest.Method.POST, AnomalyDetectorPlugin.AD_BASE_DETECTORS_URI, this); // Create
controller
.registerHandler(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class RestSearchAnomalyDetectorAction extends AbstractSearchAction<Anomal
private final String SEARCH_ANOMALY_DETECTOR_ACTION = "search_anomaly_detector";

public RestSearchAnomalyDetectorAction(Settings settings, RestController controller) {
super(settings, controller, URL_PATH, ANOMALY_DETECTORS_INDEX, AnomalyDetector.class);
super(controller, URL_PATH, ANOMALY_DETECTORS_INDEX, AnomalyDetector.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class RestSearchAnomalyResultAction extends AbstractSearchAction<AnomalyR
private final String SEARCH_ANOMALY_DETECTOR_ACTION = "search_anomaly_result";

public RestSearchAnomalyResultAction(Settings settings, RestController controller) {
super(settings, controller, URL_PATH, ALL_AD_RESULTS_INDEX_PATTERN, AnomalyResult.class);
super(controller, URL_PATH, ALL_AD_RESULTS_INDEX_PATTERN, AnomalyResult.class);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsAction;
import com.amazon.opendistroforelasticsearch.ad.transport.ADStatsRequest;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.Strings;
import org.elasticsearch.rest.action.RestActions;
import org.elasticsearch.rest.BaseRestHandler;
Expand All @@ -44,12 +43,10 @@ public class RestStatsAnomalyDetectorAction extends BaseRestHandler {
/**
* Constructor
*
* @param settings Settings
* @param controller Rest Controller
* @param adStats ADStats object
*/
public RestStatsAnomalyDetectorAction(Settings settings, RestController controller, ADStats adStats) {
super(settings);
public RestStatsAnomalyDetectorAction(RestController controller, ADStats adStats) {
controller.registerHandler(RestRequest.Method.GET, AD_BASE_URI + "/{nodeId}/stats/", this);
controller.registerHandler(RestRequest.Method.GET, AD_BASE_URI + "/{nodeId}/stats/{stat}", this);
controller.registerHandler(RestRequest.Method.GET, AD_BASE_URI + "/stats/", this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@

package com.amazon.opendistroforelasticsearch.ad.transport;

import org.elasticsearch.action.Action;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.action.ActionType;

/**
* ADStatsAction class
*/
public class ADStatsAction extends Action<ADStatsResponse> {
public class ADStatsAction extends ActionType<ADStatsResponse> {

public static final ADStatsAction INSTANCE = new ADStatsAction();
public static final String NAME = "cluster:admin/ad_stats_action";
Expand All @@ -30,16 +29,7 @@ public class ADStatsAction extends Action<ADStatsResponse> {
* Constructor
*/
private ADStatsAction() {
super(NAME);
super(NAME, ADStatsResponse::new);
}

@Override
public ADStatsResponse newResponse() {
throw new UnsupportedOperationException("Usage of Streamable is to be replaced by Writeable");
}

@Override
public Writeable.Reader<ADStatsResponse> getResponseReader() {
return ADStatsResponse::new;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,17 @@ public ADStatsNodeRequest() {
super();
}

public ADStatsNodeRequest(StreamInput in) throws IOException {
super(in);
this.request = new ADStatsRequest(in);
}

/**
* Constructor
*
* @param nodeId nodeId
* @param request ADStatsRequest
*/
public ADStatsNodeRequest(String nodeId, ADStatsRequest request) {
super(nodeId);
public ADStatsNodeRequest(ADStatsRequest request) {
this.request = request;
}

Expand All @@ -54,9 +57,7 @@ public ADStatsRequest getADStatsRequest() {
return request;
}

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
request = new ADStatsRequest();
request.readFrom(in);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ public class ADStatsNodeResponse extends BaseNodeResponse implements ToXContentF

/**
* Constructor
*
* @param in StreamInput
* @throws IOException throws an IO exception if the StreamInput cannot be read from
*/
public ADStatsNodeResponse() {}
public ADStatsNodeResponse(StreamInput in) throws IOException {
super(in);
this.statsMap = in.readMap(StreamInput::readString, StreamInput::readGenericValue);
}

/**
* Constructor
Expand All @@ -56,9 +62,8 @@ public ADStatsNodeResponse(DiscoveryNode node, Map<String, Object> statsToValues
* @throws IOException throws an IO exception if the StreamInput cannot be read from
*/
public static ADStatsNodeResponse readStats(StreamInput in) throws IOException {
ADStatsNodeResponse adStats = new ADStatsNodeResponse();
adStats.readFrom(in);
return adStats;

return new ADStatsNodeResponse(in);
}

/**
Expand All @@ -70,12 +75,6 @@ public Map<String, Object> getStatsMap() {
return statsMap;
}

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
this.statsMap = in.readMap(StreamInput::readString, StreamInput::readGenericValue);
}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public class ADStatsRequest extends BaseNodesRequest<ADStatsRequest> {

private Set<String> statsToBeRetrieved;

public ADStatsRequest(StreamInput in) throws IOException {
super(in);
statsToBeRetrieved = in.readSet(StreamInput::readString);
}

/**
* Constructor
*
Expand Down Expand Up @@ -79,9 +84,7 @@ public Set<String> getStatsToBeRetrieved() {
return statsToBeRetrieved;
}

@Override
public void readFrom(StreamInput in) throws IOException {
super.readFrom(in);
statsToBeRetrieved = in.readSet(StreamInput::readString);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public void writeTo(StreamOutput out) throws IOException {

@Override
public void writeNodesTo(StreamOutput out, List<ADStatsNodeResponse> nodes) throws IOException {
out.writeStreamableList(nodes);
out.writeList(nodes);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
import org.elasticsearch.action.support.nodes.TransportNodesAction;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.transport.TransportService;
import org.elasticsearch.threadpool.ThreadPool;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -83,13 +85,13 @@ protected ADStatsResponse newResponse(ADStatsRequest request, List<ADStatsNodeRe
}

@Override
protected ADStatsNodeRequest newNodeRequest(String nodeId, ADStatsRequest request) {
return new ADStatsNodeRequest(nodeId, request);
protected ADStatsNodeRequest newNodeRequest(ADStatsRequest request) {
return new ADStatsNodeRequest(request);
}

@Override
protected ADStatsNodeResponse newNodeResponse() {
return new ADStatsNodeResponse();
protected ADStatsNodeResponse newNodeResponse(StreamInput in) throws IOException {
return new ADStatsNodeResponse(in);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,14 @@

package com.amazon.opendistroforelasticsearch.ad.transport;

import org.elasticsearch.action.Action;
import org.elasticsearch.common.io.stream.Writeable;
import org.elasticsearch.action.ActionType;

public class AnomalyResultAction extends Action<AnomalyResultResponse> {
public class AnomalyResultAction extends ActionType<AnomalyResultResponse> {
public static final AnomalyResultAction INSTANCE = new AnomalyResultAction();
public static final String NAME = "cluster:admin/ad/result";

private AnomalyResultAction() {
super(NAME);
super(NAME, AnomalyResultResponse::new);
}

@Override
public AnomalyResultResponse newResponse() {
throw new UnsupportedOperationException("Usage of Streamable is to be replaced by Writeable");
}

@Override
public Writeable.Reader<AnomalyResultResponse> getResponseReader() {
// return constructor method reference
return AnomalyResultResponse::new;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ public double getConfidence() {

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeDouble(anomalyGrade);
out.writeDouble(confidence);
out.writeVInt(features.size());
Expand Down
Loading

0 comments on commit 040b2f3

Please sign in to comment.