Search in sources :

Example 66 with Private

use of org.apache.hadoop.classification.InterfaceAudience.Private in project tez by apache.

the class ReflectionUtils method addResourcesToSystemClassLoader.

@Private
public static synchronized void addResourcesToSystemClassLoader(List<URL> urls) {
    URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
    if (sysClassLoaderMethod == null) {
        Class<?> sysClass = URLClassLoader.class;
        Method method;
        try {
            method = sysClass.getDeclaredMethod("addURL", parameters);
        } catch (SecurityException e) {
            throw new TezUncheckedException("Failed to get handle on method addURL", e);
        } catch (NoSuchMethodException e) {
            throw new TezUncheckedException("Failed to get handle on method addURL", e);
        }
        method.setAccessible(true);
        sysClassLoaderMethod = method;
    }
    for (URL url : urls) {
        try {
            sysClassLoaderMethod.invoke(sysLoader, new Object[] { url });
        } catch (IllegalArgumentException e) {
            throw new TezUncheckedException("Failed to invoke addURL for rsrc: " + url, e);
        } catch (IllegalAccessException e) {
            throw new TezUncheckedException("Failed to invoke addURL for rsrc: " + url, e);
        } catch (InvocationTargetException e) {
            throw new TezUncheckedException("Failed to invoke addURL for rsrc: " + url, e);
        }
    }
}
Also used : TezUncheckedException(org.apache.tez.dag.api.TezUncheckedException) URLClassLoader(java.net.URLClassLoader) Method(java.lang.reflect.Method) URL(java.net.URL) InvocationTargetException(java.lang.reflect.InvocationTargetException) Private(org.apache.hadoop.classification.InterfaceAudience.Private)

Example 67 with Private

use of org.apache.hadoop.classification.InterfaceAudience.Private in project tez by apache.

the class ReflectionUtils method addResourcesToClasspath.

@Private
public static synchronized void addResourcesToClasspath(List<URL> urls) {
    ClassLoader classLoader = new URLClassLoader(urls.toArray(new URL[urls.size()]), Thread.currentThread().getContextClassLoader());
    Thread.currentThread().setContextClassLoader(classLoader);
}
Also used : URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) URL(java.net.URL) Private(org.apache.hadoop.classification.InterfaceAudience.Private)

Example 68 with Private

use of org.apache.hadoop.classification.InterfaceAudience.Private in project tez by apache.

the class TezCommonUtils method getTezSystemStagingPath.

/**
 * <p>
 * This function returns the staging directory for TEZ system. Tez creates all
 * its temporary files under this sub-directory. The function normally doesn't
 * creates any sub-directory under the base staging directory.
 * </p>
 *
 * @param conf
 *          Tez configuration
 * @param strAppId
 *          Application ID as string
 * @return TEZ system level staging directory used for Tez internals
 */
@Private
public static Path getTezSystemStagingPath(Configuration conf, String strAppId) {
    Path baseStagingPath = getTezBaseStagingPath(conf);
    Path tezStagingDir;
    tezStagingDir = new Path(baseStagingPath, TEZ_SYSTEM_SUB_DIR);
    tezStagingDir = new Path(tezStagingDir, strAppId);
    return tezStagingDir;
}
Also used : Path(org.apache.hadoop.fs.Path) Private(org.apache.hadoop.classification.InterfaceAudience.Private)

Example 69 with Private

use of org.apache.hadoop.classification.InterfaceAudience.Private in project tez by apache.

the class TezClient method submitDAGApplication.

