コード例 #1
0
  /**
   * Returns an input stream for reading the specified resource from GAR file only.
   *
   * @param name Resource name.
   * @return An input stream for reading the resource, or {@code null} if the resource could not be
   *     found.
   */
  @Nullable
  public InputStream getResourceAsStreamGarOnly(String name) {
    URL url = findResource(name);

    try {
      return url != null ? url.openStream() : null;
    } catch (IOException ignored) {
      return null;
    }
  }
コード例 #2
0
  /**
   * Resolve IGFS profiler logs directory.
   *
   * @param igfs IGFS instance to resolve logs dir for.
   * @return {@link Path} to log dir or {@code null} if not found.
   * @throws IgniteCheckedException if failed to resolve.
   */
  public static Path resolveIgfsProfilerLogsDir(IgniteFileSystem igfs)
      throws IgniteCheckedException {
    String logsDir;

    if (igfs instanceof IgfsEx) logsDir = ((IgfsEx) igfs).clientLogDirectory();
    else if (igfs == null)
      throw new IgniteCheckedException(
          "Failed to get profiler log folder (IGFS instance not found)");
    else
      throw new IgniteCheckedException(
          "Failed to get profiler log folder (unexpected IGFS instance type)");

    URL logsDirUrl = U.resolveIgniteUrl(logsDir != null ? logsDir : DFLT_IGFS_LOG_DIR);

    return logsDirUrl != null ? new File(logsDirUrl.getPath()).toPath() : null;
  }