[REEF-1428] Validate Task Stop failure => FailedTask Event #1038
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,16 +100,6 @@ public void SetException(Exception e) | |
{ | ||
try | ||
{ | ||
if (HasEnded()) | ||
{ | ||
// Note that this is possible if the job is already DONE, but a | ||
// Task Close is triggered prior to the DONE signal propagates to the | ||
// Driver. If the Task Close handler is not implemented, the Handler will | ||
// mark the Task with an Exception, although for all intents and purposes | ||
// the Task is already done and should not be affected. | ||
return; | ||
} | ||
|
||
if (!_lastException.IsPresent()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this not a valid scenarios? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. In this PR I've moved |
||
{ | ||
_lastException = Optional<Exception>.Of(e); | ||
|
@@ -130,6 +120,8 @@ public void SetResult(byte[] result) | |
lock (_heartBeatManager) | ||
{ | ||
_result = Optional<byte[]>.OfNullable(result); | ||
_taskLifeCycle.Stop(); | ||
|
||
switch (State) | ||
{ | ||
case TaskState.SuspendRequested: | ||
|
@@ -140,7 +132,6 @@ public void SetResult(byte[] result) | |
State = TaskState.Done; | ||
break; | ||
} | ||
_taskLifeCycle.Stop(); | ||
Heartbeat(); | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
using System; | ||
|
||
namespace Org.Apache.REEF.Common.Runtime.Evaluator.Task | ||
{ | ||
/// <summary> | ||
/// An Exception that indicates that the TaskStopHandlers have triggered an Exception. | ||
/// </summary> | ||
internal sealed class TaskStopHandlerException : Exception | ||
{ | ||
internal TaskStopHandlerException(string message, Exception inner) : base(message, inner) | ||
{ | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
using System; | ||
|
||
namespace Org.Apache.REEF.Tests.Functional.Common.Task.Handlers | ||
{ | ||
/// <summary> | ||
/// A helper test class that implements <see cref="IObserver{T}"/>, which throws an | ||
/// Exception after executing an optional Action provided by the caller of the constructor. | ||
/// </summary> | ||
internal abstract class ExceptionThrowingHandler<T> : IObserver<T> | ||
{ | ||
private readonly Exception _exceptionToThrow; | ||
private readonly Action<T> _action; | ||
|
||
protected ExceptionThrowingHandler( | ||
Exception exceptionToThrow, Action<T> action = null) | ||
{ | ||
_exceptionToThrow = exceptionToThrow; | ||
_action = action; | ||
} | ||
|
||
public void OnNext(T value) | ||
{ | ||
if (_action != null) | ||
{ | ||
_action(value); | ||
} | ||
|
||
throw _exceptionToThrow; | ||
} | ||
|
||
public void OnError(Exception error) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void OnCompleted() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
using System; | ||
using Org.Apache.REEF.Utilities.Logging; | ||
|
||
namespace Org.Apache.REEF.Tests.Functional.Common.Task.Handlers | ||
{ | ||
/// <summary> | ||
/// A helper test class that implements <see cref="IObserver{T}"/>, which logs | ||
/// a message provided by the caller of the constructor. | ||
/// </summary> | ||
public abstract class LoggingHandler<T> : IObserver<T> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. internal? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test classes don't particularly matter because they are not a part of our API anyway. |
||
{ | ||
private static readonly Logger Logger = Logger.GetLogger(typeof(LoggingHandler<>)); | ||
|
||
private readonly string _messageToLog; | ||
|
||
protected LoggingHandler(string messageToLog) | ||
{ | ||
_messageToLog = messageToLog; | ||
} | ||
|
||
public void OnNext(T value) | ||
{ | ||
Logger.Log(Level.Info, _messageToLog); | ||
} | ||
|
||
public void OnError(Exception error) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void OnCompleted() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Licensed to the Apache Software Foundation (ASF) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The ASF licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
using Org.Apache.REEF.Common.Tasks; | ||
using Org.Apache.REEF.Utilities.Logging; | ||
|
||
namespace Org.Apache.REEF.Tests.Functional.Common.Task | ||
{ | ||
/// <summary> | ||
/// A helper test class that implements <see cref="ITask"/>, which logs | ||
/// a message provided by the caller of the constructor. | ||
/// </summary> | ||
public abstract class LoggingTask : ITask | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. internal? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See other comment. |
||
{ | ||
private static readonly Logger Logger = Logger.GetLogger(typeof(LoggingTask)); | ||
|
||
private readonly string _messageToLog; | ||
|
||
protected LoggingTask(string messageToLog) | ||
{ | ||
_messageToLog = messageToLog; | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
} | ||
|
||
public byte[] Call(byte[] memento) | ||
{ | ||
Logger.Log(Level.Info, _messageToLog); | ||
return null; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why catch exception in Stop but not start? Any specific exception you would expect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Start is addressed in another JIRA.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we serialize TaskStopHandlerException to evalautor or eventually replaced it with SystemException in ContextRuntime? This is actually the exception from client's handler, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the client's Exception. We serialize the client's Exception using
InnerException
, as seen inTaskRuntime.cs
.