當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。