The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

JMX::Jmx4Perl::Response - A jmx4perl response

SYNOPSIS

 my $jmx_response = $jmx_agent->request($jmx_request);
 my $value = $jmx_response->value();
 

DESCRIPTION

A JMX::Jmx4Perl::Response is the result of an JMX request and encapsulates the answer as returned by a JMX::Jmx4Perl backend. Depending on the status it either contains the result of a valid request or a error message. The status is modelled after HTTP response codes (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html). For now, only the codes 200 and 400 .. 599 codes are used to specified successful request and errors respectively.

METHODS

$response = JMX::Jmx4Perl::Response->new($status,$request,$value,$error,$stacktrace)

Internal constructor for creating a response which is use withing requesting the backend. $error and $stacktrace are optional and should only provided when $status != 200.

$status = $response->status()

Return the status code of this response. Status codes are modelled after HTTP return codes. 200 is the code for a suceeded request. Any code in the range 500 - 599 specifies an error.

$timestamp = $response->timestamp()

Get the timestamp (i.e. epoch seconds) when the request was executed on the serverside.

$history = $response->history()

Get the history if history tracking is switched on. History tracking is switchen on by executing a certain JMX operation on the jolokia:type=Config MBean. See the alias JMX4PERL_HISTORY_MAX_ATTRIBUTE and "HISTORY TRACKING" in jmx4perl for details.

The returned arrayref (if any) contains hashes with two values: value contains the historical value and timestamp the timestamp when this value was recorded.

$ok = $response->is_ok()

Return true if this object contains a valid response (i.e. the status code is equal 200)

$fault = $response->is_error()

Opposite of is_ok, i.e. return true if the status code is not equal to 200

$error = $response->error_text()

Return the error text. Set only if is_error is true

$error = $response->stacktrace()

Returns the stacktrace of an Java error if any. This is only set when is_error is true and and Java exception occured on the Java agent's side.

$content = $response->value()

Return the content of this response, which is a represents the JSON response as returned by the Java agent as a hash reference value. This is set only when is_ok is true.

$request = $response->request()

Return the JMX::Jmx4Perl::Request which lead to this response

LICENSE

This file is part of jmx4perl.

Jmx4perl is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

jmx4perl is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with jmx4perl. If not, see <http://www.gnu.org/licenses/>.

A commercial license is available as well. Please contact roland@cpan.org for further details.

AUTHOR

roland@cpan.org