brooklyn-example-global-web-fabric: add org.apache package prefix
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/59cc05d5 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/59cc05d5 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/59cc05d5 Branch: refs/heads/master Commit: 59cc05d598bc803e0b922a09753b4a22bfad91bf Parents: f2792fa Author: Ciprian Ciubotariu <[email protected]> Authored: Wed Jul 15 17:55:45 2015 +0300 Committer: Ciprian Ciubotariu <[email protected]> Committed: Wed Jul 15 18:47:01 2015 +0300 ---------------------------------------------------------------------- .../brooklyn/demo/GlobalWebFabricExample.java | 119 ------------------- .../src/main/java/brooklyn/demo/ReadMe.java | 28 ----- .../brooklyn/demo/GlobalWebFabricExample.java | 119 +++++++++++++++++++ .../java/org/apache/brooklyn/demo/ReadMe.java | 28 +++++ 4 files changed, 147 insertions(+), 147 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/59cc05d5/examples/global-web-fabric/src/main/java/brooklyn/demo/GlobalWebFabricExample.java ---------------------------------------------------------------------- diff --git a/examples/global-web-fabric/src/main/java/brooklyn/demo/GlobalWebFabricExample.java b/examples/global-web-fabric/src/main/java/brooklyn/demo/GlobalWebFabricExample.java deleted file mode 100644 index cf4fa24..0000000 --- a/examples/global-web-fabric/src/main/java/brooklyn/demo/GlobalWebFabricExample.java +++ /dev/null @@ -1,119 +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 brooklyn.demo; - -import static com.google.common.base.Preconditions.checkNotNull; - -import java.util.Arrays; -import java.util.List; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import brooklyn.catalog.Catalog; -import brooklyn.catalog.CatalogConfig; -import brooklyn.config.ConfigKey; -import brooklyn.config.StringConfigMap; -import brooklyn.entity.basic.AbstractApplication; -import brooklyn.entity.basic.ConfigKeys; -import brooklyn.entity.basic.Entities; -import brooklyn.entity.basic.StartableApplication; -import brooklyn.entity.dns.geoscaling.GeoscalingDnsService; -import brooklyn.entity.group.DynamicRegionsFabric; -import brooklyn.entity.proxy.AbstractController; -import brooklyn.entity.proxying.EntitySpec; -import brooklyn.entity.webapp.ElasticJavaWebAppService; -import brooklyn.entity.webapp.JavaWebAppService; -import brooklyn.event.basic.PortAttributeSensorAndConfigKey; -import brooklyn.launcher.BrooklynLauncher; -import brooklyn.location.basic.PortRanges; -import brooklyn.util.BrooklynMavenArtifacts; -import brooklyn.util.CommandLineUtil; -import brooklyn.util.ResourceUtils; - -import com.google.common.base.Joiner; -import com.google.common.collect.ImmutableList; -import com.google.common.collect.Lists; - -@Catalog(name="Global Web Fabric", -description="Deploys a WAR to multiple clusters, showing how Brooklyn fabrics work", -iconUrl="classpath://brooklyn/demo/glossy-3d-blue-web-icon.png") -public class GlobalWebFabricExample extends AbstractApplication { - - public static final Logger log = LoggerFactory.getLogger(GlobalWebFabricExample.class); - - static final List<String> DEFAULT_LOCATIONS = ImmutableList.of( - "aws-ec2:eu-west-1", - "aws-ec2:ap-southeast-1", - "aws-ec2:us-west-1" ); - - public static final String DEFAULT_WAR_PATH = ResourceUtils.create(GlobalWebFabricExample.class) - // take this war, from the classpath, or via maven if not on the classpath - .firstAvailableUrl( - "classpath://hello-world-webapp.war", - BrooklynMavenArtifacts.localUrl("example", "brooklyn-example-hello-world-webapp", "war")) - .or("classpath://hello-world-webapp.war"); - - @CatalogConfig(label="WAR (URL)", priority=2) - public static final ConfigKey<String> WAR_PATH = ConfigKeys.newConfigKey( - "app.war", "URL to the application archive which should be deployed", - DEFAULT_WAR_PATH); - - // load-balancer instances must run on some port to work with GeoDNS, port 80 to work without special, so make that default - // (but included here in case it runs on a different port on all machines, or use a range to work with multiple localhosts) - @CatalogConfig(label="Proxy server HTTP port") - public static final PortAttributeSensorAndConfigKey PROXY_HTTP_PORT = - new PortAttributeSensorAndConfigKey(AbstractController.PROXY_HTTP_PORT, PortRanges.fromInteger(80)); - - @Override - public void initApp() { - StringConfigMap config = getManagementContext().getConfig(); - - GeoscalingDnsService geoDns = addChild(EntitySpec.create(GeoscalingDnsService.class) - .displayName("GeoScaling DNS") - .configure("username", checkNotNull(config.getFirst("brooklyn.geoscaling.username"), "username")) - .configure("password", checkNotNull(config.getFirst("brooklyn.geoscaling.password"), "password")) - .configure("primaryDomainName", checkNotNull(config.getFirst("brooklyn.geoscaling.primaryDomain"), "primaryDomain")) - .configure("smartSubdomainName", "brooklyn")); - - DynamicRegionsFabric webFabric = addChild(EntitySpec.create(DynamicRegionsFabric.class) - .displayName("Web Fabric") - .configure(DynamicRegionsFabric.FACTORY, new ElasticJavaWebAppService.Factory()) - - //specify the WAR file to use - .configure(JavaWebAppService.ROOT_WAR, Entities.getRequiredUrlConfig(this, WAR_PATH)) ); - - //tell GeoDNS what to monitor - geoDns.setTargetEntityProvider(webFabric); - } - - public static void main(String[] argv) { - List<String> args = Lists.newArrayList(argv); - String port = CommandLineUtil.getCommandLineOption(args, "--port", "8081+"); - String locations = CommandLineUtil.getCommandLineOption(args, "--locations", Joiner.on(",").join(DEFAULT_LOCATIONS)); - - BrooklynLauncher launcher = BrooklynLauncher.newInstance() - .application(EntitySpec.create(StartableApplication.class, GlobalWebFabricExample.class).displayName("Brooklyn Global Web Fabric Example")) - .webconsolePort(port) - .locations(Arrays.asList(locations)) - .start(); - - Entities.dumpInfo(launcher.getApplications()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/59cc05d5/examples/global-web-fabric/src/main/java/brooklyn/demo/ReadMe.java ---------------------------------------------------------------------- diff --git a/examples/global-web-fabric/src/main/java/brooklyn/demo/ReadMe.java b/examples/global-web-fabric/src/main/java/brooklyn/demo/ReadMe.java deleted file mode 100644 index f5d6b74..0000000 --- a/examples/global-web-fabric/src/main/java/brooklyn/demo/ReadMe.java +++ /dev/null @@ -1,28 +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 brooklyn.demo; - -public class ReadMe { - -/* This class exists only so that javadoc is generated and artifacts can be staged at sonatype for deployment to maven central. - * See: https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide - * - * (The actual examples are in other classes in this package / project.) */ - -} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/59cc05d5/examples/global-web-fabric/src/main/java/org/apache/brooklyn/demo/GlobalWebFabricExample.java ---------------------------------------------------------------------- diff --git a/examples/global-web-fabric/src/main/java/org/apache/brooklyn/demo/GlobalWebFabricExample.java b/examples/global-web-fabric/src/main/java/org/apache/brooklyn/demo/GlobalWebFabricExample.java new file mode 100644 index 0000000..9f7a83a --- /dev/null +++ b/examples/global-web-fabric/src/main/java/org/apache/brooklyn/demo/GlobalWebFabricExample.java @@ -0,0 +1,119 @@ +/* + * 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.demo; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.util.Arrays; +import java.util.List; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import brooklyn.catalog.Catalog; +import brooklyn.catalog.CatalogConfig; +import brooklyn.config.ConfigKey; +import brooklyn.config.StringConfigMap; +import brooklyn.entity.basic.AbstractApplication; +import brooklyn.entity.basic.ConfigKeys; +import brooklyn.entity.basic.Entities; +import brooklyn.entity.basic.StartableApplication; +import brooklyn.entity.dns.geoscaling.GeoscalingDnsService; +import brooklyn.entity.group.DynamicRegionsFabric; +import brooklyn.entity.proxy.AbstractController; +import brooklyn.entity.proxying.EntitySpec; +import brooklyn.entity.webapp.ElasticJavaWebAppService; +import brooklyn.entity.webapp.JavaWebAppService; +import brooklyn.event.basic.PortAttributeSensorAndConfigKey; +import brooklyn.launcher.BrooklynLauncher; +import brooklyn.location.basic.PortRanges; +import brooklyn.util.BrooklynMavenArtifacts; +import brooklyn.util.CommandLineUtil; +import brooklyn.util.ResourceUtils; + +import com.google.common.base.Joiner; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Lists; + +@Catalog(name="Global Web Fabric", +description="Deploys a WAR to multiple clusters, showing how Brooklyn fabrics work", +iconUrl="classpath://brooklyn/demo/glossy-3d-blue-web-icon.png") +public class GlobalWebFabricExample extends AbstractApplication { + + public static final Logger log = LoggerFactory.getLogger(GlobalWebFabricExample.class); + + static final List<String> DEFAULT_LOCATIONS = ImmutableList.of( + "aws-ec2:eu-west-1", + "aws-ec2:ap-southeast-1", + "aws-ec2:us-west-1" ); + + public static final String DEFAULT_WAR_PATH = ResourceUtils.create(GlobalWebFabricExample.class) + // take this war, from the classpath, or via maven if not on the classpath + .firstAvailableUrl( + "classpath://hello-world-webapp.war", + BrooklynMavenArtifacts.localUrl("example", "brooklyn-example-hello-world-webapp", "war")) + .or("classpath://hello-world-webapp.war"); + + @CatalogConfig(label="WAR (URL)", priority=2) + public static final ConfigKey<String> WAR_PATH = ConfigKeys.newConfigKey( + "app.war", "URL to the application archive which should be deployed", + DEFAULT_WAR_PATH); + + // load-balancer instances must run on some port to work with GeoDNS, port 80 to work without special, so make that default + // (but included here in case it runs on a different port on all machines, or use a range to work with multiple localhosts) + @CatalogConfig(label="Proxy server HTTP port") + public static final PortAttributeSensorAndConfigKey PROXY_HTTP_PORT = + new PortAttributeSensorAndConfigKey(AbstractController.PROXY_HTTP_PORT, PortRanges.fromInteger(80)); + + @Override + public void initApp() { + StringConfigMap config = getManagementContext().getConfig(); + + GeoscalingDnsService geoDns = addChild(EntitySpec.create(GeoscalingDnsService.class) + .displayName("GeoScaling DNS") + .configure("username", checkNotNull(config.getFirst("brooklyn.geoscaling.username"), "username")) + .configure("password", checkNotNull(config.getFirst("brooklyn.geoscaling.password"), "password")) + .configure("primaryDomainName", checkNotNull(config.getFirst("brooklyn.geoscaling.primaryDomain"), "primaryDomain")) + .configure("smartSubdomainName", "brooklyn")); + + DynamicRegionsFabric webFabric = addChild(EntitySpec.create(DynamicRegionsFabric.class) + .displayName("Web Fabric") + .configure(DynamicRegionsFabric.FACTORY, new ElasticJavaWebAppService.Factory()) + + //specify the WAR file to use + .configure(JavaWebAppService.ROOT_WAR, Entities.getRequiredUrlConfig(this, WAR_PATH)) ); + + //tell GeoDNS what to monitor + geoDns.setTargetEntityProvider(webFabric); + } + + public static void main(String[] argv) { + List<String> args = Lists.newArrayList(argv); + String port = CommandLineUtil.getCommandLineOption(args, "--port", "8081+"); + String locations = CommandLineUtil.getCommandLineOption(args, "--locations", Joiner.on(",").join(DEFAULT_LOCATIONS)); + + BrooklynLauncher launcher = BrooklynLauncher.newInstance() + .application(EntitySpec.create(StartableApplication.class, GlobalWebFabricExample.class).displayName("Brooklyn Global Web Fabric Example")) + .webconsolePort(port) + .locations(Arrays.asList(locations)) + .start(); + + Entities.dumpInfo(launcher.getApplications()); + } +} http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/59cc05d5/examples/global-web-fabric/src/main/java/org/apache/brooklyn/demo/ReadMe.java ---------------------------------------------------------------------- diff --git a/examples/global-web-fabric/src/main/java/org/apache/brooklyn/demo/ReadMe.java b/examples/global-web-fabric/src/main/java/org/apache/brooklyn/demo/ReadMe.java new file mode 100644 index 0000000..6858630 --- /dev/null +++ b/examples/global-web-fabric/src/main/java/org/apache/brooklyn/demo/ReadMe.java @@ -0,0 +1,28 @@ +/* + * 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.demo; + +public class ReadMe { + +/* This class exists only so that javadoc is generated and artifacts can be staged at sonatype for deployment to maven central. + * See: https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide + * + * (The actual examples are in other classes in this package / project.) */ + +}
