Skip to content

Commit

Permalink
[streaming] Fixed error logging in streaming tasks.
Browse files Browse the repository at this point in the history
  • Loading branch information
StephanEwen committed May 20, 2015
1 parent f27025b commit 68f41a0
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,22 @@ public void invoke() throws Exception {
LOG.debug("Task {} invocation finished", getName());
}

} catch (Exception e) {

}
catch (Exception e) {
LOG.error(getEnvironment().getTaskNameWithSubtasks() + " failed", e);

if (operatorOpen) {
try {
closeOperator();
} catch (Throwable t) {
LOG.info("Caught exception while closing operator.", e);
}
catch (Throwable t) {
LOG.warn("Exception while closing operator.", t);
}
}

if (LOG.isErrorEnabled()) {
LOG.error("StreamOperator failed.", e);
}

throw e;
} finally {
}
finally {
this.isRunning = false;
// Cleanup
inputs.clearBuffers();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@ public void invoke() throws Exception {
LOG.debug("Task {} invocation finished", getName());
}

} catch (Exception e) {
}
catch (Exception e) {
LOG.error(getEnvironment().getTaskNameWithSubtasks() + " failed", e);

if (operatorOpen) {
try {
closeOperator();
} catch (Throwable t) {
LOG.info("Caught exception while closing operator.", e);
}
}

if (LOG.isErrorEnabled()) {
LOG.error("StreamOperator failed.", e);
catch (Throwable t) {
LOG.warn("Exception while closing operator.", t);
}
}
throw e;
} finally {
}
finally {
this.isRunning = false;
// Cleanup
outputHandler.flushOutputs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.flink.streaming.api.collector.StreamOutput;
import org.apache.flink.streaming.runtime.io.BlockingQueueBroker;
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
import org.apache.flink.util.StringUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -88,16 +88,16 @@ public void invoke() throws Exception {
}
}

} catch (Exception e) {
if (LOG.isErrorEnabled()) {
LOG.error("Iteration source failed due to: {}", StringUtils.stringifyException(e));
}
}
catch (Exception e) {
LOG.error("Iteration Head " + getEnvironment().getTaskNameWithSubtasks() + " failed", e);

throw e;
} finally {
}
finally {
// Cleanup
outputHandler.flushOutputs();
clearBuffers();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public void invoke() throws Exception {
if (LOG.isDebugEnabled()) {
LOG.debug("Iteration sink {} invoke finished", getName());
}
} catch (Exception e) {
if (LOG.isErrorEnabled()) {
LOG.error("Iteration sink failed due to: {}", StringUtils.stringifyException(e));
}
}
catch (Exception e) {
LOG.error("Iteration tail " + getEnvironment().getTaskNameWithSubtasks() + " failed", e);
throw e;
} finally {
}
finally {
// Cleanup
clearBuffers();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.apache.flink.streaming.runtime.io.InputGateFactory;
import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
import org.apache.flink.streaming.runtime.streamrecord.StreamRecordSerializer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -99,21 +100,22 @@ public void invoke() throws Exception {
LOG.debug("Task {} invocation finished", getName());
}

} catch (Exception e) {
}
catch (Exception e) {
LOG.error(getEnvironment().getTaskNameWithSubtasks() + " failed", e);

if (operatorOpen) {
try {
closeOperator();
} catch (Throwable t) {
LOG.info("Caught exception while closing operator.", e);
}
catch (Throwable t) {
LOG.warn("Exception while closing operator.", t);
}
}

if (LOG.isErrorEnabled()) {
LOG.error("StreamOperator failed. ", e);
}

throw e;
} finally {
}
finally {
this.isRunning = false;
// Cleanup
outputHandler.flushOutputs();
Expand Down

0 comments on commit 68f41a0

Please sign in to comment.