| 1 | package Net::JBoss::Management; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 1 | ▶ | use 5.010; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 1 | ▶ | use Carp; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | 1 | ▶ | use URL::Encode qw /url_encode_utf8/; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | 1 | ▶ | use Moo; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | 1 | with 'Net::JBoss'; | |||||||||||||
| 9 | |||||||||||||||
| 10 | =head1 NAME | ||||||||||||||
| 11 | |||||||||||||||
| 12 | Net::JBoss::Management - Bindings for JBoss Management API | ||||||||||||||
| 13 | |||||||||||||||
| 14 | =head1 VERSION | ||||||||||||||
| 15 | |||||||||||||||
| 16 | Version 0.04 | ||||||||||||||
| 17 | |||||||||||||||
| 18 | =cut | ||||||||||||||
| 19 | |||||||||||||||
| 20 | 1 | our $VERSION = '0.04'; | |||||||||||||
| 21 | |||||||||||||||
| 22 | |||||||||||||||
| 23 | =head1 SYNOPSIS | ||||||||||||||
| 24 | |||||||||||||||
| 25 | use Net::JBoss::Management; | ||||||||||||||
| 26 | |||||||||||||||
| 27 | my %con = ( | ||||||||||||||
| 28 | username => 'admin', | ||||||||||||||
| 29 | password => 'password', | ||||||||||||||
| 30 | server => 'jboss1.example.com', | ||||||||||||||
| 31 | port => 9443, #optional, default is 9990 | ||||||||||||||
| 32 | ssl => 'on', #optional, default is 'off' | ||||||||||||||
| 33 | ssl_verify => 'yes', #optional, default is 'no' | ||||||||||||||
| 34 | realm => 'ManagementRealmHTTPS' #optional, default is 'ManagementRealm' | ||||||||||||||
| 35 | ); | ||||||||||||||
| 36 | |||||||||||||||
| 37 | my $jboss = Net::JBoss::Management->new(%con); | ||||||||||||||
| 38 | |||||||||||||||
| 39 | my $state = $jboss->get_state(); | ||||||||||||||
| 40 | my $jvm_usage = $jboss->get_jvm_usage(); | ||||||||||||||
| 41 | my $runtime_stats = $jboss->get_runtime_stats(); | ||||||||||||||
| 42 | my $deploy_info = $jboss->get_deployment_info(); | ||||||||||||||
| 43 | my $app_runtime_stats = $jboss->get_app_runtime_stats('hawtio.war'); | ||||||||||||||
| 44 | my $runtime_details = $jboss->get_runtime_details(); | ||||||||||||||
| 45 | my $app_status = $jboss->get_app_status('hawtio.war'); | ||||||||||||||
| 46 | my $active_session = $jboss->get_active_sessions('hawtio.war'); | ||||||||||||||
| 47 | my $server_env = $jboss->get_server_env(); | ||||||||||||||
| 48 | my $datasources = $jboss->get_datasources(); | ||||||||||||||
| 49 | my $test = $jboss->test_con_pool('ExampleDS'); | ||||||||||||||
| 50 | my $pool_stats = $jboss->get_ds_pool_stats('java:jboss/datasources/jboss_Pool'); | ||||||||||||||
| 51 | my $enable_pool_stats = $jboss->set_ds_pool_stats('java:jboss/datasources/jboss_Pool', 'true'); | ||||||||||||||
| 52 | my $disable_pool_stats = $jboss->set_ds_pool_stats('java:jboss/datasources/jboss_Pool', 'false'); | ||||||||||||||
| 53 | my $min_pool_size = $jboss->set_ds_pool_size('min', 'java:jboss/datasources/jboss_Pool', 20); | ||||||||||||||
| 54 | my $max_pool_size = $jboss->set_ds_pool_size('max', 'java:jboss/datasources/jboss_Pool', 50); | ||||||||||||||
| 55 | my $jndi = $jboss->get_jndi(); | ||||||||||||||
| 56 | my $loglevel = $jboss->get_log_level('CONSOLE'); | ||||||||||||||
| 57 | my $loglevel = $jboss->set_log_level('CONSOLE', 'ERROR'); | ||||||||||||||
| 58 | my $reload = $jboss->reload(); | ||||||||||||||
| 59 | my $shutdown = $jboss->shutdown(); | ||||||||||||||
| 60 | my $restart = $jboss->restart(); | ||||||||||||||
| 61 | |||||||||||||||
| 62 | =head1 Attributes | ||||||||||||||
| 63 | |||||||||||||||
| 64 | Other attributes is also inherited from JBoss.pm | ||||||||||||||
| 65 | Check 'perldoc Net::JBoss' for detail | ||||||||||||||
| 66 | |||||||||||||||
| 67 | notes : | ||||||||||||||
| 68 | ro = read only, can be specified only during initialization | ||||||||||||||
| 69 | rw = read write, user can set this attribute | ||||||||||||||
| 70 | rwp = read write protected, for internal class | ||||||||||||||
| 71 | |||||||||||||||
| 72 | management_url = (ro) store default management url path | ||||||||||||||
| 73 | reload_time = (rw) set wait time (in seconds) to check the server state after reload is fired (default 10s) | ||||||||||||||
| 74 | |||||||||||||||
| 75 | =cut | ||||||||||||||
| 76 | |||||||||||||||
| 77 | 1 | has 'management_url' => ( is => 'ro', default => '/management' ); | |||||||||||||
| 78 | 1 | has 'reload_time' => ( is => 'rw', default => 10 ); | |||||||||||||
| 79 | |||||||||||||||
| 80 | =head1 SUBROUTINES/METHODS | ||||||||||||||
| 81 | |||||||||||||||
| 82 | =head2 BUILD | ||||||||||||||
| 83 | |||||||||||||||
| 84 | The Constructor, build logging, call pass_log_obj method | ||||||||||||||
| 85 | Build final url | ||||||||||||||
| 86 | =cut | ||||||||||||||
| 87 | |||||||||||||||
| 88 | 0 | ▶ | sub BUILD { | ||||||||||||
|
Subroutine
BUILD: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 89 | 0 | my $self = shift; | |||||||||||||
| 90 | |||||||||||||||
| 91 | 0 | $self->pass_log_obj; | |||||||||||||
| 92 | |||||||||||||||
| 93 | 0 | my $url = $self->base_url . $self->management_url; | |||||||||||||
| 94 | 0 | $self->_set_url($url); | |||||||||||||
| 95 | |||||||||||||||
| 96 | 0 | $self->log->debug($url); | |||||||||||||
| 97 | } | ||||||||||||||
| 98 | |||||||||||||||
| 99 | =head2 get_state | ||||||||||||||
| 100 | |||||||||||||||
| 101 | return server state | ||||||||||||||
| 102 | my $state = $jboss->state(); | ||||||||||||||
| 103 | |||||||||||||||
| 104 | =cut | ||||||||||||||
| 105 | |||||||||||||||
| 106 | 0 | ▶ | sub get_state { | ||||||||||||
|
Subroutine
get_state: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 107 | 0 | my $self = shift; | |||||||||||||
| 108 | |||||||||||||||
| 109 | 0 | $self->_set_http_post(1); | |||||||||||||
| 110 | |||||||||||||||
| 111 | 0 | ▶ | if ($self->http_post) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 112 | 0 | $self->_set_post_json('{"operation":"read-attribute","name":"server-state","json.pretty":1}'); | |||||||||||||
| 113 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 114 | } | ||||||||||||||
| 115 | else { | ||||||||||||||
| 116 | 0 | $self->_set_resource_url('/?operation=attribute&name=server-state&json.pretty'); | |||||||||||||
| 117 | 0 | $self->log->debug($self->resource_url); | |||||||||||||
| 118 | } | ||||||||||||||
| 119 | |||||||||||||||
| 120 | 0 | $self->get_api_response(); | |||||||||||||
| 121 | } | ||||||||||||||
| 122 | |||||||||||||||
| 123 | =head2 get_jvm_usage | ||||||||||||||
| 124 | |||||||||||||||
| 125 | return jvm usage | ||||||||||||||
| 126 | my $jvm_usage = $jboss->get_jvm_usage(); | ||||||||||||||
| 127 | |||||||||||||||
| 128 | =cut | ||||||||||||||
| 129 | |||||||||||||||
| 130 | 0 | ▶ | sub get_jvm_usage { | ||||||||||||
|
Subroutine
get_jvm_usage: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 131 | 0 | my $self = shift; | |||||||||||||
| 132 | |||||||||||||||
| 133 | 0 | $self->_set_resource_url('/core-service/platform-mbean/type/memory?operation=resource&include-runtime=true&json.pretty'); | |||||||||||||
| 134 | 0 | $self->log->debug($self->resource_url); | |||||||||||||
| 135 | |||||||||||||||
| 136 | 0 | $self->get_api_response(); | |||||||||||||
| 137 | } | ||||||||||||||
| 138 | |||||||||||||||
| 139 | =head2 get_runtime_stats | ||||||||||||||
| 140 | |||||||||||||||
| 141 | get HTTP connector runtime statistics | ||||||||||||||
| 142 | my $runtime_stats = $jboss->runtime_stats(); | ||||||||||||||
| 143 | |||||||||||||||
| 144 | =cut | ||||||||||||||
| 145 | |||||||||||||||
| 146 | 0 | ▶ | sub get_runtime_stats { | ||||||||||||
|
Subroutine
get_runtime_stats: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 147 | 0 | my $self = shift; | |||||||||||||
| 148 | |||||||||||||||
| 149 | 0 | $self->_set_resource_url('/subsystem/web/connector/http?operation=resource&include-runtime=true&recursive&json.pretty'); | |||||||||||||
| 150 | 0 | $self->log->debug($self->resource_url); | |||||||||||||
| 151 | |||||||||||||||
| 152 | 0 | $self->get_api_response(); | |||||||||||||
| 153 | } | ||||||||||||||
| 154 | |||||||||||||||
| 155 | =head2 get_runtime_details | ||||||||||||||
| 156 | |||||||||||||||
| 157 | get JBoss runtime details | ||||||||||||||
| 158 | my $runtime_details = $jboss->get_runtime_details(); | ||||||||||||||
| 159 | |||||||||||||||
| 160 | =cut | ||||||||||||||
| 161 | |||||||||||||||
| 162 | 0 | ▶ | sub get_runtime_details { | ||||||||||||
|
Subroutine
get_runtime_details: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 163 | 0 | my $self = shift; | |||||||||||||
| 164 | |||||||||||||||
| 165 | 0 | $self->_set_resource_url('/core-service/platform-mbean/type/runtime?operation=resource&include-runtime=true&json.pretty'); | |||||||||||||
| 166 | 0 | $self->log->debug($self->resource_url); | |||||||||||||
| 167 | |||||||||||||||
| 168 | 0 | $self->get_api_response(); | |||||||||||||
| 169 | } | ||||||||||||||
| 170 | |||||||||||||||
| 171 | =head2 get_app_runtime_stats | ||||||||||||||
| 172 | |||||||||||||||
| 173 | get application runtime statistics | ||||||||||||||
| 174 | my $app_runtime_stats = $jboss->get_app_runtime_stats('hawtio.war'); | ||||||||||||||
| 175 | |||||||||||||||
| 176 | =cut | ||||||||||||||
| 177 | |||||||||||||||
| 178 | 0 | ▶ | sub get_app_runtime_stats { | ||||||||||||
|
Subroutine
get_app_runtime_stats: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 179 | 0 | my $self = shift; | |||||||||||||
| 180 | |||||||||||||||
| 181 | 0 | my $app_name = shift; | |||||||||||||
| 182 | 0 | ▶ | croak "web application name is required" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 183 | unless $app_name; | ||||||||||||||
| 184 | |||||||||||||||
| 185 | 0 | $self->_set_http_post(1); | |||||||||||||
| 186 | |||||||||||||||
| 187 | 0 | my $json = qq|{"operation":"read-resource","recursive":"true", "include-runtime":"true", "address":["deployment","$app_name"], "json.pretty":1}|; | |||||||||||||
| 188 | |||||||||||||||
| 189 | 0 | $self->_set_post_json($json); | |||||||||||||
| 190 | |||||||||||||||
| 191 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 192 | 0 | $self->get_api_response(); | |||||||||||||
| 193 | } | ||||||||||||||
| 194 | |||||||||||||||
| 195 | =head2 get_server_env | ||||||||||||||
| 196 | |||||||||||||||
| 197 | get JBoss server environment | ||||||||||||||
| 198 | my $server_env = $jboss->get_server_env(); | ||||||||||||||
| 199 | |||||||||||||||
| 200 | =cut | ||||||||||||||
| 201 | |||||||||||||||
| 202 | 0 | ▶ | sub get_server_env { | ||||||||||||
|
Subroutine
get_server_env: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 203 | 0 | my $self = shift; | |||||||||||||
| 204 | |||||||||||||||
| 205 | 0 | $self->_set_resource_url('/core-service/server-environment?operation=resource&include-runtime=true&json.pretty'); | |||||||||||||
| 206 | 0 | $self->log->debug($self->resource_url); | |||||||||||||
| 207 | |||||||||||||||
| 208 | 0 | $self->get_api_response(); | |||||||||||||
| 209 | } | ||||||||||||||
| 210 | |||||||||||||||
| 211 | =head2 get_datasources | ||||||||||||||
| 212 | |||||||||||||||
| 213 | get data source and driver | ||||||||||||||
| 214 | my $datasources = $jboss->get_datasources(); | ||||||||||||||
| 215 | |||||||||||||||
| 216 | =cut | ||||||||||||||
| 217 | |||||||||||||||
| 218 | 0 | ▶ | sub get_datasources { | ||||||||||||
|
Subroutine
get_datasources: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 219 | 0 | my $self = shift; | |||||||||||||
| 220 | |||||||||||||||
| 221 | 0 | $self->_set_resource_url('/subsystem/datasources/?operation=resource&recursive=true&json.pretty'); | |||||||||||||
| 222 | 0 | $self->log->debug($self->resource_url); | |||||||||||||
| 223 | |||||||||||||||
| 224 | 0 | $self->get_api_response(); | |||||||||||||
| 225 | } | ||||||||||||||
| 226 | |||||||||||||||
| 227 | =head2 get_app_status | ||||||||||||||
| 228 | |||||||||||||||
| 229 | get web application status | ||||||||||||||
| 230 | web application name is required | ||||||||||||||
| 231 | my $app_status = $jboss->get_app_status('hawtio.war'); | ||||||||||||||
| 232 | |||||||||||||||
| 233 | =cut | ||||||||||||||
| 234 | |||||||||||||||
| 235 | 0 | ▶ | sub get_app_status { | ||||||||||||
|
Subroutine
get_app_status: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 236 | 0 | my $self = shift; | |||||||||||||
| 237 | |||||||||||||||
| 238 | 0 | my $app_name = shift; | |||||||||||||
| 239 | 0 | ▶ | croak "web application name is required" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 240 | unless $app_name; | ||||||||||||||
| 241 | |||||||||||||||
| 242 | 0 | $self->_set_resource_url(qq|/deployment/$app_name?operation=attribute&name=status&json.pretty|); | |||||||||||||
| 243 | 0 | $self->log->debug($self->resource_url); | |||||||||||||
| 244 | |||||||||||||||
| 245 | 0 | $self->get_api_response(); | |||||||||||||
| 246 | } | ||||||||||||||
| 247 | |||||||||||||||
| 248 | =head2 get_active_sessions | ||||||||||||||
| 249 | |||||||||||||||
| 250 | get web application active sessions | ||||||||||||||
| 251 | web application name is required | ||||||||||||||
| 252 | my $active_session = $jboss->get_active_sessions('hawtio.war'); | ||||||||||||||
| 253 | |||||||||||||||
| 254 | =cut | ||||||||||||||
| 255 | |||||||||||||||
| 256 | 0 | ▶ | sub get_active_sessions { | ||||||||||||
|
Subroutine
get_active_sessions: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 257 | 0 | my $self = shift; | |||||||||||||
| 258 | |||||||||||||||
| 259 | 0 | my $app_name = shift; | |||||||||||||
| 260 | 0 | ▶ | croak "web application name is required" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 261 | unless $app_name; | ||||||||||||||
| 262 | |||||||||||||||
| 263 | 0 | $self->_set_resource_url(qq|/deployment/$app_name/subsystem/web?operation=attribute&name=active-sessions&json.pretty|); | |||||||||||||
| 264 | 0 | $self->log->debug($self->resource_url); | |||||||||||||
| 265 | |||||||||||||||
| 266 | 0 | $self->get_api_response(); | |||||||||||||
| 267 | } | ||||||||||||||
| 268 | |||||||||||||||
| 269 | =head2 get_ds_pool_stats | ||||||||||||||
| 270 | |||||||||||||||
| 271 | get usage metric of connection pooling of the data source | ||||||||||||||
| 272 | my $pool_stats = $jboss->get_ds_pool_stats('java:jboss/datasources/jboss_Pool'); | ||||||||||||||
| 273 | |||||||||||||||
| 274 | =cut | ||||||||||||||
| 275 | |||||||||||||||
| 276 | 0 | ▶ | sub get_ds_pool_stats { | ||||||||||||
|
Subroutine
get_ds_pool_stats: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||
| 277 | 0 | my $self = shift; | |||||||||||||
| 278 | 0 | my $ds_name = shift; | |||||||||||||
| 279 | |||||||||||||||
| 280 | 0 | ▶ | croak "data source name is required" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 281 | unless $ds_name; | ||||||||||||||
| 282 | 0 | $ds_name = url_encode_utf8($ds_name); | |||||||||||||
| 283 | 0 | $self->log->debug("encode : $ds_name"); | |||||||||||||
| 284 | |||||||||||||||
| 285 | 0 | ▶ | if ($self->is_xa eq 'no') | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 286 | { | ||||||||||||||
| 287 | 0 | $self->_set_resource_url(qq|/subsystem/datasources/data-source/$ds_name/statistics/pool/?operation=resource&recursive=true&include-runtime=true&json.pretty|); | |||||||||||||
| 288 | } | ||||||||||||||
| 289 | elsif ($self->is_xa eq 'yes') | ||||||||||||||
| 290 | { | ||||||||||||||
| 291 | 0 | $self->_set_resource_url(qq|/subsystem/datasources/xa-data-source/$ds_name/statistics/pool/?operation=resource&recursive=true&include-runtime=true&json.pretty|); | |||||||||||||
| 292 | } | ||||||||||||||
| 293 | |||||||||||||||
| 294 | 0 | $self->log->debug($self->resource_url); | |||||||||||||
| 295 | |||||||||||||||
| 296 | 0 | $self->get_api_response(); | |||||||||||||
| 297 | } | ||||||||||||||
| 298 | |||||||||||||||
| 299 | =head2 test_con_pool | ||||||||||||||
| 300 | |||||||||||||||
| 301 | test datasource connection polling | ||||||||||||||
| 302 | my $test = $jboss->test_con_pool('ExampleDS'); | ||||||||||||||
| 303 | |||||||||||||||
| 304 | =cut | ||||||||||||||
| 305 | |||||||||||||||
| 306 | 0 | ▶ | sub test_con_pool { | ||||||||||||
|
Subroutine
test_con_pool: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 307 | 0 | my $self = shift; | |||||||||||||
| 308 | |||||||||||||||
| 309 | 0 | my $ds_name = shift; | |||||||||||||
| 310 | |||||||||||||||
| 311 | 0 | ▶ | croak "data source name is required" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 312 | unless $ds_name; | ||||||||||||||
| 313 | |||||||||||||||
| 314 | 0 | $self->_set_http_post(1); | |||||||||||||
| 315 | |||||||||||||||
| 316 | 0 | my $json = qq|{"operation":"test-connection-in-pool","address":[{"subsystem":"datasources"},{"data-source":"$ds_name"}],"json.pretty":1}|; | |||||||||||||
| 317 | |||||||||||||||
| 318 | 0 | $self->_set_post_json($json); | |||||||||||||
| 319 | |||||||||||||||
| 320 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 321 | 0 | $self->get_api_response(); | |||||||||||||
| 322 | } | ||||||||||||||
| 323 | |||||||||||||||
| 324 | =head2 set_ds_pool_size | ||||||||||||||
| 325 | |||||||||||||||
| 326 | set data source min/max pool size | ||||||||||||||
| 327 | my $min_pool_size = $jboss->set_ds_pool_size('min', 'java:jboss/datasources/jboss_Pool', 20); | ||||||||||||||
| 328 | my $max_pool_size = $jboss->set_ds_pool_size('max', 'java:jboss/datasources/jboss_Pool', 20); | ||||||||||||||
| 329 | |||||||||||||||
| 330 | =cut | ||||||||||||||
| 331 | |||||||||||||||
| 332 | 0 | ▶ | sub set_ds_pool_size { | ||||||||||||
|
Subroutine
set_ds_pool_size: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||
| 333 | 0 | my $self = shift; | |||||||||||||
| 334 | |||||||||||||||
| 335 | 0 | my ($name, $ds_name, $size) = @_; | |||||||||||||
| 336 | |||||||||||||||
| 337 | 0 | ▶ | croak "min/max is required" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 338 | unless $name; | ||||||||||||||
| 339 | |||||||||||||||
| 340 | 0 | ▶ | croak "$name is not valid value, valid argument is min|max" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 341 | unless $name =~ /^\b(min|max)\b/; | ||||||||||||||
| 342 | |||||||||||||||
| 343 | 0 | ▶ | croak "data source name is required" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 344 | unless $ds_name; | ||||||||||||||
| 345 | |||||||||||||||
| 346 | 0 | ▶ | croak "size is required and must be positive integer" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 347 | unless $size =~ /^\d+$/; | ||||||||||||||
| 348 | |||||||||||||||
| 349 | 0 | ▶ | croak "size must be greater than zero" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 350 | unless $size > 0; | ||||||||||||||
| 351 | |||||||||||||||
| 352 | 0 | $self->_set_http_post(1); | |||||||||||||
| 353 | |||||||||||||||
| 354 | 0 | my $json; | |||||||||||||
| 355 | |||||||||||||||
| 356 | 0 | ▶ | if ($name eq 'min') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 357 | 0 | $json = qq|{"operation":"write-attribute","address":[{"subsystem":"datasources"},{"data-source":"$ds_name"}],"name":"min-pool-size","value":$size,"json.pretty":1}|; | |||||||||||||
| 358 | } | ||||||||||||||
| 359 | elsif ($name eq 'max') { | ||||||||||||||
| 360 | 0 | $json = qq|{"operation":"write-attribute","address":[{"subsystem":"datasources"},{"data-source":"$ds_name"}],"name":"max-pool-size","value":$size,"json.pretty":1}|; | |||||||||||||
| 361 | } | ||||||||||||||
| 362 | |||||||||||||||
| 363 | 0 | $self->_set_post_json($json); | |||||||||||||
| 364 | |||||||||||||||
| 365 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 366 | 0 | $self->get_api_response(); | |||||||||||||
| 367 | } | ||||||||||||||
| 368 | |||||||||||||||
| 369 | =head2 set_ds_pool_stats | ||||||||||||||
| 370 | |||||||||||||||
| 371 | set enable/disable data source pool statistics | ||||||||||||||
| 372 | my $enable_pool_stats = $jboss->set_ds_pool_stats('java:jboss/datasources/jboss_Pool', 'true'); | ||||||||||||||
| 373 | my $disable_pool_stats = $jboss->set_ds_pool_stats('java:jboss/datasources/jboss_Pool', 'false'); | ||||||||||||||
| 374 | |||||||||||||||
| 375 | =cut | ||||||||||||||
| 376 | |||||||||||||||
| 377 | 0 | ▶ | sub set_ds_pool_stats { | ||||||||||||
|
Subroutine
set_ds_pool_stats: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||
| 378 | 0 | my $self = shift; | |||||||||||||
| 379 | |||||||||||||||
| 380 | 0 | my ($ds_name, $value) = @_; | |||||||||||||
| 381 | |||||||||||||||
| 382 | 0 | ▶ | croak "data source name is required" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 383 | unless $ds_name; | ||||||||||||||
| 384 | |||||||||||||||
| 385 | 0 | ▶ | croak "value is not defined" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 386 | unless $value; | ||||||||||||||
| 387 | |||||||||||||||
| 388 | 0 | ▶ | $value = lc ($value) if $value; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 389 | |||||||||||||||
| 390 | 0 | ▶ | croak "value is invalid, valid value is 'true' or 'false'" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 391 | unless $value =~ /^\b(true|false)\b/; | ||||||||||||||
| 392 | |||||||||||||||
| 393 | 0 | $self->_set_http_post(1); | |||||||||||||
| 394 | |||||||||||||||
| 395 | 0 | my $json = qq|{"operation":"write-attribute","address":[{"subsystem":"datasources"},{"data-source":"$ds_name"}],"name":"statistics-enabled","value":"$value","json.pretty":1}|; | |||||||||||||
| 396 | |||||||||||||||
| 397 | 0 | $self->_set_post_json($json); | |||||||||||||
| 398 | |||||||||||||||
| 399 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 400 | 0 | $self->get_api_response(); | |||||||||||||
| 401 | } | ||||||||||||||
| 402 | |||||||||||||||
| 403 | =head2 reload | ||||||||||||||
| 404 | |||||||||||||||
| 405 | reload jboss only | ||||||||||||||
| 406 | my $reload = $jboss->reload(); | ||||||||||||||
| 407 | |||||||||||||||
| 408 | =cut | ||||||||||||||
| 409 | |||||||||||||||
| 410 | 0 | ▶ | sub reload { | ||||||||||||
|
Subroutine
reload: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 411 | 0 | my $self = shift; | |||||||||||||
| 412 | |||||||||||||||
| 413 | 0 | $self->_set_http_post(1); | |||||||||||||
| 414 | |||||||||||||||
| 415 | 0 | my $json = qq|{"operation":"reload","json.pretty":1}|; | |||||||||||||
| 416 | |||||||||||||||
| 417 | 0 | $self->_set_post_json($json); | |||||||||||||
| 418 | |||||||||||||||
| 419 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 420 | 0 | $self->get_api_response(); | |||||||||||||
| 421 | |||||||||||||||
| 422 | # wait for the state | ||||||||||||||
| 423 | 0 | $self->log->debug("wait for " . $self->reload_time . " seconds before checking the state"); | |||||||||||||
| 424 | 0 | sleep ($self->reload_time); | |||||||||||||
| 425 | 0 | $self->get_state(); | |||||||||||||
| 426 | } | ||||||||||||||
| 427 | |||||||||||||||
| 428 | =head2 shutdown | ||||||||||||||
| 429 | |||||||||||||||
| 430 | shutdown jboss | ||||||||||||||
| 431 | my $shutdown = $jboss->shutdown(); | ||||||||||||||
| 432 | |||||||||||||||
| 433 | =cut | ||||||||||||||
| 434 | |||||||||||||||
| 435 | 0 | ▶ | sub shutdown { | ||||||||||||
|
Subroutine
shutdown: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 436 | 0 | my $self = shift; | |||||||||||||
| 437 | |||||||||||||||
| 438 | 0 | $self->_set_http_post(1); | |||||||||||||
| 439 | |||||||||||||||
| 440 | 0 | my $json = qq|{"operation":"shutdown","json.pretty":1}|; | |||||||||||||
| 441 | |||||||||||||||
| 442 | 0 | $self->_set_post_json($json); | |||||||||||||
| 443 | |||||||||||||||
| 444 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 445 | 0 | $self->get_api_response(); | |||||||||||||
| 446 | } | ||||||||||||||
| 447 | |||||||||||||||
| 448 | =head2 restart | ||||||||||||||
| 449 | |||||||||||||||
| 450 | restart jboss and jvm | ||||||||||||||
| 451 | my $restart = $jboss->restart(); | ||||||||||||||
| 452 | |||||||||||||||
| 453 | =cut | ||||||||||||||
| 454 | |||||||||||||||
| 455 | 0 | ▶ | sub restart { | ||||||||||||
|
Subroutine
restart: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 456 | 0 | my $self = shift; | |||||||||||||
| 457 | |||||||||||||||
| 458 | 0 | $self->_set_http_post(1); | |||||||||||||
| 459 | |||||||||||||||
| 460 | 0 | my $json = qq|{"operation":"shutdown","restart":"true","json.pretty":1}|; | |||||||||||||
| 461 | |||||||||||||||
| 462 | 0 | $self->_set_post_json($json); | |||||||||||||
| 463 | |||||||||||||||
| 464 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 465 | 0 | $self->get_api_response(); | |||||||||||||
| 466 | } | ||||||||||||||
| 467 | |||||||||||||||
| 468 | =head2 get_deployment_info | ||||||||||||||
| 469 | |||||||||||||||
| 470 | return deployment detail information | ||||||||||||||
| 471 | my $deploy_info = $jboss->get_deployment_info(); | ||||||||||||||
| 472 | |||||||||||||||
| 473 | =cut | ||||||||||||||
| 474 | |||||||||||||||
| 475 | 0 | ▶ | sub get_deployment_info { | ||||||||||||
|
Subroutine
get_deployment_info: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 476 | 0 | my $self = shift; | |||||||||||||
| 477 | |||||||||||||||
| 478 | 0 | $self->_set_http_post(1); | |||||||||||||
| 479 | |||||||||||||||
| 480 | 0 | my $json = qq|{"operation":"read-children-resources","child-type":"deployment","recursive":"true","json.pretty":1}|; | |||||||||||||
| 481 | |||||||||||||||
| 482 | 0 | $self->_set_post_json($json); | |||||||||||||
| 483 | |||||||||||||||
| 484 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 485 | 0 | $self->get_api_response(); | |||||||||||||
| 486 | } | ||||||||||||||
| 487 | |||||||||||||||
| 488 | =head2 get_jndi | ||||||||||||||
| 489 | |||||||||||||||
| 490 | return jndi view information | ||||||||||||||
| 491 | my $jndi = $jboss->get_jndi(); | ||||||||||||||
| 492 | |||||||||||||||
| 493 | =cut | ||||||||||||||
| 494 | |||||||||||||||
| 495 | 0 | ▶ | sub get_jndi { | ||||||||||||
|
Subroutine
get_jndi: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||
| 496 | 0 | my $self = shift; | |||||||||||||
| 497 | |||||||||||||||
| 498 | 0 | $self->_set_http_post(1); | |||||||||||||
| 499 | |||||||||||||||
| 500 | 0 | my $json = qq|{"operation":"jndi-view", "address":["subsystem","naming"], "json.pretty":1}|; | |||||||||||||
| 501 | |||||||||||||||
| 502 | 0 | $self->_set_post_json($json); | |||||||||||||
| 503 | |||||||||||||||
| 504 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 505 | 0 | $self->get_api_response(); | |||||||||||||
| 506 | } | ||||||||||||||
| 507 | |||||||||||||||
| 508 | =head2 set_log_level | ||||||||||||||
| 509 | |||||||||||||||
| 510 | my $loglevel = $jboss->set_log_level('CONSOLE', 'ERROR'); | ||||||||||||||
| 511 | |||||||||||||||
| 512 | =cut | ||||||||||||||
| 513 | |||||||||||||||
| 514 | 0 | ▶ | sub set_log_level { | ||||||||||||
|
Subroutine
set_log_level: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||
| 515 | 0 | my $self = shift; | |||||||||||||
| 516 | |||||||||||||||
| 517 | 0 | my ($type, $severity) = @_; | |||||||||||||
| 518 | |||||||||||||||
| 519 | 0 | my $valid_type = 'CONSOLE'; | |||||||||||||
| 520 | 0 | my $valid_severity = 'ALL|DEBUG|INFO|WARN|WARNING|ERROR|SEVERE|FATAL|OFF'; | |||||||||||||
| 521 | |||||||||||||||
| 522 | 0 | ▶ | croak "type of console is required" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 523 | unless $type; | ||||||||||||||
| 524 | |||||||||||||||
| 525 | 0 | ▶ | croak "valid type is $valid_type" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 526 | unless $type =~ /^\b($valid_type)\b/; | ||||||||||||||
| 527 | |||||||||||||||
| 528 | 0 | ▶ | croak "valid log severity is $valid_severity" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 529 | unless $severity =~ /^\b($valid_severity)\b/; | ||||||||||||||
| 530 | |||||||||||||||
| 531 | 0 | ▶ | croak "severity level is required" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 532 | unless $severity; | ||||||||||||||
| 533 | |||||||||||||||
| 534 | 0 | $self->_set_http_post(1); | |||||||||||||
| 535 | |||||||||||||||
| 536 | 0 | my $json = qq|{"operation":"write-attribute","address":[{"subsystem":"logging"},{"console-handler":"$type"}],"name":"level","value":"$severity", "json.pretty":1}|; | |||||||||||||
| 537 | |||||||||||||||
| 538 | 0 | $self->_set_post_json($json); | |||||||||||||
| 539 | |||||||||||||||
| 540 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 541 | 0 | $self->get_api_response(); | |||||||||||||
| 542 | } | ||||||||||||||
| 543 | |||||||||||||||
| 544 | =head2 get_log_level | ||||||||||||||
| 545 | |||||||||||||||
| 546 | my $loglevel = $jboss->get_log_level('CONSOLE'); | ||||||||||||||
| 547 | |||||||||||||||
| 548 | =cut | ||||||||||||||
| 549 | |||||||||||||||
| 550 | 0 | ▶ | sub get_log_level { | ||||||||||||
|
Subroutine
get_log_level: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||
| 551 | 0 | my $self = shift; | |||||||||||||
| 552 | |||||||||||||||
| 553 | 0 | my $type = shift; | |||||||||||||
| 554 | |||||||||||||||
| 555 | 0 | my $valid_type = 'CONSOLE'; | |||||||||||||
| 556 | |||||||||||||||
| 557 | 0 | ▶ | croak "type of console is required" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 558 | unless $type; | ||||||||||||||
| 559 | |||||||||||||||
| 560 | 0 | ▶ | croak "valid type is $valid_type" | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 561 | unless $type =~ /^\b($valid_type)\b/; | ||||||||||||||
| 562 | |||||||||||||||
| 563 | 0 | $self->_set_http_post(1); | |||||||||||||
| 564 | |||||||||||||||
| 565 | 0 | my $json = qq|{"operation":"read-attribute","address":[{"subsystem":"logging"},{"console-handler":"$type"}],"name":"level", "json.pretty":1}|; | |||||||||||||
| 566 | |||||||||||||||
| 567 | 0 | $self->_set_post_json($json); | |||||||||||||
| 568 | |||||||||||||||
| 569 | 0 | $self->log->debug($self->post_json); | |||||||||||||
| 570 | 0 | $self->get_api_response(); | |||||||||||||
| 571 | } | ||||||||||||||
| 572 | |||||||||||||||
| 573 | =head1 AUTHOR | ||||||||||||||
| 574 | |||||||||||||||
| 575 | "Heince Kurniawan", C<< <"heince at cpan.org"> >> | ||||||||||||||
| 576 | |||||||||||||||
| 577 | =head1 BUGS | ||||||||||||||
| 578 | |||||||||||||||
| 579 | Please report any bugs or feature requests to "heince at cpan.org", or through | ||||||||||||||
| 580 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Net::JBoss::Management>. I will be notified, and then you'll | ||||||||||||||
| 581 | automatically be notified of progress on your bug as I make changes. | ||||||||||||||
| 582 | |||||||||||||||
| 583 | |||||||||||||||
| 584 | =head1 SUPPORT | ||||||||||||||
| 585 | |||||||||||||||
| 586 | You can find documentation for this module with the perldoc command. | ||||||||||||||
| 587 | |||||||||||||||
| 588 | perldoc Net::JBoss | ||||||||||||||
| 589 | perldoc Net::JBoss::Management | ||||||||||||||
| 590 | |||||||||||||||
| 591 | You can also look for information at: | ||||||||||||||
| 592 | |||||||||||||||
| 593 | =over 4 | ||||||||||||||
| 594 | |||||||||||||||
| 595 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||
| 596 | |||||||||||||||
| 597 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Net::JBoss> | ||||||||||||||
| 598 | |||||||||||||||
| 599 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||
| 600 | |||||||||||||||
| 601 | L<http://annocpan.org/dist/Net::JBoss> | ||||||||||||||
| 602 | |||||||||||||||
| 603 | =item * CPAN Ratings | ||||||||||||||
| 604 | |||||||||||||||
| 605 | L<http://cpanratings.perl.org/d/Net::JBoss> | ||||||||||||||
| 606 | |||||||||||||||
| 607 | =item * Search CPAN | ||||||||||||||
| 608 | |||||||||||||||
| 609 | L<http://search.cpan.org/dist/Net::JBoss/> | ||||||||||||||
| 610 | |||||||||||||||
| 611 | =back | ||||||||||||||
| 612 | |||||||||||||||
| 613 | |||||||||||||||
| 614 | =head1 ACKNOWLEDGEMENTS | ||||||||||||||
| 615 | |||||||||||||||
| 616 | |||||||||||||||
| 617 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||
| 618 | |||||||||||||||
| 619 | Copyright 2015 "Heince Kurniawan". | ||||||||||||||
| 620 | |||||||||||||||
| 621 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||
| 622 | under the terms of the the Artistic License (2.0). You may obtain a | ||||||||||||||
| 623 | copy of the full license at: | ||||||||||||||
| 624 | |||||||||||||||
| 625 | L<http://www.perlfoundation.org/artistic_license_2_0> | ||||||||||||||
| 626 | |||||||||||||||
| 627 | Any use, modification, and distribution of the Standard or Modified | ||||||||||||||
| 628 | Versions is governed by this Artistic License. By using, modifying or | ||||||||||||||
| 629 | distributing the Package, you accept this license. Do not use, modify, | ||||||||||||||
| 630 | or distribute the Package, if you do not accept this license. | ||||||||||||||
| 631 | |||||||||||||||
| 632 | If your Modified Version has been derived from a Modified Version made | ||||||||||||||
| 633 | by someone other than you, you are nevertheless required to ensure that | ||||||||||||||
| 634 | your Modified Version complies with the requirements of this license. | ||||||||||||||
| 635 | |||||||||||||||
| 636 | This license does not grant you the right to use any trademark, service | ||||||||||||||
| 637 | mark, tradename, or logo of the Copyright Holder. | ||||||||||||||
| 638 | |||||||||||||||
| 639 | This license includes the non-exclusive, worldwide, free-of-charge | ||||||||||||||
| 640 | patent license to make, have made, use, offer to sell, sell, import and | ||||||||||||||
| 641 | otherwise transfer the Package with respect to any patent claims | ||||||||||||||
| 642 | licensable by the Copyright Holder that are necessarily infringed by the | ||||||||||||||
| 643 | Package. If you institute patent litigation (including a cross-claim or | ||||||||||||||
| 644 | counterclaim) against any party alleging that the Package constitutes | ||||||||||||||
| 645 | direct or contributory patent infringement, then this Artistic License | ||||||||||||||
| 646 | to you shall terminate on the date that such litigation is filed. | ||||||||||||||
| 647 | |||||||||||||||
| 648 | Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER | ||||||||||||||
| 649 | AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. | ||||||||||||||
| 650 | THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||||||||||||||
| 651 | PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY | ||||||||||||||
| 652 | YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR | ||||||||||||||
| 653 | CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR | ||||||||||||||
| 654 | CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, | ||||||||||||||
| 655 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||||||||||||
| 656 | |||||||||||||||
| 657 | |||||||||||||||
| 658 | =cut | ||||||||||||||
| 659 | |||||||||||||||
| 660 | 1 | 1; # End of JBoss | |||||||||||||