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:54 UTC

[1/4] brooklyn-server git commit: [BROOKLYN-516] Persist feed of WindowsPerformanceCounterSensors initializer

Repository: brooklyn-server
Updated Branches:
  refs/heads/master 42f1a5d82 -> 2a94137b7


[BROOKLYN-516] Persist feed of WindowsPerformanceCounterSensors initializer


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/b8a0fb59
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/b8a0fb59
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/b8a0fb59

Branch: refs/heads/master
Commit: b8a0fb59893f605d8ef20ce6e92d3de7f4a75f73
Parents: 381b7e6
Author: Valentin Aitken <bo...@gmail.com>
Authored: Thu Jun 8 13:00:07 2017 +0300
Committer: Valentin Aitken <bo...@gmail.com>
Committed: Thu Jun 8 13:00:07 2017 +0300

----------------------------------------------------------------------
 .../core/sensor/windows/WindowsPerformanceCounterSensors.java      | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b8a0fb59/software/winrm/src/main/java/org/apache/brooklyn/core/sensor/windows/WindowsPerformanceCounterSensors.java
----------------------------------------------------------------------
diff --git a/software/winrm/src/main/java/org/apache/brooklyn/core/sensor/windows/WindowsPerformanceCounterSensors.java b/software/winrm/src/main/java/org/apache/brooklyn/core/sensor/windows/WindowsPerformanceCounterSensors.java
index 20f04db..9f9e94d 100644
--- a/software/winrm/src/main/java/org/apache/brooklyn/core/sensor/windows/WindowsPerformanceCounterSensors.java
+++ b/software/winrm/src/main/java/org/apache/brooklyn/core/sensor/windows/WindowsPerformanceCounterSensors.java
@@ -83,6 +83,6 @@ public class WindowsPerformanceCounterSensors implements EntityInitializer {
             }
             builder.addSensor(sensorConfig.get("counter"), Sensors.newSensor(clazz, name, sensorConfig.get("description")));
         }
-        builder.build();
+        entity.addFeed(builder.build());
     }
 }


[4/4] brooklyn-server git commit: This closes #724

Posted by dr...@apache.org.
This closes #724


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/2a94137b
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/2a94137b
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/2a94137b

Branch: refs/heads/master
Commit: 2a94137b71a432f6396e21700da27ac758fff7c7
Parents: 42f1a5d c526b30
Author: Duncan Godwin <dr...@googlemail.com>
Authored: Thu Jun 8 14:41:45 2017 +0100
Committer: Duncan Godwin <dr...@googlemail.com>
Committed: Thu Jun 8 14:41:45 2017 +0100

----------------------------------------------------------------------
 .../WindowsPerformanceCounterSensors.java       |  2 +-
 .../windows/WindowsPerformanceCounterFeed.java  | 13 ++++-
 ...RebindWindowsPerformanceCounterFeedTest.java | 38 ++++++++++++
 .../feed/windows/RebindWinrmCmdFeedTest.java    |  4 +-
 ...-counter-feed-no-bundle-prefixies-ueauyeu41d | 61 ++++++++++++++++++++
 .../windows-performance-counter-feed-tu4kk0xvf8 | 61 ++++++++++++++++++++
 6 files changed, 174 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[2/4] brooklyn-server git commit: WindowsPerformanceCounterFeed$GetPerformanceCountersJob do not throw exception when no machine is found.

