line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::JBoss::Management; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
1401
|
use 5.010; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
39
|
|
4
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
68
|
|
5
|
1
|
|
|
1
|
|
560
|
use URL::Encode qw /url_encode_utf8/; |
|
1
|
|
|
|
|
4565
|
|
|
1
|
|
|
|
|
53
|
|
6
|
1
|
|
|
1
|
|
641
|
use Moo; |
|
1
|
|
|
|
|
2082
|
|
|
1
|
|
|
|
|
6
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
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.03 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
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->get_ds_pool_stats('java:jboss/datasources/jboss_Pool', 'true'); |
52
|
|
|
|
|
|
|
my $disable_pool_stats = $jboss->get_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
|
|
|
|
|
|
|
has 'management_url' => ( is => 'ro', default => '/management' ); |
78
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub BUILD { |
89
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub get_state { |
107
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$self->_set_http_post(1); |
110
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
if ($self->http_post) { |
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
|
|
|
|
|
|
|
sub get_jvm_usage { |
131
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub get_runtime_stats { |
147
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub get_runtime_details { |
163
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub get_app_runtime_stats { |
179
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
my $app_name = shift; |
182
|
0
|
0
|
|
|
|
|
croak "web application name is required" |
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
|
|
|
|
|
|
|
sub get_server_env { |
203
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub get_datasources { |
219
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
sub get_app_status { |
236
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
237
|
|
|
|
|
|
|
|
238
|
0
|
|
|
|
|
|
my $app_name = shift; |
239
|
0
|
0
|
|
|
|
|
croak "web application name is required" |
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
|
|
|
|
|
|
|
sub get_active_sessions { |
257
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
258
|
|
|
|
|
|
|
|
259
|
0
|
|
|
|
|
|
my $app_name = shift; |
260
|
0
|
0
|
|
|
|
|
croak "web application name is required" |
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
|
|
|
|
|
|
|
sub get_ds_pool_stats { |
277
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
278
|
0
|
|
|
|
|
|
my $ds_name = shift; |
279
|
|
|
|
|
|
|
|
280
|
0
|
0
|
|
|
|
|
croak "data source name is required" |
281
|
|
|
|
|
|
|
unless $ds_name; |
282
|
0
|
|
|
|
|
|
$ds_name = url_encode_utf8($ds_name); |
283
|
0
|
|
|
|
|
|
$self->log->debug("encode : $ds_name"); |
284
|
|
|
|
|
|
|
|
285
|
0
|
|
|
|
|
|
$self->_set_resource_url(qq|/subsystem/datasources/data-source/$ds_name/statistics/pool/?operation=resource&recursive=true&include-runtime=true&json.pretty|); |
286
|
0
|
|
|
|
|
|
$self->log->debug($self->resource_url); |
287
|
|
|
|
|
|
|
|
288
|
0
|
|
|
|
|
|
$self->get_api_response(); |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head2 test_con_pool |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
test datasource connection polling |
294
|
|
|
|
|
|
|
my $test = $jboss->test_con_pool('ExampleDS'); |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=cut |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
sub test_con_pool { |
299
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
300
|
|
|
|
|
|
|
|
301
|
0
|
|
|
|
|
|
my $ds_name = shift; |
302
|
|
|
|
|
|
|
|
303
|
0
|
0
|
|
|
|
|
croak "data source name is required" |
304
|
|
|
|
|
|
|
unless $ds_name; |
305
|
|
|
|
|
|
|
|
306
|
0
|
|
|
|
|
|
$self->_set_http_post(1); |
307
|
|
|
|
|
|
|
|
308
|
0
|
|
|
|
|
|
my $json = qq|{"operation":"test-connection-in-pool","address":[{"subsystem":"datasources"},{"data-source":"$ds_name"}],"json.pretty":1}|; |
309
|
|
|
|
|
|
|
|
310
|
0
|
|
|
|
|
|
$self->_set_post_json($json); |
311
|
|
|
|
|
|
|
|
312
|
0
|
|
|
|
|
|
$self->log->debug($self->post_json); |
313
|
0
|
|
|
|
|
|
$self->get_api_response(); |
314
|
|
|
|
|
|
|
} |
315
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=head2 set_ds_pool_size |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
set data source min/max pool size |
319
|
|
|
|
|
|
|
my $min_pool_size = $jboss->set_ds_pool_size('min', 'java:jboss/datasources/jboss_Pool', 20); |
320
|
|
|
|
|
|
|
my $max_pool_size = $jboss->set_ds_pool_size('max', 'java:jboss/datasources/jboss_Pool', 20); |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=cut |
323
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
sub set_ds_pool_size { |
325
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
326
|
|
|
|
|
|
|
|
327
|
0
|
|
|
|
|
|
my ($name, $ds_name, $size) = @_; |
328
|
|
|
|
|
|
|
|
329
|
0
|
0
|
|
|
|
|
croak "min/max is required" |
330
|
|
|
|
|
|
|
unless $name; |
331
|
|
|
|
|
|
|
|
332
|
0
|
0
|
|
|
|
|
croak "$name is not valid value, valid argument is min|max" |
333
|
|
|
|
|
|
|
unless $name =~ /^\b(min|max)\b/; |
334
|
|
|
|
|
|
|
|
335
|
0
|
0
|
|
|
|
|
croak "data source name is required" |
336
|
|
|
|
|
|
|
unless $ds_name; |
337
|
|
|
|
|
|
|
|
338
|
0
|
0
|
|
|
|
|
croak "size is required and must be positive integer" |
339
|
|
|
|
|
|
|
unless $size =~ /^\d+$/; |
340
|
|
|
|
|
|
|
|
341
|
0
|
0
|
|
|
|
|
croak "size must be greater than zero" |
342
|
|
|
|
|
|
|
unless $size > 0; |
343
|
|
|
|
|
|
|
|
344
|
0
|
|
|
|
|
|
$self->_set_http_post(1); |
345
|
|
|
|
|
|
|
|
346
|
0
|
|
|
|
|
|
my $json; |
347
|
|
|
|
|
|
|
|
348
|
0
|
0
|
|
|
|
|
if ($name eq 'min') { |
|
|
0
|
|
|
|
|
|
349
|
0
|
|
|
|
|
|
$json = qq|{"operation":"write-attribute","address":[{"subsystem":"datasources"},{"data-source":"$ds_name"}],"name":"min-pool-size","value":$size,"json.pretty":1}|; |
350
|
|
|
|
|
|
|
} |
351
|
|
|
|
|
|
|
elsif ($name eq 'max') { |
352
|
0
|
|
|
|
|
|
$json = qq|{"operation":"write-attribute","address":[{"subsystem":"datasources"},{"data-source":"$ds_name"}],"name":"max-pool-size","value":$size,"json.pretty":1}|; |
353
|
|
|
|
|
|
|
} |
354
|
|
|
|
|
|
|
|
355
|
0
|
|
|
|
|
|
$self->_set_post_json($json); |
356
|
|
|
|
|
|
|
|
357
|
0
|
|
|
|
|
|
$self->log->debug($self->post_json); |
358
|
0
|
|
|
|
|
|
$self->get_api_response(); |
359
|
|
|
|
|
|
|
} |
360
|
|
|
|
|
|
|
|
361
|
|
|
|
|
|
|
=head2 set_ds_pool_stats |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
set enable/disable data source pool statistics |
364
|
|
|
|
|
|
|
my $enable_pool_stats = $jboss->set_ds_pool_stats('java:jboss/datasources/jboss_Pool', 'true'); |
365
|
|
|
|
|
|
|
my $disable_pool_stats = $jboss->set_ds_pool_stats('java:jboss/datasources/jboss_Pool', 'false'); |
366
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
=cut |
368
|
|
|
|
|
|
|
|
369
|
|
|
|
|
|
|
sub set_ds_pool_stats { |
370
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
371
|
|
|
|
|
|
|
|
372
|
0
|
|
|
|
|
|
my ($ds_name, $value) = @_; |
373
|
|
|
|
|
|
|
|
374
|
0
|
0
|
|
|
|
|
croak "data source name is required" |
375
|
|
|
|
|
|
|
unless $ds_name; |
376
|
|
|
|
|
|
|
|
377
|
0
|
0
|
|
|
|
|
croak "value is not defined" |
378
|
|
|
|
|
|
|
unless $value; |
379
|
|
|
|
|
|
|
|
380
|
0
|
0
|
|
|
|
|
$value = lc ($value) if $value; |
381
|
|
|
|
|
|
|
|
382
|
0
|
0
|
|
|
|
|
croak "value is invalid, valid value is 'true' or 'false'" |
383
|
|
|
|
|
|
|
unless $value =~ /^\b(true|false)\b/; |
384
|
|
|
|
|
|
|
|
385
|
0
|
|
|
|
|
|
$self->_set_http_post(1); |
386
|
|
|
|
|
|
|
|
387
|
0
|
|
|
|
|
|
my $json = qq|{"operation":"write-attribute","address":[{"subsystem":"datasources"},{"data-source":"$ds_name"}],"name":"statistics-enabled","value":"$value","json.pretty":1}|; |
388
|
|
|
|
|
|
|
|
389
|
0
|
|
|
|
|
|
$self->_set_post_json($json); |
390
|
|
|
|
|
|
|
|
391
|
0
|
|
|
|
|
|
$self->log->debug($self->post_json); |
392
|
0
|
|
|
|
|
|
$self->get_api_response(); |
393
|
|
|
|
|
|
|
} |
394
|
|
|
|
|
|
|
|
395
|
|
|
|
|
|
|
=head2 reload |
396
|
|
|
|
|
|
|
|
397
|
|
|
|
|
|
|
reload jboss only |
398
|
|
|
|
|
|
|
my $reload = $jboss->reload(); |
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
=cut |
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
sub reload { |
403
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
404
|
|
|
|
|
|
|
|
405
|
0
|
|
|
|
|
|
$self->_set_http_post(1); |
406
|
|
|
|
|
|
|
|
407
|
0
|
|
|
|
|
|
my $json = qq|{"operation":"reload","json.pretty":1}|; |
408
|
|
|
|
|
|
|
|
409
|
0
|
|
|
|
|
|
$self->_set_post_json($json); |
410
|
|
|
|
|
|
|
|
411
|
0
|
|
|
|
|
|
$self->log->debug($self->post_json); |
412
|
0
|
|
|
|
|
|
$self->get_api_response(); |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
# wait for the state |
415
|
0
|
|
|
|
|
|
$self->log->debug("wait for " . $self->reload_time . " seconds before checking the state"); |
416
|
0
|
|
|
|
|
|
sleep ($self->reload_time); |
417
|
0
|
|
|
|
|
|
$self->get_state(); |
418
|
|
|
|
|
|
|
} |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
=head2 shutdown |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
shutdown jboss |
423
|
|
|
|
|
|
|
my $shutdown = $jboss->shutdown(); |
424
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
=cut |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
sub shutdown { |
428
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
429
|
|
|
|
|
|
|
|
430
|
0
|
|
|
|
|
|
$self->_set_http_post(1); |
431
|
|
|
|
|
|
|
|
432
|
0
|
|
|
|
|
|
my $json = qq|{"operation":"shutdown","json.pretty":1}|; |
433
|
|
|
|
|
|
|
|
434
|
0
|
|
|
|
|
|
$self->_set_post_json($json); |
435
|
|
|
|
|
|
|
|
436
|
0
|
|
|
|
|
|
$self->log->debug($self->post_json); |
437
|
0
|
|
|
|
|
|
$self->get_api_response(); |
438
|
|
|
|
|
|
|
} |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
=head2 restart |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
restart jboss and jvm |
443
|
|
|
|
|
|
|
my $restart = $jboss->restart(); |
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
=cut |
446
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
sub restart { |
448
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
449
|
|
|
|
|
|
|
|
450
|
0
|
|
|
|
|
|
$self->_set_http_post(1); |
451
|
|
|
|
|
|
|
|
452
|
0
|
|
|
|
|
|
my $json = qq|{"operation":"shutdown","restart":"true","json.pretty":1}|; |
453
|
|
|
|
|
|
|
|
454
|
0
|
|
|
|
|
|
$self->_set_post_json($json); |
455
|
|
|
|
|
|
|
|
456
|
0
|
|
|
|
|
|
$self->log->debug($self->post_json); |
457
|
0
|
|
|
|
|
|
$self->get_api_response(); |
458
|
|
|
|
|
|
|
} |
459
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
=head2 get_deployment_info |
461
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
return deployment detail information |
463
|
|
|
|
|
|
|
my $deploy_info = $jboss->get_deployment_info(); |
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
=cut |
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
sub get_deployment_info { |
468
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
469
|
|
|
|
|
|
|
|
470
|
0
|
|
|
|
|
|
$self->_set_http_post(1); |
471
|
|
|
|
|
|
|
|
472
|
0
|
|
|
|
|
|
my $json = qq|{"operation":"read-children-resources","child-type":"deployment","recursive":"true","json.pretty":1}|; |
473
|
|
|
|
|
|
|
|
474
|
0
|
|
|
|
|
|
$self->_set_post_json($json); |
475
|
|
|
|
|
|
|
|
476
|
0
|
|
|
|
|
|
$self->log->debug($self->post_json); |
477
|
0
|
|
|
|
|
|
$self->get_api_response(); |
478
|
|
|
|
|
|
|
} |
479
|
|
|
|
|
|
|
|
480
|
|
|
|
|
|
|
=head2 get_jndi |
481
|
|
|
|
|
|
|
|
482
|
|
|
|
|
|
|
return jndi view information |
483
|
|
|
|
|
|
|
my $jndi = $jboss->get_jndi(); |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
=cut |
486
|
|
|
|
|
|
|
|
487
|
|
|
|
|
|
|
sub get_jndi { |
488
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
489
|
|
|
|
|
|
|
|
490
|
0
|
|
|
|
|
|
$self->_set_http_post(1); |
491
|
|
|
|
|
|
|
|
492
|
0
|
|
|
|
|
|
my $json = qq|{"operation":"jndi-view", "address":["subsystem","naming"], "json.pretty":1}|; |
493
|
|
|
|
|
|
|
|
494
|
0
|
|
|
|
|
|
$self->_set_post_json($json); |
495
|
|
|
|
|
|
|
|
496
|
0
|
|
|
|
|
|
$self->log->debug($self->post_json); |
497
|
0
|
|
|
|
|
|
$self->get_api_response(); |
498
|
|
|
|
|
|
|
} |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
=head2 set_log_level |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
my $loglevel = $jboss->set_log_level('CONSOLE', 'ERROR'); |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
=cut |
505
|
|
|
|
|
|
|
|
506
|
|
|
|
|
|
|
sub set_log_level { |
507
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
508
|
|
|
|
|
|
|
|
509
|
0
|
|
|
|
|
|
my ($type, $severity) = @_; |
510
|
|
|
|
|
|
|
|
511
|
0
|
|
|
|
|
|
my $valid_type = 'CONSOLE'; |
512
|
0
|
|
|
|
|
|
my $valid_severity = 'ALL|DEBUG|INFO|WARN|WARNING|ERROR|SEVERE|FATAL|OFF'; |
513
|
|
|
|
|
|
|
|
514
|
0
|
0
|
|
|
|
|
croak "type of console is required" |
515
|
|
|
|
|
|
|
unless $type; |
516
|
|
|
|
|
|
|
|
517
|
0
|
0
|
|
|
|
|
croak "valid type is $valid_type" |
518
|
|
|
|
|
|
|
unless $type =~ /^\b($valid_type)\b/; |
519
|
|
|
|
|
|
|
|
520
|
0
|
0
|
|
|
|
|
croak "valid log severity is $valid_severity" |
521
|
|
|
|
|
|
|
unless $severity =~ /^\b($valid_severity)\b/; |
522
|
|
|
|
|
|
|
|
523
|
0
|
0
|
|
|
|
|
croak "severity level is required" |
524
|
|
|
|
|
|
|
unless $severity; |
525
|
|
|
|
|
|
|
|
526
|
0
|
|
|
|
|
|
$self->_set_http_post(1); |
527
|
|
|
|
|
|
|
|
528
|
0
|
|
|
|
|
|
my $json = qq|{"operation":"write-attribute","address":[{"subsystem":"logging"},{"console-handler":"$type"}],"name":"level","value":"$severity", "json.pretty":1}|; |
529
|
|
|
|
|
|
|
|
530
|
0
|
|
|
|
|
|
$self->_set_post_json($json); |
531
|
|
|
|
|
|
|
|
532
|
0
|
|
|
|
|
|
$self->log->debug($self->post_json); |
533
|
0
|
|
|
|
|
|
$self->get_api_response(); |
534
|
|
|
|
|
|
|
} |
535
|
|
|
|
|
|
|
|
536
|
|
|
|
|
|
|
=head2 get_log_level |
537
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
my $loglevel = $jboss->get_log_level('CONSOLE'); |
539
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
=cut |
541
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
sub get_log_level { |
543
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
544
|
|
|
|
|
|
|
|
545
|
0
|
|
|
|
|
|
my $type = shift; |
546
|
|
|
|
|
|
|
|
547
|
0
|
|
|
|
|
|
my $valid_type = 'CONSOLE'; |
548
|
|
|
|
|
|
|
|
549
|
0
|
0
|
|
|
|
|
croak "type of console is required" |
550
|
|
|
|
|
|
|
unless $type; |
551
|
|
|
|
|
|
|
|
552
|
0
|
0
|
|
|
|
|
croak "valid type is $valid_type" |
553
|
|
|
|
|
|
|
unless $type =~ /^\b($valid_type)\b/; |
554
|
|
|
|
|
|
|
|
555
|
0
|
|
|
|
|
|
$self->_set_http_post(1); |
556
|
|
|
|
|
|
|
|
557
|
0
|
|
|
|
|
|
my $json = qq|{"operation":"read-attribute","address":[{"subsystem":"logging"},{"console-handler":"$type"}],"name":"level", "json.pretty":1}|; |
558
|
|
|
|
|
|
|
|
559
|
0
|
|
|
|
|
|
$self->_set_post_json($json); |
560
|
|
|
|
|
|
|
|
561
|
0
|
|
|
|
|
|
$self->log->debug($self->post_json); |
562
|
0
|
|
|
|
|
|
$self->get_api_response(); |
563
|
|
|
|
|
|
|
} |
564
|
|
|
|
|
|
|
|
565
|
|
|
|
|
|
|
=head1 AUTHOR |
566
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
"Heince Kurniawan", C<< <"heince at cpan.org"> >> |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
=head1 BUGS |
570
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
Please report any bugs or feature requests to "heince at cpan.org", or through |
572
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
573
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
574
|
|
|
|
|
|
|
|
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
=head1 SUPPORT |
577
|
|
|
|
|
|
|
|
578
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
579
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
perldoc Net::JBoss |
581
|
|
|
|
|
|
|
perldoc Net::JBoss::Management |
582
|
|
|
|
|
|
|
|
583
|
|
|
|
|
|
|
You can also look for information at: |
584
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
=over 4 |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker (report bugs here) |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
L |
590
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
592
|
|
|
|
|
|
|
|
593
|
|
|
|
|
|
|
L |
594
|
|
|
|
|
|
|
|
595
|
|
|
|
|
|
|
=item * CPAN Ratings |
596
|
|
|
|
|
|
|
|
597
|
|
|
|
|
|
|
L |
598
|
|
|
|
|
|
|
|
599
|
|
|
|
|
|
|
=item * Search CPAN |
600
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
L |
602
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
=back |
604
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
|
606
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
607
|
|
|
|
|
|
|
|
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
Copyright 2015 "Heince Kurniawan". |
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
614
|
|
|
|
|
|
|
under the terms of the the Artistic License (2.0). You may obtain a |
615
|
|
|
|
|
|
|
copy of the full license at: |
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
L |
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
Any use, modification, and distribution of the Standard or Modified |
620
|
|
|
|
|
|
|
Versions is governed by this Artistic License. By using, modifying or |
621
|
|
|
|
|
|
|
distributing the Package, you accept this license. Do not use, modify, |
622
|
|
|
|
|
|
|
or distribute the Package, if you do not accept this license. |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
If your Modified Version has been derived from a Modified Version made |
625
|
|
|
|
|
|
|
by someone other than you, you are nevertheless required to ensure that |
626
|
|
|
|
|
|
|
your Modified Version complies with the requirements of this license. |
627
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
This license does not grant you the right to use any trademark, service |
629
|
|
|
|
|
|
|
mark, tradename, or logo of the Copyright Holder. |
630
|
|
|
|
|
|
|
|
631
|
|
|
|
|
|
|
This license includes the non-exclusive, worldwide, free-of-charge |
632
|
|
|
|
|
|
|
patent license to make, have made, use, offer to sell, sell, import and |
633
|
|
|
|
|
|
|
otherwise transfer the Package with respect to any patent claims |
634
|
|
|
|
|
|
|
licensable by the Copyright Holder that are necessarily infringed by the |
635
|
|
|
|
|
|
|
Package. If you institute patent litigation (including a cross-claim or |
636
|
|
|
|
|
|
|
counterclaim) against any party alleging that the Package constitutes |
637
|
|
|
|
|
|
|
direct or contributory patent infringement, then this Artistic License |
638
|
|
|
|
|
|
|
to you shall terminate on the date that such litigation is filed. |
639
|
|
|
|
|
|
|
|
640
|
|
|
|
|
|
|
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER |
641
|
|
|
|
|
|
|
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. |
642
|
|
|
|
|
|
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR |
643
|
|
|
|
|
|
|
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY |
644
|
|
|
|
|
|
|
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR |
645
|
|
|
|
|
|
|
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR |
646
|
|
|
|
|
|
|
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, |
647
|
|
|
|
|
|
|
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
|
650
|
|
|
|
|
|
|
=cut |
651
|
|
|
|
|
|
|
|
652
|
|
|
|
|
|
|
1; # End of JBoss |