Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

Commit 5c39aa4

Browse files
authored
Merge pull request #187 from josejulio/jira/HAWKULAR-1154
HAWKULAR-1154 - Supports [Update Collection Intervals] command.
2 parents ce03049 + c851c18 commit 5c39aa4

3 files changed

Lines changed: 69 additions & 0 deletions

File tree

lib/hawkular/operations/operations_api.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,22 @@ def export_jdr(resource_path, &callback)
308308
invoke_specific_operation({ resourcePath: resource_path }, 'ExportJdr', &callback)
309309
end
310310

311+
# Updates the collection intervals.
312+
#
313+
# @param [Hash] hash Arguments for update collection intervals
314+
# @option hash {resourcePath} a resource managed by the target agent
315+
# @option hash {metricTypes} A map with key=MetricTypeId, value=interval (seconds).
316+
# MetricTypeId must be of form MetricTypeSet~MetricTypeName
317+
# @option hash {availTypes} A map with key=AvailTypeId, value=interval (seconds).
318+
# AvailTypeId must be of form AvailTypeSet~AvailTypeName
319+
#
320+
# @param callback [Block] callback that is run after the operation is done
321+
def update_collection_intervals(hash, &callback)
322+
required = [:resourcePath, :metricTypes, :availTypes]
323+
check_pre_conditions hash, required, &callback
324+
invoke_specific_operation(hash, 'UpdateCollectionIntervals', &callback)
325+
end
326+
311327
private
312328

313329
def invoke_operation_helper(operation_payload, operation_name = nil, binary_content = nil, &callback)

spec/integration/operations_spec.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,36 @@ module Hawkular::Operations::RSpec
555555
expect(actual_data['message']).to start_with('Performed [Export JDR] on')
556556
expect(actual_data['fileName']).to start_with('jdr_')
557557
end
558+
559+
it 'Update collection intervals should be performed and eventually respond with success' do
560+
wf_server_resource_id = 'Local~~'
561+
wf_agent_id = 'Local~%2Fsubsystem%3Dhawkular-wildfly-agent'
562+
path = CanonicalPath.new(tenant_id: @tenant_id,
563+
feed_id: @feed_id,
564+
resource_ids: [wf_server_resource_id, wf_agent_id])
565+
566+
hash = {
567+
resourcePath: path.to_s,
568+
metricTypes: { 'WildFly Memory Metrics~Heap Max' => 77, 'Unknown~Metric' => 666 },
569+
availTypes: { 'Server Availability~Server Availability' => 77, 'Unknown~Avail' => 666 }
570+
}
571+
572+
actual_data = {}
573+
client.update_collection_intervals(hash) do |on|
574+
on.success do |data|
575+
actual_data[:data] = data
576+
end
577+
on.failure do |error|
578+
actual_data[:data] = error
579+
puts 'error callback was called, reason: ' + error.to_s unless @agent_immutable
580+
end
581+
end
582+
actual_data = wait_for actual_data
583+
expect(actual_data['status']).to eq('OK') unless @agent_immutable
584+
expect(
585+
actual_data['message']).to start_with('Performed [Update Collection Intervals] on') unless @agent_immutable
586+
expect(actual_data).to include('Command not allowed because the agent is immutable') if @agent_immutable
587+
end
558588
end
559589
end
560590
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
[
3+
{
4+
"operation": "read",
5+
"type": "text",
6+
"data": "WelcomeResponse={\"sessionId\":\"xlrBtN7CfOPEFbAFsCzgn3p7wq2Ykf7OEFqPmP-F\"}"
7+
},
8+
{
9+
"operation": "write",
10+
"data": "UpdateCollectionIntervalsRequest={\"resourcePath\":\"/t;<%= tenant_id %>/f;<%= feed_id %>/r;Local~~/r;Local~%2Fsubsystem%3D<%= tenant_id %>-wildfly-agent\",\"metricTypes\":{\"WildFly Memory Metrics~Heap Max\":77,\"Unknown~Metric\":666},\"availTypes\":{\"Server Availability~Server Availability\":77,\"Unknown~Avail\":666},\"authentication\":{\"username\":\"jdoe\",\"password\":\"password\"}}"
11+
},
12+
{
13+
"operation": "read",
14+
"type": "text",
15+
"data": "GenericSuccessResponse={\"message\":\"The request has been forwarded to feed [<%= feed_id %>] (MessageId=ID:cdfef562-f793-11e6-9448-dbddd5ca48d1)\"}"
16+
},
17+
{
18+
"operation": "read",
19+
"type": "text",
20+
"data": "UpdateCollectionIntervalsResponse={\"resourcePath\":\"/t;<%= tenant_id %>/f;<%= feed_id %>/r;Local~~/r;Local~%2Fsubsystem%3D<%= tenant_id %>-wildfly-agent\",\"destinationSessionId\":\"xlrBtN7CfOPEFbAFsCzgn3p7wq2Ykf7OEFqPmP-F\",\"status\":\"OK\",\"message\":\"Performed [Update Collection Intervals] on a [DMR Nodes] given by Inventory path [/t;<%= tenant_id %>/f;<%= feed_id %>/r;Local~~/r;Local~%2Fsubsystem%3D<%= tenant_id %>-wildfly-agent]\"}"
21+
}
22+
]
23+
]

0 commit comments

Comments
 (0)