Posted by dr...@apache.org.
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) {


[3/4] brooklyn-server git commit: Test rebind WindowsPerformanceCounterFeed

Posted by dr...@apache.org.
Test rebind WindowsPerformanceCounterFeed


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/c526b308
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/c526b308
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/c526b308

Branch: refs/heads/master
Commit: c526b308dd04d58cafc9c584a5d941163995000a
Parents: 4905f3a
Author: Valentin Aitken <bo...@gmail.com>
Authored: Thu Jun 8 13:14:55 2017 +0300
Committer: Valentin Aitken <bo...@gmail.com>
Committed: Thu Jun 8 13:20:08 2017 +0300

----------------------------------------------------------------------
 ...RebindWindowsPerformanceCounterFeedTest.java | 38 ++++++++++++
 .../feed/windows/RebindWinrmCmdFeedTest.java    |  4 +-
 ...-counter-feed-no-bundle-prefixies-ueauyeu41d | 61 ++++++++++++++++++++
 .../windows-performance-counter-feed-tu4kk0xvf8 | 61 ++++++++++++++++++++
 4 files changed, 162 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c526b308/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWindowsPerformanceCounterFeedTest.java
----------------------------------------------------------------------
diff --git a/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWindowsPerformanceCounterFeedTest.java b/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWindowsPerformanceCounterFeedTest.java
new file mode 100644
index 0000000..9549fd5
--- /dev/null
+++ b/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWindowsPerformanceCounterFeedTest.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.brooklyn.feed.windows;
+
+import org.apache.brooklyn.api.objs.BrooklynObjectType;
+import org.apache.brooklyn.core.mgmt.rebind.RebindAbstractCommandFeedTest;
+import org.testng.annotations.Test;
+
+public class RebindWindowsPerformanceCounterFeedTest extends RebindAbstractCommandFeedTest {
+
+    @Test
+    public void testWindowsPerformanceCounterFeed_2017_06() throws Exception {
+        addMemento(BrooklynObjectType.FEED, "windows-performance-counter-feed", "tu4kk0xvf8");
+        rebind();
+    }
+
+    @Test
+    public void testWindowsPerformanceCounterFeed_2017_06_withoutBundlePrefixes() throws Exception {
+        addMemento(BrooklynObjectType.FEED, "windows-performance-counter-feed-no-bundle-prefixies", "ueauyeu41d");
+        rebind();
+    }
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c526b308/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWinrmCmdFeedTest.java
----------------------------------------------------------------------
diff --git a/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWinrmCmdFeedTest.java b/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWinrmCmdFeedTest.java
index cb63b39..70aed9b 100644
--- a/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWinrmCmdFeedTest.java
+++ b/software/winrm/src/test/java/org/apache/brooklyn/feed/windows/RebindWinrmCmdFeedTest.java
@@ -25,13 +25,13 @@ import org.testng.annotations.Test;
 public class RebindWinrmCmdFeedTest extends RebindAbstractCommandFeedTest {
 
     @Test
-    public void testSshFeed_2017_04() throws Exception {
+    public void testWinrmCmdFeed_2017_04() throws Exception {
         addMemento(BrooklynObjectType.FEED, "winrm-cmd-feed", "a8pno3muco");
         rebind();
     }
 
     @Test
-    public void testSshFeed_2017_04_withoutBundlePrefixes() throws Exception {
+    public void testWinrmCmdFeed_2017_04_withoutBundlePrefixes() throws Exception {
         addMemento(BrooklynObjectType.FEED, "winrm-cmd-feed-no-bundle-prefixes", "akc24nlh2k");
         rebind();
     }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c526b308/software/winrm/src/test/resources/org/apache/brooklyn/feed/windows/windows-performance-counter-feed-no-bundle-prefixies-ueauyeu41d
----------------------------------------------------------------------
diff --git a/software/winrm/src/test/resources/org/apache/brooklyn/feed/windows/windows-performance-counter-feed-no-bundle-prefixies-ueauyeu41d b/software/winrm/src/test/resources/org/apache/brooklyn/feed/windows/windows-performance-counter-feed-no-bundle-prefixies-ueauyeu41d
new file mode 100644
index 0000000..ceed339
--- /dev/null
+++ b/software/winrm/src/test/resources/org/apache/brooklyn/feed/windows/windows-performance-counter-feed-no-bundle-prefixies-ueauyeu41d
@@ -0,0 +1,61 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<feed>
+  <brooklynVersion>0.12.0-SNAPSHOT</brooklynVersion>
+  <type>org.apache.brooklyn.feed.windows.WindowsPerformanceCounterFeed</type>
+  <id>ueauyeu41d</id>
+  <displayName>org.apache.brooklyn.feed.windows.WindowsPerformanceCounterFeed</displayName>
+  <searchPath class="ImmutableList"/>
+  <tags>
+    <string>WindowsPerformanceCounterFeed[WindowsPerformanceCounterPollConfig[\Processor Information(_total....../f3c25627</string>
+  </tags>
+  <uniqueTag>WindowsPerformanceCounterFeed[WindowsPerformanceCounterPollConfig[\Processor Information(_total....../f3c25627</uniqueTag>
+  <config>
+    <polls>
+      <list>
+        <org.apache.brooklyn.feed.windows.WindowsPerformanceCounterPollConfig>
+          <sensor class="attributeSensor">
+            <type>java.lang.String</type>
+            <name>percent.processor.time</name>
+            <description>% Processor Time</description>
+            <persistence>REQUIRED</persistence>
+          </sensor>
+          <onsuccess class="com.google.common.base.Functions$IdentityFunction">INSTANCE</onsuccess>
+          <suppressDuplicates>false</suppressDuplicates>
+          <enabled>true</enabled>
+          <period>30000</period>
+          <performanceCounterName>\Processor Information(_total)\% Processor Time</performanceCounterName>
+        </org.apache.brooklyn.feed.windows.WindowsPerformanceCounterPollConfig>
+        <org.apache.brooklyn.feed.windows.WindowsPerformanceCounterPollConfig>
+          <sensor class="attributeSensor">
+            <type>java.lang.String</type>
+            <name>bytes.available</name>
+            <description>Bytes Available</description>
+            <persistence>REQUIRED</persistence>
+          </sensor>
+          <onsuccess class="com.google.common.base.Functions$IdentityFunction">INSTANCE</onsuccess>
+          <suppressDuplicates>false</suppressDuplicates>
+          <enabled>true</enabled>
+          <period>30000</period>
+          <performanceCounterName>\Memory\Available Bytes</performanceCounterName>
+        </org.apache.brooklyn.feed.windows.WindowsPerformanceCounterPollConfig>
+      </list>
+    </polls>
+  </config>
+</feed>

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c526b308/software/winrm/src/test/resources/org/apache/brooklyn/feed/windows/windows-performance-counter-feed-tu4kk0xvf8
----------------------------------------------------------------------
diff --git a/software/winrm/src/test/resources/org/apache/brooklyn/feed/windows/windows-performance-counter-feed-tu4kk0xvf8 b/software/winrm/src/test/resources/org/apache/brooklyn/feed/windows/windows-performance-counter-feed-tu4kk0xvf8
new file mode 100644
index 0000000..7811717
--- /dev/null
+++ b/software/winrm/src/test/resources/org/apache/brooklyn/feed/windows/windows-performance-counter-feed-tu4kk0xvf8
@@ -0,0 +1,61 @@
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<feed>
+  <brooklynVersion>0.12.0-SNAPSHOT</brooklynVersion>
+  <type>org.apache.brooklyn.software-winrm:org.apache.brooklyn.feed.windows.WindowsPerformanceCounterFeed</type>
+  <id>tu4kk0xvf8</id>
+  <displayName>org.apache.brooklyn.feed.windows.WindowsPerformanceCounterFeed</displayName>
+  <searchPath class="ImmutableList"/>
+  <tags>
+    <string>WindowsPerformanceCounterFeed[WindowsPerformanceCounterPollConfig[\Processor Information(_total....../f3c25627</string>
+  </tags>
+  <uniqueTag>WindowsPerformanceCounterFeed[WindowsPerformanceCounterPollConfig[\Processor Information(_total....../f3c25627</uniqueTag>
+  <config>
+    <polls>
+      <list>
+        <org.apache.brooklyn.software-winrm:org.apache.brooklyn.feed.windows.WindowsPerformanceCounterPollConfig>
+          <sensor class="attributeSensor">
+            <type>java.lang.String</type>
+            <name>percent.processor.time</name>
+            <description>% Processor Time</description>
+            <persistence>REQUIRED</persistence>
+          </sensor>
+          <onsuccess class="com.google.guava:com.google.common.base.Functions$IdentityFunction">INSTANCE</onsuccess>
+          <suppressDuplicates>false</suppressDuplicates>
+          <enabled>true</enabled>
+          <period>30000</period>
+          <performanceCounterName>\Processor Information(_total)\% Processor Time</performanceCounterName>
+        </org.apache.brooklyn.software-winrm:org.apache.brooklyn.feed.windows.WindowsPerformanceCounterPollConfig>
+        <org.apache.brooklyn.software-winrm:org.apache.brooklyn.feed.windows.WindowsPerformanceCounterPollConfig>
+          <sensor class="attributeSensor">
+            <type>java.lang.String</type>
+            <name>bytes.available</name>
+            <description>Bytes Available</description>
+            <persistence>REQUIRED</persistence>
+          </sensor>
+          <onsuccess class="com.google.guava:com.google.common.base.Functions$IdentityFunction">INSTANCE</onsuccess>
+          <suppressDuplicates>false</suppressDuplicates>
+          <enabled>true</enabled>
+          <period>30000</period>
+          <performanceCounterName>\Memory\Available Bytes</performanceCounterName>
+        </org.apache.brooklyn.software-winrm:org.apache.brooklyn.feed.windows.WindowsPerformanceCounterPollConfig>
+      </list>
+    </polls>
+  </config>
+</feed>