@Test public void shouldFireLifecycleEventsDuringStart() { cube.start(); assertEventFired(BeforeStart.class, 1); assertEventFired(AfterStart.class, 1); }
@Override public void start() throws CubeControlException { if (state == State.STARTED || state == State.PRE_RUNNING) { return; } try { lifecycle.fire(new BeforeStart(id)); long currentTime = System.currentTimeMillis(); executor.startContainer(id, configuration); long partialDuration = System.currentTimeMillis() - currentTime; this.startingTimeInMillis = this.startingTimeInMillis + partialDuration; state = State.STARTED; portBindings.containerStarted(); if (!AwaitStrategyFactory.create(executor, this, configuration).await()) { throw new IllegalArgumentException(String.format("Cannot connect to %s container", id)); } lifecycle.fire(new AfterStart(id)); } catch (Exception e) { state = State.START_FAILED; throw CubeControlException.failedStart(id, e); } }
DockerCube extends BaseCube<CubeContainer> { @Override public void start() throws CubeControlException { if (state == State.STARTED || state == State.PRE_RUNNING) { return; } try { lifecycle.fire(new BeforeStart(id)); long currentTime = System.currentTimeMillis(); executor.startContainer(id, configuration); long partialDuration = System.currentTimeMillis() - currentTime; this.startingTimeInMillis = this.startingTimeInMillis + partialDuration; state = State.STARTED; portBindings.containerStarted(); if (!AwaitStrategyFactory.create(executor, this, configuration).await()) { throw new IllegalArgumentException(String.format("Cannot connect to %s container", id)); } lifecycle.fire(new AfterStart(id)); } catch (Exception e) { state = State.START_FAILED; throw CubeControlException.failedStart(id, e); } } }
DockerCube extends BaseCube<CubeContainer> { @Override public void start() throws CubeControlException { if (state == State.STARTED || state == State.PRE_RUNNING) { return; } try { lifecycle.fire(new BeforeStart(id)); long currentTime = System.currentTimeMillis(); executor.startContainer(id, configuration); long partialDuration = System.currentTimeMillis() - currentTime; this.startingTimeInMillis = this.startingTimeInMillis + partialDuration; state = State.STARTED; portBindings.containerStarted(); if (!AwaitStrategyFactory.create(executor, this, configuration).await()) { throw new IllegalArgumentException(String.format("Cannot connect to %s container", id)); } lifecycle.fire(new AfterStart(id)); } catch (Exception e) { state = State.START_FAILED; throw CubeControlException.failedStart(id, e); } } DockerCube(String id, CubeContainer configuration, DockerClientExecutor executor); }
DockerCube extends BaseCube<CubeContainer> { @Override public void start() throws CubeControlException { if (state == State.STARTED || state == State.PRE_RUNNING) { return; } try { lifecycle.fire(new BeforeStart(id)); long currentTime = System.currentTimeMillis(); executor.startContainer(id, configuration); long partialDuration = System.currentTimeMillis() - currentTime; this.startingTimeInMillis = this.startingTimeInMillis + partialDuration; state = State.STARTED; portBindings.containerStarted(); if (!AwaitStrategyFactory.create(executor, this, configuration).await()) { throw new IllegalArgumentException(String.format("Cannot connect to %s container", id)); } lifecycle.fire(new AfterStart(id)); } catch (Exception e) { state = State.START_FAILED; throw CubeControlException.failedStart(id, e); } } DockerCube(String id, CubeContainer configuration, DockerClientExecutor executor); @Override State state(); @Override String getId(); @Override void create(); @Override void start(); @Override void stop(); @Override void destroy(); @Override Binding bindings(); @Override Binding configuredBindings(); @Override boolean isRunningOnRemote(); @Override CubeContainer configuration(); @Override void changeToPreRunning(); long getStartingTimeInMillis(); long getStoppingTimeInMillis(); }
DockerCube extends BaseCube<CubeContainer> { @Override public void start() throws CubeControlException { if (state == State.STARTED || state == State.PRE_RUNNING) { return; } try { lifecycle.fire(new BeforeStart(id)); long currentTime = System.currentTimeMillis(); executor.startContainer(id, configuration); long partialDuration = System.currentTimeMillis() - currentTime; this.startingTimeInMillis = this.startingTimeInMillis + partialDuration; state = State.STARTED; portBindings.containerStarted(); if (!AwaitStrategyFactory.create(executor, this, configuration).await()) { throw new IllegalArgumentException(String.format("Cannot connect to %s container", id)); } lifecycle.fire(new AfterStart(id)); } catch (Exception e) { state = State.START_FAILED; throw CubeControlException.failedStart(id, e); } } DockerCube(String id, CubeContainer configuration, DockerClientExecutor executor); @Override State state(); @Override String getId(); @Override void create(); @Override void start(); @Override void stop(); @Override void destroy(); @Override Binding bindings(); @Override Binding configuredBindings(); @Override boolean isRunningOnRemote(); @Override CubeContainer configuration(); @Override void changeToPreRunning(); long getStartingTimeInMillis(); long getStoppingTimeInMillis();  }