Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Meaning of "%Total CPU" and "%Busy CPU" in AWR

User_A7RKTJun 8 2019 — edited Jun 9 2019

Hi guys,

Following is an excerpt from an AWR  report.

My questions are:

(1) What is the "%Total CPU" under  the Instance CPU?

Obviously it isn't how much CPU is consumed by the instance because the "%User" is 10.7% and there is no way for the Instance CPU consumption to be more than %User.

(2) What is the "%Busy CPU"? How come it is more than 100?

Host CPU

CPUsCoresSocketsLoad Average BeginLoad Average End%User%System%WIO%Idle
2210.301.2310.75.65.377.7

Instance CPU

%Total CPU%Busy CPU%DB time waiting for CPU (Resource Manager)
29.8133.80.0

It's Oracle 12c R2 on Linux x86-64.

This post has been answered by Jonathan Lewis on Jun 9 2019
Jump to Answer

Comments

tschodt
827388 wrote:
We want to use a filter to do a message authentication check (HMAC-SHA1) for web-service calls. We want to use the request body as part of the message to hash/authenticate (ala Amazon Web Services). Our problem: we can retrieve the message body--via request.getReader() or request.getInputStream()--and use it to authenticate the incoming request. However, calls to chain.doFilter() or getRequestDispatcher().forward() fail with a "java.lang.IllegalStateException: getReader()|getInputStream() has already been called for this request" error. Attempts to copy the request to another object before calling getReader(),
using a HttpServletRequestWrapper, closing or resetting the reader etc all result in the IllegalStateException error.
It will if you do not override getInputStream()
So: is there a way to retrieve the request body without using getReader()|getInputStream()?
No.
Or is there a way to reset the request/reader state so that the request can be reached from the filter?
Yes.

Use HttpServletRequestWrapper and override getInputStream().
I assume Request.getReader() wraps Request.getInputStream(). If that is not so you may need to implement both.

HttpServletRequest only allows one of those methods to be called just once,
but your Wrapper can
intercept the first call and read the InputStream and store the data and return a Wrapped InputStream which returns the data and
intercept subsequent calls and return a Wrapped InputStream which returns the same data.
Or something along those lines.
ramp
We want to use a filter to do a message authentication check (HMAC-SHA1) for web-service calls. We want to use the request body as part of the message to >hash/authenticate (ala Amazon Web Services)
If you use java 5 and jax-ws you can use the jax-ws Handler framework. Handlers are to web services what filters are to web resources like servlets/jsp. Besides they are better suited to intercept web service requests by providing a richer api. With a filter, you would be dealing with the SOAP message like you would any other http request. Instead if you write for example a SOAPHandler, you would have access to the SOAPMessageContext object and a simple call to msgContext.getMessage() returns the entire SOAP message. More easier than parsing a http request :)

cheers,
ram.
830391
Actually we're using Jersey restful services...
830391
I may just be obtuse, but...
ServletInputStream is an abstract class, so I'm not certain how to construct a wrapper class.
I've tried building a HttpServletRequestWrapper and overriding getReader(), and then sending the wrapper into the chain.doFilter() method--but I still get an InvalidStateException. My wrapper class:

public class RequestWrapper
extends HttpServletRequestWrapper
{
private HttpServletRequest origRequest;
private byte[] reqBytes;
private boolean firstTime = true;

public RequestWrapper( HttpServletRequest httpServletRequest )
{
super( httpServletRequest );
origRequest = httpServletRequest;
}

public BufferedReader getReader()
throws IOException
{
BufferedReader returnReader;
BufferedReader originalReader;
InputStreamReader newReader;
StringBuffer buffer;
String line;

if ( firstTime )
{
firstTime = false;
buffer = new StringBuffer();
originalReader = origRequest.getReader();
while ( ( line = originalReader.readLine() ) != null )
{
buffer.append( line );
buffer.append( "\n" );
}
reqBytes = buffer.toString().getBytes();
}

newReader = new InputStreamReader( new ByteArrayInputStream( reqBytes ) );
returnReader = new BufferedReader( newReader );
return returnReader;
}

}
ramp
I am deleting my original comments as some tests that I have since run has shown that I may be wrong about what I had originally posted. I will post back after I confirm the findings.

cheers,
ram.

Edited by: ramp on Jan 13, 2011 7:04 PM
tschodt
Answer
827388 wrote:
I've tried building a HttpServletRequestWrapper and overriding getReader(),
and then sending the wrapper into the chain.doFilter() method--but I still get an InvalidStateException.
Yes, if what is invoked eventually is getInputStream() you will get that.
ServletInputStream is an abstract class, so I'm not certain how to construct a wrapper class.
I would imagine it would be something along the lines of
public class RequestWrapper
  extends HttpServletRequestWrapper
{
  public RequestWrapper(HttpServletRequest httpServletRequest)
  {
    super(httpServletRequest); // super.request = httpServletRequest;
  }

  private byte[] bytes = null;
 
  public ServletInputStream getInputStream()
    throws IOException
  {
    if (bytes==null) { // first time
      InputStream in = super.request.getInputStream();
      bytes = new byte[super.request.getContentLength()];
      for(int r,offset=0; (r = in.read(bytes,offset,bytes.length-offset))>-1 ; ) { offset += r; }
    }
    final InputStream in = new ByteArrayInputStream(bytes);
    return new ServletInputStream() {
      public int read() {
        return in.read();
      }
    };
  }
 
  public BufferedReader getReader()
    throws IOException
  {
    return new BufferedReader(new InputStreamReader(getInputStream()));
  }
}
Marked as Answer by 830391 · Sep 27 2020
830391
It works! It works!
Thanks for the example, tschodt--that's a solid "I owe you."
807422
hey i m facing through the same proplem
i am filtering a request and then reading content .
i used the above solution but still gettting the same exception as you were
so it is very helpful if u put some working code ...
1 - 8

Post Details

Added on Jun 8 2019
6 comments
14,835 views