You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:47:38 UTC
[02/51] [abbrv] [partial] brooklyn-library git commit: move subdir
from incubator up a level as it is promoted to its own repo (first
non-incubator commit!)
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainer.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainer.java b/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainer.java
deleted file mode 100644
index e605c08..0000000
--- a/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainer.java
+++ /dev/null
@@ -1,137 +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.entity.osgi.karaf;
-
-import java.net.URISyntaxException;
-import java.util.Map;
-
-import org.apache.brooklyn.api.catalog.Catalog;
-import org.apache.brooklyn.api.entity.ImplementedBy;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.annotation.Effector;
-import org.apache.brooklyn.core.annotation.EffectorParam;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.config.MapConfigKey;
-import org.apache.brooklyn.core.effector.MethodEffector;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensor;
-import org.apache.brooklyn.core.sensor.BasicAttributeSensorAndConfigKey;
-import org.apache.brooklyn.core.sensor.PortAttributeSensorAndConfigKey;
-import org.apache.brooklyn.entity.java.UsesJava;
-import org.apache.brooklyn.entity.java.UsesJmx;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-
-/**
- * This sets up a Karaf OSGi container
- */
-@Catalog(name="Karaf", description="Apache Karaf is a small OSGi based runtime which provides a lightweight container onto which various components and applications can be deployed.", iconUrl="classpath:///karaf-logo.png")
-@ImplementedBy(KarafContainerImpl.class)
-public interface KarafContainer extends SoftwareProcess, UsesJava, UsesJmx {
-
- // TODO Better way of setting/overriding defaults for config keys that are defined in super class SoftwareProcess
-
- public static final String WRAP_SCHEME = "wrap";
- public static final String FILE_SCHEME = "file";
- public static final String MVN_SCHEME = "mvn";
- public static final String HTTP_SCHEME = "http";
-
- public static final MethodEffector<Map<Long,Map<String,?>>> LIST_BUNDLES = new MethodEffector(KarafContainer.class, "listBundles");
- public static final MethodEffector<Long> INSTALL_BUNDLE = new MethodEffector<Long>(KarafContainer.class, "installBundle");
- public static final MethodEffector<Void> UNINSTALL_BUNDLE = new MethodEffector<Void>(KarafContainer.class, "uninstallBundle");
- public static final MethodEffector<Void> INSTALL_FEATURE = new MethodEffector<Void>(KarafContainer.class, "installFeature");
- public static final MethodEffector<Void> UPDATE_SERVICE_PROPERTIES = new MethodEffector<Void>(KarafContainer.class, "updateServiceProperties");
-
- @SetFromFlag("version")
- public static final ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(
- SoftwareProcess.SUGGESTED_VERSION, "2.3.0");
-
- @SetFromFlag("downloadUrl")
- public static final BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = new BasicAttributeSensorAndConfigKey<String>(
- SoftwareProcess.DOWNLOAD_URL, "http://apache.mirror.anlx.net/karaf/${version}/apache-karaf-${version}.tar.gz");
-
- @SetFromFlag("karafName")
- public static final BasicAttributeSensorAndConfigKey<String> KARAF_NAME = new BasicAttributeSensorAndConfigKey<String>(
- String.class, "karaf.name", "Karaf instance name", "root");
-
- // TODO too complicated? Used by KarafContainer; was in JavaApp; where should it be in brave new world?
- public static final MapConfigKey<Map<String,String>> NAMED_PROPERTY_FILES = new MapConfigKey(
- Map.class, "karaf.runtime.files", "Property files to be generated, referenced by name relative to runDir");
-
- @SetFromFlag("jmxUser")
- public static final BasicAttributeSensorAndConfigKey<String> JMX_USER = new BasicAttributeSensorAndConfigKey<String>(
- UsesJmx.JMX_USER, "karaf");
-
- @SetFromFlag("jmxPassword")
- public static final BasicAttributeSensorAndConfigKey<String> JMX_PASSWORD = new BasicAttributeSensorAndConfigKey<String>(
- UsesJmx.JMX_PASSWORD, "karaf");
-
- @SetFromFlag("jmxPort")
- public static final PortAttributeSensorAndConfigKey JMX_PORT = new PortAttributeSensorAndConfigKey(
- UsesJmx.JMX_PORT, "44444+");
-
- @SetFromFlag("rmiRegistryPort")
- public static final PortAttributeSensorAndConfigKey RMI_REGISTRY_PORT = UsesJmx.RMI_REGISTRY_PORT;
-
- @SetFromFlag("jmxContext")
- public static final BasicAttributeSensorAndConfigKey<String> JMX_CONTEXT = new BasicAttributeSensorAndConfigKey<String>(
- UsesJmx.JMX_CONTEXT, "karaf-"+KARAF_NAME.getConfigKey().getDefaultValue());
-
- public static final BasicAttributeSensor<Map> KARAF_INSTANCES = new BasicAttributeSensor<Map>(
- Map.class, "karaf.admin.instances", "Karaf admin instances");
- public static final BasicAttributeSensor<Boolean> KARAF_ROOT = new BasicAttributeSensor<Boolean>(
- Boolean.class, "karaf.admin.isRoot", "Karaf admin isRoot");
- public static final BasicAttributeSensor<String> KARAF_JAVA_OPTS = new BasicAttributeSensor<String>(
- String.class, "karaf.admin.java_opts", "Karaf Java opts");
- public static final BasicAttributeSensor<String> KARAF_INSTALL_LOCATION = new BasicAttributeSensor<String>(
- String.class, "karaf.admin.location", "Karaf install location");
- public static final BasicAttributeSensor<Integer> KARAF_PID = new BasicAttributeSensor<Integer>(
- Integer.class, "karaf.admin.pid", "Karaf instance PID");
- public static final BasicAttributeSensor<Integer> KARAF_SSH_PORT = new BasicAttributeSensor<Integer>(
- Integer.class, "karaf.admin.ssh_port", "Karaf SSH Port");
- public static final BasicAttributeSensor<Integer> KARAF_RMI_REGISTRY_PORT = new BasicAttributeSensor<Integer>(
- Integer.class, "karaf.admin.rmi_registry_port", "Karaf instance RMI registry port");
- public static final BasicAttributeSensor<Integer> KARAF_RMI_SERVER_PORT = new BasicAttributeSensor<Integer>(
- Integer.class, "karaf.admin.rmi_server_port", "Karaf RMI (JMX) server port");
- public static final BasicAttributeSensor<String> KARAF_STATE = new BasicAttributeSensor<String>(
- String.class, "karaf.admin.state", "Karaf instance state");
-
- @Effector(description="Updates the OSGi Service's properties, adding (and overriding) the given key-value pairs")
- public void updateServiceProperties(
- @EffectorParam(name="serviceName", description="Name of the OSGi service") String serviceName,
- Map<String,String> additionalVals);
-
- @Effector(description="Installs the given OSGi feature")
- public void installFeature(
- @EffectorParam(name="featureName", description="Name of the feature - see org.apache.karaf:type=features#installFeature()") final String featureName)
- throws Exception;
-
- @Effector(description="Lists all the karaf bundles")
- public Map<Long,Map<String,?>> listBundles();
-
- /**
- * throws URISyntaxException If bundle name is not a valid URI
- */
- @Effector(description="Deploys the given bundle, returning the bundle id - see osgi.core:type=framework#installBundle()")
- public long installBundle(
- @EffectorParam(name="bundle", description="URI of bundle to be deployed") String bundle) throws URISyntaxException;
-
- @Effector(description="Undeploys the bundle with the given id")
- public void uninstallBundle(
- @EffectorParam(name="bundleId", description="Id of the bundle") Long bundleId);
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerImpl.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerImpl.java b/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerImpl.java
deleted file mode 100644
index 92e5b2f..0000000
--- a/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerImpl.java
+++ /dev/null
@@ -1,297 +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.entity.osgi.karaf;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-
-import javax.management.ObjectName;
-import javax.management.openmbean.CompositeData;
-import javax.management.openmbean.CompositeDataSupport;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.TabularData;
-
-import org.apache.brooklyn.api.sensor.SensorEvent;
-import org.apache.brooklyn.api.sensor.SensorEventListener;
-import org.apache.brooklyn.core.annotation.Effector;
-import org.apache.brooklyn.core.annotation.EffectorParam;
-import org.apache.brooklyn.core.feed.ConfigToAttributes;
-import org.apache.brooklyn.entity.java.JmxSupport;
-import org.apache.brooklyn.entity.software.base.SoftwareProcessImpl;
-import org.apache.brooklyn.feed.jmx.JmxAttributePollConfig;
-import org.apache.brooklyn.feed.jmx.JmxFeed;
-import org.apache.brooklyn.feed.jmx.JmxHelper;
-import org.apache.brooklyn.feed.jmx.JmxValueFunctions;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.os.Os;
-import org.apache.brooklyn.util.repeat.Repeater;
-import org.osgi.jmx.JmxConstants;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.base.Function;
-import com.google.common.collect.Maps;
-
-/**
- * This sets up a Karaf OSGi container
- */
-public class KarafContainerImpl extends SoftwareProcessImpl implements KarafContainer {
-
- // TODO Better way of setting/overriding defaults for config keys that are defined in super class SoftwareProcess
-
- private static final Logger LOG = LoggerFactory.getLogger(KarafContainerImpl.class);
-
- public static final String KARAF_ADMIN = "org.apache.karaf:type=admin,name=%s";
- public static final String KARAF_FEATURES = "org.apache.karaf:type=features,name=%s";
-
- public static final String OSGI_BUNDLE_STATE = "osgi.core:type=bundleState,version=1.5";
- public static final String OSGI_FRAMEWORK = "osgi.core:type=framework,version=1.5";
- public static final String OSGI_COMPENDIUM = "osgi.compendium:service=cm,version=1.3";
-
- protected JmxHelper jmxHelper;
-
- private JmxFeed jmxFeed;
-
- public KarafContainerImpl() {
- super();
- }
-
- @Override
- public Class<KarafDriver> getDriverInterface() {
- return KarafDriver.class;
- }
-
- @Override
- public KarafDriver getDriver() {
- return (KarafDriver) super.getDriver();
- }
-
- @Override
- public void init() {
- super.init();
- new JmxSupport(this, null).recommendJmxRmiCustomAgent();
- }
-
- @Override
- protected void postDriverStart() {
- super.postDriverStart();
- uploadPropertyFiles(getConfig(NAMED_PROPERTY_FILES));
-
- jmxHelper = new JmxHelper(this);
- jmxHelper.connect(0); // i.e. don't block
- }
-
- @Override
- protected void connectSensors() {
- super.connectSensors();
-
- //FIXME should have a better way of setting config -- firstly, not here!
- //preferred style is to have config auto-applied to attributes, and have default values in their definition, not here
- //use of "properties.{user,password}" is non-standard; is that requried? use default jmxUser, jmxPassword flags?
- sensors().set(JMX_CONTEXT, String.format("karaf-%s", getConfig(KARAF_NAME.getConfigKey())));
-
- ConfigToAttributes.apply(this);
-
- ObjectName karafAdminObjectName = JmxHelper.createObjectName(String.format(KARAF_ADMIN, getConfig(KARAF_NAME.getConfigKey())));
-
- jmxFeed = JmxFeed.builder()
- .entity(this)
- .helper(jmxHelper)
- .period(500, TimeUnit.MILLISECONDS)
- .pollAttribute(new JmxAttributePollConfig<Map>(KARAF_INSTANCES)
- .objectName(karafAdminObjectName)
- .attributeName("Instances")
- .onSuccess(new Function<Object, Map>() {
- @Override
- public Map apply(Object input) {
- return JmxValueFunctions.tabularDataToMap((TabularData)input);
- }
- })
- .onException(new Function<Exception,Map>() {
- @Override public Map apply(Exception input) {
- // If MBean is unreachable, then mark as service-down
- if (Boolean.TRUE.equals(getAttribute(SERVICE_UP))) {
- LOG.debug("Entity "+this+" is not reachable on JMX");
- sensors().set(SERVICE_UP, false);
- }
- return null;
- }}))
- .build();
-
-
-
- // INSTANCES aggregates data for the other sensors.
- subscriptions().subscribe(this, KARAF_INSTANCES, new SensorEventListener<Map>() {
- @Override public void onEvent(SensorEvent<Map> event) {
- Map<?,?> map = event.getValue();
- if (map == null) return;
-
- sensors().set(SERVICE_UP, "Started".equals(map.get("State")));
- sensors().set(KARAF_ROOT, (Boolean) map.get("Is Root"));
- sensors().set(KARAF_JAVA_OPTS, (String) map.get("JavaOpts"));
- sensors().set(KARAF_INSTALL_LOCATION, (String) map.get("Location"));
- sensors().set(KARAF_NAME, (String) map.get("Name"));
- sensors().set(KARAF_PID, (Integer) map.get("Pid"));
- sensors().set(KARAF_SSH_PORT, (Integer) map.get("Ssh Port"));
- sensors().set(KARAF_RMI_REGISTRY_PORT, (Integer) map.get("RMI Registry Port"));
- sensors().set(KARAF_RMI_SERVER_PORT, (Integer) map.get("RMI Server Port"));
- sensors().set(KARAF_STATE, (String) map.get("State"));
- }});
-
- }
-
- @Override
- protected void disconnectSensors() {
- super.disconnectSensors();
- if (jmxFeed != null) jmxFeed.stop();
- }
-
- @Override
- protected void preStop() {
- super.preStop();
-
- if (jmxHelper != null) jmxHelper.terminate();
- }
-
- @Effector(description="Updates the OSGi Service's properties, adding (and overriding) the given key-value pairs")
- public void updateServiceProperties(
- @EffectorParam(name="serviceName", description="Name of the OSGi service") String serviceName,
- Map<String,String> additionalVals) {
- TabularData table = (TabularData) jmxHelper.operation(OSGI_COMPENDIUM, "getProperties", serviceName);
-
- try {
- for (Map.Entry<String, String> entry: additionalVals.entrySet()) {
- String key = entry.getKey();
- String value = entry.getValue();
- CompositeData data = new CompositeDataSupport(
- JmxConstants.PROPERTY_TYPE,
- MutableMap.of(JmxConstants.KEY, key, JmxConstants.TYPE, "String", JmxConstants.VALUE, value));
- table.remove(data.getAll(new String[] {JmxConstants.KEY}));
- table.put(data);
- }
- } catch (OpenDataException e) {
- throw Exceptions.propagate(e);
- }
-
- LOG.info("Updating monterey-service configuration with changes {}", additionalVals);
- if (LOG.isTraceEnabled()) LOG.trace("Updating monterey-service configuration with new configuration {}", table);
-
- jmxHelper.operation(OSGI_COMPENDIUM, "update", serviceName, table);
- }
-
- @Effector(description="Updates the OSGi Service's properties, adding (and overriding) the given key-value pairs")
- public void installFeature(
- @EffectorParam(name="featureName", description="Name of the feature - see org.apache.karaf:type=features#installFeature()") final String featureName) throws Exception {
-
- LOG.info("Installing feature {} via JMX", featureName);
-
- Repeater.create("Wait for Karaf, to install feature "+featureName)
- .limitIterationsTo(40)
- .every(500, TimeUnit.MILLISECONDS)
- .until(new Callable<Boolean>() {
- public Boolean call() {
- jmxHelper.operation(String.format(KARAF_FEATURES, getConfig(KARAF_NAME.getConfigKey())), "installFeature", featureName);
- return true;
- }})
- .rethrowException()
- .run();
- }
-
- public Map<Long,Map<String,?>> listBundles() {
- TabularData table = (TabularData) jmxHelper.operation(OSGI_BUNDLE_STATE, "listBundles");
- Map<List<?>, Map<String, Object>> map = JmxValueFunctions.tabularDataToMapOfMaps(table);
-
- Map<Long,Map<String,?>> result = Maps.newLinkedHashMap();
- for (Map.Entry<List<?>, Map<String, Object>> entry : map.entrySet()) {
- result.put((Long)entry.getKey().get(0), entry.getValue());
- }
- return result;
- }
-
- /**
- * throws URISyntaxException If bundle name is not a valid URI
- */
- @Effector(description="Deploys the given bundle, returning the bundle id - see osgi.core:type=framework#installBundle()")
- public long installBundle(
- @EffectorParam(name="bundle", description="URI of bundle to be deployed") String bundle) throws URISyntaxException {
-
- // TODO Consider switching to use either:
- // - org.apache.karaf:type=bundles#install(String), or
- // - dropping file into $RUN_DIR/deploy (but that would be async)
-
- URI uri = new URI(bundle);
- boolean wrap = false;
- if (WRAP_SCHEME.equals(uri.getScheme())) {
- bundle = bundle.substring(WRAP_SCHEME.length() + 1);
- uri = new URI(bundle);
- wrap = true;
- }
- if (FILE_SCHEME.equals(uri.getScheme())) {
- LOG.info("Deploying bundle {} via file copy", bundle);
- File source = new File(uri);
- String target = getDriver().getRunDir() + "/" + source.getName();
- getDriver().copyResource(source, target);
- return (Long) jmxHelper.operation(OSGI_FRAMEWORK, "installBundle", (wrap ? WRAP_SCHEME + ":" : "") + FILE_SCHEME + "://" + target);
- } else {
- LOG.info("Deploying bundle {} via JMX", bundle);
- return (Long) jmxHelper.operation(OSGI_FRAMEWORK, "installBundle", (wrap ? WRAP_SCHEME + ":" : "") + bundle);
- }
- }
-
- @Effector(description="Undeploys the bundle with the given id")
- public void uninstallBundle(
- @EffectorParam(name="bundleId", description="Id of the bundle") Long bundleId) {
-
- // TODO Consider switching to use either:
- // - org.apache.karaf:type=bundles#install(String), or
- // - dropping file into $RUN_DIR/deploy (but that would be async)
-
- jmxHelper.operation(OSGI_FRAMEWORK, "uninstallBundle", bundleId);
- }
-
- protected void uploadPropertyFiles(Map<String,Map<String,String>> propertyFiles) {
- if (propertyFiles == null) return;
-
- for (Map.Entry<String,Map<String,String>> entry : propertyFiles.entrySet()) {
- String file = entry.getKey();
- Map<String,String> contents = entry.getValue();
-
- Properties props = new Properties();
- for (Map.Entry<String,String> prop : contents.entrySet()) {
- props.setProperty(prop.getKey(), prop.getValue());
- }
-
- File local = Os.writePropertiesToTempFile(props, "karaf-"+getId(), ".cfg");
- local.setReadable(true);
- try {
- String remote = getDriver().getRunDir() + "/" + file;
- getDriver().copyResource(local, remote);
- } finally {
- local.delete();
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafDriver.java b/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafDriver.java
deleted file mode 100644
index ec90e45..0000000
--- a/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafDriver.java
+++ /dev/null
@@ -1,30 +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.entity.osgi.karaf;
-
-import java.io.File;
-
-import org.apache.brooklyn.entity.java.JavaSoftwareProcessDriver;
-
-public interface KarafDriver extends JavaSoftwareProcessDriver {
-
- public String getRunDir();
-
- public int copyResource(File src, String destination);
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafSshDriver.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafSshDriver.java b/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafSshDriver.java
deleted file mode 100644
index 35e8c22..0000000
--- a/brooklyn-library/software/osgi/src/main/java/org/apache/brooklyn/entity/osgi/karaf/KarafSshDriver.java
+++ /dev/null
@@ -1,149 +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.entity.osgi.karaf;
-
-import static java.lang.String.format;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.entity.java.JavaSoftwareProcessSshDriver;
-import org.apache.brooklyn.location.ssh.SshMachineLocation;
-import org.apache.brooklyn.util.collections.MutableList;
-import org.apache.brooklyn.util.collections.MutableMap;
-import org.apache.brooklyn.util.net.Networking;
-import org.apache.brooklyn.util.os.Os;
-import org.apache.brooklyn.util.ssh.BashCommands;
-
-import com.google.common.collect.ImmutableList;
-
-public class KarafSshDriver extends JavaSoftwareProcessSshDriver implements KarafDriver {
-
- // TODO getJmxJavaSystemProperties(), don't set via JAVA_OPTS; set ourselves manually
- // (karaf reads from props files)
- // but do set "java.rmi.server.hostname"
-
- public KarafSshDriver(KarafContainerImpl entity, SshMachineLocation machine) {
- super(entity, machine);
- }
-
- @Override
- public KarafContainerImpl getEntity() {
- return (KarafContainerImpl) super.getEntity();
- }
-
- @Override
- protected String getLogFileLocation() {
- return Os.mergePaths(getRunDir(), "data", "karaf.out");
- }
-
- @Override
- public void preInstall() {
- resolver = Entities.newDownloader(this);
- setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("apache-karaf-%s", getVersion()))));
- }
-
- @Override
- public void install() {
- List<String> urls = resolver.getTargets();
- String saveAs = resolver.getFilename();
-
- List<String> commands = ImmutableList.<String>builder()
- .addAll(BashCommands.commandsToDownloadUrlsAs(urls, saveAs))
- .add(BashCommands.INSTALL_TAR)
- .add("tar xzfv " + saveAs)
- .build();
-
- newScript(INSTALLING)
- .body.append(commands)
- .execute();
- }
-
- @Override
- public void customize() {
- Map<String, Object> ports = new HashMap<String, Object>();
- ports.put("jmxPort", getJmxPort());
- ports.put("rmiRegistryPort", getRmiRegistryPort());
- Networking.checkPortsValid(ports);
-
- newScript(CUSTOMIZING)
- .body.append(
- format("cd %s", getRunDir()),
- format("cp -R %s/{bin,etc,lib,system,deploy} . || exit $!", getExpandedInstallDir()),
- format("sed -i.bk 's/rmiRegistryPort = 1099/rmiRegistryPort = %s/g' etc/org.apache.karaf.management.cfg", getRmiRegistryPort()),
- format("sed -i.bk 's/rmiServerPort = 44444/rmiServerPort = %s/g' etc/org.apache.karaf.management.cfg", getJmxPort())
- )
- .execute();
- }
-
- @Override
- public void launch() {
- newScript(MutableMap.of(USE_PID_FILE, true), LAUNCHING)
- .body.append("nohup ./bin/start")
- .execute();
- }
-
- @Override
- public boolean isRunning() {
- // TODO Can we use the pidFile, auto-generated by launch?
-
- Integer pid = entity.getAttribute(KarafContainer.KARAF_PID);
- // This method is called on startup, before JMX is initialised, so pid won't always be available.
- if (pid != null) {
- return newScript(CHECK_RUNNING)
- .body.append(format("ps aux | grep 'karaf' | grep %s > /dev/null", pid))
- .execute() == 0;
- } else {
- // Simple method isn't available, use pid in instance.properties.
- return newScript(CHECK_RUNNING)
- .body.append(
- format("cd %s/instances/",getRunDir()),
- "[ $(uname) = \"Darwin\" ] && pid=$(sed -n -e 's/.*pid=\\([0-9]*\\)$/\\1/p' instance.properties) || pid=$(sed -r -n -e 's/.*pid=([0-9]*)$/\\1/p' instance.properties)",
- "ps aux | grep 'karaf' | grep $(echo ${pid:-X}) > /dev/null"
- )
- .execute() == 0;
- }
- }
-
- @Override
- public void stop() {
- newScript(STOPPING)
- .environmentVariablesReset()
- .body.append(format("%s/bin/stop",getRunDir()))
- .execute();
- }
-
- @Override
- public void kill() {
- stop(); // TODO no pid file to easily do `kill -9`
- }
-
- @Override
- protected List<String> getCustomJavaConfigOptions() {
- return MutableList.<String>builder()
- .addAll(super.getCustomJavaConfigOptions())
- .add("-Xms200m")
- .add("-Xmx800m")
- .add("-XX:MaxPermSize=400m")
- .build();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/osgi/src/main/java/org/osgi/jmx/Item.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/osgi/src/main/java/org/osgi/jmx/Item.java b/brooklyn-library/software/osgi/src/main/java/org/osgi/jmx/Item.java
deleted file mode 100644
index 900dc71..0000000
--- a/brooklyn-library/software/osgi/src/main/java/org/osgi/jmx/Item.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2009). All Rights Reserved.
- *
- * Licensed 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.osgi.jmx;
-
-/*
- * BROOKLYN NOTE: This is a verbatim copy of the original in org.osgi.enterprise-4.2.0,
- * reproduced here to avoid pulling in the rest of that bundle and its chain of dependencies.
- * The only difference is this comment and the suppress warnings.
- */
-
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import javax.management.openmbean.ArrayType;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.OpenType;
-import javax.management.openmbean.TabularType;
-
-/**
- * The item class enables the definition of open types in the appropriate
- * interfaces.
- *
- * This class contains a number of methods that make it possible to create open
- * types for {@link CompositeType}, {@link TabularType}, and {@link ArrayType}.
- * The normal creation throws a checked exception, making it impossible to use
- * them in a static initializer. The constructors are also not very suitable
- * for static construction.
- *
- *
- * An Item instance describes an item in a Composite Type. It groups the triplet
- * of name, description, and Open Type. These Item instances allows the
- * definitions of an item to stay together.
- *
- * @version $Revision: 8482 $
- * @Immutable
- */
-@SuppressWarnings({"unchecked","rawtypes"})
-public class Item {
-
- /**
- * The name of this item.
- */
- private final String name;
-
- /**
- * The description of this item.
- */
- private final String description;
-
- /**
- * The type of this item.
- */
- private final OpenType type;
-
- /**
- * Create a triple of name, description, and type. This triplet is used in
- * the creation of a Composite Type.
- *
- * @param name
- * The name of the item.
- * @param description
- * The description of the item.
- * @param type
- * The Open Type of this item.
- * @param restrictions
- * Ignored, contains list of restrictions
- */
- public Item(String name, String description, OpenType type,
- String... restrictions) {
- this.name = name;
- this.description = description;
- this.type = type;
- }
-
- /**
- * Create a Tabular Type.
- *
- * @param name
- * The name of the Tabular Type.
- * @param description
- * The description of the Tabular Type.
- * @param rowType
- * The Open Type for a row
- * @param index
- * The names of the items that form the index .
- * @return A new Tabular Type composed from the parameters.
- * @throws RuntimeException
- * when the Tabular Type throws an OpenDataException
- */
- static public TabularType tabularType(String name, String description,
- CompositeType rowType, String... index) {
- try {
- return new TabularType(name, description, rowType, index);
- } catch (OpenDataException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Create a Composite Type
- *
- * @param name
- * The name of the Tabular Type.
- * @param description
- * The description of the Tabular Type.
- * @param items
- * The items that describe the composite type.
- * @return a new Composite Type
- * @throws RuntimeException
- * when the Tabular Type throws an OpenDataException
- */
- static public CompositeType compositeType(String name, String description,
- Item... items) {
- return extend(null, name, description, items);
- }
-
- /**
- * Return a new Array Type.
- *
- * @param dim
- * The dimension
- * @param elementType
- * The element type
- * @return A new Array Type
- */
- public static ArrayType arrayType(int dim, OpenType elementType) {
- try {
- return new ArrayType(dim, elementType);
- } catch (OpenDataException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Extend a Composite Type by adding new items. Items can override items in
- * the parent type.
- *
- * @param parent
- * The parent type, can be {@code null}
- * @param name
- * The name of the type
- * @param description
- * The description of the type
- * @param items
- * The items that should be added/override to the parent type
- * @return A new Composite Type that extends the parent type
- * @throws RuntimeException
- * when an OpenDataException is thrown
- */
- public static CompositeType extend(CompositeType parent, String name,
- String description, Item... items) {
- Set<Item> all = new LinkedHashSet<Item>();
-
- if (parent != null) {
- for (Object nm : parent.keySet()) {
- String key = (String) nm;
- all.add(new Item(key, parent.getDescription(key),
- parent.getType(key)));
- }
- }
-
- Collections.addAll(all, items);
-
- int size = all.size();
- String names[] = new String[size];
- String descriptions[] = new String[size];
- OpenType types[] = new OpenType[size];
-
- int m = 0;
- for (Item item : all) {
- names[m] = item.name;
- descriptions[m] = item.description;
- types[m] = item.type;
- m++;
- }
-
- try {
- return new CompositeType(name, description, names, descriptions,
- types);
- } catch (OpenDataException e) {
- throw new RuntimeException(e);
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/osgi/src/main/java/org/osgi/jmx/JmxConstants.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/osgi/src/main/java/org/osgi/jmx/JmxConstants.java b/brooklyn-library/software/osgi/src/main/java/org/osgi/jmx/JmxConstants.java
deleted file mode 100644
index c4d64c8..0000000
--- a/brooklyn-library/software/osgi/src/main/java/org/osgi/jmx/JmxConstants.java
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (c) OSGi Alliance (2009, 2010). All Rights Reserved.
- *
- * Licensed 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.osgi.jmx;
-
-/*
- * BROOKLYN NOTE: This is a verbatim copy of the original in org.osgi.enterprise-4.2.0,
- * reproduced here to avoid pulling in the rest of that bundle and its chain of dependencies.
- * The only difference is this comment and the suppress warnings.
- */
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import javax.management.openmbean.ArrayType;
-import javax.management.openmbean.CompositeType;
-import javax.management.openmbean.SimpleType;
-import javax.management.openmbean.TabularType;
-
-/**
- * Constants for OSGi JMX Specification.
- *
- * Additionally, this class contains a number of utility types that are used in
- * different places in the specification. These are {@link #LONG_ARRAY_TYPE},
- * {@link #STRING_ARRAY_TYPE}, and {@link #PROPERTIES_TYPE}.
- *
- * @version $Revision: 8512 $
- * @Immutable
- */
-@SuppressWarnings("rawtypes")
-public class JmxConstants {
-
- /*
- * Empty constructor to make sure this is not used as an object.
- */
- private JmxConstants() {
- // empty
- }
-
- /**
- * The MBean Open type for an array of strings
- */
- public static final ArrayType STRING_ARRAY_TYPE = Item
- .arrayType(
- 1,
- SimpleType.STRING);
- /**
- * The MBean Open type for an array of longs
- */
- public static final ArrayType LONG_ARRAY_TYPE = Item
- .arrayType(
- 1,
- SimpleType.LONG);
-
- /**
- * For an encoded array we need to start with ARRAY_OF. This must be
- * followed by one of the names in {@link #SCALAR}.
- *
- */
- public final static String ARRAY_OF = "Array of ";
-
- /**
- * For an encoded vector we need to start with ARRAY_OF. This must be
- * followed by one of the names in {@link #SCALAR}.
- */
- public final static String VECTOR_OF = "Vector of ";
-
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * {@link java.lang.String}
- */
- public static final String STRING = "String";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * {@link java.lang.Integer}
- */
- public static final String INTEGER = "Integer";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * {@link java.lang.Long}
- */
- public static final String LONG = "Long";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * {@link java.lang.Float}
- */
- public static final String FLOAT = "Float";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * {@link java.lang.Double}
- */
- public static final String DOUBLE = "Double";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * {@link java.lang.Byte}
- */
- public static final String BYTE = "Byte";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * {@link java.lang.Short}
- */
- public static final String SHORT = "Short";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * {@link java.lang.Character}
- */
- public static final String CHARACTER = "Character";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * {@link java.lang.Boolean}
- */
- public static final String BOOLEAN = "Boolean";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * {@link java.math.BigDecimal}
- */
- public static final String BIGDECIMAL = "BigDecimal";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * {@link java.math.BigInteger}
- */
- public static final String BIGINTEGER = "BigInteger";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * the <code>double</code> primitive type.
- */
- public static final String P_DOUBLE = "double";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * the <code>float</code> primitive type.
- */
- public static final String P_FLOAT = "float";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * the <code>long</code> primitive type.
- */
- public static final String P_LONG = "long";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * the <code>int</code> primitive type.
- */
- public static final String P_INT = "int";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * the <code>short</code> primitive type.
- */
- public static final String P_SHORT = "short";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * the <code>byte</code> primitive type.
- */
- public static final String P_BYTE = "byte";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * the <code>char</code> primitive type.
- */
- public static final String P_CHAR = "char";
- /**
- * Value for {@link #PROPERTY_TYPE} value in the case of
- * the <code>boolean</code> primitive type.
- */
- public static final String P_BOOLEAN = "boolean";
-
- /**
- * A set of all scalars that can be used in the {@link #TYPE} property of a
- * {@link #PROPERTIES_TYPE}. This contains the following names:
- * <ul>
- * <li>{@link #BIGDECIMAL}</li>
- * <li>{@link #BIGINTEGER}</li>
- * <li>{@link #BOOLEAN}</li>
- * <li>{@link #BYTE}</li>
- * <li>{@link #CHARACTER}</li>
- * <li>{@link #DOUBLE}</li>
- * <li>{@link #FLOAT}</li>
- * <li>{@link #INTEGER}</li>
- * <li>{@link #LONG}</li>
- * <li>{@link #SHORT}</li>
- * <li>{@link #STRING}</li>
- * <li>{@link #P_BYTE}</li>
- * <li>{@link #P_CHAR}</li>
- * <li>{@link #P_DOUBLE}</li>
- * <li>{@link #P_FLOAT}</li>
- * <li>{@link #P_INT}</li>
- * <li>{@link #P_LONG}</li>
- * <li>{@link #P_SHORT}</li>
- */
- public final static List<String> SCALAR = Collections
- .unmodifiableList(Arrays
- .asList(
- STRING,
- INTEGER,
- LONG,
- FLOAT,
- DOUBLE,
- BYTE,
- SHORT,
- CHARACTER,
- BOOLEAN,
- BIGDECIMAL,
- BIGINTEGER,
- P_BYTE,
- P_CHAR,
- P_SHORT,
- P_INT,
- P_LONG,
- P_DOUBLE,
- P_FLOAT));
- /**
- * The key KEY.
- */
- public static final String KEY = "Key";
- /**
- * The key of a property. The key is {@link #KEY} and the type is
- * {@link SimpleType#STRING}.
- */
- public static final Item KEY_ITEM = new Item(
- KEY,
- "The key of the property",
- SimpleType.STRING);
-
- /**
- * The key VALUE.
- */
- public static final String VALUE = "Value";
-
- /**
- * The value of a property. The key is {@link #VALUE} and the type is
- * {@link SimpleType#STRING}. A value will be encoded by the string given in
- * {@link #TYPE}. The syntax for this type is given in {@link #TYPE_ITEM}.
- */
- public static final Item VALUE_ITEM = new Item(
- VALUE,
- "The value of the property",
- SimpleType.STRING);
-
- /**
- * The key TYPE.
- */
- public static final String TYPE = "Type";
-
- /**
- * The type of the property. The key is {@link #TYPE} and the type is
- * {@link SimpleType#STRING}. This string must follow the following syntax:
- *
- * TYPE ::= ( 'Array of ' | 'Vector of ' )? {@link #SCALAR}
- *
- */
- public static final Item TYPE_ITEM = new Item(
- TYPE,
- "The type of the property",
- SimpleType.STRING,
- STRING,
- INTEGER,
- LONG,
- FLOAT,
- DOUBLE,
- BYTE,
- SHORT,
- CHARACTER,
- BOOLEAN,
- BIGDECIMAL,
- BIGINTEGER,
- P_DOUBLE,
- P_FLOAT,
- P_LONG,
- P_INT,
- P_SHORT,
- P_CHAR,
- P_BYTE,
- P_BOOLEAN);
-
- /**
- * A Composite Type describing a a single property. A property consists of
- * the following items {@link #KEY_ITEM}, {@link #VALUE_ITEM}, and
- * {@link #TYPE_ITEM}.
- */
- public static final CompositeType PROPERTY_TYPE = Item
- .compositeType(
- "PROPERTY",
- "This type encapsulates a key/value pair with a type identifier",
- KEY_ITEM,
- VALUE_ITEM,
- TYPE_ITEM);
-
- /**
- * Describes a map with properties. The row type is {@link #PROPERTY_TYPE}.
- * The index is defined to the {@link #KEY} of the property.
- */
- public static final TabularType PROPERTIES_TYPE = Item
- .tabularType(
- "PROPERTIES",
- "A table of PROPERTY",
- PROPERTY_TYPE,
- KEY);
-
- /**
- * The domain name of the core OSGi MBeans
- */
- public static final String OSGI_CORE = "osgi.core";
-
- /**
- * The domain name of the selected OSGi compendium MBeans
- */
- public static final String OSGI_COMPENDIUM = "osgi.compendium";
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/osgi/src/main/resources/karaf-logo.png
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/osgi/src/main/resources/karaf-logo.png b/brooklyn-library/software/osgi/src/main/resources/karaf-logo.png
deleted file mode 100644
index 8ae2f4f..0000000
Binary files a/brooklyn-library/software/osgi/src/main/resources/karaf-logo.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/osgi/src/test/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerEc2LiveTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/osgi/src/test/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerEc2LiveTest.java b/brooklyn-library/software/osgi/src/test/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerEc2LiveTest.java
deleted file mode 100644
index e3d3090..0000000
--- a/brooklyn-library/software/osgi/src/test/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerEc2LiveTest.java
+++ /dev/null
@@ -1,52 +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.entity.osgi.karaf;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.Location;
-import org.apache.brooklyn.entity.AbstractEc2LiveTest;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.util.text.Identifiers;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableList;
-
-public class KarafContainerEc2LiveTest extends AbstractEc2LiveTest {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(KarafContainerEc2LiveTest.class);
-
- @Override
- protected void doTest(Location loc) throws Exception {
- KarafContainer karaf = app.createAndManageChild(EntitySpec.create(KarafContainer.class)
- .configure("name", Identifiers.makeRandomId(8))
- .configure("displayName", "Karaf Test")
- .configure("jmxPort", "8099+")
- .configure("rmiRegistryPort", "9099+"));
-
- app.start(ImmutableList.of(loc));
-
- EntityTestUtils.assertAttributeEqualsEventually(karaf, KarafContainer.SERVICE_UP, true);
- }
-
- @Test(enabled=false)
- public void testDummy() {} // Convince testng IDE integration that this really does have test methods
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/osgi/src/test/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerTest.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/osgi/src/test/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerTest.java b/brooklyn-library/software/osgi/src/test/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerTest.java
deleted file mode 100644
index 624fc4e..0000000
--- a/brooklyn-library/software/osgi/src/test/java/org/apache/brooklyn/entity/osgi/karaf/KarafContainerTest.java
+++ /dev/null
@@ -1,146 +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.entity.osgi.karaf;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-
-import java.net.URL;
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.EntitySpec;
-import org.apache.brooklyn.api.location.NoMachinesAvailableException;
-import org.apache.brooklyn.core.effector.ssh.SshEffectorTasks;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.Entities;
-import org.apache.brooklyn.core.test.BrooklynAppLiveTestSupport;
-import org.apache.brooklyn.test.Asserts;
-import org.apache.brooklyn.test.EntityTestUtils;
-import org.apache.brooklyn.test.support.TestResourceUnavailableException;
-import org.apache.brooklyn.util.exceptions.Exceptions;
-import org.apache.brooklyn.util.text.Identifiers;
-import org.testng.Assert;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import org.apache.brooklyn.location.localhost.LocalhostMachineProvisioningLocation;
-
-import com.google.common.collect.ImmutableList;
-
-public class KarafContainerTest extends BrooklynAppLiveTestSupport {
-
- private static final String HELLO_WORLD_JAR = "/hello-world.jar";
-
- LocalhostMachineProvisioningLocation localhost;
- KarafContainer karaf;
-
- @BeforeMethod(alwaysRun=true)
- public void setUp() throws Exception {
- super.setUp();
- localhost = app.newLocalhostProvisioningLocation();
- }
-
- // FIXME Test failing in jenkins; not sure why. The karaf log shows the mbeans never being
- // registered so we are never able to connect to them over jmx.
- @Test(groups = {"Integration", "WIP"})
- public void canStartupAndShutdown() throws Exception {
- karaf = app.createAndManageChild(EntitySpec.create(KarafContainer.class)
- .configure("name", Identifiers.makeRandomId(8))
- .configure("displayName", "Karaf Test"));
-
- app.start(ImmutableList.of(localhost));
- EntityTestUtils.assertAttributeEqualsEventually(karaf, Attributes.SERVICE_UP, true);
-
- Entities.dumpInfo(karaf);
- final int pid = karaf.getAttribute(KarafContainer.KARAF_PID);
- Entities.submit(app, SshEffectorTasks.requirePidRunning(pid).machine(localhost.obtain())).get();
-
- karaf.stop();
- EntityTestUtils.assertAttributeEqualsEventually(karaf, Attributes.SERVICE_UP, false);
-
- Asserts.succeedsEventually(new Runnable() {
- public void run() {
- try {
- Assert.assertFalse(Entities.submit(app, SshEffectorTasks.isPidRunning(pid).machine(localhost.obtain())).get());
- } catch (NoMachinesAvailableException e) {
- throw Exceptions.propagate(e);
- }
- }});
- }
-
- @Test(groups = {"Integration", "WIP"})
- public void canStartupAndShutdownExplicitJmx() throws Exception {
- karaf = app.createAndManageChild(EntitySpec.create(KarafContainer.class)
- .configure("name", Identifiers.makeRandomId(8))
- .configure("displayName", "Karaf Test")
- .configure("rmiRegistryPort", "8099+")
- .configure("jmxPort", "9099+"));
-
- app.start(ImmutableList.of(localhost));
- EntityTestUtils.assertAttributeEqualsEventually(karaf, Attributes.SERVICE_UP, true);
-
- karaf.stop();
- EntityTestUtils.assertAttributeEqualsEventually(karaf, Attributes.SERVICE_UP, false);
- }
-
- @Test(groups = {"Integration", "WIP"})
- public void canStartupAndShutdownLegacyJmx() throws Exception {
- karaf = app.createAndManageChild(EntitySpec.create(KarafContainer.class)
- .configure("name", Identifiers.makeRandomId(8))
- .configure("displayName", "Karaf Test")
- .configure("jmxPort", "8099+")
- .configure("rmiRegistryPort", "9099+"));
- // NB: now the above parameters have the opposite semantics to before
-
- app.start(ImmutableList.of(localhost));
- EntityTestUtils.assertAttributeEqualsEventually(karaf, Attributes.SERVICE_UP, true);
-
- karaf.stop();
- EntityTestUtils.assertAttributeEqualsEventually(karaf, Attributes.SERVICE_UP, false);
- }
-
- // FIXME Test failing in jenkins; not sure why. The karaf log shows the mbeans never being
- // registered so we are never able to connect to them over jmx.
- @Test(groups = {"Integration", "WIP"})
- public void testCanInstallAndUninstallBundle() throws Exception {
- TestResourceUnavailableException.throwIfResourceUnavailable(getClass(), HELLO_WORLD_JAR);
- URL jarUrl = getClass().getResource(HELLO_WORLD_JAR);
- assertNotNull(jarUrl);
-
- karaf = app.createAndManageChild(EntitySpec.create(KarafContainer.class)
- .configure("name", Identifiers.makeRandomId(8))
- .configure("displayName", "Karaf Test")
- .configure("jmxPort", "8099+")
- .configure("rmiRegistryPort", "9099+"));
-
- app.start(ImmutableList.of(localhost));
-
- long bundleId = karaf.installBundle("wrap:"+jarUrl.toString());
-
- Map<Long, Map<String,?>> bundles = karaf.listBundles();
- Map<String,?> bundle = bundles.get(bundleId);
- assertNotNull(bundle, "expected="+bundleId+"; actual="+bundles.keySet());
-
- // Undeploy: expect bundle to no longer be listed
- karaf.uninstallBundle(bundleId);
-
- Map<Long, Map<String,?>> bundles2 = karaf.listBundles();
- Map<String,?> bundle2 = bundles2.get(bundleId);
- assertNull(bundle2, "expectedAbsent="+bundleId+"; actual="+bundles2.keySet());
- }
-}
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/osgi/src/test/resources/hello-world.jar
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/osgi/src/test/resources/hello-world.jar b/brooklyn-library/software/osgi/src/test/resources/hello-world.jar
deleted file mode 100644
index 956d621..0000000
Binary files a/brooklyn-library/software/osgi/src/test/resources/hello-world.jar and /dev/null differ
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/osgi/src/test/resources/hello-world.txt
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/osgi/src/test/resources/hello-world.txt b/brooklyn-library/software/osgi/src/test/resources/hello-world.txt
deleted file mode 100644
index f3060f0..0000000
--- a/brooklyn-library/software/osgi/src/test/resources/hello-world.txt
+++ /dev/null
@@ -1,26 +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.
-
-The file hello-world.jar is used by KarafContainerTest. It is a
-simple OSGi bundle that can be deployed.
-
-The jar contains its source code.
-
-Under Apache conventions, binary files are not part of the source
-release. If you are using the source release, you may add this file
-by copying it from the master repository, which is accessible on the
-web at https://github.com/apache/incubator-brooklyn
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/webapp/pom.xml
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/webapp/pom.xml b/brooklyn-library/software/webapp/pom.xml
deleted file mode 100644
index 434e808..0000000
--- a/brooklyn-library/software/webapp/pom.xml
+++ /dev/null
@@ -1,193 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <artifactId>brooklyn-software-webapp</artifactId>
- <packaging>jar</packaging>
- <name>Brooklyn Web App Software Entities</name>
- <description>
- Brooklyn entities for Web App software processes
- </description>
-
- <parent>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-library</artifactId>
- <version>0.9.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <build>
- <pluginManagement>
- <plugins>
- <plugin>
- <groupId>org.apache.rat</groupId>
- <artifactId>apache-rat-plugin</artifactId>
- <configuration>
- <excludes combine.children="append">
- <!--
- Configuration artifacts (for installations) are based on templated defaults for
- the given components. These are files "without any degree of creativity" from the
- perspective of the Brooklyn/Apache contribution.
- -->
- <exclude>src/main/resources/org/apache/brooklyn/entity/webapp/jboss/jboss7-standalone.xml</exclude>
- <exclude>src/main/resources/org/apache/brooklyn/entity/webapp/jetty/jetty-brooklyn.xml</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </pluginManagement>
- </build>
-
- <dependencies>
- <!-- required for GeoScaling DNS (entity accesses management service via HTTP) -->
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpclient</artifactId>
- <version>${httpclient.version}</version>
- </dependency>
- <dependency>
- <groupId>org.hibernate</groupId>
- <artifactId>jtidy</artifactId>
- <version>${jtidy.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-policy</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-base</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-api</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-core</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-utils-common</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-utils-groovy</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.httpcomponents</groupId>
- <artifactId>httpcore</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
- <groupId>com.google.code.findbugs</groupId>
- <artifactId>jsr305</artifactId>
- </dependency>
- <dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-api</artifactId>
- </dependency>
-
- <!-- test dependencies -->
- <dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>mx4j</groupId>
- <artifactId>mx4j-tools</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-jms_1.1_spec</artifactId>
- <version>${geronimo-jms_1.1_spec.version}</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-test-support</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-core</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-base</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-software-database</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
-
- <!-- bring in camp test deps for moved tests -->
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-camp</artifactId>
- <version>0.9.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-camp</artifactId>
- <version>${project.version}</version>
- <classifier>tests</classifier>
- <scope>test</scope>
- </dependency>
-
- <!-- bring in jclouds for testing -->
- <dependency>
- <groupId>org.apache.brooklyn</groupId>
- <artifactId>brooklyn-locations-jclouds</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>${jclouds.groupId}</groupId>
- <artifactId>jclouds-core</artifactId>
- <version>${jclouds.version}</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
-</project>
http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/02abbab0/brooklyn-library/software/webapp/src/main/java/org/apache/brooklyn/entity/dns/AbstractGeoDnsService.java
----------------------------------------------------------------------
diff --git a/brooklyn-library/software/webapp/src/main/java/org/apache/brooklyn/entity/dns/AbstractGeoDnsService.java b/brooklyn-library/software/webapp/src/main/java/org/apache/brooklyn/entity/dns/AbstractGeoDnsService.java
deleted file mode 100644
index 6e55d5d..0000000
--- a/brooklyn-library/software/webapp/src/main/java/org/apache/brooklyn/entity/dns/AbstractGeoDnsService.java
+++ /dev/null
@@ -1,74 +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.entity.dns;
-
-import java.util.Map;
-
-import org.apache.brooklyn.api.entity.Entity;
-import org.apache.brooklyn.api.entity.Group;
-import org.apache.brooklyn.api.sensor.AttributeSensor;
-import org.apache.brooklyn.config.ConfigKey;
-import org.apache.brooklyn.core.config.ConfigKeys;
-import org.apache.brooklyn.core.entity.Attributes;
-import org.apache.brooklyn.core.entity.lifecycle.Lifecycle;
-import org.apache.brooklyn.core.entity.trait.Startable;
-import org.apache.brooklyn.core.location.geo.HostGeoInfo;
-import org.apache.brooklyn.core.sensor.Sensors;
-import org.apache.brooklyn.util.core.flags.SetFromFlag;
-
-import com.google.common.reflect.TypeToken;
-
-public interface AbstractGeoDnsService extends Entity {
-
- @SetFromFlag("includeHomelessEntities")
- ConfigKey<Boolean> INCLUDE_HOMELESS_ENTITIES = ConfigKeys.newBooleanConfigKey(
- "geodns.includeHomeless", "Whether to include entities whose geo-coordinates cannot be inferred", false);
-
- @SetFromFlag("useHostnames")
- ConfigKey<Boolean> USE_HOSTNAMES = ConfigKeys.newBooleanConfigKey(
- "geodns.useHostnames", "Whether to use the hostname for the returned value for routing, rather than IP address (defaults to true)", true);
-
- @SetFromFlag("provider")
- ConfigKey<Group> ENTITY_PROVIDER = ConfigKeys.newConfigKey(Group.class,
- "geodns.entityProvider", "The group whose members should be tracked");
-
- /** @see Lifecycle#RUNNING */
- @SetFromFlag("filterForRunning")
- ConfigKey<Boolean> FILTER_FOR_RUNNING = ConfigKeys.newBooleanConfigKey(
- "geodns.filterForRunning", "Whether to only track targets whose status is \"RUNNING\"", true);
-
- AttributeSensor<Lifecycle> SERVICE_STATE_ACTUAL = Attributes.SERVICE_STATE_ACTUAL;
- AttributeSensor<Boolean> SERVICE_UP = Startable.SERVICE_UP;
- AttributeSensor<String> HOSTNAME = Attributes.HOSTNAME;
- AttributeSensor<String> ADDRESS = Attributes.ADDRESS;
-
- AttributeSensor<Map<String,String>> TARGETS = Sensors.newSensor(new TypeToken<Map<String, String>>() {},
- "geodns.targets", "Map of targets currently being managed (entity ID to URL)");
-
- void setServiceState(Lifecycle state);
-
- /** sets target to be a group whose *members* will be searched (non-Group items not supported) */
- // prior to 0.7.0 the API accepted non-group items, but did not handle them correctly
- void setTargetEntityProvider(final Group entityProvider);
-
- /** should return the hostname which this DNS service is configuring */
- String getHostname();
-
- Map<Entity, HostGeoInfo> getTargetHosts();
-}