Github user aledsage commented on a diff in the pull request:
https://github.com/apache/incubator-brooklyn/pull/650#discussion_r30615641
--- Diff:
core/src/main/java/brooklyn/event/feed/windows/WindowsPerformanceCounterFeed.java
---
@@ -251,10 +258,71 @@ public T call() throws Exception {
}
}
+ private static class SendPerfCountersToSensors implements
PollHandler<WinRmToolResponse> {
+
+ private final EntityLocal entity;
+ private final List<WindowsPerformanceCounterPollConfig<?>> polls;
+
+ public SendPerfCountersToSensors(EntityLocal entity,
List<WindowsPerformanceCounterPollConfig<?>> polls) {
+ this.entity = entity;
+ this.polls = polls;
+ }
+
+ @Override
+ public boolean checkSuccess(WinRmToolResponse val) {
+ if (val.getStatusCode() != 0) return false;
+ String stderr = val.getStdErr();
+ if (stderr == null || stderr.length() != 0) return false;
+ String out = val.getStdOut();
+ if (out == null || out.length() == 0) return false;
+ return true;
+ }
+
+ @Override
+ public void onSuccess(WinRmToolResponse val) {
+ String[] values = val.getStdOut().split("\r\n");
+ for (int i = 0; i < polls.size(); i++) {
+ Class<?> clazz = polls.get(i).getSensor().getType();
+ Maybe<? extends Object> maybeValue =
TypeCoercions.tryCoerce(values[i], TypeToken.of(clazz));
--- End diff --
Does use of `tryCoerce` mean that we'll ignore it if the returned value was
of an unexpected format? Would seem good to log at least once to say that (e.g.
if get "1.2" when we expect an integer, then we should log that somewhere
sensible).
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---