/** * Send mr job jar on agent. * * @param config the config * @param jarFilepath the jar filepath */ public static void sendMRJobJarOnAgent(Config config, String jarFilepath) { JobConfig jobConfig = (JobConfig) config; String jumbuneHome = JobConfig.getJumbuneHome() + File.separator; Remoter remoter = RemotingUtil.getRemoter(config, jumbuneHome); File resourceDir = new File(jarFilepath); File[] files = resourceDir.listFiles(); for (File file : files) { if (file.getName().endsWith(".tmp")) { file.delete(); } else { String filename = file.getAbsolutePath(); String relativeAgentPath = Constants.JOB_JARS_LOC + File.separator + jobConfig.getFormattedJumbuneJobName() + Constants.MR_RESOURCES; String resourceFolder = System.getenv("AGENT_HOME") + File.separator + Constants.JOB_JARS_LOC + File.separator + jobConfig.getFormattedJumbuneJobName() + Constants.MR_RESOURCES; File resourceDirAgent = new File(resourceFolder); if (!resourceDirAgent.exists()) { resourceDirAgent.mkdirs(); } remoter.sendJar(relativeAgentPath, filename); } } remoter.close(); }
/** * Send jumbune supplied jar on agent. * * @param config the config * @param cse the cse * @param agentHome the agent home */ public static void sendJumbuneSuppliedJarOnAgent( Config config, ClasspathElement cse, String agentHome) { String jumbuneHome = JobConfig.getJumbuneHome(); Remoter remoter = RemotingUtil.getRemoter(config, jumbuneHome); String hadoopHome = RemotingUtil.getHadoopHome(remoter, config); String[] files = cse.getFiles(); for (String string : files) { remoter.sendJar("lib/", string.replace(agentHome, jumbuneHome)); if (string.contains("log4j")) { StringBuilder copyJarToHadoopLib = new StringBuilder() .append(Constants.COPY_COMMAND) .append(string) .append(" ") .append(hadoopHome) .append(Constants.LIB_DIRECTORY); sendLibJarCommand(remoter, config, copyJarToHadoopLib.toString()); } } remoter.close(); }