Search in sources :

Example 1 with DAGAppMasterEvent

use of org.apache.tez.dag.app.dag.event.DAGAppMasterEvent in project tez by apache.

the class TaskSchedulerManager method appShutdownRequested.

public synchronized void appShutdownRequested(int schedulerId) {
    // This can happen if the RM has been restarted. If it is in that state,
    // this application must clean itself up.
    LOG.info("App shutdown requested by scheduler {}", schedulerId);
    sendEvent(new DAGAppMasterEvent(DAGAppMasterEventType.AM_REBOOT));
}
Also used : DAGAppMasterEvent(org.apache.tez.dag.app.dag.event.DAGAppMasterEvent)

Example 2 with DAGAppMasterEvent

use of org.apache.tez.dag.app.dag.event.DAGAppMasterEvent in project tez by apache.

the class TaskSchedulerManager method serviceStart.

@Override
public synchronized void serviceStart() throws Exception {
    InetSocketAddress serviceAddr = clientService.getBindAddress();
    dagAppMaster = appContext.getAppMaster();
    // if web service is enabled then set tracking url. else disable it (value = "").
    // the actual url set on the rm web ui will be the proxy url set by WebAppProxyServlet, which
    // always try to connect to AM and proxy the response. hence it wont work if the webUIService
    // is not enabled.
    String trackingUrl = (webUI != null) ? webUI.getTrackingURL() : "";
    instantiateSchedulers(serviceAddr.getHostName(), serviceAddr.getPort(), trackingUrl, appContext);
    for (int i = 0; i < taskSchedulers.length; i++) {
        taskSchedulerServiceWrappers[i].init(getConfig());
        taskSchedulerServiceWrappers[i].start();
        if (shouldUnregisterFlag.get()) {
            // Flag may have been set earlier when task scheduler was not initialized
            // External services could need to talk to some other entity.
            taskSchedulers[i].setShouldUnregister();
        }
    }
    this.eventHandlingThread = new Thread("TaskSchedulerEventHandlerThread") {

        @Override
        public void run() {
            AMSchedulerEvent event;
            while (!stopEventHandling && !Thread.currentThread().isInterrupted()) {
                try {
                    if (TaskSchedulerManager.this.eventQueue.peek() == null) {
                        notifyForTest();
                    }
                    event = TaskSchedulerManager.this.eventQueue.take();
                } catch (InterruptedException e) {
                    if (!stopEventHandling) {
                        LOG.warn("Continuing after interrupt : ", e);
                    }
                    continue;
                }
                try {
                    handleEvent(event);
                } catch (Throwable t) {
                    LOG.error("Error in handling event type " + event.getType() + " to the TaskScheduler", t);
                    // Kill the AM.
                    sendEvent(new DAGAppMasterEvent(DAGAppMasterEventType.INTERNAL_ERROR));
                    return;
                } finally {
                    notifyForTest();
                }
            }
        }
    };
    this.eventHandlingThread.start();
}
Also used : DAGAppMasterEvent(org.apache.tez.dag.app.dag.event.DAGAppMasterEvent) InetSocketAddress(java.net.InetSocketAddress) TaskLocationHint(org.apache.tez.dag.api.TaskLocationHint)

Example 3 with DAGAppMasterEvent

use of org.apache.tez.dag.app.dag.event.DAGAppMasterEvent in project tez by apache.

the class DAGAppMaster method startDAGExecution.

private void startDAGExecution(DAG dag, final Map<String, LocalResource> additionalAmResources) throws TezException {
    currentDAG = dag;
    // Try localizing the actual resources.
    List<URL> additionalUrlsForClasspath;
    try {
        additionalUrlsForClasspath = dag.getDagUGI().doAs(new PrivilegedExceptionAction<List<URL>>() {

            @Override
            public List<URL> run() throws Exception {
                return processAdditionalResources(currentDAG.getID(), additionalAmResources);
            }
        });
    } catch (IOException e) {
        throw new TezException(e);
    } catch (InterruptedException e) {
        throw new TezException(e);
    }
    dagIDs.add(currentDAG.getID().toString());
    // End of creating the job.
    ((RunningAppContext) context).setDAG(currentDAG);
    // Send out an event to inform components that a new DAG has been submitted.
    // Information about this DAG is available via the context.
    sendEvent(new DAGAppMasterEvent(DAGAppMasterEventType.NEW_DAG_SUBMITTED));
    // create a job event for job initialization
    DAGEvent initDagEvent = new DAGEvent(currentDAG.getID(), DAGEventType.DAG_INIT);
    // Send init to the job (this does NOT trigger job execution)
    // This is a synchronous call, not an event through dispatcher. We want
    // job-init to be done completely here.
    dagEventDispatcher.handle(initDagEvent);
    // All components have started, start the job.
    /**
     * create a job-start event to get this ball rolling
     */
    DAGEvent startDagEvent = new DAGEventStartDag(currentDAG.getID(), additionalUrlsForClasspath);
    /**
     * send the job-start event. this triggers the job execution.
     */
    sendEvent(startDagEvent);
}
Also used : TezException(org.apache.tez.dag.api.TezException) DAGEvent(org.apache.tez.dag.app.dag.event.DAGEvent) DAGAppMasterEvent(org.apache.tez.dag.app.dag.event.DAGAppMasterEvent) DAGEventStartDag(org.apache.tez.dag.app.dag.event.DAGEventStartDag) PrivilegedExceptionAction(java.security.PrivilegedExceptionAction) IOException(java.io.IOException) URL(java.net.URL)

Aggregations

DAGAppMasterEvent (org.apache.tez.dag.app.dag.event.DAGAppMasterEvent)3 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 URL (java.net.URL)1 PrivilegedExceptionAction (java.security.PrivilegedExceptionAction)1 TaskLocationHint (org.apache.tez.dag.api.TaskLocationHint)1 TezException (org.apache.tez.dag.api.TezException)1 DAGEvent (org.apache.tez.dag.app.dag.event.DAGEvent)1 DAGEventStartDag (org.apache.tez.dag.app.dag.event.DAGEventStartDag)1