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.
Disable the circuit breaker for buffers that write data off-heap only…
…. This is currently only the Kafka buffer. Resolves opensearch-project#3616 Signed-off-by: David Venable <[email protected]>
- Loading branch information
Showing
13 changed files
with
182 additions
and
98 deletions.
There are no files selected for viewing
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
49 changes: 49 additions & 0 deletions
49
data-prepper-core/src/main/java/org/opensearch/dataprepper/parser/MultiBufferDecorator.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,49 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.parser; | ||
|
||
import org.opensearch.dataprepper.model.buffer.Buffer; | ||
import org.opensearch.dataprepper.model.buffer.DelegatingBuffer; | ||
import org.opensearch.dataprepper.model.record.Record; | ||
|
||
import java.time.Duration; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* Buffer decorator created for pipelines that make use of multiple buffers, such as PeerForwarder-enabled pipelines. The decorator | ||
* acts as a pass-through to the primary buffer for most methods except those that rely on a combination of the primary | ||
* and second. For example, isEmpty depends on all buffers being empty. | ||
* | ||
* @since 2.0 | ||
*/ | ||
class MultiBufferDecorator<T extends Record<?>> extends DelegatingBuffer<T> implements Buffer<T> { | ||
private final List<Buffer> allBuffers; | ||
|
||
MultiBufferDecorator(final Buffer primaryBuffer, final List<Buffer> secondaryBuffers) { | ||
super(primaryBuffer); | ||
allBuffers = new ArrayList<>(1 + secondaryBuffers.size()); | ||
allBuffers.add(primaryBuffer); | ||
allBuffers.addAll(secondaryBuffers); | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return allBuffers.stream().allMatch(Buffer::isEmpty); | ||
} | ||
|
||
@Override | ||
public Duration getDrainTimeout() { | ||
return allBuffers.stream() | ||
.map(Buffer::getDrainTimeout) | ||
.reduce(Duration.ZERO, Duration::plus); | ||
} | ||
|
||
@Override | ||
public void shutdown() { | ||
allBuffers.forEach(Buffer::shutdown); | ||
} | ||
} |
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
83 changes: 0 additions & 83 deletions
83
data-prepper-core/src/main/java/org/opensearch/dataprepper/plugins/MultiBufferDecorator.java
This file was deleted.
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
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
48 changes: 48 additions & 0 deletions
48
data-prepper-core/src/test/java/org/opensearch/dataprepper/plugins/TestOffHeapBuffer.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,48 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins; | ||
|
||
import org.opensearch.dataprepper.model.CheckpointState; | ||
import org.opensearch.dataprepper.model.annotations.DataPrepperPlugin; | ||
import org.opensearch.dataprepper.model.buffer.Buffer; | ||
import org.opensearch.dataprepper.model.record.Record; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
@DataPrepperPlugin(name = "test_off_heap", pluginType = Buffer.class) | ||
public class TestOffHeapBuffer implements Buffer { | ||
@Override | ||
public void write(Record record, int timeoutInMillis) throws TimeoutException { | ||
|
||
} | ||
|
||
@Override | ||
public void writeAll(Collection records, int timeoutInMillis) throws Exception { | ||
|
||
} | ||
|
||
@Override | ||
public Map.Entry<Collection, CheckpointState> read(int timeoutInMillis) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public void checkpoint(CheckpointState checkpointState) { | ||
|
||
} | ||
|
||
@Override | ||
public boolean isWrittenOffHeapOnly() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean isEmpty() { | ||
return false; | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
data-prepper-core/src/test/resources/single_pipeline_valid_off_heap_buffer.yml
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,7 @@ | ||
test-pipeline-1: | ||
source: | ||
stdin: | ||
buffer: | ||
test_off_heap: | ||
sink: | ||
- stdout: |
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