@Test public void shouldFireLifecycleEventsDuringStop() { cube.stop(); assertEventFired(BeforeStop.class, 1); assertEventFired(AfterStop.class, 1); }
@Override public void stop() throws CubeControlException { if (state == State.STOPPED || state == State.PRE_RUNNING || state == State.DESTROYED) { return; } try { lifecycle.fire(new BeforeStop(id)); long currentTime = System.currentTimeMillis(); try { if (configuration.isKillContainer()) { executor.killContainer(id); } else { executor.stopContainer(id); } } catch (NotFoundException e) { } catch (NotModifiedException e) { } this.stoppingTimeInMillis = System.currentTimeMillis() - currentTime; state = State.STOPPED; lifecycle.fire(new AfterStop(id)); } catch (Exception e) { state = State.STOP_FAILED; throw CubeControlException.failedStop(id, e); } }
DockerCube extends BaseCube<CubeContainer> { @Override public void stop() throws CubeControlException { if (state == State.STOPPED || state == State.PRE_RUNNING || state == State.DESTROYED) { return; } try { lifecycle.fire(new BeforeStop(id)); long currentTime = System.currentTimeMillis(); try { if (configuration.isKillContainer()) { executor.killContainer(id); } else { executor.stopContainer(id); } } catch (NotFoundException e) { } catch (NotModifiedException e) { } this.stoppingTimeInMillis = System.currentTimeMillis() - currentTime; state = State.STOPPED; lifecycle.fire(new AfterStop(id)); } catch (Exception e) { state = State.STOP_FAILED; throw CubeControlException.failedStop(id, e); } } }
DockerCube extends BaseCube<CubeContainer> { @Override public void stop() throws CubeControlException { if (state == State.STOPPED || state == State.PRE_RUNNING || state == State.DESTROYED) { return; } try { lifecycle.fire(new BeforeStop(id)); long currentTime = System.currentTimeMillis(); try { if (configuration.isKillContainer()) { executor.killContainer(id); } else { executor.stopContainer(id); } } catch (NotFoundException e) { } catch (NotModifiedException e) { } this.stoppingTimeInMillis = System.currentTimeMillis() - currentTime; state = State.STOPPED; lifecycle.fire(new AfterStop(id)); } catch (Exception e) { state = State.STOP_FAILED; throw CubeControlException.failedStop(id, e); } } DockerCube(String id, CubeContainer configuration, DockerClientExecutor executor); }
DockerCube extends BaseCube<CubeContainer> { @Override public void stop() throws CubeControlException { if (state == State.STOPPED || state == State.PRE_RUNNING || state == State.DESTROYED) { return; } try { lifecycle.fire(new BeforeStop(id)); long currentTime = System.currentTimeMillis(); try { if (configuration.isKillContainer()) { executor.killContainer(id); } else { executor.stopContainer(id); } } catch (NotFoundException e) { } catch (NotModifiedException e) { } this.stoppingTimeInMillis = System.currentTimeMillis() - currentTime; state = State.STOPPED; lifecycle.fire(new AfterStop(id)); } catch (Exception e) { state = State.STOP_FAILED; throw CubeControlException.failedStop(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 stop() throws CubeControlException { if (state == State.STOPPED || state == State.PRE_RUNNING || state == State.DESTROYED) { return; } try { lifecycle.fire(new BeforeStop(id)); long currentTime = System.currentTimeMillis(); try { if (configuration.isKillContainer()) { executor.killContainer(id); } else { executor.stopContainer(id); } } catch (NotFoundException e) { } catch (NotModifiedException e) { } this.stoppingTimeInMillis = System.currentTimeMillis() - currentTime; state = State.STOPPED; lifecycle.fire(new AfterStop(id)); } catch (Exception e) { state = State.STOP_FAILED; throw CubeControlException.failedStop(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();  }