You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@giraph.apache.org by ma...@apache.org on 2019/09/09 20:35:45 UTC

[giraph] branch trunk updated: JIRA-1223

This is an automated email from the ASF dual-hosted git repository.

maja pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/giraph.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 1c5a4e7  JIRA-1223
1c5a4e7 is described below

commit 1c5a4e7790d526edfe31a03e41749c9d71f3f3fa
Author: Maja Kabiljo <ma...@fb.com>
AuthorDate: Mon Sep 9 13:34:19 2019 -0700

    JIRA-1223
    
    closes #107
---
 .../org/apache/giraph/conf/GiraphConstants.java    |  6 ++++++
 .../main/java/org/apache/giraph/utils/JMap.java    | 25 +++++++++++++---------
 .../org/apache/giraph/utils/JMapHistoDumper.java   |  5 ++++-
 .../giraph/utils/ReactiveJMapHistoDumper.java      |  5 ++++-
 4 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
index e9a5f32..2a0d24d 100644
--- a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
+++ b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
@@ -1311,5 +1311,11 @@ public interface GiraphConstants {
             "Disables GiraphClassResolver, which is a custom implementation " +
             "of kryo class resolver that avoids writing class names to the " +
             "underlying stream for faster serialization.");
+
+  /**
+   * Path where jmap exists
+   */
+  StrConfOption JMAP_PATH = new StrConfOption("giraph.jmapPath", "jmap",
+          "Path to use for invoking jmap");
 }
 // CHECKSTYLE: resume InterfaceIsTypeCheck
