org.elasticsearch.common.io.PathUtils Java Examples
The following examples show how to use
org.elasticsearch.common.io.PathUtils.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Dictionary.java From Elasticsearch-Tutorial-zh-CN with GNU General Public License v3.0 | 6 votes |
public List<String> getExtDictionarys() { List<String> extDictFiles = new ArrayList<String>(2); String extDictCfg = getProperty(EXT_DICT); if (extDictCfg != null) { String[] filePaths = extDictCfg.split(";"); for (String filePath : filePaths) { if (filePath != null && !"".equals(filePath.trim())) { Path file = PathUtils.get(filePath.trim()); extDictFiles.add(file.toString()); } } } return extDictFiles; }
Example #2
Source File: Dictionary.java From Elasticsearch-Tutorial-zh-CN with GNU General Public License v3.0 | 6 votes |
public List<String> getExtStopWordDictionarys() { List<String> extStopWordDictFiles = new ArrayList<String>(2); String extStopWordDictCfg = getProperty(EXT_STOP); if (extStopWordDictCfg != null) { String[] filePaths = extStopWordDictCfg.split(";"); for (String filePath : filePaths) { if (filePath != null && !"".equals(filePath.trim())) { Path file = PathUtils.get(filePath.trim()); extStopWordDictFiles.add(file.toString()); } } } return extStopWordDictFiles; }
Example #3
Source File: InternalSettingsPreparerTest.java From crate with Apache License 2.0 | 6 votes |
@Test public void testCustomConfigMustNotContainSettingsFromDefaultCrateYml() throws Exception { HashMap<String, String> settings = new HashMap<>(); Path home = PathUtils.get(getClass().getResource(".").toURI()); settings.put("path.home", home.toString()); Path config = PathUtils.get(getClass().getResource("config_custom").toURI()); settings.put("path.conf", config.toString()); Settings finalSettings = InternalSettingsPreparer .prepareEnvironment(Settings.EMPTY, settings, config, () -> "node1").settings(); // Values from crate.yml assertThat(finalSettings.get("cluster.name"), is("custom")); // path.logs is not set in config_custom/crate.yml // so it needs to use default value and not the value set in config/crate.yml assertThat(finalSettings.get("path.logs"), Matchers.anyOf( endsWith("org/elasticsearch/node/logs"), endsWith("org\\elasticsearch\\node\\logs") )); }
Example #4
Source File: ESFileStore.java From Elasticsearch with Apache License 2.0 | 6 votes |
@SuppressForbidden(reason = "tries to determine if disk is spinning") // TODO: move PathUtils to be package-private here instead of // public+forbidden api! ESFileStore(FileStore in) { this.in = in; Boolean spins; // Lucene's IOUtils.spins only works on Linux today: if (Constants.LINUX) { try { spins = IOUtils.spins(PathUtils.get(getMountPointLinux(in))); } catch (Exception e) { spins = null; } } else { spins = null; } this.spins = spins; }
Example #5
Source File: MetaDataCreateIndexService.java From Elasticsearch with Apache License 2.0 | 6 votes |
List<String> getIndexSettingsValidationErrors(Settings settings) { String customPath = settings.get(IndexMetaData.SETTING_DATA_PATH, null); List<String> validationErrors = new ArrayList<>(); if (customPath != null && env.sharedDataFile() == null) { validationErrors.add("path.shared_data must be set in order to use custom data paths"); } else if (customPath != null) { Path resolvedPath = PathUtils.get(new Path[]{env.sharedDataFile()}, customPath); if (resolvedPath == null) { validationErrors.add("custom path [" + customPath + "] is not a sub-path of path.shared_data [" + env.sharedDataFile() + "]"); } } Integer number_of_primaries = settings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_SHARDS, null); Integer number_of_replicas = settings.getAsInt(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, null); if (number_of_primaries != null && number_of_primaries <= 0) { validationErrors.add("index must have 1 or more primary shards"); } if (number_of_replicas != null && number_of_replicas < 0) { validationErrors.add("index must have 0 or more replica shards"); } return validationErrors; }
Example #6
Source File: Security.java From Elasticsearch with Apache License 2.0 | 6 votes |
/** Adds access to classpath jars/classes for jar hell scan, etc */ @SuppressForbidden(reason = "accesses fully qualified URLs to configure security") static void addClasspathPermissions(Permissions policy) throws IOException { // add permissions to everything in classpath // really it should be covered by lib/, but there could be e.g. agents or similar configured) for (URL url : JarHell.parseClassPath()) { Path path; try { path = PathUtils.get(url.toURI()); } catch (URISyntaxException e) { throw new RuntimeException(e); } // resource itself policy.add(new FilePermission(path.toString(), "read,readlink")); // classes underneath if (Files.isDirectory(path)) { policy.add(new FilePermission(path.toString() + path.getFileSystem().getSeparator() + "-", "read,readlink")); } } }
Example #7
Source File: InternalSettingsPreparerTest.java From crate with Apache License 2.0 | 6 votes |
@Test public void testThatCommandLineArgumentsOverrideSettingsFromConfigFile() throws Exception { HashMap<String, String> settings = new HashMap<>(); settings.put("path.home", "."); Path config = PathUtils.get(getClass().getResource("config").toURI()); settings.put("path.conf", config.toString()); settings.put("stats.enabled", "false"); settings.put("cluster.name", "clusterNameOverridden"); settings.put("path.logs", "/some/other/path"); Settings finalSettings = InternalSettingsPreparer .prepareEnvironment(Settings.EMPTY, settings, config, () -> "node1").settings(); // Overriding value from crate.yml assertThat(finalSettings.getAsBoolean("stats.enabled", null), is(false)); // Value kept from crate.yml assertThat(finalSettings.getAsBoolean("psql.enabled", null), is(false)); // Overriding value from crate.yml assertThat(finalSettings.get("cluster.name"), is("clusterNameOverridden")); // Value kept from crate.yml assertThat(finalSettings.get("path.logs"), Matchers.anyOf( is("/some/other/path"), is("D:\\some\\other\\path") )); }
Example #8
Source File: OsProbe.java From crate with Apache License 2.0 | 6 votes |
/** * Checks if cgroup stats are available by checking for the existence of {@code /proc/self/cgroup}, {@code /sys/fs/cgroup/cpu}, * {@code /sys/fs/cgroup/cpuacct} and {@code /sys/fs/cgroup/memory}. * * @return {@code true} if the stats are available, otherwise {@code false} */ @SuppressForbidden(reason = "access /proc/self/cgroup, /sys/fs/cgroup/cpu, /sys/fs/cgroup/cpuacct and /sys/fs/cgroup/memory") boolean areCgroupStatsAvailable() { if (!Files.exists(PathUtils.get("/proc/self/cgroup"))) { return false; } if (!Files.exists(PathUtils.get("/sys/fs/cgroup/cpu"))) { return false; } if (!Files.exists(PathUtils.get("/sys/fs/cgroup/cpuacct"))) { return false; } if (!Files.exists(PathUtils.get("/sys/fs/cgroup/memory"))) { return false; } return true; }
Example #9
Source File: InternalSettingsPreparerTest.java From crate with Apache License 2.0 | 5 votes |
@Test public void testErrorWithDuplicateSettingInConfigFile() throws Exception { HashMap<String, String> settings = new HashMap<>(); settings.put("path.home", "."); Path config = PathUtils.get(getClass().getResource("config_invalid").toURI()); settings.put("path.conf", config.toString()); expectedException.expect(SettingsException.class); expectedException.expectMessage("Failed to load settings from"); expectedException.expectCause(Matchers.hasProperty("message", containsString("Duplicate field 'stats.enabled'"))); InternalSettingsPreparer.prepareEnvironment(Settings.EMPTY, settings, config, () -> "node1"); }
Example #10
Source File: InternalSettingsPreparerTest.java From crate with Apache License 2.0 | 5 votes |
@Test public void testClusterNameMissingFromConfigFile() throws Exception { HashMap<String, String> settings = new HashMap<>(); settings.put("path.home", "."); settings.put("cluster.name", "clusterName"); Path config = PathUtils.get(getClass().getResource("config").toURI()); Settings finalSettings = InternalSettingsPreparer .prepareEnvironment(Settings.EMPTY, settings, config, () -> "node1").settings(); assertThat(finalSettings.get("cluster.name"), is("clusterName")); }
Example #11
Source File: ESTestCase.java From crate with Apache License 2.0 | 5 votes |
/** * Returns a {@link java.nio.file.Path} pointing to the class path relative resource given * as the first argument. In contrast to * <code>getClass().getResource(...).getFile()</code> this method will not * return URL encoded paths if the parent path contains spaces or other * non-standard characters. */ @Override public Path getDataPath(String relativePath) { // we override LTC behavior here: wrap even resources with mockfilesystems, // because some code is buggy when it comes to multiple nio.2 filesystems // (e.g. FileSystemUtils, and likely some tests) try { return PathUtils.get(getClass().getResource(relativePath).toURI()); } catch (Exception e) { throw new RuntimeException("resource not found: " + relativePath, e); } }
Example #12
Source File: BlobIndicesService.java From crate with Apache License 2.0 | 5 votes |
@Nullable public static Path getGlobalBlobPath(Settings settings) { String customGlobalBlobPathSetting = SETTING_BLOBS_PATH.get(settings); if (Strings.isNullOrEmpty(customGlobalBlobPathSetting)) { return null; } Path globalBlobPath = PathUtils.get(customGlobalBlobPathSetting); ensureExistsAndWritable(globalBlobPath); return globalBlobPath; }
Example #13
Source File: Netty4HttpServerTransport.java From crate with Apache License 2.0 | 5 votes |
protected HttpChannelHandler(Netty4HttpServerTransport transport, NodeClient nodeClient, Settings settings, PipelineRegistry pipelineRegistry) { this.transport = transport; this.nodeClient = nodeClient; this.pipelineRegistry = pipelineRegistry; this.nodeName = NODE_NAME_SETTING.get(settings); this.home = PathUtils.get(PATH_HOME_SETTING.get(settings)).normalize(); }
Example #14
Source File: ESFileStore.java From crate with Apache License 2.0 | 5 votes |
@SuppressForbidden(reason = "tries to determine if disk is spinning") // TODO: move PathUtils to be package-private here instead of // public+forbidden api! ESFileStore(final FileStore in) { this.in = in; if (Constants.LINUX) { try { final List<String> lines = Files.readAllLines(PathUtils.get("/proc/self/mountinfo")); for (final String line : lines) { final String[] fields = line.trim().split("\\s+"); final String mountPoint = fields[4]; if (mountPoint.equals(getMountPointLinux(in))) { final String[] deviceNumbers = fields[2].split(":"); majorDeviceNumber = Integer.parseInt(deviceNumbers[0]); minorDeviceNumber = Integer.parseInt(deviceNumbers[1]); break; } } } catch (final Exception e) { majorDeviceNumber = -1; minorDeviceNumber = -1; } } else { majorDeviceNumber = -1; minorDeviceNumber = -1; } }
Example #15
Source File: OpenNlpProcessorTests.java From elasticsearch-ingest-opennlp with Apache License 2.0 | 5 votes |
@BeforeClass public static void createOpenNlpService() throws Exception { Settings settings = Settings.builder() .put("ingest.opennlp.model.file.names", "en-ner-persons.bin") .put("ingest.opennlp.model.file.locations", "en-ner-locations.bin") .put("ingest.opennlp.model.file.dates", "en-ner-dates.bin") .build(); Path path = PathUtils.get(OpenNlpProcessorTests.class.getResource("/models/en-ner-persons.bin").toURI()); service = new OpenNlpService(path.getParent(), settings).start(); }
Example #16
Source File: PluginLoader.java From crate with Apache License 2.0 | 5 votes |
PluginLoader(Settings settings) { this.settings = settings; String pluginFolder = SETTING_CRATE_PLUGINS_PATH.get(settings); if (pluginFolder.isEmpty()) { pluginsPath = PathUtils.get(settings.get("path.home")).normalize().resolve("plugins"); } else { pluginsPath = PathUtils.get(pluginFolder).normalize(); } logger = LogManager.getLogger(getClass().getPackage().getName()); Collection<Class<? extends Plugin>> implementations = findImplementations(); ImmutableList.Builder<Plugin> builder = ImmutableList.builder(); for (Class<? extends Plugin> pluginClass : implementations) { try { builder.add(loadPlugin(pluginClass)); } catch (Throwable t) { logger.error("error loading plugin: " + pluginClass.getSimpleName(), t); } } plugins = builder.build(); if (logger.isInfoEnabled()) { logger.info("plugins loaded: {} ", plugins.stream().map(Plugin::name).collect(Collectors.toList())); } }
Example #17
Source File: JarHell.java From crate with Apache License 2.0 | 4 votes |
/** * Parses the classpath into a set of URLs. For testing. * @param classPath classpath to parse (typically the system property {@code java.class.path}) * @return array of URLs * @throws IllegalStateException if the classpath contains empty elements */ @SuppressForbidden(reason = "resolves against CWD because that is how classpaths work") static Set<URL> parseClassPath(String classPath) { String pathSeparator = System.getProperty("path.separator"); String fileSeparator = System.getProperty("file.separator"); String[] elements = classPath.split(pathSeparator); Set<URL> urlElements = new LinkedHashSet<>(); // order is already lost, but some filesystems have it for (String element : elements) { // Technically empty classpath element behaves like CWD. // So below is the "correct" code, however in practice with ES, this is usually just a misconfiguration, // from old shell scripts left behind or something: // if (element.isEmpty()) { // element = System.getProperty("user.dir"); // } // Instead we just throw an exception, and keep it clean. if (element.isEmpty()) { throw new IllegalStateException("Classpath should not contain empty elements! (outdated shell script from a previous" + " version?) classpath='" + classPath + "'"); } // we should be able to just Paths.get() each element, but unfortunately this is not the // whole story on how classpath parsing works: if you want to know, start at sun.misc.Launcher, // be sure to stop before you tear out your eyes. we just handle the "alternative" filename // specification which java seems to allow, explicitly, right here... if (element.startsWith("/") && "\\".equals(fileSeparator)) { // "correct" the entry to become a normal entry // change to correct file separators element = element.replace("/", "\\"); // if there is a drive letter, nuke the leading separator if (element.length() >= 3 && element.charAt(2) == ':') { element = element.substring(1); } } // now just parse as ordinary file try { URL url = PathUtils.get(element).toUri().toURL(); if (urlElements.add(url) == false) { if (!url.getPath().endsWith("idea_rt.jar")) { throw new IllegalStateException("jar hell!" + System.lineSeparator() + "duplicate jar [" + element + "] on classpath: " + classPath); } } } catch (MalformedURLException e) { // should not happen, as we use the filesystem API throw new RuntimeException(e); } } return Collections.unmodifiableSet(urlElements); }
Example #18
Source File: Configuration.java From Elasticsearch-Tutorial-zh-CN with GNU General Public License v3.0 | 4 votes |
public Path getConfigInPluginDir() { return PathUtils .get(new File(AnalysisIkPlugin.class.getProtectionDomain().getCodeSource().getLocation().getPath()) .getParent(), "config") .toAbsolutePath(); }
Example #19
Source File: Environment.java From Elasticsearch with Apache License 2.0 | 4 votes |
public Environment(Settings settings) { this.settings = settings; final Path homeFile; if (settings.get("path.home") != null) { homeFile = PathUtils.get(cleanPath(settings.get("path.home"))); } else { throw new IllegalStateException("path.home is not configured"); } if (settings.get("path.conf") != null) { configFile = PathUtils.get(cleanPath(settings.get("path.conf"))); } else { configFile = homeFile.resolve("config"); } if (settings.get("path.scripts") != null) { scriptsFile = PathUtils.get(cleanPath(settings.get("path.scripts"))); } else { scriptsFile = configFile.resolve("scripts"); } if (settings.get("path.plugins") != null) { pluginsFile = PathUtils.get(cleanPath(settings.get("path.plugins"))); } else { pluginsFile = homeFile.resolve("plugins"); } String[] dataPaths = settings.getAsArray("path.data"); if (dataPaths.length > 0) { dataFiles = new Path[dataPaths.length]; dataWithClusterFiles = new Path[dataPaths.length]; dataPathLimits = new String[dataPaths.length]; for (int i = 0; i < dataPaths.length; i++) { String[] dataPathConfig = dataPaths[i].split("#"); dataFiles[i] = PathUtils.get(dataPathConfig[0]); dataWithClusterFiles[i] = dataFiles[i].resolve(ClusterName.clusterNameFromSettings(settings).value()); if (dataPathConfig.length > 1) { dataPathLimits[i] = dataPathConfig[1]; } else { dataPathLimits[i] = "-1"; } } } else { dataFiles = new Path[]{homeFile.resolve("data")}; dataWithClusterFiles = new Path[]{homeFile.resolve("data").resolve(ClusterName.clusterNameFromSettings(settings).value())}; dataPathLimits = new String[]{"-1"}; } if (settings.get("path.shared_data") != null) { sharedDataFile = PathUtils.get(cleanPath(settings.get("path.shared_data"))); } else { sharedDataFile = null; } String[] repoPaths = settings.getAsArray("path.repo"); if (repoPaths.length > 0) { repoFiles = new Path[repoPaths.length]; for (int i = 0; i < repoPaths.length; i++) { repoFiles[i] = PathUtils.get(repoPaths[i]); } } else { repoFiles = new Path[0]; } if (settings.get("path.logs") != null) { logsFile = PathUtils.get(cleanPath(settings.get("path.logs"))); } else { logsFile = homeFile.resolve("logs"); } if (settings.get("pidfile") != null) { pidFile = PathUtils.get(cleanPath(settings.get("pidfile"))); } else { pidFile = null; } binFile = homeFile.resolve("bin"); libFile = homeFile.resolve("lib"); modulesFile = homeFile.resolve("modules"); }
Example #20
Source File: JarHell.java From Elasticsearch with Apache License 2.0 | 4 votes |
/** * Parses the classpath into a set of URLs. For testing. * @param classPath classpath to parse (typically the system property {@code java.class.path}) * @return array of URLs * @throws IllegalStateException if the classpath contains empty elements */ @SuppressForbidden(reason = "resolves against CWD because that is how classpaths work") static URL[] parseClassPath(String classPath) { String pathSeparator = System.getProperty("path.separator"); String fileSeparator = System.getProperty("file.separator"); String elements[] = classPath.split(pathSeparator); URL urlElements[] = new URL[elements.length]; for (int i = 0; i < elements.length; i++) { String element = elements[i]; // Technically empty classpath element behaves like CWD. // So below is the "correct" code, however in practice with ES, this is usually just a misconfiguration, // from old shell scripts left behind or something: // if (element.isEmpty()) { // element = System.getProperty("user.dir"); // } // Instead we just throw an exception, and keep it clean. if (element.isEmpty()) { throw new IllegalStateException("Classpath should not contain empty elements! (outdated shell script from a previous version?) classpath='" + classPath + "'"); } // we should be able to just Paths.get() each element, but unfortunately this is not the // whole story on how classpath parsing works: if you want to know, start at sun.misc.Launcher, // be sure to stop before you tear out your eyes. we just handle the "alternative" filename // specification which java seems to allow, explicitly, right here... if (element.startsWith("/") && "\\".equals(fileSeparator)) { // "correct" the entry to become a normal entry // change to correct file separators element = element.replace("/", "\\"); // if there is a drive letter, nuke the leading separator if (element.length() >= 3 && element.charAt(2) == ':') { element = element.substring(1); } } // now just parse as ordinary file try { urlElements[i] = PathUtils.get(element).toUri().toURL(); } catch (MalformedURLException e) { // should not happen, as we use the filesystem API throw new RuntimeException(e); } } return urlElements; }
Example #21
Source File: BootstrapChecks.java From crate with Apache License 2.0 | 4 votes |
@SuppressForbidden(reason = "access /proc/sys/vm/max_map_count") private Path getProcSysVmMaxMapCountPath() { return PathUtils.get("/proc/sys/vm/max_map_count"); }
Example #22
Source File: FsProbe.java From crate with Apache License 2.0 | 4 votes |
@SuppressForbidden(reason = "read /proc/diskstats") List<String> readProcDiskStats() throws IOException { return Files.readAllLines(PathUtils.get("/proc/diskstats")); }
Example #23
Source File: Environment.java From crate with Apache License 2.0 | 4 votes |
public Environment(final Settings settings, final Path configPath) { this(settings, configPath, PathUtils.get(System.getProperty("java.io.tmpdir"))); }
Example #24
Source File: Environment.java From crate with Apache License 2.0 | 4 votes |
Environment(final Settings settings, final Path configPath, final Path tmpPath) { final Path homeFile; if (PATH_HOME_SETTING.exists(settings)) { homeFile = PathUtils.get(PATH_HOME_SETTING.get(settings)).normalize(); } else { throw new IllegalStateException(PATH_HOME_SETTING.getKey() + " is not configured"); } if (configPath != null) { configFile = configPath.normalize(); } else { configFile = homeFile.resolve("config"); } tmpFile = Objects.requireNonNull(tmpPath); pluginsFile = homeFile.resolve("plugins"); List<String> dataPaths = PATH_DATA_SETTING.get(settings); final ClusterName clusterName = ClusterName.CLUSTER_NAME_SETTING.get(settings); if (DiscoveryNode.nodeRequiresLocalStorage(settings)) { if (dataPaths.isEmpty() == false) { dataFiles = new Path[dataPaths.size()]; dataWithClusterFiles = new Path[dataPaths.size()]; for (int i = 0; i < dataPaths.size(); i++) { dataFiles[i] = PathUtils.get(dataPaths.get(i)); dataWithClusterFiles[i] = dataFiles[i].resolve(clusterName.value()); } } else { dataFiles = new Path[]{homeFile.resolve("data")}; dataWithClusterFiles = new Path[]{homeFile.resolve("data").resolve(clusterName.value())}; } } else { if (dataPaths.isEmpty()) { dataFiles = dataWithClusterFiles = EMPTY_PATH_ARRAY; } else { final String paths = String.join(",", dataPaths); throw new IllegalStateException("node does not require local storage yet path.data is set to [" + paths + "]"); } } if (PATH_SHARED_DATA_SETTING.exists(settings)) { sharedDataFile = PathUtils.get(PATH_SHARED_DATA_SETTING.get(settings)).normalize(); } else { sharedDataFile = null; } List<String> repoPaths = PATH_REPO_SETTING.get(settings); if (repoPaths.isEmpty()) { repoFiles = EMPTY_PATH_ARRAY; } else { repoFiles = new Path[repoPaths.size()]; for (int i = 0; i < repoPaths.size(); i++) { repoFiles[i] = PathUtils.get(repoPaths.get(i)); } } // this is trappy, Setting#get(Settings) will get a fallback setting yet return false for Settings#exists(Settings) if (PATH_LOGS_SETTING.exists(settings)) { logsFile = PathUtils.get(PATH_LOGS_SETTING.get(settings)).normalize(); } else { logsFile = homeFile.resolve("logs"); } if (PIDFILE_SETTING.exists(settings)) { pidFile = PathUtils.get(PIDFILE_SETTING.get(settings)).normalize(); } else { pidFile = null; } binFile = homeFile.resolve("bin"); libFile = homeFile.resolve("lib"); modulesFile = homeFile.resolve("modules"); Settings.Builder finalSettings = Settings.builder().put(settings); finalSettings.put(PATH_HOME_SETTING.getKey(), homeFile); if (PATH_DATA_SETTING.exists(settings)) { finalSettings.putList(PATH_DATA_SETTING.getKey(), dataPaths); } finalSettings.put(PATH_LOGS_SETTING.getKey(), logsFile.toString()); this.settings = finalSettings.build(); }
Example #25
Source File: OsProbe.java From crate with Apache License 2.0 | 2 votes |
/** * Returns the line from {@code memory.usage_in_bytes} for the control group to which the Elasticsearch process belongs for the * {@code memory} subsystem. This line represents the total current memory usage by processes in the cgroup (in bytes). * * @param controlGroup the control group to which the Elasticsearch process belongs for the {@code memory} subsystem * @return the line from {@code memory.usage_in_bytes} * @throws IOException if an I/O exception occurs reading {@code memory.usage_in_bytes} for the control group */ @SuppressForbidden(reason = "access /sys/fs/cgroup/memory") String readSysFsCgroupMemoryUsageInBytes(final String controlGroup) throws IOException { return readSingleLine(PathUtils.get("/sys/fs/cgroup/memory", controlGroup, "memory.usage_in_bytes")); }
Example #26
Source File: Environment.java From crate with Apache License 2.0 | 2 votes |
/** * Resolves the specified location against the list of configured repository roots * * If the specified location doesn't match any of the roots, returns null. */ public Path resolveRepoFile(String location) { return PathUtils.get(repoFiles, location); }
Example #27
Source File: OsProbe.java From crate with Apache License 2.0 | 2 votes |
/** * Returns the line from {@code memory.limit_in_bytes} for the control group to which the Elasticsearch process belongs for the * {@code memory} subsystem. This line represents the maximum amount of user memory (including file cache). * * @param controlGroup the control group to which the Elasticsearch process belongs for the {@code memory} subsystem * @return the line from {@code memory.limit_in_bytes} * @throws IOException if an I/O exception occurs reading {@code memory.limit_in_bytes} for the control group */ @SuppressForbidden(reason = "access /sys/fs/cgroup/memory") String readSysFsCgroupMemoryLimitInBytes(final String controlGroup) throws IOException { return readSingleLine(PathUtils.get("/sys/fs/cgroup/memory", controlGroup, "memory.limit_in_bytes")); }
Example #28
Source File: OsProbe.java From crate with Apache License 2.0 | 2 votes |
/** * Returns the line from {@code cpu.cfs_quota_us} for the control group to which the Elasticsearch process belongs for the {@code cpu} * subsystem. This line represents the total time in microseconds that all tasks in the control group can run during one period as * specified by {@code cpu.cfs_period_us}. * * @param controlGroup the control group to which the Elasticsearch process belongs for the {@code cpu} subsystem * @return the line from {@code cpu.cfs_quota_us} * @throws IOException if an I/O exception occurs reading {@code cpu.cfs_quota_us} for the control group */ @SuppressForbidden(reason = "access /sys/fs/cgroup/cpu") String readSysFsCgroupCpuAcctCpuAcctCfsQuota(final String controlGroup) throws IOException { return readSingleLine(PathUtils.get("/sys/fs/cgroup/cpu", controlGroup, "cpu.cfs_quota_us")); }
Example #29
Source File: OsProbe.java From crate with Apache License 2.0 | 2 votes |
/** * Returns the line from {@code cpu.cfs_period_us} for the control group to which the Elasticsearch process belongs for the {@code cpu} * subsystem. This line represents the period of time in microseconds for how frequently the control group's access to CPU resources * will be reallocated. * * @param controlGroup the control group to which the Elasticsearch process belongs for the {@code cpu} subsystem * @return the line from {@code cpu.cfs_period_us} * @throws IOException if an I/O exception occurs reading {@code cpu.cfs_period_us} for the control group */ @SuppressForbidden(reason = "access /sys/fs/cgroup/cpu") String readSysFsCgroupCpuAcctCpuCfsPeriod(final String controlGroup) throws IOException { return readSingleLine(PathUtils.get("/sys/fs/cgroup/cpu", controlGroup, "cpu.cfs_period_us")); }
Example #30
Source File: OsProbe.java From crate with Apache License 2.0 | 2 votes |
/** * Returns the line from {@code cpuacct.usage} for the control group to which the Elasticsearch process belongs for the {@code cpuacct} * subsystem. This line represents the total CPU time in nanoseconds consumed by all tasks in the same control group. * * @param controlGroup the control group to which the Elasticsearch process belongs for the {@code cpuacct} subsystem * @return the line from {@code cpuacct.usage} * @throws IOException if an I/O exception occurs reading {@code cpuacct.usage} for the control group */ @SuppressForbidden(reason = "access /sys/fs/cgroup/cpuacct") String readSysFsCgroupCpuAcctCpuAcctUsage(final String controlGroup) throws IOException { return readSingleLine(PathUtils.get("/sys/fs/cgroup/cpuacct", controlGroup, "cpuacct.usage")); }