You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@samza.apache.org by GitBox <gi...@apache.org> on 2022/10/26 05:28:19 UTC

[GitHub] [samza] alnzng opened a new pull request, #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

alnzng opened a new pull request, #1636:
URL: https://github.com/apache/samza/pull/1636

   # Symptom
   
   We have observed that some use cases used quasar(TensorFlow framework) to do model inference and this framework spawn child processes(non-JVM) to run TensorFlow serving. These child processes were using high CPU usage(200%) however their CPU usage can't be captured by the existing CPU usage metric `process-cpu-usage`
   
   # Cause
   
   The existing metric `process-cpu-usage` metric was designed for capturing the [CPU usage for the JVM process](https://samza.apache.org/learn/documentation/1.6.0/operations/monitoring.html) only, it can't count the child processes(especially for non-JVM processes) usage.
   
   # Changes
   
   - Reply on [oshi framwork](https://www.oshi.ooo/) to capture the CPU usage for the JVM process and all its child processes, and create a new metric to display the total CPU usage.
   # API Changes
   
   - Added a new metric `total-process-cpu-usage` in `SamzaContainerMetrics` which is similar with [how we provided `physical-memory-mb` metric](https://github.com/apache/samza/pull/1530)
   
   # Tests
   
   - Unit tests
   - Tested with `samza-hello-samza` and verify the metric data points
   ![Screen Shot 2022-10-25 at 10 23 58 PM](https://user-images.githubusercontent.com/59407935/197942249-21dae598-7e18-4bb0-88e5-6a752ca49765.png)
   


-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015949373


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);

Review Comment:
   Oh, I see the gap here: Your point is that host CPU num != JVM available CPU num, and I thought they were the same. I think your point is correct in some scenarios. 
   
   I did some research/test on the `OperatingSystemMXBean. getAvailableProcessors()`, the count is for logical CPU count instead of phsical CPU count. For non-containerization or VM use cases, the available logic/phsical CPU count in JVM could be the same as in host, IIUC. I will update this oshi implementation based on logical CPU count anyway since we should be consistent with JVM. 
   
   Note: I didn't verify if oshi shows the consistent behavior/result regarding the CPU count in the containerizaiton or VM land(e.g. docker, kubernetes).
   
   
   
   
   



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014528695


##########
samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala:
##########
@@ -49,6 +49,7 @@ class SamzaContainerMetrics(
   val executorWorkFactor = newGauge("executor-work-factor", 1.0)
   val physicalMemoryMb = newGauge("physical-memory-mb", 0.0F)
   val physicalMemoryUtilization = newGauge("physical-memory-utilization", 0.0F)
+  val totalProcessCpuUsage = newGauge("total-process-cpu-usage", 0.0)

Review Comment:
   Prefer to create a new metric(e.g. total-process-cpu-usage) to represent the cpu usage for the Samza container’s JVM process and all its child/descendant processes because of
   - I view it as a non-backward compatible change if let the existing “process-cpu-usage” metric to include child/descendant processes especially for non-JVM processes.
     - Samza official doc clearly states that the `process-cpu-usage` returns the “recent cpu usage” for the Java Virtual Machine process: https://samza.apache.org/learn/documentation/1.6.0/operations/monitoring.html
   - Having a new metric could be consistent with how Samza exposes physical-memory-mb . This memory related metric which includes child process is available for Samza container only, the AM doesn’t have it.
   - Implementation/Maintainance complexity. If keep using the existing `process-cpu-usage` we will have to deprecate the JVMMetrics implementation and add a new hook into AM to expose the metric.
   
   Good point on the doc, let me update the document.



##########
samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala:
##########
@@ -49,6 +49,7 @@ class SamzaContainerMetrics(
   val executorWorkFactor = newGauge("executor-work-factor", 1.0)
   val physicalMemoryMb = newGauge("physical-memory-mb", 0.0F)
   val physicalMemoryUtilization = newGauge("physical-memory-utilization", 0.0F)
+  val totalProcessCpuUsage = newGauge("total-process-cpu-usage", 0.0)

Review Comment:
   Prefer to create a new metric(e.g. total-process-cpu-usage) to represent the cpu usage for the Samza container’s JVM process and all its child/descendant processes because of
   - I view it as a non-backward compatible change if let the existing “process-cpu-usage” metric to include child/descendant processes especially for non-JVM processes.
     - Samza official doc clearly states that the `process-cpu-usage` returns the “recent cpu usage” for the Java Virtual Machine process: https://samza.apache.org/learn/documentation/1.6.0/operations/monitoring.html
   - Having a new metric could be consistent with how Samza exposes `physical-memory-mb`. This memory related metric which includes child process is available for Samza container only, the AM doesn’t have it.
   - Implementation/Maintainance complexity. If keep using the existing `process-cpu-usage` we will have to deprecate the JVMMetrics implementation and add a new hook into AM to expose the metric.
   
   Good point on the doc, let me update the document.



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] mynameborat commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
mynameborat commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1013440757


##########
samza-core/src/main/java/org/apache/samza/container/host/DefaultSystemStatisticsGetter.java:
##########
@@ -0,0 +1,53 @@
+/*
+ * 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;
+
+
+/**
+ * An default implementation of {@link SystemStatisticsGetter} that relies on {@link PosixCommandBasedStatisticsGetter}
+ * and {@link OshiBasedStatisticsGetter} implementations
+ */
+public class DefaultSystemStatisticsGetter implements SystemStatisticsGetter {
+

Review Comment:
   nit: remove extra line



##########
samza-core/src/main/java/org/apache/samza/container/host/ProcessCPUStatistics.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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 java.util.Objects;
+
+
+/**
+ * A {@link ProcessCPUStatistics} object represents recent CPU usage percentage about the container process(including its child processes)
+ */
+public class ProcessCPUStatistics {

Review Comment:
   why do we need to wrap this into a container object? 



##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);
+  }
+
+  private List<OSProcess> getCurrentProcessAndChildProcesses() {
+    final List<OSProcess> processes = new ArrayList<>();
+    // get current process
+    processes.add(os.getProcess(os.getProcessId()));
+    // get all child processes of current process
+    processes.addAll(os.getChildProcesses(os.getProcessId(), OperatingSystem.ProcessFiltering.ALL_PROCESSES,
+        OperatingSystem.ProcessSorting.NO_SORTING, 0));
+    return processes;
+  }
+
+  private double getTotalCPUUsage(List<OSProcess> processes) {
+    return processes.stream()
+        .mapToDouble(p -> p.getProcessCpuLoadBetweenTicks(previousProcessSnapshots.get(p.getProcessID())))

Review Comment:
   What is the behavior if `previousProcessSnapshots.get(...)` returns `null`? 
   Will `getProcessCpuLoadBetweenTicks(null)` throw errors?



##########
samza-core/src/main/java/org/apache/samza/container/host/PosixCommandBasedStatisticsGetter.java:
##########
@@ -85,4 +86,10 @@ public SystemMemoryStatistics getSystemMemoryStatistics() {
       return null;
     }
   }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    throw new NotImplementedException(
+        "No appropriate Posix command available for getting recent CPU usage information. For example, the CPU information exposed by ps command 'ps -o %cpu= -p <PID>' represents the percentage of time spent running during the entire lifetime of a process not for the recent CPU usage");
+  }

Review Comment:
   Why not `top`?



##########
samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala:
##########
@@ -49,6 +49,7 @@ class SamzaContainerMetrics(
   val executorWorkFactor = newGauge("executor-work-factor", 1.0)
   val physicalMemoryMb = newGauge("physical-memory-mb", 0.0F)
   val physicalMemoryUtilization = newGauge("physical-memory-utilization", 0.0F)
+  val totalProcessCpuUsage = newGauge("total-process-cpu-usage", 0.0)

Review Comment:
   We are not rolling into the existing metrics is it? Why so? 
   If we want to keep it separate, can we add documentation about the new metric to the website docs?



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015949373


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);

Review Comment:
   Oh, I see the gap here: Your point is that host CPU num != JVM available CPU num, and I thought they were the same. I think your point is correct in some scenarios. 
   
   I did some research/test on the `OperatingSystemMXBean. getAvailableProcessors()`, the count is for logical CPU count instead of phsical CPU count. For non-containerization or VM use cases, the available logic/phsical CPU count in JVM should be same as in host, IIUC. I will update this oshi implementation based on logical CPU count anyway since we should be consistent with JVM. 
   
   Note: I didn't verify if oshi shows the consistent behavior/result regarding the CPU count in the containerizaiton or VM land(e.g. docker, kubernetes).
   
   
   
   
   



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014523821


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();

Review Comment:
   The child processes might be different not only for start-up but also for runtime, think about a case that some child processes are died because of exceptions or they are completed.
   
   I think we'd better get the real-time information.



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014522272


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);

Review Comment:
   The existing CPU reporting actually takes into account the core-count on the host, right? Because it leverages on Java function `OperatingSystemMXBean. getProcessCpuLoad ()` whose value is a double in the [0.0,1.0] interval. If not, the value could be larger than 1.0.
   
   https://docs.oracle.com/javase/8/docs/jre/api/management/extension/com/sun/management/OperatingSystemMXBean.html#getProcessCpuTime--
   
   >Returns the "recent cpu usage" for the Java Virtual Machine process. This value is a double in the [0.0,1.0] interval. A value of 0.0 means that none of the CPUs were running threads from the JVM process during the recent period of time observed, while a value of 1.0 means that all CPUs were actively running threads from the JVM 100% of the time during the recent period being observed. Threads from the JVM include the application threads as well as the JVM internal threads. All values betweens 0.0 and 1.0 are possible depending of the activities going on in the JVM process and the whole system. If the Java Virtual Machine recent CPU usage is not available, the method returns a negative value.
   



##########
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;

Review Comment:
    I found some classes used this `NotImplementedException ` class so I used it here. I'm good with `UnsupportedOperationException`, I can change it.



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014527343


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);
+  }
+
+  private List<OSProcess> getCurrentProcessAndChildProcesses() {
+    final List<OSProcess> processes = new ArrayList<>();
+    // get current process
+    processes.add(os.getProcess(os.getProcessId()));
+    // get all child processes of current process
+    processes.addAll(os.getChildProcesses(os.getProcessId(), OperatingSystem.ProcessFiltering.ALL_PROCESSES,
+        OperatingSystem.ProcessSorting.NO_SORTING, 0));
+    return processes;
+  }
+
+  private double getTotalCPUUsage(List<OSProcess> processes) {
+    return processes.stream()
+        .mapToDouble(p -> p.getProcessCpuLoadBetweenTicks(previousProcessSnapshots.get(p.getProcessID())))

Review Comment:
   No, it won't: https://github.com/oshi/oshi/blob/master/oshi-core/src/main/java/oshi/software/common/AbstractOSProcess.java#L52
   
   ```java
       @Override
       public double getProcessCpuLoadBetweenTicks(OSProcess priorSnapshot) {
           if (priorSnapshot != null && this.processID == priorSnapshot.getProcessID()
                   && getUpTime() > priorSnapshot.getUpTime()) {
               return (getUserTime() - priorSnapshot.getUserTime() + getKernelTime() - priorSnapshot.getKernelTime())
                       / (double) (getUpTime() - priorSnapshot.getUpTime());
           }
           return getProcessCpuLoadCumulative();
       }
   
   ```



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014528695


##########
samza-core/src/main/scala/org/apache/samza/container/SamzaContainerMetrics.scala:
##########
@@ -49,6 +49,7 @@ class SamzaContainerMetrics(
   val executorWorkFactor = newGauge("executor-work-factor", 1.0)
   val physicalMemoryMb = newGauge("physical-memory-mb", 0.0F)
   val physicalMemoryUtilization = newGauge("physical-memory-utilization", 0.0F)
+  val totalProcessCpuUsage = newGauge("total-process-cpu-usage", 0.0)

Review Comment:
   Prefer to create a new metric `total-process-cpu-usage` to represent the cpu usage for the Samza container’s JVM process and all its child/descendant processes because of
   - I view it as a non-backward compatible change if let the existing “process-cpu-usage” metric includes child/descendant processes especially for non-JVM processes.
     - Samza official doc clearly states that the `process-cpu-usage` returns the “recent cpu usage” for the Java Virtual Machine process: https://samza.apache.org/learn/documentation/1.6.0/operations/monitoring.html
   - Having a new metric could be consistent with how Samza exposes `physical-memory-mb`. This memory related metric which includes child process is available for Samza container only, the AM doesn’t have it.
   - Implementation/Maintainance complexity. If keep using the existing `process-cpu-usage` we will have to deprecate the JVMMetrics implementation and add a new hook into AM to expose the metric.
   
   Good point on the doc, let me update the document.



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] mynameborat commented on pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
mynameborat commented on PR #1636:
URL: https://github.com/apache/samza/pull/1636#issuecomment-1306336433

   Looks good to me mostly. Can you close out the conversations that have been resolved and respond to the comments that are pending.
   
   Also, fix the latest checks so that I can merge them.


-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015983431


##########
samza-core/src/main/java/org/apache/samza/container/host/ProcessCPUStatistics.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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 java.util.Objects;
+
+
+/**
+ * A {@link ProcessCPUStatistics} object represents recent CPU usage percentage about the container process(including its child processes)
+ */
+public class ProcessCPUStatistics {

Review Comment:
   This is for the consistency with the memory metric implementation: `SystemMemoryStatistics`



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014525560


##########
samza-core/src/main/java/org/apache/samza/container/host/SystemStatistics.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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 java.util.Objects;
+
+/**
+ * A {@link SystemStatistics} object represents system related information about the physical process that runs the
+ * {@link org.apache.samza.container.SamzaContainer}.
+ */
+public class SystemStatistics {
+
+  private final ProcessCPUStatistics cpuStatistics;
+  private final SystemMemoryStatistics memoryStatistics;
+
+  public SystemStatistics(ProcessCPUStatistics cpuStatistics, SystemMemoryStatistics memoryStatistics) {

Review Comment:
   The actual logic to handle the null is inside the Listener implementaiton: https://github.com/apache/samza/pull/1636/files#diff-f79781ad4c55ae7860829b06fd9dfd15e8069c37e64f8854d8f27ca2cd1f3ee5R653



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] lakshmi-manasa-g commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
lakshmi-manasa-g commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015754291


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);

Review Comment:
   no, i am saying that the current samza process-cpu usage does NOT take into account the num cpu cores on the host. 
   
   OperatingSystemMXBean is actually giving out the fraction of the total available cpu that the jvm process is using. hence it is between [0,1] AND NOT the actual cpu tick count which would need to take into account cpu core count
   
   but the proposed change in the pr takes into account num cores and gives the actual cpu tick count 
   



##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();

Review Comment:
   i wouldnt think throwing another exception is needed. we can just return null form this stat getter right



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015751569


##########
samza-core/src/main/java/org/apache/samza/container/host/ProcessCPUStatistics.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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 java.util.Objects;
+
+
+/**
+ * A {@link ProcessCPUStatistics} object represents recent CPU usage percentage about the container process(including its child processes)
+ */
+public class ProcessCPUStatistics {

Review Comment:
   Can you please clarify `wrap this into a container object`?



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015949373


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);

Review Comment:
   Oh, I see the gap here: Your point is that host CPU num != JVM available CPU num, and I thought they were the same. I think your point is correct. 
   
   I did some research/test on the `OperatingSystemMXBean. getAvailableProcessors()`, the count is for logical CPU count instead of phsical CPU count. For non-containerization or VM use cases, the available logic/phsical CPU count in JVM should be same with host, IIUC. I will update this oshi implementation based on logical CPU count anyway since we should be consistent with JVM. 
   
   Note: I didn't verify if oshi shows the consistent behavior/result regarding the CPU count in the containerizaiton or VM land(e.g. docker, kubernetes).
   
   
   
   
   



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014527935


##########
samza-core/src/main/java/org/apache/samza/container/host/PosixCommandBasedStatisticsGetter.java:
##########
@@ -85,4 +86,10 @@ public SystemMemoryStatistics getSystemMemoryStatistics() {
       return null;
     }
   }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    throw new NotImplementedException(
+        "No appropriate Posix command available for getting recent CPU usage information. For example, the CPU information exposed by ps command 'ps -o %cpu= -p <PID>' represents the percentage of time spent running during the entire lifetime of a process not for the recent CPU usage");
+  }

Review Comment:
   Yes, `top` can give the instant/recent CPU usage information for a given process, but it has below cons so that I didn't choose it:
   
   - Need to have operating system specific implementation, since the top command is not a POSIX command and its input and output format in Linux and macOS are different.
   - Slower than ps/oshi command. Especially, on macOS the top command needs to get at least two samples to get the right CPU usage, which takes longer time(~ 2 seconds) than 1 sample.
     - not clear the reason, but it shows the consistent behavior that one sample(-l1) always return 0.0 on my macOS
   



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014524771


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();

Review Comment:
   There is already a try-catch block to catch all the exceptions: https://github.com/apache/samza/pull/1636/files#diff-3b72fed01e1d344575c2eaf6dd353a69ae1fcb8c304c0ebb7543ab23ded6ad9fR126, it seems not necessary to do it here.



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] lakshmi-manasa-g commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
lakshmi-manasa-g commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015641830


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);

