Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop processor #801

Merged
merged 7 commits into from
Jan 4, 2022
Merged

Conversation

dapowers87
Copy link
Contributor

Description

This creates a Drop Processor to drop messages

Issues Resolved

#598

Check List

  • New functionality includes testing.
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@dapowers87 dapowers87 requested a review from a team as a code owner January 3, 2022 16:09
David Powers added 3 commits January 3, 2022 10:15
Signed-off-by: David Powers <[email protected]>
Signed-off-by: David Powers <[email protected]>
Signed-off-by: David Powers <[email protected]>
@codecov-commenter
Copy link

codecov-commenter commented Jan 3, 2022

Codecov Report

Merging #801 (95d3350) into main (1183a7a) will increase coverage by 0.10%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #801      +/-   ##
============================================
+ Coverage     91.53%   91.64%   +0.10%     
- Complexity      637      640       +3     
============================================
  Files            75       75              
  Lines          1902     1902              
  Branches        161      161              
============================================
+ Hits           1741     1743       +2     
  Misses          121      121              
+ Partials         40       38       -2     
Impacted Files Coverage Δ
...com/amazon/dataprepper/pipeline/ProcessWorker.java 91.42% <0.00%> (+5.71%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1183a7a...95d3350. Read the comment docs.

@@ -0,0 +1,29 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct copyright header (unless you copied this source code from another project).

It should be:

/*
 * Copyright OpenSearch Contributors
 * SPDX-License-Identifier: Apache-2.0
 */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,59 @@
/*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect copyright header - see message above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,49 @@
package com.amazon.dataprepper.plugins.processor.drop;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add copyright header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

import java.util.LinkedList;
import java.util.List;

@SingleThread
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This processor does not need the @SingleThread annotation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed


@Override
public Collection<Record<Event>> doExecute(Collection<Record<Event>> records) {
List<Record<Event>> emptySet = new LinkedList<>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can return Collections.emptyList() here instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


final List<Record<Event>> droppedRecords = (List<Record<Event>>) dropProcessor.doExecute(Collections.singletonList(record));

Assert.assertEquals(0, droppedRecords.size());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use Hamcrest:

assertThat(droppedRecords.size(), equalTo(0));

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to Hamcrest

private final String PLUGIN_NAME = "drop_events";

@Test
void doExecute() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to have a test which also has more than one item in the input list.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the second test

settings.gradle Outdated
@@ -31,6 +31,7 @@ include 'data-prepper-plugins:otel-trace-source'
include 'data-prepper-plugins:peer-forwarder'
include 'data-prepper-plugins:blocking-buffer'
include 'data-prepper-plugins:http-source'
include 'data-prepper-plugins:drop-processor'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should try to keep the names consistent. You named the plugin drop_events. So, I think this project should be drop-events-processor.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to drop-events-processor

Copy link
Contributor

@cmanning09 cmanning09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's document this plugin with a README.md file.

dlvenable
dlvenable previously approved these changes Jan 3, 2022
@dapowers87 dapowers87 merged commit a59d2d2 into opensearch-project:main Jan 4, 2022
@dapowers87 dapowers87 deleted the DropProcessor branch January 4, 2022 16:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants