forked from opensearch-project/data-prepper
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementation for default non-blocking buffer.
Signed-off-by: Souvik Bose <[email protected]>
- Loading branch information
Showing
7 changed files
with
65 additions
and
40 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
data-prepper-api/src/main/java/org/opensearch/dataprepper/model/buffer/DefinesBuffer.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,8 @@ | ||
package org.opensearch.dataprepper.model.buffer; | ||
|
||
import java.util.Optional; | ||
|
||
public interface DefinesBuffer { | ||
|
||
Optional<Buffer> getDefaultBuffer(); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, 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
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
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 |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
package org.opensearch.dataprepper.pipeline.buffer; | ||
|
||
import io.micrometer.core.instrument.Counter; | ||
import org.apache.commons.collections.buffer.SynchronizedBuffer; | ||
import org.opensearch.dataprepper.metrics.MetricNames; | ||
import org.opensearch.dataprepper.metrics.PluginMetrics; | ||
import org.opensearch.dataprepper.model.CheckpointState; | ||
|
@@ -23,16 +24,15 @@ | |
|
||
import static com.google.common.base.Preconditions.checkNotNull; | ||
|
||
@DataPrepperPlugin(name = "synchronized_buffer", pluginType = Buffer.class) | ||
public class SynchronizedBuffer<T extends Record<?>> extends AbstractSynchronizedBuffer<T> { | ||
private static final Logger LOG = LoggerFactory.getLogger(SynchronizedBuffer.class); | ||
public class NonBlockingBuffer<T extends Record<?>> extends AbstractNonBlockingBuffer<T> { | ||
private static final Logger LOG = LoggerFactory.getLogger(NonBlockingBuffer.class); | ||
private static final String SYNCHRONIZED_BUFFER = "SynchronizedBuffer"; | ||
private final String pipelineName; | ||
private final ThreadLocal<Collection<T>> threadLocalStore; | ||
private final Counter recordsWrittenCounter; | ||
private final Counter recordsReadCounter; | ||
|
||
public SynchronizedBuffer(final String pipelineName) { | ||
public NonBlockingBuffer(final String pipelineName) { | ||
This comment has been minimized.
Sorry, something went wrong.
kkondaka
|
||
this.pipelineName = pipelineName; | ||
this.threadLocalStore = new ThreadLocal<>(); | ||
|
||
|
@@ -41,7 +41,7 @@ public SynchronizedBuffer(final String pipelineName) { | |
this.recordsReadCounter = pluginMetrics.counter(MetricNames.RECORDS_READ); | ||
} | ||
|
||
public SynchronizedBuffer(final PluginSetting pluginSetting) { | ||
public NonBlockingBuffer(final PluginSetting pluginSetting) { | ||
this(checkNotNull(pluginSetting, "PluginSetting cannot be null").getPipelineName()); | ||
} | ||
|
||
|
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
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
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
The logic below forces a buffer. So we might want to rename this to
getBuffer()
orgetDefinedBuffer()
.