1616package org .jboss .hal .op .task ;
1717
1818import java .util .EnumSet ;
19- import java .util .Set ;
2019
2120import org .jboss .elemento .logger .Logger ;
21+ import org .jboss .hal .dmr .ModelNode ;
2222import org .jboss .hal .dmr .Operation ;
2323import org .jboss .hal .dmr .Property ;
2424import org .jboss .hal .dmr .dispatch .Dispatcher ;
3030
3131import elemental2 .promise .Promise ;
3232
33- import static java .util .Collections .emptySet ;
3433import static java .util .Collections .singleton ;
35- import static java .util .stream .Collectors .toSet ;
3634import static org .jboss .hal .dmr .ModelDescriptionConstants .ATTRIBUTES_ONLY ;
3735import static org .jboss .hal .dmr .ModelDescriptionConstants .INCLUDE_RUNTIME ;
3836import static org .jboss .hal .dmr .ModelDescriptionConstants .READ_RESOURCE_OPERATION ;
@@ -52,31 +50,30 @@ class FindStatisticsEnabledAttributes {
5250
5351 void find (AddressTemplate root ) {
5452 TraverseContinuation continuation = new TraverseContinuation ();
55- TraverseOperation <Set < String > > readAttributes = (template , context ) -> {
53+ TraverseOperation <ModelNode > readAttributes = (template , context ) -> {
5654 if (template .fullyQualified ()) {
5755 return dispatcher .execute (new Operation .Builder (template .resolve (context ), READ_RESOURCE_OPERATION )
5856 .param (ATTRIBUTES_ONLY , true )
5957 .param (INCLUDE_RUNTIME , true )
6058 .build ())
61- .then (result -> {
62- Set <String > collect = result .asPropertyList ().stream ()
63- .map (Property ::getName )
64- .collect (toSet ());
65- return Promise .resolve (collect );
66- })
59+ .then (result -> Promise .resolve (result .asPropertyList ().stream ()
60+ .filter (property -> STATISTICS_ENABLED .equals (property .getName ()))
61+ .map (Property ::getValue )
62+ .findFirst ()
63+ .orElse (new ModelNode ())))
6764 .catch_ (error -> {
6865 logger .error ("Failed to read attributes of %s: %s" , template , error );
69- return Promise .resolve (emptySet ());
66+ return Promise .resolve (new ModelNode ());
7067 });
7168 } else {
72- return Promise .resolve (emptySet ());
69+ return Promise .resolve (new ModelNode ());
7370 }
7471 };
7572 modelTree .traverse (continuation , root , singleton ("/core-service" ),
7673 EnumSet .noneOf (TraverseType .class ), readAttributes ,
77- (template , attributes , context ) -> {
78- if (template .fullyQualified () && attributes . contains ( STATISTICS_ENABLED )) {
79- logger .info ("Found statistics enabled attribute for %s" , template );
74+ (template , statisticsEnabled , context ) -> {
75+ if (template .fullyQualified () && statisticsEnabled . isDefined ( )) {
76+ logger .info ("Found statistics enabled attribute for %s: %s " , template , statisticsEnabled . asString () );
8077 }
8178 })
8279 .then (context -> {
0 commit comments