AppDeployer { @VisibleForTesting public void install(Application app, Path appPath, File settingsFile, List<File> jars) { String tempBase = context.getHadoopConf().get("hadoop.tmp.dir", "/tmp"); Path tempDestination = new Path(tempBase, "kite-" + (random.nextInt() & Integer.MAX_VALUE)); try { fs.mkdirs(tempDestination); } catch (IOException e) { throw new AppException(e); } if (settingsFile != null) { Path appProps = new Path(tempDestination, "conf/app.properties"); try { fs.copyFromLocalFile(new Path(settingsFile.getAbsolutePath()), appProps); } catch (IOException e) { throw new AppException(e); } } List<Schedule> schedules = app.getSchedules(); for (Schedule schedule: schedules) { writeSchedule(tempDestination, schedule); installWorkflow(tempDestination, schedule); installCoordinator(tempDestination, schedule); } installBundle(app.getClass(), tempDestination, appPath, schedules); List<StreamDescription> descriptions = app.getStreamDescriptions(); for (StreamDescription description: descriptions) { StreamingJobManager manager = JobManagers.createStreaming(description, context); manager.install(fs, tempDestination); } installJars(new Path(tempDestination, "lib"), jars); try { if (!fs.rename(tempDestination, appPath)) { throw new AppException("Unable to rename " + tempDestination + " to " + appPath + "."); } } catch (IOException e) { throw new AppException(e); } } AppDeployer(FileSystem fs, AppContext context); void deploy(Class<? extends Application> applicationClass, Path appPath, File settingsFile, List<File> jars); @VisibleForTesting void install(Application app, Path appPath, File settingsFile, List<File> jars);  }
@Test public void testDeploySimpleApp() throws Exception { Path testDirectory = createTestDirectory(); AppDeployer deployer = new AppDeployer(fs, new AppContext(getConfiguration())); ScheduledInputOutputApp app = new ScheduledInputOutputApp(); app.setup(new AppContext(getConfiguration())); File propFile = createTestProperties(); deployer.install(app, testDirectory, propFile, Collections.<File>emptyList()); assertValidInstallation(testDirectory); }