@Test public void shouldFireLifecycleEventsDuringCreate() { cube.create(); assertEventFired(BeforeCreate.class, 1); assertEventFired(AfterCreate.class, 1); }
@Override public void create() throws CubeControlException { if (state == State.BEFORE_CREATE || state == State.DESTROYED) { try { lifecycle.fire(new BeforeCreate(id)); log.fine(String.format("Creating container with name %s and configuration %s.", id, configuration)); long currentTime = System.currentTimeMillis(); executor.createContainer(id, configuration); this.startingTimeInMillis = System.currentTimeMillis() - currentTime; log.fine(String.format("Created container with id %s.", id)); state = State.CREATED; lifecycle.fire(new AfterCreate(id)); } catch (Exception e) { state = State.CREATE_FAILED; throw CubeControlException.failedCreate(id, e); } } }
DockerCube extends BaseCube<CubeContainer> { @Override public void create() throws CubeControlException { if (state == State.BEFORE_CREATE || state == State.DESTROYED) { try { lifecycle.fire(new BeforeCreate(id)); log.fine(String.format("Creating container with name %s and configuration %s.", id, configuration)); long currentTime = System.currentTimeMillis(); executor.createContainer(id, configuration); this.startingTimeInMillis = System.currentTimeMillis() - currentTime; log.fine(String.format("Created container with id %s.", id)); state = State.CREATED; lifecycle.fire(new AfterCreate(id)); } catch (Exception e) { state = State.CREATE_FAILED; throw CubeControlException.failedCreate(id, e); } } } }
DockerCube extends BaseCube<CubeContainer> { @Override public void create() throws CubeControlException { if (state == State.BEFORE_CREATE || state == State.DESTROYED) { try { lifecycle.fire(new BeforeCreate(id)); log.fine(String.format("Creating container with name %s and configuration %s.", id, configuration)); long currentTime = System.currentTimeMillis(); executor.createContainer(id, configuration); this.startingTimeInMillis = System.currentTimeMillis() - currentTime; log.fine(String.format("Created container with id %s.", id)); state = State.CREATED; lifecycle.fire(new AfterCreate(id)); } catch (Exception e) { state = State.CREATE_FAILED; throw CubeControlException.failedCreate(id, e); } } } DockerCube(String id, CubeContainer configuration, DockerClientExecutor executor); }
DockerCube extends BaseCube<CubeContainer> { @Override public void create() throws CubeControlException { if (state == State.BEFORE_CREATE || state == State.DESTROYED) { try { lifecycle.fire(new BeforeCreate(id)); log.fine(String.format("Creating container with name %s and configuration %s.", id, configuration)); long currentTime = System.currentTimeMillis(); executor.createContainer(id, configuration); this.startingTimeInMillis = System.currentTimeMillis() - currentTime; log.fine(String.format("Created container with id %s.", id)); state = State.CREATED; lifecycle.fire(new AfterCreate(id)); } catch (Exception e) { state = State.CREATE_FAILED; throw CubeControlException.failedCreate(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 create() throws CubeControlException { if (state == State.BEFORE_CREATE || state == State.DESTROYED) { try { lifecycle.fire(new BeforeCreate(id)); log.fine(String.format("Creating container with name %s and configuration %s.", id, configuration)); long currentTime = System.currentTimeMillis(); executor.createContainer(id, configuration); this.startingTimeInMillis = System.currentTimeMillis() - currentTime; log.fine(String.format("Created container with id %s.", id)); state = State.CREATED; lifecycle.fire(new AfterCreate(id)); } catch (Exception e) { state = State.CREATE_FAILED; throw CubeControlException.failedCreate(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();  }