@Override public void start(String cubeId) { Cube<?> cube = cubeRegistry.get().getCube(cubeId); Validate.notNull(cube, "Cube with id '" + cubeId + "' to start does not exist."); controlEvent.fire(new StartCube(cubeId)); }
public void start(@Observes StartCube event, CubeRegistry registry) { validateAndGet(registry, event.getCubeId()).start(); }
@Override public void start(String cubeId) { Cube<?> cube = cubeRegistry.get().getCube(cubeId); Validate.notNull(cube, "Cube with id '" + cubeId + "' to start does not exist."); controlEvent.fire(new StartCube(cubeId)); }
public void start(@Observes StartCube event, CubeRegistry registry) { validateAndGet(registry, event.getCubeId()).start(); }
public void startAutoContainers(@Observes(precedence = 99) BeforeSuite event, Configuration conf) { if (!(conf instanceof CubeOpenShiftConfiguration)) { return; } CubeOpenShiftConfiguration openshiftConfiguration = (CubeOpenShiftConfiguration) conf; for (String cubeId : openshiftConfiguration.getAutoStartContainers()) { controlEvent.fire(new CreateCube(cubeId)); controlEvent.fire(new StartCube(cubeId)); } }
@Override public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException { final CubeRegistry cubeRegistry = cubeRegistryInstance.get(); Cube<?> cube = resolveMainCube(cubeRegistry); if (cube.hasMetadata(IsBuildable.class)) { File location = new File(cube.getMetadata(IsBuildable.class).getTemplatePath()); if (location.isDirectory()) { //Because ShrinkWrap may create different jar files depending on what we are testing in this case //we need a template which is the responsible to copy the jar to desired location try { createDockerfileFromTemplate(archive, location); // fire events as usually. controlEvent.fire(new CreateCube(cube)); controlEvent.fire(new StartCube(cube)); return createProtocolMetadata(cube, archive); } catch (FileNotFoundException e) { throw new IllegalArgumentException("Containerless Docker container requires a file named " + DOCKERFILE_TEMPLATE); } } else { throw new IllegalArgumentException( "Dockerfile Template of containerless Docker container must be in a directory."); } } else { throw new IllegalArgumentException( "Containerless container should be built using a Dockerfile, and no templatePath property found for container."); } }
@Test(expected = IllegalArgumentException.class) public void shouldThrowExceptionOnMisingCubeDuringStartCube() { fire(new StartCube(MISSING_CUBE_ID)); }
@Test public void shouldStartCube() { fire(new StartCube(CUBE_ID)); verify(cube).start(); }
@Override public RuntimeException call() throws Exception { try { if (connectionMode.isAllowReconnect() && isCubeRunning(cubeId)) { controlEvent.fire(new PreRunningCube(cubeId)); return null; } controlEvent.fire(new CreateCube(cubeId)); controlEvent.fire(new StartCube(cubeId)); if (connectionMode.isAllowReconnect() && !connectionMode.isStoppable()) { // If we allow reconnections and containers are none stoppable which means that they will be able to be // reused in next executions then at this point we can assume that the container is a prerunning container. controlEvent.fire(new PreRunningCube(cubeId)); } } catch (RuntimeException e) { return e; } return null; } }
@Override public RuntimeException call() throws Exception { try { if (connectionMode.isAllowReconnect() && isCubeRunning(cubeId)) { controlEvent.fire(new PreRunningCube(cubeId)); return null; } controlEvent.fire(new CreateCube(cubeId)); controlEvent.fire(new StartCube(cubeId)); if (connectionMode.isAllowReconnect() && !connectionMode.isStoppable()) { // If we allow reconnections and containers are none stoppable which means that they will be able to be // reused in next executions then at this point we can assume that the container is a prerunning container. controlEvent.fire(new PreRunningCube(cubeId)); } } catch (RuntimeException e) { return e; } return null; } }
public void startCubeMappedContainer(@Observes BeforeStart event, CubeRegistry cubeRegistry, ContainerRegistry containerRegistry, CubeConfiguration cubeConfiguration) { Container container = ContainerUtil.getContainerByDeployableContainer(containerRegistry, event.getDeployableContainer()); if (container == null) { return; } Cube<?> cube = cubeRegistry.getCube(ContainerUtil.getCubeIDForContainer(container)); if (cube == null) { return; // No Cube found matching Container name, not managed by Cube } ConnectionMode connectionMode = cubeConfiguration.getConnectionMode(); if (connectionMode.isAllowReconnect() && cube.isRunningOnRemote()) { controlEvent.fire(new PreRunningCube(cube)); return; } controlEvent.fire(new CreateCube(cube)); controlEvent.fire(new StartCube(cube)); if (connectionMode.isAllowReconnect() && !connectionMode.isStoppable()) { // If we allow reconnections and containers are none stoppable which means that they will be able to be // reused in next executions then at this point we can assume that the container is a prerunning container. controlEvent.fire(new PreRunningCube(cube)); } }
public void startCubeMappedContainer(@Observes BeforeStart event, CubeRegistry cubeRegistry, ContainerRegistry containerRegistry, CubeConfiguration cubeConfiguration) { Container container = ContainerUtil.getContainerByDeployableContainer(containerRegistry, event.getDeployableContainer()); if (container == null) { return; } Cube<?> cube = cubeRegistry.getCube(ContainerUtil.getCubeIDForContainer(container)); if (cube == null) { return; // No Cube found matching Container name, not managed by Cube } ConnectionMode connectionMode = cubeConfiguration.getConnectionMode(); if (connectionMode.isAllowReconnect() && cube.isRunningOnRemote()) { controlEvent.fire(new PreRunningCube(cube)); return; } controlEvent.fire(new CreateCube(cube)); controlEvent.fire(new StartCube(cube)); if (connectionMode.isAllowReconnect() && !connectionMode.isStoppable()) { // If we allow reconnections and containers are none stoppable which means that they will be able to be // reused in next executions then at this point we can assume that the container is a prerunning container. controlEvent.fire(new PreRunningCube(cube)); } }