4545import org .graylog2 .indexer .InvalidWriteTargetException ;
4646import org .graylog2 .indexer .MapperParsingException ;
4747import org .graylog2 .indexer .MasterNotDiscoveredException ;
48+ import org .graylog2 .indexer .ParentCircuitBreakingException ;
4849import org .slf4j .Logger ;
4950import org .slf4j .LoggerFactory ;
5051
@@ -202,6 +203,9 @@ public static RuntimeException exceptionFrom(Exception e, String errorMessage) {
202203 if (isMapperParsingExceptionException (elasticsearchException )) {
203204 return new MapperParsingException (elasticsearchException .getMessage ());
204205 }
206+ if (isParentCircuitBreakingException (elasticsearchException )) {
207+ return new ParentCircuitBreakingException (elasticsearchException .getMessage ());
208+ }
205209 } else if (e instanceof IOException && e .getCause () instanceof ContentTooLongException ) {
206210 return new BatchSizeTooLargeException (e .getMessage ());
207211 }
@@ -231,8 +235,8 @@ private static boolean isIndexNotFoundException(ElasticsearchException elasticse
231235 return elasticsearchException .getMessage ().contains ("index_not_found_exception" );
232236 }
233237
234- private static boolean isMapperParsingExceptionException (ElasticsearchException openSearchException ) {
235- return openSearchException .getMessage ().contains ("mapper_parsing_exception" );
238+ private static boolean isMapperParsingExceptionException (ElasticsearchException elasticSearchException ) {
239+ return elasticSearchException .getMessage ().contains ("mapper_parsing_exception" );
236240 }
237241
238242 private static boolean isBatchSizeTooLargeException (ElasticsearchException elasticsearchException ) {
@@ -254,6 +258,19 @@ private static boolean isBatchSizeTooLargeException(ElasticsearchException elast
254258 return false ;
255259 }
256260
261+ private static boolean isParentCircuitBreakingException (ElasticsearchException elasticsearchException ) {
262+ try {
263+ final ParsedElasticsearchException parsedException = ParsedElasticsearchException .from (elasticsearchException .getMessage ());
264+ if (parsedException .type ().equals ("circuit_breaking_exception" )) {
265+ ParsedElasticsearchException parsedCause = ParsedElasticsearchException .from (elasticsearchException .getRootCause ().getMessage ());
266+ return parsedCause .reason ().contains ("[parent] Data too large" );
267+ }
268+ } catch (Exception e ) {
269+ return false ;
270+ }
271+ return false ;
272+ }
273+
257274 public static RequestOptions withTimeout (RequestOptions requestOptions , Duration timeout ) {
258275 final RequestConfig .Builder requestConfigBuilder = (requestOptions == null || requestOptions .getRequestConfig () == null )
259276 ? RequestConfig .custom ()
0 commit comments