Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package brooklyn.demo;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.util.List;
 
 import  org.slf4j.Logger;
 import  org.slf4j.LoggerFactory;
import  brooklyn.config.StringConfigMap;
import  brooklyn.entity.basic.AbstractApplication;
import  brooklyn.entity.basic.Entities;
import  brooklyn.entity.dns.geoscaling.GeoscalingDnsService;
import  brooklyn.entity.group.DynamicFabric;
import  brooklyn.entity.proxy.AbstractController;
import  brooklyn.entity.proxying.EntitySpecs;
import  brooklyn.entity.webapp.ElasticJavaWebAppService;
import  brooklyn.launcher.BrooklynLauncher;
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 AbstractApplication {
    public static final Logger log = LoggerFactory.getLogger(GlobalWebFabricExample.class);
    
    public static final String WAR_PATH = "classpath://hello-world-webapp.war";
    
    static final List<StringDEFAULT_LOCATIONS = ImmutableList.of(
            "aws-ec2:eu-west-1",
            "aws-ec2:ap-southeast-1",
            "aws-ec2:us-west-1" );
    @Override
    public void init() {
        StringConfigMap config = getManagementContext().getConfig();
        
        GeoscalingDnsService geoDns = addChild(EntitySpecs.spec(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 = addChild(EntitySpecs.spec(DynamicFabric.class)
                .displayName("Web Fabric")
                .configure(DynamicFabric.FACTORY, new ElasticJavaWebAppService.Factory())
                
                //specify the WAR file to use
                .configure(ElasticJavaWebAppService.ROOT_WAR, )
                
                //load-balancer instances must run on 80 to work with GeoDNS (default is 8000)
                .configure(AbstractController.PROXY_HTTP_PORT, PortRanges.fromInteger(80)));
        //tell GeoDNS what to monitor
        geoDns.setTargetEntityProvider(webFabric);
    }
    public static void main(String[] argv) {
        List<Stringargs = Lists.newArrayList(argv);
        String port =  CommandLineUtil.getCommandLineOption(args"--port""8081+");
        String locations = CommandLineUtil.getCommandLineOption(args"--locations", Joiner.on(",").join());
        BrooklynLauncher launcher = BrooklynLauncher.newInstance()
                .application(EntitySpecs.appSpec(GlobalWebFabricExample.class).displayName("Brooklyn Global Web Fabric Example"))
                .webconsolePort(port)
                .locations(Arrays.asList(locations))
                .start();
         
        Entities.dumpInfo(launcher.getApplications());
    }
New to GrepCode? Check out our FAQ X