Search in sources :

Example 1 with LifecycleException

use of io.fabric8.runtime.container.LifecycleException in project fabric8 by jboss-fuse.

the class Fabric8Container method start.

@Override
public void start() throws LifecycleException {
    // lets kill any containers that are running before we start
    FabricAssertions.killJavaAndDockerProcesses();
    fabricControllerManager = createFabricControllerManager();
    Fabric8ContainerConfiguration config = configuration.get();
    config.configure(fabricControllerManager);
    try {
        FabricController fabricController = FabricAssertions.assertFabricCreate(fabricControllerManager);
        controller.set(fabricController);
    } catch (Exception e) {
        throw new LifecycleException("Failed to create fabric: " + e, e);
    }
    System.out.println("Created a controller " + controller.get());
}
Also used : LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) FabricController(io.fabric8.testkit.FabricController) LifecycleException(org.jboss.arquillian.container.spi.client.container.LifecycleException) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException)

Example 2 with LifecycleException

use of io.fabric8.runtime.container.LifecycleException in project fabric8 by jboss-fuse.

the class AbstractManagedContainer method start.

@Override
public final synchronized void start() throws LifecycleException {
    assertNotDestroyed();
    try {
        if (state == State.CREATED || state == State.STOPPED) {
            doStart(configuration);
            state = State.STARTED;
        }
    } catch (Exception ex) {
        throw new LifecycleException("Cannot start container", ex);
    }
}
Also used : LifecycleException(io.fabric8.runtime.container.LifecycleException) LifecycleException(io.fabric8.runtime.container.LifecycleException) IOException(java.io.IOException)

Example 3 with LifecycleException

use of io.fabric8.runtime.container.LifecycleException in project fabric8 by jboss-fuse.

the class AbstractManagedContainer method stop.

@Override
public final synchronized void stop() throws LifecycleException {
    assertNotDestroyed();
    try {
        if (state == State.STARTED) {
            doStop(configuration);
            state = State.STOPPED;
        }
    } catch (Exception ex) {
        throw new LifecycleException("Cannot stop container", ex);
    }
}
Also used : LifecycleException(io.fabric8.runtime.container.LifecycleException) LifecycleException(io.fabric8.runtime.container.LifecycleException) IOException(java.io.IOException)

Example 4 with LifecycleException

use of io.fabric8.runtime.container.LifecycleException in project fabric8 by jboss-fuse.

the class AbstractManagedContainer method create.

@Override
public final synchronized void create(T configuration) throws LifecycleException {
    if (state != null)
        throw new IllegalStateException("Cannot create container in state: " + state);
    this.configuration = configuration;
    // [TODO] [FABRIC-929] No connector available to access repository jboss-public-repository-group
    // Remove this hack. It shouldbe possible to use the shrinkwrap maven resolver
    boolean useShrinkwrap = System.getProperty("shrinkwrap.resolver") != null;
    for (MavenCoordinates artefact : configuration.getMavenCoordinates()) {
        File zipfile = useShrinkwrap ? shrinkwrapResolve(artefact) : localResolve(artefact);
        GenericArchive archive = ShrinkWrap.createFromZipFile(GenericArchive.class, zipfile);
        ExplodedExporter exporter = archive.as(ExplodedExporter.class);
        File targetdir = configuration.getTargetDirectory();
        if (!targetdir.isDirectory() && !targetdir.mkdirs())
            throw new IllegalStateException("Cannot create target dir: " + targetdir);
        if (containerHome == null) {
            exporter.exportExploded(targetdir, "");
            File[] childDirs = targetdir.listFiles();
            if (childDirs.length != 1)
                throw new IllegalStateException("Expected one child directory, but was: " + Arrays.asList(childDirs));
            containerHome = childDirs[0];
        } else {
            exporter.exportExploded(containerHome, "");
        }
    }
    state = State.CREATED;
    try {
        doConfigure(configuration);
    } catch (Exception ex) {
        throw new LifecycleException("Cannot configure container", ex);
    }
}
Also used : MavenCoordinates(io.fabric8.api.gravia.MavenCoordinates) LifecycleException(io.fabric8.runtime.container.LifecycleException) GenericArchive(org.jboss.shrinkwrap.api.GenericArchive) ExplodedExporter(org.jboss.shrinkwrap.api.exporter.ExplodedExporter) File(java.io.File) LifecycleException(io.fabric8.runtime.container.LifecycleException) IOException(java.io.IOException)

Aggregations

LifecycleException (io.fabric8.runtime.container.LifecycleException)3 IOException (java.io.IOException)3 MavenCoordinates (io.fabric8.api.gravia.MavenCoordinates)1 FabricController (io.fabric8.testkit.FabricController)1 File (java.io.File)1 DeploymentException (org.jboss.arquillian.container.spi.client.container.DeploymentException)1 LifecycleException (org.jboss.arquillian.container.spi.client.container.LifecycleException)1 GenericArchive (org.jboss.shrinkwrap.api.GenericArchive)1 ExplodedExporter (org.jboss.shrinkwrap.api.exporter.ExplodedExporter)1