Skip to content

Commit

Permalink
Move getDrainTimeout to default method in the interface, add test for…
Browse files Browse the repository at this point in the history
… it, disable SNS sink

Signed-off-by: Chase Engelbrecht <[email protected]>
  • Loading branch information
engechas committed Oct 6, 2023
1 parent ba2891e commit 4ca6b1b
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 23 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ gradle/tools
# Ignore config file generated by test
data-prepper-main/src/test/resources/logstash-filter.yaml
data-prepper-main/src/test/resources/logstash-conf/logstash-filter.yaml
data-prepper-plugins/sns-sink/C:\\Work\\dlq.txt
data-prepper-plugins/sns-sink/local_dlq_file
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.opensearch.dataprepper.model.configuration.PluginSetting;
import org.opensearch.dataprepper.model.record.Record;

import java.time.Duration;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -181,9 +180,4 @@ protected int getRecordsInFlight() {
public void postProcess(final Long recordsInBuffer) {

}

@Override
public Duration getDrainTimeout() {
return Duration.ZERO;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,7 @@ public interface Buffer<T extends Record<?>> {

boolean isEmpty();

Duration getDrainTimeout();
default Duration getDrainTimeout() {
return Duration.ZERO;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.opensearch.dataprepper.model.configuration.PluginSetting;
import org.opensearch.dataprepper.model.record.Record;

import java.time.Duration;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -260,13 +259,6 @@ public void testWriteAllRuntimeException() {
Assert.assertThrows(NullPointerException.class, () -> abstractBuffer.writeAll(testRecords, 1000));
}

@Test
public void testGetDrainTimeout() {
final AbstractBuffer<Record<String>> abstractBuffer = new AbstractBufferImpl(testPluginSetting);

Assert.assertEquals(Duration.ZERO, abstractBuffer.getDrainTimeout());
}

public static class AbstractBufferImpl extends AbstractBuffer<Record<String>> {
private final Queue<Record<String>> queue;
public AbstractBufferImpl(PluginSetting pluginSetting) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

package org.opensearch.dataprepper.model.buffer;

import org.junit.Assert;
import org.junit.jupiter.api.Test;
import org.opensearch.dataprepper.model.event.Event;
import org.opensearch.dataprepper.model.record.Record;

import java.time.Duration;

import static org.mockito.Mockito.spy;

public class BufferTest {

@Test
public void testGetDrainTimeout() {
final Buffer<Record<Event>> buffer = spy(Buffer.class);

Assert.assertEquals(Duration.ZERO, buffer.getDrainTimeout());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.opensearch.dataprepper.model.event.Event;
import org.opensearch.dataprepper.model.record.Record;

import java.time.Duration;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -93,8 +92,4 @@ public int size() {
return buffer.size();
}

@Override
public Duration getDrainTimeout() {
return Duration.ZERO;
}
}
2 changes: 1 addition & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ include 'data-prepper-plugins:buffer-common'
include 'data-prepper-plugins:sqs-source'
include 'data-prepper-plugins:cloudwatch-logs'
include 'data-prepper-plugins:http-sink'
include 'data-prepper-plugins:sns-sink'
//include 'data-prepper-plugins:sns-sink'
include 'data-prepper-plugins:prometheus-sink'
include 'data-prepper-plugins:dissect-processor'
include 'data-prepper-plugins:dynamodb-source'

0 comments on commit 4ca6b1b

Please sign in to comment.