HadoopConfOverlay implements ContainerOverlay { @Override public void configure(ContainerSpecification container) throws IOException { if(hadoopConfDir == null) { return; } File coreSitePath = new File(hadoopConfDir, "core-site.xml"); File hdfsSitePath = new File(hadoopConfDir, "hdfs-site.xml"); container.getEnvironmentVariables().put("HADOOP_CONF_DIR", TARGET_CONF_DIR.toString()); container.getDynamicConfiguration().setString(ConfigConstants.PATH_HADOOP_CONFIG, TARGET_CONF_DIR.toString()); container.getArtifacts().add(ContainerSpecification.Artifact .newBuilder() .setSource(new Path(coreSitePath.toURI())) .setDest(new Path(TARGET_CONF_DIR, coreSitePath.getName())) .setCachable(true) .build()); container.getArtifacts().add(ContainerSpecification.Artifact .newBuilder() .setSource(new Path(hdfsSitePath.toURI())) .setDest(new Path(TARGET_CONF_DIR, hdfsSitePath.getName())) .setCachable(true) .build()); } HadoopConfOverlay(@Nullable File hadoopConfDir); @Override void configure(ContainerSpecification container); static Builder newBuilder();  }
@Test public void testConfigure() throws Exception { File confDir = tempFolder.newFolder(); initConfDir(confDir); HadoopConfOverlay overlay = new HadoopConfOverlay(confDir); ContainerSpecification spec = new ContainerSpecification(); overlay.configure(spec); assertEquals(TARGET_CONF_DIR.getPath(), spec.getEnvironmentVariables().get("HADOOP_CONF_DIR")); assertEquals(TARGET_CONF_DIR.getPath(), spec.getDynamicConfiguration().getString(ConfigConstants.PATH_HADOOP_CONFIG, null)); checkArtifact(spec, new Path(TARGET_CONF_DIR, "core-site.xml")); checkArtifact(spec, new Path(TARGET_CONF_DIR, "hdfs-site.xml")); }
@Test public void testNoConf() throws Exception { HadoopConfOverlay overlay = new HadoopConfOverlay(null); ContainerSpecification containerSpecification = new ContainerSpecification(); overlay.configure(containerSpecification); }