/** * 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; }
/** * Discover WS device on the local network with specified filter * * @param regexpProtocol url protocol matching regexp like "^http$", might be empty "" * @param regexpPath url path matching regexp like "onvif", might be empty "" * @return list of unique device urls filtered */ public static Collection<URL> discoverWsDevicesAsUrls(String regexpProtocol, String regexpPath) { final Collection<URL> urls = new TreeSet<>( new Comparator<URL>() { public int compare(URL o1, URL o2) { return o1.toString().compareTo(o2.toString()); } }); for (String key : discoverWsDevices()) { try { final URL url = new URL(key); boolean ok = true; if (regexpProtocol.length() > 0 && !url.getProtocol().matches(regexpProtocol)) ok = false; if (regexpPath.length() > 0 && !url.getPath().matches(regexpPath)) ok = false; if (ok) urls.add(url); } catch (MalformedURLException e) { e.printStackTrace(); } } return urls; }