Search in sources :

Example 1 with ReadaheadPool

use of org.apache.hadoop.io.ReadaheadPool in project hive by apache.

the class HivePreWarmProcessor method run.

@Override
public void run(Map<String, LogicalInput> inputs, Map<String, LogicalOutput> outputs) throws Exception {
    if (prewarmed) {
        /* container reuse */
        return;
    }
    for (LogicalInput input : inputs.values()) {
        input.start();
    }
    for (LogicalOutput output : outputs.values()) {
        output.start();
    }
    /* these are things that goes through singleton initialization on most queries */
    FileSystem fs = FileSystem.get(conf);
    Mac mac = Mac.getInstance("HmacSHA1");
    ReadaheadPool rpool = ReadaheadPool.getInstance();
    ShimLoader.getHadoopShims();
    URL hiveurl = new URL("jar:" + DagUtils.getInstance().getExecJarPathLocal() + "!/");
    JarURLConnection hiveconn = (JarURLConnection) hiveurl.openConnection();
    JarFile hivejar = hiveconn.getJarFile();
    try {
        Enumeration<JarEntry> classes = hivejar.entries();
        while (classes.hasMoreElements()) {
            JarEntry je = classes.nextElement();
            if (je.getName().endsWith(".class")) {
                String klass = je.getName().replace(".class", "").replaceAll("/", "\\.");
                if (klass.indexOf("ql.exec") != -1 || klass.indexOf("ql.io") != -1) {
                    /* several hive classes depend on the metastore APIs, which is not included
             * in hive-exec.jar. These are the relatively safe ones - operators & io classes.
             */
                    if (klass.indexOf("vector") != -1 || klass.indexOf("Operator") != -1) {
                        JavaUtils.loadClass(klass);
                    }
                }
            }
        }
    } finally {
        hivejar.close();
    }
    prewarmed = true;
}
Also used : LogicalOutput(org.apache.tez.runtime.api.LogicalOutput) ReadaheadPool(org.apache.hadoop.io.ReadaheadPool) JarURLConnection(java.net.JarURLConnection) FileSystem(org.apache.hadoop.fs.FileSystem) LogicalInput(org.apache.tez.runtime.api.LogicalInput) JarFile(java.util.jar.JarFile) JarEntry(java.util.jar.JarEntry) Mac(javax.crypto.Mac) URL(java.net.URL)

Aggregations

JarURLConnection (java.net.JarURLConnection)1 URL (java.net.URL)1 JarEntry (java.util.jar.JarEntry)1 JarFile (java.util.jar.JarFile)1 Mac (javax.crypto.Mac)1 FileSystem (org.apache.hadoop.fs.FileSystem)1 ReadaheadPool (org.apache.hadoop.io.ReadaheadPool)1 LogicalInput (org.apache.tez.runtime.api.LogicalInput)1 LogicalOutput (org.apache.tez.runtime.api.LogicalOutput)1