4 Replies Latest reply: Jul 13, 2012 6:58 AM by 946410 RSS

    Capture Thread Status Using ExecuteThreads

    860113
      I am attempting to capture when threads transition into
      a hogger or stuck state. I get the ExecuteThreads object
      from the MBeanServerConnection object using the ExecuteThreads attribute.

      After I place a JVM into a stuck state, the status of the
      ExecuteThreads object does not reflect that change in status.

      What piece am I missing to correctly capture a stuck thread status?

      connection = connector.getMBeanServerConnection();
      ObjectName executeQueueRT[] = (ObjectName[]) connection.getAttribute(serverRT[a],"ExecuteQueueRuntimes");
      for(int b=0;k<executeQueueRT.length;b++)
      {
      ExecuteThread[] executeThreads=(ExecuteThread[])connection.getAttribute(executeQueueRT, "ExecuteThreads");

      for(int c=0;c<executeThreads.length;c++)
      {
      *hogger = executeThreads[c].isHogger();     // ALWAYS FALSE*
      *stuck = executeThreads[c].isStuck();     // ALWAYS FALSE*
      }
      }
        • 1. Re: Capture Thread Status Using ExecuteThreads
          jtahlborn
          how are you placing the jvm into the "stuck" state. also, i would imagine you need to wait a period of time before those states will become true (from what i can see, those states are based on various thresholds).
          • 2. Re: Capture Thread Status Using ExecuteThreads
            860113
            I can place a jvm thread into a stuck state by repeatedly sending it bad URLs strings that will eventually place a thread in this state.
            Once the thread is in this state, should the isStuck method return true?
            • 3. Re: Capture Thread Status Using ExecuteThreads
              jtahlborn
              857110 wrote:
              I can place a jvm thread into a stuck state by repeatedly sending it bad URLs strings that will eventually place a thread in this state.
              huh?
              • 4. Re: Capture Thread Status Using ExecuteThreads
                946410
                Your code looks correct, however I think you have not put a thread in your server at a STUCK state.

                To put a thread in a STUCK state you should make the thread to be active for more time than the configured "Stuck Thread Max Time" (default is 600 seconds).

                Go to the Admin console, and select the server you want to monitor for stuck threads. In its configuration tab go to Tuning. There you can configure the Stuck Thread Max Time.

                Then in your application (EJB, WS, jsp) pause a method that you can invoke with Thread.sleep(1000000);
                and then invoke this method.

                If your Stuck Thread Max Time is set for example to 600 seconds and you pause the Thread for 1000 seconds (1000000 ms) you will see a stuck thread after 600 seconds from the moment you invoked this method and for 400 seconds untill the Thread.sleep returns.