Search in sources :

Example 6 with WildflyRuntime

use of org.guvnor.ala.wildfly.model.WildflyRuntime in project kie-wb-common by kiegroup.

the class WildflyRuntimeExecExecutor method create.

private Optional<WildflyRuntime> create(final WildflyRuntimeConfiguration runtimeConfig) throws ProvisioningException {
    String warPath = runtimeConfig.getWarPath();
    final Optional<WildflyProvider> _wildflyProvider = runtimeRegistry.getProvider(runtimeConfig.getProviderId(), WildflyProvider.class);
    if (!_wildflyProvider.isPresent()) {
        throw new ProvisioningException("No Wildfly provider was found for providerId: " + runtimeConfig.getProviderId());
    }
    WildflyProvider wildflyProvider = _wildflyProvider.get();
    File file = new File(warPath);
    final String id = file.getName();
    WildflyAppState appState = wildfly.getWildflyClient(wildflyProvider).getAppState(id);
    if (UNKNOWN.equals(appState.getState())) {
        int result = wildfly.getWildflyClient(wildflyProvider).deploy(file);
        if (result != 200) {
            throw new ProvisioningException("Deployment to Wildfly Failed with error code: " + result);
        }
    } else if ((RUNNING.equals(appState.getState()) || STOPPED.equals(appState.getState())) && (isNullOrEmpty(runtimeConfig.getRedeployStrategy()) || "auto".equals(runtimeConfig.getRedeployStrategy()))) {
        wildfly.getWildflyClient(wildflyProvider).undeploy(id);
        int result = wildfly.getWildflyClient(wildflyProvider).deploy(file);
        if (result != 200) {
            throw new ProvisioningException("Deployment to Wildfly Failed with error code: " + result);
        }
    } else {
        throw new ProvisioningException("A runtime with the given identifier: " + id + " is already deployed");
    }
    String appContext = id.substring(0, id.lastIndexOf(".war"));
    WildflyRuntimeEndpoint endpoint = new WildflyRuntimeEndpoint();
    endpoint.setHost(wildfly.getWildflyClient(wildflyProvider).getHost());
    endpoint.setPort(wildfly.getWildflyClient(wildflyProvider).getPort());
    endpoint.setContext(appContext);
    return Optional.of(new WildflyRuntime(id, buildRuntimeName(runtimeConfig, id), runtimeConfig, wildflyProvider, endpoint, new WildflyRuntimeInfo(), new WildflyRuntimeState(RUNNING, new Date().toString())));
}
Also used : WildflyRuntimeEndpoint(org.guvnor.ala.wildfly.model.WildflyRuntimeEndpoint) WildflyRuntime(org.guvnor.ala.wildfly.model.WildflyRuntime) WildflyRuntimeInfo(org.guvnor.ala.wildfly.model.WildflyRuntimeInfo) ProvisioningException(org.guvnor.ala.exceptions.ProvisioningException) WildflyRuntimeState(org.guvnor.ala.wildfly.model.WildflyRuntimeState) File(java.io.File) WildflyAppState(org.guvnor.ala.wildfly.access.WildflyAppState) WildflyRuntimeEndpoint(org.guvnor.ala.wildfly.model.WildflyRuntimeEndpoint) Date(java.util.Date) WildflyProvider(org.guvnor.ala.wildfly.model.WildflyProvider)

Example 7 with WildflyRuntime

use of org.guvnor.ala.wildfly.model.WildflyRuntime in project kie-wb-common by kiegroup.

the class WildflyRuntimeManager method start.

@Override
public void start(RuntimeId runtimeId) throws RuntimeOperationException {
    WildflyRuntime runtime = (WildflyRuntime) runtimeRegistry.getRuntimeById(runtimeId.getId());
    int result = wildfly.getWildflyClient(runtime.getProviderId()).start(runtime.getId());
    if (result != 200) {
        throw new RuntimeOperationException("Error Starting container: " + runtimeId.getId() + " \n\t There as a problem with starting your application, please check into the Wildfly Logs for more information.");
    }
    refresh(runtimeId);
}
Also used : WildflyRuntime(org.guvnor.ala.wildfly.model.WildflyRuntime) RuntimeOperationException(org.guvnor.ala.exceptions.RuntimeOperationException)

Example 8 with WildflyRuntime

use of org.guvnor.ala.wildfly.model.WildflyRuntime in project kie-wb-common by kiegroup.

the class WildflyRuntimeManager method stop.

@Override
public void stop(RuntimeId runtimeId) throws RuntimeOperationException {
    WildflyRuntime runtime = (WildflyRuntime) runtimeRegistry.getRuntimeById(runtimeId.getId());
    try {
        wildfly.getWildflyClient(runtime.getProviderId()).stop(runtime.getId());
        refresh(runtimeId);
    } catch (WildflyClientException ex) {
        throw new RuntimeOperationException("Error Stopping container: " + runtimeId.getId() + "\n\t There as a problem with stopping your application, please check into the Wildfly Logs for more information.", ex);
    }
}
Also used : WildflyRuntime(org.guvnor.ala.wildfly.model.WildflyRuntime) WildflyClientException(org.guvnor.ala.wildfly.access.exceptions.WildflyClientException) RuntimeOperationException(org.guvnor.ala.exceptions.RuntimeOperationException)

Aggregations

WildflyRuntime (org.guvnor.ala.wildfly.model.WildflyRuntime)8 RuntimeOperationException (org.guvnor.ala.exceptions.RuntimeOperationException)5 WildflyClientException (org.guvnor.ala.wildfly.access.exceptions.WildflyClientException)4 MavenBuildConfig (org.guvnor.ala.build.maven.config.MavenBuildConfig)2 MavenBuildExecConfig (org.guvnor.ala.build.maven.config.MavenBuildExecConfig)2 MavenProjectConfig (org.guvnor.ala.build.maven.config.MavenProjectConfig)2 MavenBuildConfigExecutor (org.guvnor.ala.build.maven.executor.MavenBuildConfigExecutor)2 MavenBuildExecConfigExecutor (org.guvnor.ala.build.maven.executor.MavenBuildExecConfigExecutor)2 MavenProjectConfigExecutor (org.guvnor.ala.build.maven.executor.MavenProjectConfigExecutor)2 Input (org.guvnor.ala.pipeline.Input)2 Pipeline (org.guvnor.ala.pipeline.Pipeline)2 PipelineExecutor (org.guvnor.ala.pipeline.execution.PipelineExecutor)2 BuildRegistry (org.guvnor.ala.registry.BuildRegistry)2 SourceRegistry (org.guvnor.ala.registry.SourceRegistry)2 InMemoryBuildRegistry (org.guvnor.ala.registry.inmemory.InMemoryBuildRegistry)2 InMemoryRuntimeRegistry (org.guvnor.ala.registry.inmemory.InMemoryRuntimeRegistry)2 InMemorySourceRegistry (org.guvnor.ala.registry.inmemory.InMemorySourceRegistry)2 Runtime (org.guvnor.ala.runtime.Runtime)2 GitConfig (org.guvnor.ala.source.git.config.GitConfig)2 GitConfigExecutor (org.guvnor.ala.source.git.executor.GitConfigExecutor)2