-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add error handling strategy to pull-based ingestion
Signed-off-by: Varun Bharadwaj <varunbharadwaj1995@gmail.com>
- Loading branch information
1 parent
8447737
commit dc4722f
Showing
14 changed files
with
376 additions
and
28 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
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
36 changes: 36 additions & 0 deletions
36
server/src/main/java/org/opensearch/indices/pollingingest/BlockIngestionErrorStrategy.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,36 @@ | ||
/* | ||
* 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.indices.pollingingest; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
/** | ||
* This error handling strategy blocks on failures preventing processing of remaining updates in the ingestion source. | ||
*/ | ||
public class BlockIngestionErrorStrategy implements IngestionErrorStrategy { | ||
private static final Logger logger = LogManager.getLogger(BlockIngestionErrorStrategy.class); | ||
private final String ingestionSource; | ||
|
||
public BlockIngestionErrorStrategy(String ingestionSource) { | ||
this.ingestionSource = ingestionSource; | ||
} | ||
|
||
@Override | ||
public void handleError(Throwable e, ErrorStage stage) { | ||
logger.error("Error processing update from {}: {}", ingestionSource, e); | ||
|
||
// todo: record blocking update and emit metrics | ||
} | ||
|
||
@Override | ||
public boolean shouldPauseIngestion(Throwable e, ErrorStage stage) { | ||
return true; | ||
} | ||
} |
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
37 changes: 37 additions & 0 deletions
37
server/src/main/java/org/opensearch/indices/pollingingest/DropIngestionErrorStrategy.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,37 @@ | ||
/* | ||
* 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.indices.pollingingest; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
/** | ||
* This error handling strategy drops failures and proceeds with remaining updates in the ingestion source. | ||
*/ | ||
public class DropIngestionErrorStrategy implements IngestionErrorStrategy { | ||
private static final Logger logger = LogManager.getLogger(DropIngestionErrorStrategy.class); | ||
private final String ingestionSource; | ||
|
||
public DropIngestionErrorStrategy(String ingestionSource) { | ||
this.ingestionSource = ingestionSource; | ||
} | ||
|
||
@Override | ||
public void handleError(Throwable e, ErrorStage stage) { | ||
logger.error("Error processing update from {}: {}", ingestionSource, e); | ||
|
||
// todo: record failed update stats and emit metrics | ||
} | ||
|
||
@Override | ||
public boolean shouldPauseIngestion(Throwable e, ErrorStage stage) { | ||
return false; | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
server/src/main/java/org/opensearch/indices/pollingingest/IngestionErrorStrategy.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 @@ | ||
/* | ||
* 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.indices.pollingingest; | ||
|
||
/** | ||
* Defines the error handling strategy when an error is encountered either during polling records from ingestion source | ||
* or during processing the polled records. | ||
*/ | ||
public interface IngestionErrorStrategy { | ||
|
||
/** | ||
* Process and record the error. | ||
*/ | ||
void handleError(Throwable e, ErrorStage stage); | ||
|
||
/** | ||
* Indicates if ingestion must be paused, blocking further writes. | ||
*/ | ||
boolean shouldPauseIngestion(Throwable e, ErrorStage stage); | ||
|
||
static IngestionErrorStrategy create(ErrorStrategy errorStrategy, String ingestionSource) { | ||
switch (errorStrategy) { | ||
case BLOCK: | ||
return new BlockIngestionErrorStrategy(ingestionSource); | ||
case DROP: | ||
default: | ||
return new DropIngestionErrorStrategy(ingestionSource); | ||
} | ||
} | ||
|
||
// Indicates available error handling strategies | ||
enum ErrorStrategy { | ||
DROP, | ||
BLOCK | ||
} | ||
|
||
// Indicates different stages of encountered errors | ||
enum ErrorStage { | ||
POLLING, | ||
PROCESSING | ||
} | ||
|
||
} |
Oops, something went wrong.