// To be used only by YarnRunner
@Private
DAGClient submitDAGApplication(ApplicationId appId, DAG dag) throws TezException, IOException {
    LOG.info("Submitting DAG application with id: " + appId);
    try {
        // Use the AMCredentials object in client mode, since this won't be re-used.
        // Ensures we don't fetch credentially unnecessarily if the user has already provided them.
        Credentials credentials = amConfig.getCredentials();
        if (credentials == null) {
            credentials = new Credentials();
        }
        TezClientUtils.processTezLocalCredentialsFile(credentials, amConfig.getTezConfiguration());
        // Add session token for shuffle
        TezClientUtils.createSessionToken(appId.toString(), jobTokenSecretManager, credentials);
        // Add credentials for tez-local resources.
        Map<String, LocalResource> tezJarResources = getTezJarResources(credentials);
        ApplicationSubmissionContext appContext = TezClientUtils.createApplicationSubmissionContext(appId, dag, dag.getName(), amConfig, tezJarResources, credentials, usingTezArchiveDeploy, apiVersionInfo, servicePluginsDescriptor, javaOptsChecker);
        String callerContextStr = "";
        if (dag.getCallerContext() != null) {
            callerContextStr = ", callerContext=" + dag.getCallerContext().contextAsSimpleString();
        }
        LOG.info("Submitting DAG to YARN" + ", applicationId=" + appId + ", dagName=" + dag.getName() + callerContextStr);
        frameworkClient.submitApplication(appContext);
        ApplicationReport appReport = frameworkClient.getApplicationReport(appId);
        LOG.info("The url to track the Tez AM: " + appReport.getTrackingUrl());
        lastSubmittedAppId = appId;
    } catch (YarnException e) {
        throw new TezException(e);
    }
    // wait for dag in non-session mode to start running, so that we can start to getDAGStatus
    waitNonSessionTillReady();
    return getDAGClient(appId, amConfig.getTezConfiguration(), amConfig.getYarnConfiguration(), frameworkClient);
}
Also used : ApplicationReport(org.apache.hadoop.yarn.api.records.ApplicationReport) TezException(org.apache.tez.dag.api.TezException) ApplicationSubmissionContext(org.apache.hadoop.yarn.api.records.ApplicationSubmissionContext) Credentials(org.apache.hadoop.security.Credentials) YarnException(org.apache.hadoop.yarn.exceptions.YarnException) LocalResource(org.apache.hadoop.yarn.api.records.LocalResource) Private(org.apache.hadoop.classification.InterfaceAudience.Private)

Example 70 with Private

use of org.apache.hadoop.classification.InterfaceAudience.Private in project tez by apache.

the class TezCommonUtils method compressByteArrayToByteString.

@Private
public static ByteString compressByteArrayToByteString(byte[] inBytes, Deflater deflater) throws IOException {
    deflater.reset();
    ByteString.Output os = ByteString.newOutput();
    DeflaterOutputStream compressOs = null;
    try {
        compressOs = new DeflaterOutputStream(os, deflater);
        compressOs.write(inBytes);
        compressOs.finish();
        ByteString byteString = os.toByteString();
        return byteString;
    } finally {
        if (compressOs != null) {
            compressOs.close();
        }
    }
}
Also used : ByteString(com.google.protobuf.ByteString) DeflaterOutputStream(java.util.zip.DeflaterOutputStream) Private(org.apache.hadoop.classification.InterfaceAudience.Private)

Aggregations

Private (org.apache.hadoop.classification.InterfaceAudience.Private)75 VisibleForTesting (com.google.common.annotations.VisibleForTesting)18 IOException (java.io.IOException)15 Path (org.apache.hadoop.fs.Path)13 ApplicationId (org.apache.hadoop.yarn.api.records.ApplicationId)12 ArrayList (java.util.ArrayList)9 FileStatus (org.apache.hadoop.fs.FileStatus)8 FileSystem (org.apache.hadoop.fs.FileSystem)6 Resource (org.apache.hadoop.yarn.api.records.Resource)6 DataInputStream (java.io.DataInputStream)5 EOFException (java.io.EOFException)5 PrintStream (java.io.PrintStream)5 Credentials (org.apache.hadoop.security.Credentials)5 LogReader (org.apache.hadoop.yarn.logaggregation.AggregatedLogFormat.LogReader)5 ApplicationAttemptId (org.apache.hadoop.yarn.api.records.ApplicationAttemptId)4 LocalResource (org.apache.hadoop.yarn.api.records.LocalResource)4 YarnRuntimeException (org.apache.hadoop.yarn.exceptions.YarnRuntimeException)4 ByteString (com.google.protobuf.ByteString)3 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)3