@Before public void setUp() { HiveConf conf = new HiveConf(); String tmp = System.getProperty("java.io.tmpdir"); File tmpDir = new File(tmp); if (!tmpDir.exists()) { tmpDir.mkdir(); } hiveReloadPath = Files.createTempDir().getAbsolutePath(); // create the reloading folder to place jar files if not exist reloadFolder = new File(hiveReloadPath); if (!reloadFolder.exists()) { reloadFolder.mkdir(); } try { generateRefreshJarFiles(V2); generateRefreshJarFiles(V1); } catch (Throwable e) { Assert.fail("fail to generate refresh jar file due to the error " + e); } if (prewarm) { HiveConf.setBoolVar(conf, ConfVars.HIVE_PREWARM_ENABLED, true); HiveConf.setIntVar(conf, ConfVars.HIVE_PREWARM_NUM_CONTAINERS, 1); } SessionState.start(conf); }
ss.loadReloadableAuxJars(); Assert.assertEquals("version1", getReloadedClazzVersion(ss.getConf().getClassLoader())); Assert.assertEquals("version2", getReloadedClazzVersion(ss.getConf().getClassLoader()));
@Test public void testReloadAuxJars2() { HiveConf conf = new HiveConf(); HiveConf.setVar(conf, ConfVars.HIVERELOADABLEJARS, hiveReloadPath); SessionState ss = new SessionState(conf); SessionState.start(ss); ss = SessionState.get(); File dist = null; try { dist = new File(reloadFolder.getAbsolutePath() + File.separator + reloadClazzFileName); Files.copy(new File(HiveTestUtils.getFileFromClasspath(clazzDistFileName)), dist); ss.loadReloadableAuxJars(); Assert.assertEquals("version1", getReloadedClazzVersion(ss.getConf().getClassLoader())); } catch (Exception e) { LOG.error("Reload auxiliary jar test fail with message: ", e); Assert.fail(e.getMessage()); } finally { FileUtils.deleteQuietly(dist); try { ss.close(); } catch (IOException ioException) { Assert.fail(ioException.getMessage()); LOG.error("Fail to close the created session: ", ioException); } } }