-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TEZ-4543: Throw a special exception to DagClient when there is no current DAG #338
Changes from 1 commit
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* 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. | ||
*/ | ||
|
||
package org.apache.tez.dag.api; | ||
|
||
import org.apache.hadoop.classification.InterfaceAudience.Private; | ||
|
||
/** | ||
* Fatal exception: thrown by the AM if there is no DAG running when | ||
* when a DAG's status is queried. This is different from {@link org.apache.tez.dag.api.DAGNotRunningException} | ||
* in a sense that this exception is fatal, in which scenario the client might consider the DAG failed, because | ||
* it tries to ask a status from an AM which is not currently running a DAG. This scenario is possible in case | ||
* an AM is restarted and the DagClient fails to realize it's asking the status of a possibly lost DAG. | ||
*/ | ||
@Private | ||
public class NoCurrentDAGException extends TezException { | ||
private static final long serialVersionUID = 6337442733802964448L; | ||
|
||
public static final String MESSAGE_PREFIX = "No running DAG at present"; | ||
|
||
public NoCurrentDAGException(String dagId) { | ||
super(MESSAGE_PREFIX + ": " + dagId); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ | |
import org.apache.tez.client.FrameworkClient; | ||
import org.apache.tez.common.counters.TezCounters; | ||
import org.apache.tez.dag.api.DAGNotRunningException; | ||
import org.apache.tez.dag.api.NoCurrentDAGException; | ||
import org.apache.tez.dag.api.TezConfiguration; | ||
import org.apache.tez.dag.api.TezException; | ||
import org.apache.tez.dag.api.TezUncheckedException; | ||
|
@@ -408,6 +409,8 @@ private DAGStatus getDAGStatusViaAM(@Nullable Set<StatusGetOpts> statusOptions, | |
} catch (ApplicationNotFoundException e) { | ||
LOG.info("DAG is no longer running - application not found by YARN", e); | ||
dagCompleted = true; | ||
} catch (NoCurrentDAGException e) { | ||
return dagLost(e); | ||
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. the exception 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. agreed |
||
} catch (TezException e) { | ||
// can be either due to a n/w issue or due to AM completed. | ||
LOG.info("Cannot retrieve DAG Status due to TezException: {}", e.getMessage()); | ||
|
@@ -423,6 +426,14 @@ private DAGStatus getDAGStatusViaAM(@Nullable Set<StatusGetOpts> statusOptions, | |
return dagStatus; | ||
} | ||
|
||
private DAGStatus dagLost(Exception e) { | ||
DAGProtos.DAGStatusProto.Builder builder = DAGProtos.DAGStatusProto.newBuilder(); | ||
DAGStatus dagStatus = new DAGStatus(builder, DagStatusSource.AM); | ||
builder.setState(DAGProtos.DAGStatusStateProto.DAG_FAILED); | ||
builder.addAllDiagnostics(Collections.singleton(NoCurrentDAGException.MESSAGE_PREFIX)); | ||
return dagStatus; | ||
} | ||
|
||
private VertexStatus getVertexStatusViaAM(String vertexName, Set<StatusGetOpts> statusOptions) throws | ||
IOException { | ||
VertexStatus vertexStatus = null; | ||
|
@@ -435,9 +446,11 @@ private VertexStatus getVertexStatusViaAM(String vertexName, Set<StatusGetOpts> | |
LOG.info("DAG is no longer running - application not found by YARN", e); | ||
dagCompleted = true; | ||
} catch (TezException e) { | ||
// can be either due to a n/w issue of due to AM completed. | ||
// can be either due to a n/w issue or due to AM completed. | ||
LOG.info("Cannot retrieve Vertex Status due to TezException: {}", e.getMessage()); | ||
} catch (IOException e) { | ||
// can be either due to a n/w issue of due to AM completed. | ||
LOG.info("Cannot retrieve Vertex Status due to IOException: {}", e.getMessage()); | ||
} | ||
|
||
if (vertexStatus == null && !dagCompleted) { | ||
|
@@ -455,10 +468,11 @@ private VertexStatus getVertexStatusViaAM(String vertexName, Set<StatusGetOpts> | |
*/ | ||
@VisibleForTesting | ||
protected DAGStatus getDAGStatusViaRM() throws TezException, IOException { | ||
LOG.debug("GetDAGStatus via AM for app: {} dag:{}", appId, dagId); | ||
LOG.debug("Get DAG status via framework client for app: {} dag: {}", appId, dagId); | ||
ApplicationReport appReport; | ||
try { | ||
appReport = frameworkClient.getApplicationReport(appId); | ||
LOG.debug("Got appReport from framework client: {}", appReport); | ||
} catch (ApplicationNotFoundException e) { | ||
LOG.info("DAG is no longer running - application not found by YARN", e); | ||
throw new DAGNotRunningException(e); | ||
|
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.
nit
two times when, once in first line & then in second
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.
:) fixing it