Review Comment:
   from the desc above, it seems the OperatingSystemMXBean is actually giving out the **fraction** of the total available cpu that the jvm process is using. hence it is between [0,1]. My understanding is based on the following excerpt pasted above
   
   >A value of 0.0 means that none of the CPUs were running threads from the JVM process during the recent period of time observed, while a value of 1.0 means that all CPUs were actively running threads from the JVM 100% of the time during the recent period being observed.
   
   this to me indicates fraction of the num CPUs being used by jvm process. 
   Also matches the way `getProccessCpuLoad` is used within Samza's JVMMetrics
   
   ```
         val processCpuLoad = operatingSystemMXBean.getProcessCpuLoad
         gProcessCpuUsage.set(processCpuLoad * PCT)
         gProcessCpuUsageProcessors.set(processCpuLoad * operatingSystemMXBean.getAvailableProcessors)
         gSystemCpuUsage.set(operatingSystemMXBean.getSystemCpuLoad * PCT)
   ```
   
   Note how we multiply processCpuLoad with 100 to get the percent of total cpu being used by the process. 
   
   
   
   



##########
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:
   agree that the current impl of the caller/user of this is single threaded but its always good to not assume things about downstream impl when doing an interface impl imo. 
   marking Not thread safe is enough for now i thinkl



