alnzng commented on code in PR #1636: URL: https://github.com/apache/samza/pull/1636#discussion_r1014523336
########## samza-core/src/main/java/org/apache/samza/container/host/OshiBasedStatisticsGetter.java: ########## @@ -0,0 +1,90 @@ +/* + * 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.samza.container.host; + +import com.google.common.annotations.VisibleForTesting; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.lang3.NotImplementedException; +import oshi.SystemInfo; +import oshi.software.os.OSProcess; +import oshi.software.os.OperatingSystem; + + +/** + * An implementation of {@link SystemStatisticsGetter} that relies on using oshi framework(https://www.oshi.ooo/) + */ +public class OshiBasedStatisticsGetter implements SystemStatisticsGetter { + // the snapshots of current JVM process and its child processes + private final Map<Integer, OSProcess> previousProcessSnapshots = new HashMap<>(); Review Comment: My understanding is that the current Samza implementation only runs one thread to trigger all SystemStatisticsGetter implementations, so there won't be any race conditions. And in general, for such container/system/global metric, it doesn't make sense that we run multiple threads to collect data points. If we update the class as NotThreadSafe as you suggested in the first comment, will it help? -- 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]
