@Test public void testGetApplicationMetainfo() throws Exception { String zipFileName = TestUtility.createAppPackage( folder, "testpkg", "test.zip", "target/test-classes/org/apache/slider/common/tools/test"); Configuration configuration = new Configuration(); FileSystem fs = FileSystem.getLocal(configuration); log.info("fs working dir is {}", fs.getWorkingDirectory().toString()); SliderFileSystem sliderFileSystem = new SliderFileSystem(fs, configuration); Metainfo metainfo = AgentUtils.getApplicationMetainfo( sliderFileSystem, zipFileName, false); Assert.assertNotNull(metainfo.getApplication()); Assert.assertEquals("STORM", metainfo.getApplication().getName()); String acompanyFileName = zipFileName + ".metainfo.xml"; File f = new File(acompanyFileName); try (BufferedWriter writer = new BufferedWriter(new FileWriter(f))) { writer.write(metainfo_str); } metainfo = AgentUtils.getApplicationMetainfo( sliderFileSystem, zipFileName, false); Assert.assertNotNull(metainfo.getApplication()); Assert.assertEquals("MYTESTAPPLICATION", metainfo.getApplication().getName()); }
public static Metainfo getApplicationMetainfo(SliderFileSystem fileSystem, String metainfoPath, boolean metainfoForAddon) throws IOException, BadConfigException { log.info("Reading metainfo at {}", metainfoPath); Metainfo metainfo = getApplicationMetainfoFromSummaryFile(fileSystem, metainfoPath, metainfoForAddon); if (metainfo != null) { log.info("Got metainfo from summary file"); return metainfo; } FileSystem fs = fileSystem.getFileSystem(); Path appPath = new Path(metainfoPath); InputStream metainfoJsonStream = SliderUtils.getApplicationResourceInputStream( fs, appPath, "metainfo.json"); if (metainfoJsonStream == null) { InputStream metainfoXMLStream = SliderUtils.getApplicationResourceInputStream( fs, appPath, "metainfo.xml"); if (metainfoXMLStream != null) { metainfo = parseMetainfo(metainfoXMLStream, metainfoForAddon, "xml"); } } else { metainfo = parseMetainfo(metainfoJsonStream, metainfoForAddon, "json"); } if (metainfo == null) { log.error("metainfo is unavailable at {}.", metainfoPath); throw new FileNotFoundException("metainfo.xml/json is required in app package. " + appPath); } return metainfo; }
AgentUtils { public static Metainfo getApplicationMetainfo(SliderFileSystem fileSystem, String metainfoPath, boolean metainfoForAddon) throws IOException, BadConfigException { log.info("Reading metainfo at {}", metainfoPath); Metainfo metainfo = getApplicationMetainfoFromSummaryFile(fileSystem, metainfoPath, metainfoForAddon); if (metainfo != null) { log.info("Got metainfo from summary file"); return metainfo; } FileSystem fs = fileSystem.getFileSystem(); Path appPath = new Path(metainfoPath); InputStream metainfoJsonStream = SliderUtils.getApplicationResourceInputStream( fs, appPath, "metainfo.json"); if (metainfoJsonStream == null) { InputStream metainfoXMLStream = SliderUtils.getApplicationResourceInputStream( fs, appPath, "metainfo.xml"); if (metainfoXMLStream != null) { metainfo = parseMetainfo(metainfoXMLStream, metainfoForAddon, "xml"); } } else { metainfo = parseMetainfo(metainfoJsonStream, metainfoForAddon, "json"); } if (metainfo == null) { log.error("metainfo is unavailable at {}.", metainfoPath); throw new FileNotFoundException("metainfo.xml/json is required in app package. " + appPath); } return metainfo; } }
AgentUtils { public static Metainfo getApplicationMetainfo(SliderFileSystem fileSystem, String metainfoPath, boolean metainfoForAddon) throws IOException, BadConfigException { log.info("Reading metainfo at {}", metainfoPath); Metainfo metainfo = getApplicationMetainfoFromSummaryFile(fileSystem, metainfoPath, metainfoForAddon); if (metainfo != null) { log.info("Got metainfo from summary file"); return metainfo; } FileSystem fs = fileSystem.getFileSystem(); Path appPath = new Path(metainfoPath); InputStream metainfoJsonStream = SliderUtils.getApplicationResourceInputStream( fs, appPath, "metainfo.json"); if (metainfoJsonStream == null) { InputStream metainfoXMLStream = SliderUtils.getApplicationResourceInputStream( fs, appPath, "metainfo.xml"); if (metainfoXMLStream != null) { metainfo = parseMetainfo(metainfoXMLStream, metainfoForAddon, "xml"); } } else { metainfo = parseMetainfo(metainfoJsonStream, metainfoForAddon, "json"); } if (metainfo == null) { log.error("metainfo is unavailable at {}.", metainfoPath); throw new FileNotFoundException("metainfo.xml/json is required in app package. " + appPath); } return metainfo; }  }
AgentUtils { public static Metainfo getApplicationMetainfo(SliderFileSystem fileSystem, String metainfoPath, boolean metainfoForAddon) throws IOException, BadConfigException { log.info("Reading metainfo at {}", metainfoPath); Metainfo metainfo = getApplicationMetainfoFromSummaryFile(fileSystem, metainfoPath, metainfoForAddon); if (metainfo != null) { log.info("Got metainfo from summary file"); return metainfo; } FileSystem fs = fileSystem.getFileSystem(); Path appPath = new Path(metainfoPath); InputStream metainfoJsonStream = SliderUtils.getApplicationResourceInputStream( fs, appPath, "metainfo.json"); if (metainfoJsonStream == null) { InputStream metainfoXMLStream = SliderUtils.getApplicationResourceInputStream( fs, appPath, "metainfo.xml"); if (metainfoXMLStream != null) { metainfo = parseMetainfo(metainfoXMLStream, metainfoForAddon, "xml"); } } else { metainfo = parseMetainfo(metainfoJsonStream, metainfoForAddon, "json"); } if (metainfo == null) { log.error("metainfo is unavailable at {}.", metainfoPath); throw new FileNotFoundException("metainfo.xml/json is required in app package. " + appPath); } return metainfo; }  static Metainfo getApplicationMetainfoFromSummaryFile(
      SliderFileSystem fileSystem, String metainfoPath, boolean metainfoForAddon); static Metainfo getApplicationMetainfo(SliderFileSystem fileSystem,
      String metainfoPath, boolean metainfoForAddon); }
