You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by dr...@apache.org on 2017/06/08 13:41:55 UTC
[2/4] brooklyn-server git commit:
WindowsPerformanceCounterFeed$GetPerformanceCountersJob do not throw
exception when no machine is found.
WindowsPerformanceCounterFeed$GetPerformanceCountersJob do not throw exception
when no machine is found.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/4905f3a2
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/4905f3a2
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/4905f3a2
Branch: refs/heads/master
Commit: 4905f3a2b073ffc5bd2c93a5f2ab106be5c6e625
Parents: b8a0fb5
Author: Valentin Aitken <bo...@gmail.com>
Authored: Thu Jun 8 13:01:19 2017 +0300
Committer: Valentin Aitken <bo...@gmail.com>
Committed: Thu Jun 8 13:01:19 2017 +0300
----------------------------------------------------------------------
.../feed/windows/WindowsPerformanceCounterFeed.java | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/4905f3a2/software/winrm/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterFeed.java
----------------------------------------------------------------------
diff --git a/software/winrm/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterFeed.java b/software/winrm/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterFeed.java
index 6f62612..d5d9751 100644
--- a/software/winrm/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterFeed.java
+++ b/software/winrm/src/main/java/org/apache/brooklyn/feed/windows/WindowsPerformanceCounterFeed.java
@@ -44,12 +44,13 @@ import org.apache.brooklyn.core.entity.EntityInternal;
import org.apache.brooklyn.core.feed.AbstractFeed;
import org.apache.brooklyn.core.feed.PollHandler;
import org.apache.brooklyn.core.feed.Poller;
+import org.apache.brooklyn.core.location.Machines;
import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.feed.windows.WindowsPerformanceCounterPollConfig;
import org.apache.brooklyn.location.winrm.WinRmMachineLocation;
import org.apache.brooklyn.util.core.flags.TypeCoercions;
import org.apache.brooklyn.util.core.internal.winrm.WinRmToolResponse;
import org.apache.brooklyn.util.exceptions.Exceptions;
+import org.apache.brooklyn.util.guava.Maybe;
import org.apache.brooklyn.util.time.Duration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -230,6 +231,10 @@ public class WindowsPerformanceCounterFeed extends AbstractFeed {
@Override
@SuppressWarnings("unchecked")
public T call() throws Exception {
+ Maybe<WinRmMachineLocation> machineLocationMaybe = Machines.findUniqueMachineLocation(entity.getLocations(), WinRmMachineLocation.class);
+ if (machineLocationMaybe.isAbsent()) {
+ return null;
+ }
WinRmMachineLocation machine = EffectorTasks.getMachine(entity, WinRmMachineLocation.class);
WinRmToolResponse response = machine.executePsScript(command);
return (T)response;
@@ -282,7 +287,7 @@ public class WindowsPerformanceCounterFeed extends AbstractFeed {
// TODO not just using statusCode; also looking at absence of stderr.
// Status code is (empirically) unreliable: it returns 0 sometimes even when failed
// (but never returns non-zero on success).
- if (val.getStatusCode() != 0) return false;
+ if (val == null || val.getStatusCode() != 0) return false;
String stderr = val.getStdErr();
if (stderr == null || stderr.length() != 0) return false;
String out = val.getStdOut();
@@ -323,6 +328,10 @@ public class WindowsPerformanceCounterFeed extends AbstractFeed {
@Override
public void onFailure(WinRmToolResponse val) {
+ if (val == null) {
+ log.trace("Windows Performance Counter not executed since there is still now WinRmMachineLocation");
+ return;
+ }
log.error("Windows Performance Counter query did not respond as expected. exitcode={} stdout={} stderr={}",
new Object[]{val.getStatusCode(), val.getStdOut(), val.getStdErr()});
for (WindowsPerformanceCounterPollConfig<?> config : polls) {