Tabnine Logo
SliderUtils.getApplicationResourceInputStream
Code IndexAdd Tabnine to your IDE (free)

How to use
getApplicationResourceInputStream
method
in
org.apache.slider.common.tools.SliderUtils

Best Java code snippets using org.apache.slider.common.tools.SliderUtils.getApplicationResourceInputStream (Showing top 8 results out of 315)

origin: apache/incubator-slider

private void createSummaryMetainfoFile(Path srcFile, Path destFile,
  boolean overwrite) throws IOException {
 FileSystem srcFs = srcFile.getFileSystem(getConfig());
 try (InputStream inputStreamJson = SliderUtils
   .getApplicationResourceInputStream(srcFs, srcFile, "metainfo.json");
   InputStream inputStreamXml = SliderUtils
     .getApplicationResourceInputStream(srcFs, srcFile, "metainfo.xml");) {
  InputStream inputStream = null;
  Path summaryFileInFs = null;
  if (inputStreamJson != null) {
   inputStream = inputStreamJson;
   summaryFileInFs = new Path(destFile.getParent(), destFile.getName()
     + ".metainfo.json");
   log.info("Found JSON metainfo file in package");
  } else if (inputStreamXml != null) {
   inputStream = inputStreamXml;
   summaryFileInFs = new Path(destFile.getParent(), destFile.getName()
     + ".metainfo.xml");
   log.info("Found XML metainfo file in package");
  }
  if (inputStream != null) {
   try (FSDataOutputStream dataOutputStream = sliderFileSystem
     .getFileSystem().create(summaryFileInFs, overwrite)) {
    log.info("Creating summary metainfo file");
    IOUtils.copy(inputStream, dataOutputStream);
   }
  }
 }
}
origin: apache/incubator-slider

static DefaultConfig getDefaultConfig(SliderFileSystem fileSystem,
                   String appDef, String configFileName)
  throws IOException {
 // this is the path inside the zip file
 String fileToRead = "configuration/" + configFileName;
 log.info("Reading default config file {} at {}", fileToRead, appDef);
 InputStream configStream = SliderUtils.getApplicationResourceInputStream(
   fileSystem.getFileSystem(), new Path(appDef), fileToRead);
 if (configStream == null) {
  log.error("{} is unavailable at {}.", fileToRead, appDef);
  throw new IOException("Expected config file " + fileToRead + " is not available.");
 }
 return new DefaultConfigParser().parse(configStream);
}
origin: org.apache.slider/slider-core

private void createSummaryMetainfoFile(Path srcFile, Path destFile,
  boolean overwrite) throws IOException {
 FileSystem srcFs = srcFile.getFileSystem(getConfig());
 try (InputStream inputStreamJson = SliderUtils
   .getApplicationResourceInputStream(srcFs, srcFile, "metainfo.json");
   InputStream inputStreamXml = SliderUtils
     .getApplicationResourceInputStream(srcFs, srcFile, "metainfo.xml");) {
  InputStream inputStream = null;
  Path summaryFileInFs = null;
  if (inputStreamJson != null) {
   inputStream = inputStreamJson;
   summaryFileInFs = new Path(destFile.getParent(), destFile.getName()
     + ".metainfo.json");
   log.info("Found JSON metainfo file in package");
  } else if (inputStreamXml != null) {
   inputStream = inputStreamXml;
   summaryFileInFs = new Path(destFile.getParent(), destFile.getName()
     + ".metainfo.xml");
   log.info("Found XML metainfo file in package");
  }
  if (inputStream != null) {
   try (FSDataOutputStream dataOutputStream = sliderFileSystem
     .getFileSystem().create(summaryFileInFs, overwrite)) {
    log.info("Creating summary metainfo file");
    IOUtils.copy(inputStream, dataOutputStream);
   }
  }
 }
}
origin: org.apache.slider/slider-core

static DefaultConfig getDefaultConfig(SliderFileSystem fileSystem,
                   String appDef, String configFileName)
  throws IOException {
 // this is the path inside the zip file
 String fileToRead = "configuration/" + configFileName;
 log.info("Reading default config file {} at {}", fileToRead, appDef);
 InputStream configStream = SliderUtils.getApplicationResourceInputStream(
   fileSystem.getFileSystem(), new Path(appDef), fileToRead);
 if (configStream == null) {
  log.error("{} is unavailable at {}.", fileToRead, appDef);
  throw new IOException("Expected config file " + fileToRead + " is not available.");
 }
 return new DefaultConfigParser().parse(configStream);
}
origin: org.apache.slider/slider-core

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;
}
origin: apache/incubator-slider

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;
}
origin: org.apache.slider/slider-core

@Test
public void testGetMetaInfoStreamFromZip() 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);
 InputStream stream = SliderUtils.getApplicationResourceInputStream(
   sliderFileSystem.getFileSystem(),
   new Path(zipFileName),
   "metainfo.xml");
 Assert.assertTrue(stream != null);
 Assert.assertTrue(stream.available() > 0);
}
origin: apache/incubator-slider

@Test
public void testGetMetaInfoStreamFromZip() 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);
 InputStream stream = SliderUtils.getApplicationResourceInputStream(
   sliderFileSystem.getFileSystem(),
   new Path(zipFileName),
   "metainfo.xml");
 Assert.assertTrue(stream != null);
 Assert.assertTrue(stream.available() > 0);
}
org.apache.slider.common.toolsSliderUtilsgetApplicationResourceInputStream

Popular methods of SliderUtils

  • buildEnvMap
  • isSet
  • extractDomainNameFromFQDN
  • extractFirstLine
    Extract the first line of a multi-line string. This is typically used to prune the stack trace appen
  • getHdpVersion
    Retrieve the HDP version if it is an HDP cluster, or null otherwise. It first checks if system prope
  • isHdp
    Query to find if it is an HDP cluster
  • listDir
    List a directory in the local filesystem
  • sortApplicationsByMostRecent
    Sorts the given list of application reports, most recently started or finished instance first.
  • truncate
    Truncate the given string to a maximum length provided with a pad (...) added to the end if expected
  • write
    Write bytes to a file
  • addBuildInfo
    Add the cluster build information; this will include Hadoop details too
  • appReportToString
  • addBuildInfo,
  • appReportToString,
  • appendToURL,
  • buildApplicationReportMap,
  • buildClasspath,
  • checkCredentialCacheFile,
  • checkForRequiredNativeLibraries,
  • checkPort,
  • collectionToStringList

Popular in Java

  • Running tasks concurrently on multiple threads
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • setRequestProperty (URLConnection)
  • findViewById (Activity)
  • URL (java.net)
    A Uniform Resource Locator that identifies the location of an Internet resource as specified by RFC
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • Date (java.util)
    A specific moment in time, with millisecond precision. Values typically come from System#currentTime
  • Queue (java.util)
    A collection designed for holding elements prior to processing. Besides basic java.util.Collection o
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now