smiklosovic commented on code in PR #2842: URL: https://github.com/apache/cassandra/pull/2842#discussion_r1430289836
########## src/java/org/apache/cassandra/utils/SystemInfo.java: ########## @@ -0,0 +1,210 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.utils; + +import java.util.List; +import java.util.Optional; +import java.util.function.Supplier; +import java.util.regex.Pattern; + +import com.google.common.collect.ImmutableList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.cassandra.io.util.File; +import org.apache.cassandra.io.util.FileUtils; +import oshi.PlatformEnum; + +import static java.lang.String.format; +import static java.util.Optional.empty; +import static java.util.Optional.of; + + +/** + * An abstraction of System information, this class provides access to system information without specifying how + * it is retrieved. + */ +public class SystemInfo +{ + + private static final long INFINITY = -1l; + private static final long EXPECTED_MIN_NOFILE = 10000l; // number of files that can be opened + private static final long EXPECTED_NPROC = 32768l; // number of processes + private static final long EXPECTED_AS = 0x7FFFFFFFl; // address space + /** + * The default number of processes that are reported if the actual value can not be retrieved. + */ + public static final long DEFAULT_MAX_PROCESSES = 1024; + + private static final Pattern SPACES_PATTERN = Pattern.compile("\\s+"); + + private Logger logger = LoggerFactory.getLogger(SystemInfo.class); + + /* The oshi.SystemInfo has the following note: + * Platform-specific Hardware and Software objects are retrieved via memoized suppliers. To conserve memory at the + * cost of additional processing time, create a new version of SystemInfo() for subsequent calls. To conserve + * processing time at the cost of additional memory usage, re-use the same {@link SystemInfo} object for future + * queries. + * + * We are opting for minimal memory footprint. */ + private oshi.SystemInfo si ; + + public SystemInfo() { Review Comment: braces on new line -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

