<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Your calling method (even there were such method, in fact there is
    no such function) will not be executed during STW, since all java
    threads stopped. The result is that after JVM resumes all java
    threads, your call will return true always. To know the jvm status,
    you have to use some agents like JVMTI.<br>
    <br>
    --Yumin<br>
    <br>
    On 12/11/2011 7:55 PM, Li Li wrote:
    <blockquote
cite="mid:CAFAd71UU4TYBgtM2O7wUro4WNiQ=xAqzgN+QoU3LX-ppf3dGNw@mail.gmail.com"
      type="cite"><br>
      <div class="gmail_quote">---------- Forwarded message ----------<br>
        From: <b class="gmail_sendername">Krystal Mok</b> <span
          dir="ltr"><<a moz-do-not-send="true"
            href="mailto:rednaxelafx@gmail.com">rednaxelafx@gmail.com</a>></span><br>
        Date: Sun, Dec 11, 2011 at 5:53 PM<br>
        Subject: Re: how to know jvm is stopping the world?<br>
        To: Li Li <<a moz-do-not-send="true"
          href="mailto:fancyerii@gmail.com">fancyerii@gmail.com</a>><br>
        <br>
        <br>
        HI,
        <div><br>
        </div>
        <div>You're probably looking in the wrong direction. When the
          JVM "stops-the-world", it stops the world -- all Java threads
          (or "mutators") are suspended. There's no way for you to
          execute any Java code during that period.</div>
        <div>HotSpot VM uses a "safepoint" mechanism to stop-the-world.
          You can get safepoint stats with
          -XX:+PrintSafepointStatistics.</div>
        <div><br>
        </div>
        <div>There's an alternative that might help. Try GC notification
          with JMX [1]. Setup a notification threshold, and when the
          heap usage crosses the threshold, you'll get a notification.
          Put the load balancing logic in the callback. Even though this
          is different from "a notification of stop-the-world pause", it
          might work for you.</div>
        <div><br>
        </div>
        <div>There's a GC notification mechanism in .NET that might have
          been closer to what you wanted [2].</div>
        <div><br>
        </div>
        <div>- Kris</div>
        <div><br>
        </div>
        <div>[1]: <a moz-do-not-send="true"
href="http://docs.oracle.com/javase/6/docs/api/java/lang/management/MemoryMXBean.html"
            target="_blank">http://docs.oracle.com/javase/6/docs/api/java/lang/management/MemoryMXBean.html</a><br>
          [2]: <a moz-do-not-send="true"
            href="http://msdn.microsoft.com/en-us/library/cc713687.aspx"
            target="_blank">http://msdn.microsoft.com/en-us/library/cc713687.aspx</a></div>
        <div>
          <div class="h5">
            <div><br>
              <div class="gmail_quote">On Sun, Dec 11, 2011 at 2:31 PM,
                Li Li <span dir="ltr"><<a moz-do-not-send="true"
                    href="mailto:fancyerii@gmail.com" target="_blank">fancyerii@gmail.com</a>></span>
                wrote:<br>
                <blockquote class="gmail_quote" style="margin: 0pt 0pt
                  0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204);
                  padding-left: 1ex;">
                  <div>hi,</div>
                  <div>    In our application of full text searching
                    with lucene and solr. we will give jvm about 25GB
                    memory. we use CMS as old generation garbage
                    collector. But the jvm sometimes can't do anything.
                    So our clients complain that the connection is time
                    out. we find the reason is the jvm is doing full gc
                    and it will stop service for about 1-3 seconds.</div>
                  <div>    I know that this situation is inevitable when
                    using CMS collector. but we have more than one
                    searching machines, so if I know jvm is doing full
                    gc(specially stop the world), I can send requests to
                    other machines. But the question now is that jvm
                    don't provide an api for that. I think it's not very
                    difficult(for guys developing hotspot, but is in
                    deed difficult for me ). So I want your help.</div>
                  <div>    The first question is where is the position
                    of CMS full gc.</div>
                  <div>    from <a moz-do-not-send="true"
                      href="http://blogs.oracle.com/jonthecollector/entry/did_you_know"
                      target="_blank">http://blogs.oracle.com/jonthecollector/entry/did_you_know</a></div>
                  <div>    there are many steps:</div>
                  <div>      1. STW initial mark</div>
                  <div>      2. Concurrent marking</div>
                  <div>      3. Concurrent precleaning</div>
                  <div>      4. STW remark</div>
                  <div>      5. Concurrent sweeping</div>
                  <div>      6. Concurrent reset</div>
                  <div>    there are 2 stop the world stages. I want to
                    know the line number(or functions) of this stages.
                    so I can tell java program that jvm now is doing
                    full gc.</div>
                  <div>     The second is that how to communicate
                    between jvm and java program? My expected thing is
                    like :</div>
                  <div>     //java program</div>
                  <div>     if(System.isStopTheWolrd()){</div>
                  <div>           //system is busy, tell the dispatch
                    node that don't send request to me</div>
                  <div>     }else{</div>
                  <div>           do service;</div>
                  <div>     }</div>
                  <div>     I have no experience in jvm developing. jvm
                    is implemented in c and jni is the interface between
                    them. is there any other method that jvm can achieve
                    this? obviously, it can extend System class and add
                    a static method named isStopTheWorld(). Could some
                    one tell me how to do this in details? Thank you
                    very much.</div>
                </blockquote>
              </div>
              <br>
            </div>
          </div>
        </div>
      </div>
      <br>
    </blockquote>
  </body>
</html>