diff --git a/giraph-core/src/main/java/org/apache/giraph/utils/JMap.java b/giraph-core/src/main/java/org/apache/giraph/utils/JMap.java
index 92dd9e2..6d9d0f7 100644
--- a/giraph-core/src/main/java/org/apache/giraph/utils/JMap.java
+++ b/giraph-core/src/main/java/org/apache/giraph/utils/JMap.java
@@ -30,8 +30,6 @@ import java.util.Date;
  * Helper to run jmap and print the output
  */
 public class JMap {
-  /** The command to run */
-  public static final String CMD = "jmap ";
   /** Arguments to pass in to command */
   public static final String ARGS = " -histo ";
   /** This option will print out onlu live objects */
@@ -58,19 +56,22 @@ public class JMap {
    *
    * @param numLines Number of lines to print
    * @param liveObjectsOnly Should we only print non GC-able objects?
+   * @param jmapPath Path to jmap binary
    */
   public static void heapHistogramDump(int numLines,
-                                       boolean liveObjectsOnly) {
-    heapHistogramDump(numLines, liveObjectsOnly, System.err);
+                                       boolean liveObjectsOnly,
+                                       String jmapPath) {
+    heapHistogramDump(numLines, liveObjectsOnly, System.err, jmapPath);
   }
 
   /**
    * Run jmap, print numLines of output from it to stderr.
    *
    * @param numLines Number of lines to print
+   * @param jmapPath Path to jmap binary
    */
-  public static void heapHistogramDump(int numLines) {
-    heapHistogramDump(numLines, System.err);
+  public static void heapHistogramDump(int numLines, String jmapPath) {
+    heapHistogramDump(numLines, System.err, jmapPath);
   }
 
   /**
@@ -78,9 +79,11 @@ public class JMap {
    *
    * @param numLines Number of lines to print
    * @param printStream Stream to print to
+   * @param jmapPath Path to jmap binary
    */
-  public static void heapHistogramDump(int numLines, PrintStream printStream) {
-    heapHistogramDump(numLines, false, printStream);
+  public static void heapHistogramDump(int numLines, PrintStream printStream,
+                                       String jmapPath) {
+    heapHistogramDump(numLines, false, printStream, jmapPath);
   }
 
   /**
@@ -89,13 +92,15 @@ public class JMap {
    * @param numLines Number of lines to print
    * @param liveObjectsOnly Should we only print non GC-able objects?
    * @param printStream Stream to print to
+   * @param jmapPath Path to jmap binary
    */
   private static void heapHistogramDump(int numLines,
                                         boolean liveObjectsOnly,
-                                        PrintStream printStream) {
+                                        PrintStream printStream,
+                                        String jmapPath) {
     try {
       String args = liveObjectsOnly ? LIVE_HISTO_OPTION : ARGS;
-      Process p = Runtime.getRuntime().exec(CMD + args + getProcessId());
+      Process p = Runtime.getRuntime().exec(jmapPath + args + getProcessId());
       BufferedReader in = new BufferedReader(
           new InputStreamReader(p.getInputStream(), Charset.defaultCharset()));
       printStream.println("JMap " +
diff --git a/giraph-core/src/main/java/org/apache/giraph/utils/JMapHistoDumper.java b/giraph-core/src/main/java/org/apache/giraph/utils/JMapHistoDumper.java
index fff63ed..b1c110c 100644
--- a/giraph-core/src/main/java/org/apache/giraph/utils/JMapHistoDumper.java
+++ b/giraph-core/src/main/java/org/apache/giraph/utils/JMapHistoDumper.java
@@ -47,6 +47,8 @@ public class JMapHistoDumper implements MasterObserver, WorkerObserver {
   private Thread thread;
   /** Halt jmap thread */
   private volatile boolean stop = false;
+  /** Path to jmap*/
+  private String jmapPath;
 
   @Override
   public void preLoad() {
@@ -90,7 +92,7 @@ public class JMapHistoDumper implements MasterObserver, WorkerObserver {
       @Override
       public void run() {
         while (!stop) {
-          JMap.heapHistogramDump(linesToPrint, liveObjectsOnly);
+          JMap.heapHistogramDump(linesToPrint, liveObjectsOnly, jmapPath);
           ThreadUtils.trySleep(sleepMillis);
         }
       }
@@ -116,6 +118,7 @@ public class JMapHistoDumper implements MasterObserver, WorkerObserver {
     sleepMillis = GiraphConstants.JMAP_SLEEP_MILLIS.get(configuration);
     linesToPrint = GiraphConstants.JMAP_PRINT_LINES.get(configuration);
     liveObjectsOnly = GiraphConstants.JMAP_LIVE_ONLY.get(configuration);
+    jmapPath = GiraphConstants.JMAP_PATH.get(configuration);
   }
 
   @Override
diff --git a/giraph-core/src/main/java/org/apache/giraph/utils/ReactiveJMapHistoDumper.java b/giraph-core/src/main/java/org/apache/giraph/utils/ReactiveJMapHistoDumper.java
index 230dfdf..17b84a4 100644
--- a/giraph-core/src/main/java/org/apache/giraph/utils/ReactiveJMapHistoDumper.java
+++ b/giraph-core/src/main/java/org/apache/giraph/utils/ReactiveJMapHistoDumper.java
@@ -54,6 +54,8 @@ public class ReactiveJMapHistoDumper extends
   private Thread thread;
   /** Halt jmap thread */
   private volatile boolean stop = false;
+  /** Path to jmap*/
+  private String jmapPath;
 
   @Override
   public void preLoad() {
@@ -100,7 +102,7 @@ public class ReactiveJMapHistoDumper extends
           long potentialMemory = (runtime.maxMemory() -
               runtime.totalMemory()) + runtime.freeMemory();
           if (potentialMemory / MB < minFreeMemory) {
-            JMap.heapHistogramDump(linesToPrint);
+            JMap.heapHistogramDump(linesToPrint, jmapPath);
           }
           ThreadUtils.trySleep(sleepMillis);
         }
@@ -127,5 +129,6 @@ public class ReactiveJMapHistoDumper extends
     sleepMillis = GiraphConstants.JMAP_SLEEP_MILLIS.get(configuration);
     linesToPrint = GiraphConstants.JMAP_PRINT_LINES.get(configuration);
     minFreeMemory = GiraphConstants.MIN_FREE_MBS_ON_HEAP.get(configuration);
+    jmapPath = GiraphConstants.JMAP_PATH.get(configuration);
   }
 }