Example usage for org.apache.hadoop.fs FileSystem clearStatistics

List of usage examples for org.apache.hadoop.fs FileSystem clearStatistics

Introduction

In this page you can find the example usage for org.apache.hadoop.fs FileSystem clearStatistics.

Prototype

public static synchronized void clearStatistics() 

Source Link

Document

Reset all statistics for all file systems.

Usage

From source file:org.apache.tez.runtime.task.TezChild.java

License:Apache License

public ContainerExecutionResult run() throws IOException, InterruptedException, TezException {

    ContainerContext containerContext = new ContainerContext(containerIdString);
    ContainerReporter containerReporter = new ContainerReporter(umbilical, containerContext,
            getTaskMaxSleepTime);/*from w  w w . j ava  2  s .  co  m*/

    taskReporter = new TaskReporter(umbilical, amHeartbeatInterval, sendCounterInterval, maxEventsToGet,
            heartbeatCounter, containerIdString);

    UserGroupInformation childUGI = null;

    while (!executor.isTerminated()) {
        if (taskCount > 0) {
            TezUtilsInternal.updateLoggers("");
        }
        ListenableFuture<ContainerTask> getTaskFuture = executor.submit(containerReporter);
        boolean error = false;
        ContainerTask containerTask = null;
        try {
            containerTask = getTaskFuture.get();
        } catch (ExecutionException e) {
            error = true;
            Throwable cause = e.getCause();
            return new ContainerExecutionResult(ContainerExecutionResult.ExitStatus.EXECUTION_FAILURE, cause,
                    "Execution Exception while fetching new work: " + e.getMessage());
        } catch (InterruptedException e) {
            error = true;
            LOG.info("Interrupted while waiting for new work");
            return new ContainerExecutionResult(ContainerExecutionResult.ExitStatus.INTERRUPTED, e,
                    "Interrupted while waiting for new work");
        } finally {
            if (error) {
                shutdown();
            }
        }
        if (containerTask.shouldDie()) {
            LOG.info("ContainerTask returned shouldDie=true, Exiting");
            shutdown();
            return new ContainerExecutionResult(ContainerExecutionResult.ExitStatus.SUCCESS, null,
                    "Asked to die by the AM");
        } else {
            String loggerAddend = containerTask.getTaskSpec().getTaskAttemptID().toString();
            taskCount++;
            TezUtilsInternal.updateLoggers(loggerAddend);
            FileSystem.clearStatistics();

            childUGI = handleNewTaskCredentials(containerTask, childUGI);
            handleNewTaskLocalResources(containerTask);
            cleanupOnTaskChanged(containerTask);

            // Execute the Actual Task
            TezTaskRunner taskRunner = new TezTaskRunner(defaultConf, childUGI, localDirs,
                    containerTask.getTaskSpec(), umbilical, appAttemptNumber, serviceConsumerMetadata,
                    serviceProviderEnvMap, startedInputsMap, taskReporter, executor, objectRegistry, pid,
                    executionContext, memAvailable);
            boolean shouldDie;
            try {
                shouldDie = !taskRunner.run();
                if (shouldDie) {
                    LOG.info("Got a shouldDie notification via hearbeats. Shutting down");
                    shutdown();
                    return new ContainerExecutionResult(ContainerExecutionResult.ExitStatus.SUCCESS, null,
                            "Asked to die by the AM");
                }
            } catch (IOException e) {
                handleError(e);
                return new ContainerExecutionResult(ContainerExecutionResult.ExitStatus.EXECUTION_FAILURE, e,
                        "TaskExecutionFailure: " + e.getMessage());
            } catch (TezException e) {
                handleError(e);
                return new ContainerExecutionResult(ContainerExecutionResult.ExitStatus.EXECUTION_FAILURE, e,
                        "TaskExecutionFailure: " + e.getMessage());
            } finally {
                FileSystem.closeAllForUGI(childUGI);
            }
        }
    }
    return new ContainerExecutionResult(ContainerExecutionResult.ExitStatus.SUCCESS, null, null);
}