Search in sources :

Example 11 with Task

use of io.fabric8.maven.docker.util.Task in project fabric8 by jboss-fuse.

the class WaitForProvisionTaskTest method testProvisioningTimeout.

@Test
public void testProvisioningTimeout() throws Exception {
    Container container = createMock(Container.class);
    expect(container.getId()).andReturn("container").anyTimes();
    expect(container.isAlive()).andReturn(true).anyTimes();
    expect(container.isManaged()).andReturn(true).anyTimes();
    expect(container.getProvisionStatus()).andReturn("").anyTimes();
    expect(container.getSshUrl()).andReturn("container:8181").anyTimes();
    expect(container.getProvisionException()).andReturn(null).anyTimes();
    replay(container);
    WaitForProvisionTask task = new WaitForProvisionTask(container, "success", 4000L);
    assertFalse(task.call());
    verify(container);
}
Also used : Container(io.fabric8.api.Container) Test(org.junit.Test)

Example 12 with Task

use of io.fabric8.maven.docker.util.Task in project fabric8-maven-plugin by fabric8io.

the class DockerImageWatcher method watch.

@Override
public void watch(List<ImageConfiguration> configs, final Set<HasMetadata> resources, PlatformMode mode) {
    BuildService.BuildContext buildContext = getContext().getBuildContext();
    WatchService.WatchContext watchContext = getContext().getWatchContext();
    // add a image customizer
    watchContext = new WatchService.WatchContext.Builder(watchContext).imageCustomizer(new Task<ImageConfiguration>() {

        @Override
        public void execute(ImageConfiguration imageConfiguration) throws DockerAccessException, MojoExecutionException, MojoFailureException {
            buildImage(imageConfiguration);
        }
    }).containerRestarter(new Task<WatchService.ImageWatcher>() {

        @Override
        public void execute(WatchService.ImageWatcher imageWatcher) throws DockerAccessException, MojoExecutionException, MojoFailureException {
            restartContainer(imageWatcher, resources);
        }
    }).build();
    ServiceHub hub = getContext().getServiceHub();
    try {
        hub.getWatchService().watch(watchContext, buildContext, configs);
    } catch (Exception ex) {
        throw new RuntimeException("Error while watching", ex);
    }
}
Also used : Task(io.fabric8.maven.docker.util.Task) ServiceHub(io.fabric8.maven.docker.service.ServiceHub) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) BuildService(io.fabric8.maven.docker.service.BuildService) MojoFailureException(org.apache.maven.plugin.MojoFailureException) DockerAccessException(io.fabric8.maven.docker.access.DockerAccessException) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ImageConfiguration(io.fabric8.maven.docker.config.ImageConfiguration) DockerAccessException(io.fabric8.maven.docker.access.DockerAccessException) WatchService(io.fabric8.maven.docker.service.WatchService)

Aggregations

Test (org.junit.Test)6 Container (io.fabric8.api.Container)5 IOException (java.io.IOException)4 FabricException (io.fabric8.api.FabricException)2 ImageConfiguration (io.fabric8.maven.docker.config.ImageConfiguration)2 Task (io.fabric8.maven.docker.util.Task)2 MalformedURLException (java.net.MalformedURLException)2 KeeperException (org.apache.zookeeper.KeeperException)2 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)2 DataStoreTemplate (io.fabric8.api.DataStoreTemplate)1 GitContext (io.fabric8.api.GitContext)1 LockHandle (io.fabric8.api.LockHandle)1 Dispatched (io.fabric8.dosgi.api.Dispatched)1 GitProxyService (io.fabric8.git.GitProxyService)1 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)1 DockerAccessException (io.fabric8.maven.docker.access.DockerAccessException)1 PortMapping (io.fabric8.maven.docker.access.PortMapping)1 WatchImageConfiguration (io.fabric8.maven.docker.config.WatchImageConfiguration)1 BuildService (io.fabric8.maven.docker.service.BuildService)1 ServiceHub (io.fabric8.maven.docker.service.ServiceHub)1