Skip to content

Commit

Permalink
update index monitor method to include namedWriteableRegistry for com…
Browse files Browse the repository at this point in the history
…mon utils interface (#101) (#105)

Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>

Signed-off-by: Surya Sashank Nistala <snistala@amazon.com>
  • Loading branch information
eirsep committed Nov 3, 2022
1 parent f6e66d5 commit dc558fb
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.opensearch.client.node.NodeClient;
import org.opensearch.cluster.service.ClusterService;
import org.opensearch.common.inject.Inject;
import org.opensearch.common.io.stream.NamedWriteableRegistry;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.common.xcontent.LoggingDeprecationHandler;
Expand Down Expand Up @@ -106,10 +107,22 @@ public class TransportIndexDetectorAction extends HandledTransportAction<IndexDe

private final Settings settings;

private final NamedWriteableRegistry namedWriteableRegistry;

private volatile TimeValue indexTimeout;

@Inject
public TransportIndexDetectorAction(TransportService transportService, Client client, ActionFilters actionFilters, NamedXContentRegistry xContentRegistry, DetectorIndices detectorIndices, RuleTopicIndices ruleTopicIndices, RuleIndices ruleIndices, MapperService mapperService, ClusterService clusterService, Settings settings) {
public TransportIndexDetectorAction(TransportService transportService,
Client client,
ActionFilters actionFilters,
NamedXContentRegistry xContentRegistry,
DetectorIndices detectorIndices,
RuleTopicIndices ruleTopicIndices,
RuleIndices ruleIndices,
MapperService mapperService,
ClusterService clusterService,
Settings settings,
NamedWriteableRegistry namedWriteableRegistry) {
super(IndexDetectorAction.NAME, transportService, actionFilters, IndexDetectorRequest::new);
this.client = client;
this.xContentRegistry = xContentRegistry;
Expand All @@ -119,6 +132,7 @@ public TransportIndexDetectorAction(TransportService transportService, Client cl
this.mapperService = mapperService;
this.clusterService = clusterService;
this.settings = settings;
this.namedWriteableRegistry = namedWriteableRegistry;
this.threadPool = this.detectorIndices.getThreadPool();

this.indexTimeout = SecurityAnalyticsSettings.INDEX_TIMEOUT.get(this.settings);
Expand Down Expand Up @@ -179,7 +193,7 @@ private void createAlertingMonitorFromQueries(Pair<String, List<Pair<String, Rul
true));

IndexMonitorRequest indexMonitorRequest = new IndexMonitorRequest(Monitor.NO_ID, SequenceNumbers.UNASSIGNED_SEQ_NO, SequenceNumbers.UNASSIGNED_PRIMARY_TERM, refreshPolicy, RestRequest.Method.POST, monitor, null);
AlertingPluginInterface.INSTANCE.indexMonitor((NodeClient) client, indexMonitorRequest, listener);
AlertingPluginInterface.INSTANCE.indexMonitor((NodeClient) client, indexMonitorRequest, namedWriteableRegistry, listener);
}

private void updateAlertingMonitorFromQueries(Pair<String, List<Pair<String, Rule>>> logIndexToQueries, Detector detector, ActionListener<IndexMonitorResponse> listener, WriteRequest.RefreshPolicy refreshPolicy) {
Expand Down Expand Up @@ -231,7 +245,7 @@ private void updateAlertingMonitorFromQueries(Pair<String, List<Pair<String, Rul
true));

IndexMonitorRequest indexMonitorRequest = new IndexMonitorRequest(detector.getMonitorIds().get(0), SequenceNumbers.UNASSIGNED_SEQ_NO, SequenceNumbers.UNASSIGNED_PRIMARY_TERM, refreshPolicy, RestRequest.Method.PUT, monitor, null);
AlertingPluginInterface.INSTANCE.indexMonitor((NodeClient) client, indexMonitorRequest, listener);
AlertingPluginInterface.INSTANCE.indexMonitor((NodeClient) client, indexMonitorRequest, namedWriteableRegistry, listener);
}

private void onCreateMappingsResponse(CreateIndexResponse response) throws IOException {
Expand Down

0 comments on commit dc558fb

Please sign in to comment.