use of io.siddhi.core.util.error.handler.model.ErroneousEvent in project siddhi by wso2.
the class StreamJunction method handleError.
public void handleError(Object event, Exception e) {
if (exceptionListener != null) {
exceptionListener.exceptionThrown(e);
}
switch(onErrorAction) {
case LOG:
log.error("Error in '" + siddhiAppContext.getName() + "' after consuming events " + "from Stream '" + streamDefinition.getId() + "', " + e.getMessage() + ". Hence, dropping event '" + event.toString() + "'", e);
break;
case STREAM:
if (faultStreamJunction != null) {
StreamEvent streamEvent = null;
if (event instanceof ComplexEvent) {
streamEvent = faultStreamEventConverter.convert((ComplexEvent) event, e);
faultStreamJunction.sendEvent(streamEvent);
} else if (event instanceof Event) {
streamEvent = faultStreamEventConverter.convert((Event) event, e);
faultStreamJunction.sendEvent(streamEvent);
} else if (event instanceof Event[]) {
streamEvent = faultStreamEventConverter.convert((Event[]) event, e);
faultStreamJunction.sendEvent(streamEvent);
} else if (event instanceof List) {
streamEvent = faultStreamEventConverter.convert((List<Event>) event, e);
faultStreamJunction.sendEvent(streamEvent);
}
} else {
log.error("Error in SiddhiApp '" + siddhiAppContext.getName() + "' after consuming events from Stream '" + streamDefinition.getId() + "', " + e.getMessage() + ". Siddhi Fault Stream for '" + streamDefinition.getId() + "' is not defined. " + "Hence, dropping event '" + event.toString() + "'", e);
}
break;
case STORE:
ErroneousEvent erroneousEvent = new ErroneousEvent(event, e, "Error in SiddhiApp '" + siddhiAppContext.getName() + "' after consuming events from Stream '" + streamDefinition.getId() + "', " + e.getMessage() + ". Siddhi Fault Stream for '" + streamDefinition.getId() + "' is not defined. " + "Hence, dropping event '" + event.toString() + "'");
ErrorStoreHelper.storeErroneousEvent(siddhiAppContext.getSiddhiContext().getErrorStore(), ErrorOccurrence.STORE_ON_STREAM_ERROR, siddhiAppContext.getName(), erroneousEvent, streamDefinition.getId());
break;
default:
break;
}
}
use of io.siddhi.core.util.error.handler.model.ErroneousEvent in project siddhi by wso2.
the class Table method onUpdateError.
protected void onUpdateError(ComplexEventChunk<StateEvent> updatingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet, Exception e) {
OnErrorAction errorAction = onErrorAction;
if (e instanceof ConnectionUnavailableException) {
isConnected.set(false);
if (errorAction == OnErrorAction.STORE) {
updatingEventChunk.reset();
ErroneousEvent erroneousEvent = new ErroneousEvent(new ReplayableTableRecord(updatingEventChunk, compiledCondition, compiledUpdateSet), e, e.getMessage());
erroneousEvent.setOriginalPayload(ErrorHandlerUtils.constructErrorRecordString(updatingEventChunk, isObjectColumnPresent, tableDefinition, e));
ErrorStoreHelper.storeErroneousEvent(siddhiAppContext.getSiddhiContext().getErrorStore(), ErrorOccurrence.STORE_ON_TABLE_UPDATE, siddhiAppContext.getName(), erroneousEvent, tableDefinition.getId());
LOG.error("Error on '" + siddhiAppContext.getName() + "' while performing update for events " + "at '" + tableDefinition.getId() + "'. Events saved '" + updatingEventChunk.toString() + "'");
if (LOG.isDebugEnabled()) {
LOG.debug(e);
}
if (!isTryingToConnect.get()) {
connectWithRetry();
}
} else {
if (isTryingToConnect.get()) {
LOG.warn("Error on '" + siddhiAppContext.getName() + "' while performing update for " + "events '" + updatingEventChunk + "', operation busy waiting at Table '" + tableDefinition.getId() + "' as its trying to reconnect!");
waitWhileConnect();
LOG.info("SiddhiApp '" + siddhiAppContext.getName() + "' table '" + tableDefinition.getId() + "' has become available for update operation for events '" + updatingEventChunk + "'");
update(updatingEventChunk, compiledCondition, compiledUpdateSet);
} else {
connectWithRetry();
update(updatingEventChunk, compiledCondition, compiledUpdateSet);
}
}
} else if (e instanceof DatabaseRuntimeException) {
if (errorAction == OnErrorAction.STORE) {
updatingEventChunk.reset();
ReplayableTableRecord record = new ReplayableTableRecord(updatingEventChunk, compiledCondition, compiledUpdateSet);
record.setFromConnectionUnavailableException(false);
ErroneousEvent erroneousEvent = new ErroneousEvent(record, e, e.getMessage());
erroneousEvent.setOriginalPayload(ErrorHandlerUtils.constructErrorRecordString(updatingEventChunk, isObjectColumnPresent, tableDefinition, e));
ErrorStoreHelper.storeErroneousEvent(siddhiAppContext.getSiddhiContext().getErrorStore(), ErrorOccurrence.STORE_ON_TABLE_UPDATE, siddhiAppContext.getName(), erroneousEvent, tableDefinition.getId());
LOG.error("Error on '" + siddhiAppContext.getName() + "' while performing update for events " + "at '" + tableDefinition.getId() + "'. Events saved '" + updatingEventChunk.toString() + "'");
if (LOG.isDebugEnabled()) {
LOG.debug(e);
}
}
}
}
use of io.siddhi.core.util.error.handler.model.ErroneousEvent in project siddhi by wso2.
the class Table method onUpdateOrAddError.
protected void onUpdateOrAddError(ComplexEventChunk<StateEvent> updateOrAddingEventChunk, CompiledCondition compiledCondition, CompiledUpdateSet compiledUpdateSet, AddingStreamEventExtractor addingStreamEventExtractor, Exception e) {
OnErrorAction errorAction = onErrorAction;
if (e instanceof ConnectionUnavailableException) {
isConnected.set(false);
if (errorAction == OnErrorAction.STORE) {
updateOrAddingEventChunk.reset();
ErroneousEvent erroneousEvent = new ErroneousEvent(new ReplayableTableRecord(updateOrAddingEventChunk, compiledCondition, compiledUpdateSet, addingStreamEventExtractor), e, e.getMessage());
erroneousEvent.setOriginalPayload(ErrorHandlerUtils.constructErrorRecordString(updateOrAddingEventChunk, isObjectColumnPresent, tableDefinition, e));
ErrorStoreHelper.storeErroneousEvent(siddhiAppContext.getSiddhiContext().getErrorStore(), ErrorOccurrence.STORE_ON_TABLE_UPDATE_OR_ADD, siddhiAppContext.getName(), erroneousEvent, tableDefinition.getId());
LOG.error("Error on '" + siddhiAppContext.getName() + "' while performing update or add for " + "events at '" + tableDefinition.getId() + "'. Events saved '" + updateOrAddingEventChunk.toString() + "'");
if (LOG.isDebugEnabled()) {
LOG.debug(e);
}
if (!isTryingToConnect.get()) {
connectWithRetry();
}
} else {
if (isTryingToConnect.get()) {
LOG.warn("Error on '" + siddhiAppContext.getName() + "' while performing update or add for " + "events '" + updateOrAddingEventChunk + "', operation busy waiting at Table '" + tableDefinition.getId() + "' as its trying to reconnect!");
waitWhileConnect();
LOG.info("SiddhiApp '" + siddhiAppContext.getName() + "' table '" + tableDefinition.getId() + "' has become available for update or add operation for events '" + updateOrAddingEventChunk + "'");
updateOrAdd(updateOrAddingEventChunk, compiledCondition, compiledUpdateSet, addingStreamEventExtractor);
} else {
connectWithRetry();
updateOrAdd(updateOrAddingEventChunk, compiledCondition, compiledUpdateSet, addingStreamEventExtractor);
}
}
} else if (e instanceof DatabaseRuntimeException) {
if (errorAction == OnErrorAction.STORE) {
updateOrAddingEventChunk.reset();
ReplayableTableRecord record = new ReplayableTableRecord(updateOrAddingEventChunk, compiledCondition, compiledUpdateSet, addingStreamEventExtractor);
record.setFromConnectionUnavailableException(false);
ErroneousEvent erroneousEvent = new ErroneousEvent(record, e, e.getMessage());
erroneousEvent.setOriginalPayload(ErrorHandlerUtils.constructErrorRecordString(updateOrAddingEventChunk, isObjectColumnPresent, tableDefinition, e));
ErrorStoreHelper.storeErroneousEvent(siddhiAppContext.getSiddhiContext().getErrorStore(), ErrorOccurrence.STORE_ON_TABLE_UPDATE_OR_ADD, siddhiAppContext.getName(), erroneousEvent, tableDefinition.getId());
LOG.error("Error on '" + siddhiAppContext.getName() + "' while performing update or add for " + "events at '" + tableDefinition.getId() + "'. Events saved '" + updateOrAddingEventChunk.toString() + "'");
if (LOG.isDebugEnabled()) {
LOG.debug(e);
}
}
}
}
use of io.siddhi.core.util.error.handler.model.ErroneousEvent in project siddhi by wso2.
the class SourceMapper method onEvent.
public final void onEvent(Object eventObject, Object[] transportProperties, String[] transportSyncProperties) {
try {
if (eventObject != null) {
if (!allowNullInTransportProperties() && transportProperties != null) {
for (Object property : transportProperties) {
if (property == null) {
log.error("Dropping event " + eventObject.toString() + " belonging to stream " + streamDefinition.getId() + " as it contains null transport properties and system " + "is configured to not allow null transport properties. You can " + "configure it via source mapper if the respective " + "mapper type allows it. Refer mapper documentation to verify " + "supportability");
return;
}
}
}
trpProperties.set(transportProperties);
if (transportSyncProperties != null) {
trpSyncProperties.set(transportSyncProperties);
}
try {
if (throughputTracker != null && Level.BASIC.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
throughputTracker.eventIn();
}
if (throughputTracker != null && Level.DETAIL.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
mapperLatencyTracker.markIn();
}
mapAndProcess(eventObject, inputEventHandler);
if (logEventCount) {
if (firstRun) {
receivedEventCounter.scheduleEventCounterLogger();
firstRun = false;
}
receivedEventCounter.countEvents(eventObject);
}
} finally {
if (throughputTracker != null && Level.DETAIL.compareTo(siddhiAppContext.getRootMetricsLevel()) <= 0) {
mapperLatencyTracker.markOut();
}
}
}
} catch (MappingFailedException e) {
ErrorStoreHelper.storeErroneousEvent(siddhiAppContext.getSiddhiContext().getErrorStore(), ErrorOccurrence.BEFORE_SOURCE_MAPPING, siddhiAppContext.getName(), e.getFailures(), streamDefinition.getId());
log.error("Error while processing '" + eventObject + "', for the input Mapping '" + mapType + "' for the stream '" + streamDefinition.getId() + "'.", e);
} catch (InterruptedException | RuntimeException e) {
ErroneousEvent erroneousEvent = new ErroneousEvent(eventObject, e, "Error while processing '" + eventObject + "', for the input Mapping '" + mapType + "' for the stream '" + streamDefinition.getId() + "'.");
ErrorStoreHelper.storeErroneousEvent(siddhiAppContext.getSiddhiContext().getErrorStore(), ErrorOccurrence.BEFORE_SOURCE_MAPPING, siddhiAppContext.getName(), Collections.singletonList(erroneousEvent), streamDefinition.getId());
log.error("Error while processing '" + eventObject + "', for the input Mapping '" + mapType + "' for the stream '" + streamDefinition.getId() + "'.", e);
} finally {
trpProperties.remove();
if (transportSyncProperties != null) {
trpSyncProperties.remove();
}
}
}
use of io.siddhi.core.util.error.handler.model.ErroneousEvent in project siddhi by wso2.
the class TestTrpSourceMapper method mapAndProcess.
@Override
protected void mapAndProcess(Object eventObject, InputEventHandler inputEventHandler) throws MappingFailedException, InterruptedException {
if (eventObject != null) {
if (eventObject instanceof Event) {
Event output = new Event(streamDefinition.getAttributeList().size());
for (AttributeMapping attributeMapping : attributeMappingList) {
output.getData()[attributeMapping.getPosition()] = ((Event) eventObject).getData(Integer.parseInt(attributeMapping.getMapping()));
}
inputEventHandler.sendEvent(output);
} else {
throw new MappingFailedException(Collections.singletonList(new ErroneousEvent(eventObject, "Event object must be either Event[], Event or Object[] " + "but found " + eventObject.getClass().getCanonicalName())));
}
}
}
Aggregations