##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();

Review Comment:
   ya that makes sense. 



##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();

Review Comment:
   for this use case of resource usage/metrics only because the current impl of samza invokes this from exactly one place, has only one listener, so it seems okay. but in general, an interface impl should have a clear contract instead of bubbling up exceptions that are internal to its impl and except the caller/user of the interface to deal with it. 
   
   that is mostly why the earlier impl of memory stats returned a null in situations w/ exceptions



##########
samza-core/src/main/java/org/apache/samza/container/host/StatisticsMonitorImpl.java:
##########
@@ -117,23 +118,23 @@ public void run() {
   }
 
   private void sampleStatistics() {
-    SystemMemoryStatistics statistics = null;
+    SystemMemoryStatistics memoryStatistics = null;
+    ProcessCPUStatistics cpuStatistics = null;
     try {
-      statistics = statisticsGetter.getSystemMemoryStatistics();
+      memoryStatistics = statisticsGetter.getSystemMemoryStatistics();
+      cpuStatistics = statisticsGetter.getProcessCPUStatistics();
     } catch (Throwable e) {
       LOG.error("Error during obtaining statistics: ", e);
     }
-
+    SystemStatistics systemStatistics = new SystemStatistics(cpuStatistics, memoryStatistics);
     for (Listener listener : listenerSet.keySet()) {
-      if (statistics != null) {

Review Comment:
   same reply as above. 
   works for this use case and current impl of samza but in general pushing responsbility of interface impl into interface user 



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] mynameborat commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
mynameborat commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015978318


##########
samza-core/src/main/java/org/apache/samza/container/host/ProcessCPUStatistics.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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 java.util.Objects;
+
+
+/**
+ * A {@link ProcessCPUStatistics} object represents recent CPU usage percentage about the container process(including its child processes)
+ */
+public class ProcessCPUStatistics {

Review Comment:
   as in why not use primitive and have a class to represent CPU statistics? Do you plan to expand the PCU stats?



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] lakshmi-manasa-g commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
lakshmi-manasa-g commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015642158


##########
samza-core/src/main/java/org/apache/samza/container/host/SystemStatisticsGetter.java:
##########
@@ -30,4 +30,11 @@ public interface SystemStatisticsGetter {
    * @return {@link SystemMemoryStatistics} for the Samza container
    */
   SystemMemoryStatistics getSystemMemoryStatistics();
+
+  /**
+   * Returns the {@link ProcessCPUStatistics} for the current Samza container process(includes its child processes)
+   *
+   * @return {@link ProcessCPUStatistics} for the Samza container process
+   */
+  ProcessCPUStatistics getProcessCPUStatistics();

Review Comment:
   got it. that makes sense to me.



##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);
+  }
+
+  private List<OSProcess> getCurrentProcessAndChildProcesses() {
+    final List<OSProcess> processes = new ArrayList<>();
+    // get current process
+    processes.add(os.getProcess(os.getProcessId()));
+    // get all child processes of current process
+    processes.addAll(os.getChildProcesses(os.getProcessId(), OperatingSystem.ProcessFiltering.ALL_PROCESSES,
+        OperatingSystem.ProcessSorting.NO_SORTING, 0));
+    return processes;
+  }
+
+  private double getTotalCPUUsage(List<OSProcess> processes) {
+    return processes.stream()
+        .mapToDouble(p -> p.getProcessCpuLoadBetweenTicks(previousProcessSnapshots.get(p.getProcessID())))

Review Comment:
   actually this brings out an important point:
   the impl is 
   ```
   public ProcessCPUStatistics getProcessCPUStatistics() {
       final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
       final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
       refreshProcessSnapshots(currentProcessAndChildProcesses);
       return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);
   ```
   so the first time this is called, `previousProcessSnapshots` is an empty hash map right. so `get` from it will return null. seems in this case the cpu usage returned cumulative in that case. which seems okay. 
    



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] lakshmi-manasa-g commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
lakshmi-manasa-g commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014326963


##########
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/)

Review Comment:
   would be good to more docs on how the Stat getter works - aka previous snapshots, 
   we should also call out if the impl is thread safe and if not, clarify why its not a problem



##########
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:
   should we use ConcurrentHashMap?



##########
samza-core/src/main/java/org/apache/samza/container/host/ProcessCPUStatistics.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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 java.util.Objects;
+
+
+/**
+ * A {@link ProcessCPUStatistics} object represents recent CPU usage percentage about the container process(including its child processes)

Review Comment:
   small clarification might be good to say that the percentage is against total cpu of host



##########
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;

Review Comment:
   samza already uses `UnsupportedOperationException` to indicate these kind of scenarios. can we use the same?



##########
samza-core/src/main/java/org/apache/samza/container/host/PosixCommandBasedStatisticsGetter.java:
##########
@@ -21,6 +21,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import org.apache.commons.lang3.NotImplementedException;

Review Comment:
   same as above.
   samza already uses `UnsupportedOperationException` to indicate these kind of scenarios. can we use the same?



##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();

Review Comment:
   wondering if we should get this list fresh every time?
   one scenario could be that the first time(s) this method is called not all child processes are up and they may come up later times the method is called.
   just looking to see if this can be optimized. 



##########
samza-core/src/main/java/org/apache/samza/container/host/SystemStatistics.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * 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 java.util.Objects;
+
+/**
+ * A {@link SystemStatistics} object represents system related information about the physical process that runs the
+ * {@link org.apache.samza.container.SamzaContainer}.
+ */
+public class SystemStatistics {
+
+  private final ProcessCPUStatistics cpuStatistics;
+  private final SystemMemoryStatistics memoryStatistics;
+
+  public SystemStatistics(ProcessCPUStatistics cpuStatistics, SystemMemoryStatistics memoryStatistics) {

Review Comment:
   what if either or both stats are null?
   how do we handle it?



##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();

Review Comment:
   similar to the memory one in PosxCommandBasedStatsGetter, should we catch exceptions and return a null?



##########
samza-core/src/main/java/org/apache/samza/container/host/SystemStatisticsGetter.java:
##########
@@ -30,4 +30,11 @@ public interface SystemStatisticsGetter {
    * @return {@link SystemMemoryStatistics} for the Samza container
    */
   SystemMemoryStatistics getSystemMemoryStatistics();
+
+  /**
+   * Returns the {@link ProcessCPUStatistics} for the current Samza container process(includes its child processes)
+   *
+   * @return {@link ProcessCPUStatistics} for the Samza container process
+   */
+  ProcessCPUStatistics getProcessCPUStatistics();

Review Comment:
   
   should we call ProcessCPUStats as SystemCPUStats similar to the mem one? 
   but maybe that is confusing since process and system cpu mean different things. 
   not a big concern at all. feel free to drop this one if it was chosen to avoid confusion



##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);

Review Comment:
   this accounts for absolute cpu usage right as it takes into account the num cores on the host (if the answer to the previous q is yes)
   
   if so, we should add to the PR desc saying this is the case as the currently existing cpu reporting does not take into account core-count on host. This will impact downstream usage if users look to replace existing cpu metric with the new one.



##########
samza-core/src/main/java/org/apache/samza/container/host/StatisticsMonitorImpl.java:
##########
@@ -117,23 +118,23 @@ public void run() {
   }
 
   private void sampleStatistics() {
-    SystemMemoryStatistics statistics = null;
+    SystemMemoryStatistics memoryStatistics = null;
+    ProcessCPUStatistics cpuStatistics = null;
     try {
-      statistics = statisticsGetter.getSystemMemoryStatistics();
+      memoryStatistics = statisticsGetter.getSystemMemoryStatistics();
+      cpuStatistics = statisticsGetter.getProcessCPUStatistics();
     } catch (Throwable e) {
       LOG.error("Error during obtaining statistics: ", e);
     }
-
+    SystemStatistics systemStatistics = new SystemStatistics(cpuStatistics, memoryStatistics);
     for (Listener listener : listenerSet.keySet()) {
-      if (statistics != null) {

Review Comment:
   seems like a good check to have to prevent null stats from causing issues in a listener.
   



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on PR #1636:
URL: https://github.com/apache/samza/pull/1636#issuecomment-1306372678

   @mynameborat I have fixed the check issue(checksytle issue) and resolved all the comments. Can you please check? Thanks.


-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] mynameborat merged pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
mynameborat merged PR #1636:
URL: https://github.com/apache/samza/pull/1636


-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014527935


##########
samza-core/src/main/java/org/apache/samza/container/host/PosixCommandBasedStatisticsGetter.java:
##########
@@ -85,4 +86,10 @@ public SystemMemoryStatistics getSystemMemoryStatistics() {
       return null;
     }
   }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    throw new NotImplementedException(
+        "No appropriate Posix command available for getting recent CPU usage information. For example, the CPU information exposed by ps command 'ps -o %cpu= -p <PID>' represents the percentage of time spent running during the entire lifetime of a process not for the recent CPU usage");
+  }

Review Comment:
   Yes, `top` can give the instant/recent CPU usage information for a given process, but it has below cons so that I didn't choose it:
   
   - Need to have operating system specific implementation, since the top command is not a POSIX command and its input and output format in Linux and macOS are different.
   - Slower than ps command. Especially, on macOS the top command needs to get at least two samples to get the right CPU usage, which takes longer time(~ 2 seconds) than 1 sample.
     - not clear the reason, but it shows the consistent behavior that one sample(-l1) always return 0.0 on my macOS
   



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015714131


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();

Review Comment:
   >but in general, an interface impl should have a clear contract instead of bubbling up exceptions that are internal to its impl and except the caller/user of the interface to deal with it.
   
   Make sense. But in this case, I didn't see any checked/unchecked/errors that can be thrown in the current oshi implementation.  Will you still suggest that we should catch all Exceptions explicitly or throw Samza its own exception?



##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);
+  }
+
+  private List<OSProcess> getCurrentProcessAndChildProcesses() {
+    final List<OSProcess> processes = new ArrayList<>();
+    // get current process
+    processes.add(os.getProcess(os.getProcessId()));
+    // get all child processes of current process
+    processes.addAll(os.getChildProcesses(os.getProcessId(), OperatingSystem.ProcessFiltering.ALL_PROCESSES,
+        OperatingSystem.ProcessSorting.NO_SORTING, 0));
+    return processes;
+  }
+
+  private double getTotalCPUUsage(List<OSProcess> processes) {
+    return processes.stream()
+        .mapToDouble(p -> p.getProcessCpuLoadBetweenTicks(previousProcessSnapshots.get(p.getProcessID())))

Review Comment:
   Yes, it will return cumulative data points. And I think it is reasonable and accurate because that's the first data point available in the process start-up phase.



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015713429


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);

Review Comment:
   Yeah, your understanding is the same as mine. So you are good with this PR's implementation, right?



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014525279


##########
samza-core/src/main/java/org/apache/samza/container/host/StatisticsMonitorImpl.java:
##########
@@ -117,23 +118,23 @@ public void run() {
   }
 
   private void sampleStatistics() {
-    SystemMemoryStatistics statistics = null;
+    SystemMemoryStatistics memoryStatistics = null;
+    ProcessCPUStatistics cpuStatistics = null;
     try {
-      statistics = statisticsGetter.getSystemMemoryStatistics();
+      memoryStatistics = statisticsGetter.getSystemMemoryStatistics();
+      cpuStatistics = statisticsGetter.getProcessCPUStatistics();
     } catch (Throwable e) {
       LOG.error("Error during obtaining statistics: ", e);
     }
-
+    SystemStatistics systemStatistics = new SystemStatistics(cpuStatistics, memoryStatistics);
     for (Listener listener : listenerSet.keySet()) {
-      if (statistics != null) {

Review Comment:
   I moved the null check in the listener: https://github.com/apache/samza/pull/1636/files#diff-f79781ad4c55ae7860829b06fd9dfd15e8069c37e64f8854d8f27ca2cd1f3ee5R653 



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1014525707


##########
samza-core/src/main/java/org/apache/samza/container/host/SystemStatisticsGetter.java:
##########
@@ -30,4 +30,11 @@ public interface SystemStatisticsGetter {
    * @return {@link SystemMemoryStatistics} for the Samza container
    */
   SystemMemoryStatistics getSystemMemoryStatistics();
+
+  /**
+   * Returns the {@link ProcessCPUStatistics} for the current Samza container process(includes its child processes)
+   *
+   * @return {@link ProcessCPUStatistics} for the Samza container process
+   */
+  ProcessCPUStatistics getProcessCPUStatistics();

Review Comment:
   Exactly that's the point why I decided to use `ProcessCPUStats` which is trying to avoid confusion.



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015949373


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();
+    final double totalCPUUsage = getTotalCPUUsage(currentProcessAndChildProcesses);
+    refreshProcessSnapshots(currentProcessAndChildProcesses);
+    return new ProcessCPUStatistics(100d * totalCPUUsage / cpuCount);

Review Comment:
   Oh, I see the gap here: Your point is that host CPU num != JVM available CPU num, and I thought they were the same. I think your point is correct. 
   
   I did some research/test on the `OperatingSystemMXBean. getAvailableProcessors()`, the count is for logical CPU count instead of phsical CPU count. For non-containerization or VM use cases, the available logic/phsical CPU count in JVM should be same as in host, IIUC. I will update this oshi implementation based on logical CPU count anyway since we should be consistent with JVM. 
   
   Note: I didn't verify if oshi shows the consistent behavior/result regarding the CPU count in the containerizaiton or VM land(e.g. docker, kubernetes).
   
   
   
   
   



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [samza] alnzng commented on a diff in pull request #1636: SAMZA-2762: new cpu usage metric which counts child processes usage

Posted by GitBox <gi...@apache.org>.
alnzng commented on code in PR #1636:
URL: https://github.com/apache/samza/pull/1636#discussion_r1015958371


##########
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<>();
+
+  private final OperatingSystem os;
+  private final int cpuCount;
+
+  public OshiBasedStatisticsGetter() {
+    this(new SystemInfo());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(SystemInfo si) {
+    this(si.getOperatingSystem(), si.getHardware().getProcessor().getPhysicalProcessorCount());
+  }
+
+  @VisibleForTesting
+  OshiBasedStatisticsGetter(OperatingSystem os, int cpuCount) {
+    this.os = os;
+    this.cpuCount = cpuCount;
+  }
+
+  @Override
+  public SystemMemoryStatistics getSystemMemoryStatistics() {
+    throw new NotImplementedException("Not implemented");
+  }
+
+  @Override
+  public ProcessCPUStatistics getProcessCPUStatistics() {
+    final List<OSProcess> currentProcessAndChildProcesses = getCurrentProcessAndChildProcesses();

Review Comment:
   Yes, we can. I can update it and return null for consistent with `PosxCommandBasedStatsGetter ` implementation.



-- 
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: commits-unsubscribe@samza.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org