move WindowsPerformanceCounterSensors to o.a.b.core.sensor.windows - Was previously in software-base, in o.a.b.sensor.winrm. - Renamed to .windows to be consistent with .feed.windows - Moved to core to be consistent with .sensor.ssh and .sensor.http
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/e7420b1e Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/e7420b1e Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/e7420b1e Branch: refs/heads/master Commit: e7420b1e4194cbe597a9d467bddc1a197804af50 Parents: 1dde632 Author: Aled Sage <[email protected]> Authored: Thu Aug 20 11:32:42 2015 +0100 Committer: Aled Sage <[email protected]> Committed: Thu Aug 20 11:32:42 2015 +0100 ---------------------------------------------------------------------- .../WindowsPerformanceCounterSensors.java | 73 ++++++++++++++++++++ .../winrm/WindowsPerformanceCounterSensors.java | 73 -------------------- 2 files changed, 73 insertions(+), 73 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e7420b1e/core/src/main/java/org/apache/brooklyn/core/sensor/windows/WindowsPerformanceCounterSensors.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/brooklyn/core/sensor/windows/WindowsPerformanceCounterSensors.java b/core/src/main/java/org/apache/brooklyn/core/sensor/windows/WindowsPerformanceCounterSensors.java new file mode 100644 index 0000000..f5c2271 --- /dev/null +++ b/core/src/main/java/org/apache/brooklyn/core/sensor/windows/WindowsPerformanceCounterSensors.java @@ -0,0 +1,73 @@ +/* + * 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.core.sensor.windows; + +import java.util.Map; +import java.util.Set; + +import org.apache.brooklyn.api.entity.EntityInitializer; +import org.apache.brooklyn.api.entity.EntityLocal; +import org.apache.brooklyn.config.ConfigKey; +import org.apache.brooklyn.core.config.ConfigKeys; +import org.apache.brooklyn.core.entity.EntityInternal; +import org.apache.brooklyn.core.sensor.Sensors; +import org.apache.brooklyn.feed.windows.WindowsPerformanceCounterFeed; +import org.apache.brooklyn.util.core.config.ConfigBag; +import org.apache.brooklyn.util.text.Strings; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.reflect.TypeToken; + +public class WindowsPerformanceCounterSensors implements EntityInitializer { + + private static final Logger LOG = LoggerFactory.getLogger(WindowsPerformanceCounterSensors.class); + + public final static ConfigKey<Set<Map<String, String>>> PERFORMANCE_COUNTERS = ConfigKeys.newConfigKey(new TypeToken<Set<Map<String, String>>>(){}, "performance.counters"); + + protected final Set<Map<String, String>> sensors; + + public WindowsPerformanceCounterSensors(ConfigBag params) { + sensors = params.get(PERFORMANCE_COUNTERS); + } + + public WindowsPerformanceCounterSensors(Map<String, String> params) { + this(ConfigBag.newInstance(params)); + } + + @Override + public void apply(EntityLocal entity) { + WindowsPerformanceCounterFeed.Builder builder = WindowsPerformanceCounterFeed.builder() + .entity(entity); + for (Map<String, String> sensorConfig : sensors) { + String name = sensorConfig.get("name"); + String sensorType = sensorConfig.get("sensorType"); + Class<?> clazz; + try { + clazz = Strings.isNonEmpty(sensorType) + ? ((EntityInternal)entity).getManagementContext().getCatalog().getRootClassLoader().loadClass(sensorType) + : String.class; + } catch (ClassNotFoundException e) { + throw new IllegalStateException("Could not load type "+sensorType+" for sensor "+name, e); + } + builder.addSensor(sensorConfig.get("counter"), Sensors.newSensor(clazz, name, sensorConfig.get("description"))); + } + builder.build(); + } +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e7420b1e/software/base/src/main/java/org/apache/brooklyn/sensor/winrm/WindowsPerformanceCounterSensors.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/org/apache/brooklyn/sensor/winrm/WindowsPerformanceCounterSensors.java b/software/base/src/main/java/org/apache/brooklyn/sensor/winrm/WindowsPerformanceCounterSensors.java deleted file mode 100644 index 3e0e4c6..0000000 --- a/software/base/src/main/java/org/apache/brooklyn/sensor/winrm/WindowsPerformanceCounterSensors.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.sensor.winrm; - -import java.util.Map; -import java.util.Set; - -import org.apache.brooklyn.api.entity.EntityInitializer; -import org.apache.brooklyn.api.entity.EntityLocal; -import org.apache.brooklyn.config.ConfigKey; -import org.apache.brooklyn.core.config.ConfigKeys; -import org.apache.brooklyn.core.entity.EntityInternal; -import org.apache.brooklyn.core.sensor.Sensors; -import org.apache.brooklyn.feed.windows.WindowsPerformanceCounterFeed; -import org.apache.brooklyn.util.core.config.ConfigBag; -import org.apache.brooklyn.util.text.Strings; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.common.reflect.TypeToken; - -public class WindowsPerformanceCounterSensors implements EntityInitializer { - - private static final Logger LOG = LoggerFactory.getLogger(WindowsPerformanceCounterSensors.class); - - public final static ConfigKey<Set<Map<String, String>>> PERFORMANCE_COUNTERS = ConfigKeys.newConfigKey(new TypeToken<Set<Map<String, String>>>(){}, "performance.counters"); - - protected final Set<Map<String, String>> sensors; - - public WindowsPerformanceCounterSensors(ConfigBag params) { - sensors = params.get(PERFORMANCE_COUNTERS); - } - - public WindowsPerformanceCounterSensors(Map<String, String> params) { - this(ConfigBag.newInstance(params)); - } - - @Override - public void apply(EntityLocal entity) { - WindowsPerformanceCounterFeed.Builder builder = WindowsPerformanceCounterFeed.builder() - .entity(entity); - for (Map<String, String> sensorConfig : sensors) { - String name = sensorConfig.get("name"); - String sensorType = sensorConfig.get("sensorType"); - Class<?> clazz; - try { - clazz = Strings.isNonEmpty(sensorType) - ? ((EntityInternal)entity).getManagementContext().getCatalog().getRootClassLoader().loadClass(sensorType) - : String.class; - } catch (ClassNotFoundException e) { - throw new IllegalStateException("Could not load type "+sensorType+" for sensor "+name, e); - } - builder.addSensor(sensorConfig.get("counter"), Sensors.newSensor(clazz, name, sensorConfig.get("description"))); - } - builder.build(); - } -}
