当前位置: 首页>>代码示例>>Java>>正文


Java Locations类代码示例

本文整理汇总了Java中org.apache.brooklyn.core.location.Locations的典型用法代码示例。如果您正苦于以下问题:Java Locations类的具体用法?Java Locations怎么用?Java Locations使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Locations类属于org.apache.brooklyn.core.location包,在下文中一共展示了Locations类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: connectSensors

import org.apache.brooklyn.core.location.Locations; //导入依赖的package包/类
@Override
protected void connectSensors() {
    super.connectSensors();
    connectServiceUpIsRunning();

    Maybe<SshMachineLocation> machine = Locations.findUniqueSshMachineLocation(getLocations());
    if (machine.isPresent()) {
        addFeed(sshFeed = SshFeed.builder()
            .entity(this)
            .period(FEED_UPDATE_PERIOD)
            .machine(machine.get())
            .poll(new SshPollConfig<String>(SHOW)
                .command(getDriver().makeTerraformCommand("show -no-color"))
                .onSuccess(new ShowSuccessFunction())
                .onFailure(new ShowFailureFunction()))
            .poll(new SshPollConfig<Map<String, Object>>(STATE)
                .command(getDriver().makeTerraformCommand("refresh -no-color"))
                .onSuccess(new StateSuccessFunction())
                .onFailure(new StateFailureFunction()))
            .poll(new SshPollConfig<String>(PLAN)
                .command(getDriver().makeTerraformCommand("plan -no-color"))
                .onSuccess(new PlanSuccessFunction())
                .onFailure(new PlanFailureFunction()))
            .build());
    }
}
 
开发者ID:mikezaccardo,项目名称:brooklyn-terraform,代码行数:27,代码来源:TerraformConfigurationImpl.java

示例2: apply

import org.apache.brooklyn.core.location.Locations; //导入依赖的package包/类
@Override
@Effector(description="Performs the Terraform apply command which will create all of the infrastructure specified by the configuration.")
public void apply() {
    if (!isConfigurationApplied() && !configurationChangeInProgress.getAndSet(true)) {
        try {
            String command = getDriver().makeTerraformCommand("apply -no-color");
            SshMachineLocation machine = Locations.findUniqueSshMachineLocation(getLocations()).get();

            ProcessTaskWrapper<Object> task = SshEffectorTasks.ssh(command)
                .returning(ScriptReturnType.EXIT_CODE)
                .requiringExitCodeZero()
                .machine(machine)
                .summary(command)
                .newTask();

            DynamicTasks.queue(task).asTask();
            task.block();

            if (task.getExitCode() == 0)
                setConfigurationApplied(true);
        } finally {
            configurationChangeInProgress.set(false);
        }
    }
}
 
开发者ID:mikezaccardo,项目名称:brooklyn-terraform,代码行数:26,代码来源:TerraformConfigurationImpl.java

示例3: destroy

import org.apache.brooklyn.core.location.Locations; //导入依赖的package包/类
@Override
@Effector(description="Performs the Terraform destroy command which will destroy all of the infrastructure that has been previously created by the configuration.")
public void destroy() {
    if (isConfigurationApplied() && !configurationChangeInProgress.getAndSet(true)) {
        try {
            String command = getDriver().makeTerraformCommand("destroy -force -no-color");
            SshMachineLocation machine = Locations.findUniqueSshMachineLocation(getLocations()).get();

            ProcessTaskWrapper<Object> task = SshEffectorTasks.ssh(command)
                .returning(ScriptReturnType.EXIT_CODE)
                .requiringExitCodeZero()
                .machine(machine)
                .summary(command)
                .newTask();

            DynamicTasks.queue(task).asTask();
            task.block();

            if (task.getExitCode() == 0)
                setConfigurationApplied(false);
        } finally {
            configurationChangeInProgress.set(false);
        }
    }
}
 
开发者ID:mikezaccardo,项目名称:brooklyn-terraform,代码行数:26,代码来源:TerraformConfigurationImpl.java

示例4: newStartEffector

import org.apache.brooklyn.core.location.Locations; //导入依赖的package包/类
private Effector<Void> newStartEffector() {
    return Effectors.effector(Startable.START)
            .impl(new EffectorBody<Void>() {
                @Override
                public Void call(ConfigBag parameters) {
                    LOG.info("Starting SeaCloudsInitializerPolicy " + "for " + entity.getId());
                    installSLA();
                    installMonitoringRules();
                    notifyRulesReady();
                    installInfluxDbObservers();
                    installGrafanaDashboards();

                    // Rewire the original behaviour
                    Collection<? extends Location> locations = null;
                    Object locationRaw = parameters.getStringKey(EffectorStartableImpl.StartParameters.LOCATIONS.getName());
                    locations = Locations.coerceToCollectionOfLocationsManaged(getManagementContext(), locationRaw);
                    ((StartableApplication) entity).start(locations);

                    return null;
                }
            })
            .build();
}
 
开发者ID:SeaCloudsEU,项目名称:SeaCloudsPlatform,代码行数:24,代码来源:SeaCloudsManagementPolicy.java

示例5: connectSensors

import org.apache.brooklyn.core.location.Locations; //导入依赖的package包/类
@Override
protected void connectSensors() {
    super.connectSensors();
    connectServiceUpIsRunning();

    Collection<? extends Location> locations = Locations.getLocationsCheckingAncestors(getLocations(), this);
    Maybe<MachineLocation> location =  Machines.findUniqueElement(locations, MachineLocation.class);
    if (location.isPresent() && location.get().hasExtension(HttpExecutorFactory.class)) {
        ambariRestClient = AmbariRestClient.builder()
                .httpExecutorFactory(location.get().getExtension(HttpExecutorFactory.class))
                .httpExecutorProps(location.get().getAllConfig(true))
                .build();
    } else {
        ambariRestClient = new AmbariRestClient();
    }


    HostAndPort hp = BrooklynAccessUtils.getBrooklynAccessibleAddress(this, getAttribute(HTTP_PORT));

    ambariUri = String.format("http://%s:%d", hp.getHostText(), hp.getPort());

    setAttribute(Attributes.MAIN_URI, URI.create(ambariUri));

    sensors().set(AmbariServer.USERNAME, USERNAME);
    usernamePasswordCredentials = new UsernamePasswordCredentials(
            USERNAME,
            getAttribute(AmbariServer.PASSWORD) == null ? INITIAL_PASSWORD : getAttribute(AmbariServer.PASSWORD));

    restAdapter = new RestAdapter.Builder()
            .setEndpoint(ambariUri)
            .setClient(ambariRestClient)
            .setRequestInterceptor(new AmbariRequestInterceptor(usernamePasswordCredentials))
            .setLogLevel(RestAdapter.LogLevel.FULL)
            .build();

    serviceUpHttpFeed = HttpFeed.builder()
            .entity(this)
            .period(500, TimeUnit.MILLISECONDS)
            .baseUri(ambariUri)
            .poll(new HttpPollConfig<Boolean>(URL_REACHABLE)
                    .onSuccess(HttpValueFunctions.responseCodeEquals(200))
                    .onFailureOrException(Functions.constant(false)))
            .build();

    enrichers().add(Enrichers.builder().updatingMap(Attributes.SERVICE_NOT_UP_INDICATORS)
            .from(URL_REACHABLE)
            .computing(Functionals.ifNotEquals(true).value("URL not reachable"))
            .build());

    connectAuthenticatedSensors();
}
 
开发者ID:brooklyncentral,项目名称:brooklyn-ambari,代码行数:52,代码来源:AmbariServerImpl.java


注:本文中的org.apache.brooklyn.core.location.Locations类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。