-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add joins, insertion & search to correlation engine
Signed-off-by: Subhobrata Dey <[email protected]>
- Loading branch information
Showing
21 changed files
with
3,168 additions
and
3 deletions.
There are no files selected for viewing
701 changes: 701 additions & 0 deletions
701
...lusterTest/java/org/opensearch/plugin/correlation/EventsCorrelationPluginTransportIT.java
Large diffs are not rendered by default.
Oops, something went wrong.
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
21 changes: 21 additions & 0 deletions
21
...src/main/java/org/opensearch/plugin/correlation/events/action/IndexCorrelationAction.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,21 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.plugin.correlation.events.action; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
public class IndexCorrelationAction extends ActionType<IndexCorrelationResponse> { | ||
|
||
public static final IndexCorrelationAction INSTANCE = new IndexCorrelationAction(); | ||
public static final String NAME = "cluster:admin/index/correlation/events"; | ||
|
||
private IndexCorrelationAction() { | ||
super(NAME, IndexCorrelationResponse::new); | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...rc/main/java/org/opensearch/plugin/correlation/events/action/IndexCorrelationRequest.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,60 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.plugin.correlation.events.action; | ||
|
||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.action.ActionRequestValidationException; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class IndexCorrelationRequest extends ActionRequest { | ||
|
||
private String index; | ||
|
||
private String event; | ||
|
||
private Boolean store; | ||
|
||
public IndexCorrelationRequest(String index, String event, Boolean store) { | ||
super(); | ||
this.index = index; | ||
this.event = event; | ||
this.store = store; | ||
} | ||
|
||
public IndexCorrelationRequest(StreamInput sin) throws IOException { | ||
this(sin.readString(), sin.readString(), sin.readBoolean()); | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(index); | ||
out.writeString(event); | ||
out.writeBoolean(store); | ||
} | ||
|
||
public String getIndex() { | ||
return index; | ||
} | ||
|
||
public String getEvent() { | ||
return event; | ||
} | ||
|
||
public Boolean getStore() { | ||
return store; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...c/main/java/org/opensearch/plugin/correlation/events/action/IndexCorrelationResponse.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,61 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.plugin.correlation.events.action; | ||
|
||
import org.opensearch.action.ActionResponse; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.rest.RestStatus; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class IndexCorrelationResponse extends ActionResponse { | ||
|
||
private Boolean isOrphan; | ||
|
||
private Map<String, List<String>> neighborEvents; | ||
|
||
private RestStatus status; | ||
|
||
public IndexCorrelationResponse(Boolean isOrphan, Map<String, List<String>> neighborEvents, RestStatus status) { | ||
super(); | ||
this.isOrphan = isOrphan; | ||
this.neighborEvents = neighborEvents; | ||
this.status = status; | ||
} | ||
|
||
public IndexCorrelationResponse(StreamInput sin) throws IOException { | ||
this( | ||
sin.readBoolean(), | ||
sin.readMap(StreamInput::readString, StreamInput::readStringList), | ||
sin.readEnum(RestStatus.class) | ||
); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeBoolean(isOrphan); | ||
out.writeMap(neighborEvents, StreamOutput::writeString, StreamOutput::writeStringCollection); | ||
out.writeEnum(status); | ||
} | ||
|
||
public RestStatus getStatus() { | ||
return status; | ||
} | ||
|
||
public Boolean getOrphan() { | ||
return isOrphan; | ||
} | ||
|
||
public Map<String, List<String>> getNeighborEvents() { | ||
return neighborEvents; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...in/java/org/opensearch/plugin/correlation/events/action/SearchCorrelatedEventsAction.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,21 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.plugin.correlation.events.action; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
public class SearchCorrelatedEventsAction extends ActionType<SearchCorrelatedEventsResponse> { | ||
|
||
public static final SearchCorrelatedEventsAction INSTANCE = new SearchCorrelatedEventsAction(); | ||
public static final String NAME = "cluster:admin/search/correlation/events"; | ||
|
||
private SearchCorrelatedEventsAction() { | ||
super(NAME, SearchCorrelatedEventsResponse::new); | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
...n/java/org/opensearch/plugin/correlation/events/action/SearchCorrelatedEventsRequest.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,82 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.plugin.correlation.events.action; | ||
|
||
import org.opensearch.action.ActionRequest; | ||
import org.opensearch.action.ActionRequestValidationException; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
|
||
import java.io.IOException; | ||
|
||
public class SearchCorrelatedEventsRequest extends ActionRequest { | ||
|
||
private String index; | ||
|
||
private String event; | ||
|
||
private String timestampField; | ||
|
||
private Long timeWindow; | ||
|
||
private Integer nearbyEvents; | ||
|
||
public SearchCorrelatedEventsRequest(String index, String event, String timestampField, Long timeWindow, Integer nearbyEvents) { | ||
super(); | ||
this.index = index; | ||
this.event = event; | ||
this.timestampField = timestampField; | ||
this.timeWindow = timeWindow; | ||
this.nearbyEvents = nearbyEvents; | ||
} | ||
|
||
public SearchCorrelatedEventsRequest(StreamInput sin) throws IOException { | ||
this( | ||
sin.readString(), | ||
sin.readString(), | ||
sin.readString(), | ||
sin.readLong(), | ||
sin.readInt() | ||
); | ||
} | ||
|
||
@Override | ||
public ActionRequestValidationException validate() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeString(index); | ||
out.writeString(event); | ||
out.writeString(timestampField); | ||
out.writeLong(timeWindow); | ||
out.writeInt(nearbyEvents); | ||
} | ||
|
||
public String getIndex() { | ||
return index; | ||
} | ||
|
||
public String getEvent() { | ||
return event; | ||
} | ||
|
||
public String getTimestampField() { | ||
return timestampField; | ||
} | ||
|
||
public Long getTimeWindow() { | ||
return timeWindow; | ||
} | ||
|
||
public Integer getNearbyEvents() { | ||
return nearbyEvents; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
.../java/org/opensearch/plugin/correlation/events/action/SearchCorrelatedEventsResponse.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,57 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.plugin.correlation.events.action; | ||
|
||
import org.opensearch.action.ActionResponse; | ||
import org.opensearch.common.io.stream.StreamInput; | ||
import org.opensearch.common.io.stream.StreamOutput; | ||
import org.opensearch.core.xcontent.ToXContentObject; | ||
import org.opensearch.core.xcontent.XContentBuilder; | ||
import org.opensearch.plugin.correlation.events.model.EventWithScore; | ||
import org.opensearch.rest.RestStatus; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
public class SearchCorrelatedEventsResponse extends ActionResponse implements ToXContentObject { | ||
|
||
private List<EventWithScore> events; | ||
|
||
private RestStatus status; | ||
|
||
private static final String EVENTS = "events"; | ||
|
||
public SearchCorrelatedEventsResponse(List<EventWithScore> events, RestStatus status) { | ||
super(); | ||
this.events = events; | ||
this.status = status; | ||
} | ||
|
||
public SearchCorrelatedEventsResponse(StreamInput sin) throws IOException { | ||
this( | ||
Collections.unmodifiableList(sin.readList(EventWithScore::new)), | ||
sin.readEnum(RestStatus.class) | ||
); | ||
} | ||
|
||
@Override | ||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { | ||
builder.startObject() | ||
.field(EVENTS, events) | ||
.endObject(); | ||
return builder.endObject(); | ||
} | ||
|
||
@Override | ||
public void writeTo(StreamOutput out) throws IOException { | ||
out.writeCollection(events); | ||
out.writeEnum(status); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...src/main/java/org/opensearch/plugin/correlation/events/action/StoreCorrelationAction.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,21 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.plugin.correlation.events.action; | ||
|
||
import org.opensearch.action.ActionType; | ||
|
||
public class StoreCorrelationAction extends ActionType<StoreCorrelationResponse> { | ||
|
||
public static final StoreCorrelationAction INSTANCE = new StoreCorrelationAction(); | ||
public static final String NAME = "cluster:admin/store/correlation/events"; | ||
|
||
private StoreCorrelationAction() { | ||
super(NAME, StoreCorrelationResponse::new); | ||
} | ||
} |
Oops, something went wrong.