Search in sources :

Example 1 with ResourceType

use of org.apache.hadoop.hive.ql.session.SessionState.ResourceType in project hive by apache.

the class FunctionLocalizer method localizeFunctionResources.

private void localizeFunctionResources(String fqfn, List<ResourceUri> resources, String className, FnResources result, boolean doRefreshClassloader) throws URISyntaxException, IOException {
    // are no collisions within the same fn). That doesn't mean we download for every fn.
    if (LOG.isInfoEnabled()) {
        LOG.info("Localizing " + resources.size() + " resources for " + fqfn);
    }
    for (ResourceUri resource : resources) {
        URI srcUri = ResourceDownloader.createURI(resource.getUri());
        ResourceType rt = FunctionUtils.getResourceType(resource.getResourceType());
        localizeOneResource(fqfn, srcUri, rt, result);
    }
    recentlyLocalizedClasses.add(className);
    if (doRefreshClassloader) {
        refreshClassloader();
    }
}
Also used : ResourceUri(org.apache.hadoop.hive.metastore.api.ResourceUri) ResourceType(org.apache.hadoop.hive.ql.session.SessionState.ResourceType) URI(java.net.URI)

Example 2 with ResourceType

use of org.apache.hadoop.hive.ql.session.SessionState.ResourceType in project hive by apache.

the class TestAddResource method testUnion.

// test when two jars with shared dependencies are added, the classloader contains union of the dependencies
@Test
public void testUnion() throws URISyntaxException, IOException {
    HiveConf conf = new HiveConf();
    SessionState ss = Mockito.spy(SessionState.start(conf).get());
    ResourceType t = ResourceType.JAR;
    String query1 = "testQuery1";
    String query2 = "testQuery2";
    List<String> addList = new LinkedList<String>();
    // add dependencies for the jars
    List<URI> list1 = new LinkedList<URI>();
    List<URI> list2 = new LinkedList<URI>();
    list1.add(createURI(TEST_JAR_DIR + "testjar1.jar"));
    list1.add(createURI(TEST_JAR_DIR + "testjar2.jar"));
    list1.add(createURI(TEST_JAR_DIR + "testjar3.jar"));
    list1.add(createURI(TEST_JAR_DIR + "testjar4.jar"));
    list2.add(createURI(TEST_JAR_DIR + "testjar5.jar"));
    list2.add(createURI(TEST_JAR_DIR + "testjar3.jar"));
    list2.add(createURI(TEST_JAR_DIR + "testjar4.jar"));
    Mockito.when(ss.resolveAndDownload(t, query1, false)).thenReturn(list1);
    Mockito.when(ss.resolveAndDownload(t, query2, false)).thenReturn(list2);
    addList.add(query1);
    addList.add(query2);
    ss.add_resources(t, addList);
    Set<String> dependencies = ss.list_resource(t, null);
    LinkedList<URI> actual = new LinkedList<URI>();
    for (String dependency : dependencies) {
        actual.add(createURI(dependency));
    }
    List<URI> expected = union(list1, list2);
    Collections.sort(expected);
    Collections.sort(actual);
    assertEquals(expected, actual);
    ss.close();
}
Also used : HiveConf(org.apache.hadoop.hive.conf.HiveConf) ResourceType(org.apache.hadoop.hive.ql.session.SessionState.ResourceType) URI(java.net.URI) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

URI (java.net.URI)2 ResourceType (org.apache.hadoop.hive.ql.session.SessionState.ResourceType)2 LinkedList (java.util.LinkedList)1 HiveConf (org.apache.hadoop.hive.conf.HiveConf)1 ResourceUri (org.apache.hadoop.hive.metastore.api.ResourceUri)1 Test (org.junit.Test)1