AgentUtils { public static Metainfo getApplicationMetainfo(SliderFileSystem fileSystem, String metainfoPath, boolean metainfoForAddon) throws IOException, BadConfigException { log.info("Reading metainfo at {}", metainfoPath); Metainfo metainfo = getApplicationMetainfoFromSummaryFile(fileSystem, metainfoPath, metainfoForAddon); if (metainfo != null) { log.info("Got metainfo from summary file"); return metainfo; } FileSystem fs = fileSystem.getFileSystem(); Path appPath = new Path(metainfoPath); InputStream metainfoJsonStream = SliderUtils.getApplicationResourceInputStream( fs, appPath, "metainfo.json"); if (metainfoJsonStream == null) { InputStream metainfoXMLStream = SliderUtils.getApplicationResourceInputStream( fs, appPath, "metainfo.xml"); if (metainfoXMLStream != null) { metainfo = parseMetainfo(metainfoXMLStream, metainfoForAddon, "xml"); } } else { metainfo = parseMetainfo(metainfoJsonStream, metainfoForAddon, "json"); } if (metainfo == null) { log.error("metainfo is unavailable at {}.", metainfoPath); throw new FileNotFoundException("metainfo.xml/json is required in app package. " + appPath); } return metainfo; }  static Metainfo getApplicationMetainfoFromSummaryFile(
      SliderFileSystem fileSystem, String metainfoPath, boolean metainfoForAddon); static Metainfo getApplicationMetainfo(SliderFileSystem fileSystem,
      String metainfoPath, boolean metainfoForAddon);  }