Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update examples to 0.5.0-M2 #2

Open
wants to merge 1 commit into
base: 0.5.0-M2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion global-web-fabric/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>io.brooklyn.example</groupId>
<artifactId>brooklyn-examples-parent</artifactId>
<version>0.5.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
<version>0.5.0-M2</version> <!-- BROOKLYN_VERSION -->
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
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.config.StringConfigMap;
import brooklyn.entity.basic.ApplicationBuilder;
import brooklyn.entity.basic.Attributes;
import brooklyn.entity.basic.Entities;
import brooklyn.entity.basic.StartableApplication;
import brooklyn.entity.dns.geoscaling.GeoscalingDnsService;
import brooklyn.entity.group.DynamicFabric;
import brooklyn.entity.proxy.AbstractController;
import brooklyn.entity.proxying.BasicEntitySpec;
import brooklyn.entity.webapp.ElasticJavaWebAppService;
import brooklyn.event.basic.DependentConfiguration;
import brooklyn.extras.cloudfoundry.CloudFoundryJavaWebAppCluster;
import brooklyn.launcher.BrooklynLauncher;
import brooklyn.launcher.BrooklynServerDetails;
import brooklyn.location.Location;
import brooklyn.location.basic.LocationRegistry;
import brooklyn.location.basic.PortRanges;
import brooklyn.util.CommandLineUtil;

import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;

public class GlobalWebFabricExample extends ApplicationBuilder {

public static final Logger log = LoggerFactory.getLogger(GlobalWebFabricExample.class);

public static final String WAR_PATH = "classpath://hello-world-webapp.war";

static final List<String> DEFAULT_LOCATIONS = ImmutableList.of(
"aws-ec2:eu-west-1",
"aws-ec2:ap-southeast-1",
"aws-ec2:us-west-1"
// "cloudfoundry:https://api.aws.af.cm/",
);

protected void doBuild() {
StringConfigMap config = getManagementContext().getConfig();

GeoscalingDnsService geoDns = createChild(BasicEntitySpec.newInstance(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"));

DynamicFabric webFabric = createChild(BasicEntitySpec.newInstance(DynamicFabric.class)
.displayName("Web Fabric")
.configure(DynamicFabric.FACTORY, new ElasticJavaWebAppService.Factory())

//specify the WAR file to use
.configure(ElasticJavaWebAppService.ROOT_WAR, WAR_PATH)

//load-balancer instances must run on 80 to work with GeoDNS (default is 8000)
.configure(AbstractController.PROXY_HTTP_PORT, PortRanges.fromInteger(80))

//CloudFoundry requires to be told what URL it should listen to, which is chosen by the GeoDNS service
.configure(CloudFoundryJavaWebAppCluster.HOSTNAME_TO_USE_FOR_URL,
DependentConfiguration.attributeWhenReady(geoDns, Attributes.HOSTNAME)));

//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));

BrooklynServerDetails server = BrooklynLauncher.newLauncher()
.webconsolePort(port)
.launch();

// TODO instead use server.getManagementContext().getLocationRegistry().resolve(location)
List<Location> locs = new LocationRegistry().getLocationsById(Arrays.asList(locations));

StartableApplication app = new GlobalWebFabricExample()
.appDisplayName("Brooklyn Global Web Fabric Example")
.manage(server.getManagementContext());

app.start(locs);

Entities.dumpInfo(app);
}
}
2 changes: 1 addition & 1 deletion hadoop-and-whirr/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>io.brooklyn.example</groupId>
<artifactId>brooklyn-examples-parent</artifactId>
<version>0.5.0-SNAPSHOT</version> <!-- BROOKLYN_VERSION -->
<version>0.5.0-M2</version> <!-- BROOKLYN_VERSION -->
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down

This file was deleted.

Loading