protected void awaitShutdown(long timeout) throws InterruptedException { awaitStatus(Status.SHUT_DOWN, timeout); }
@PreDestroy public void shutdown() { shutdown(2000); }
public void run() { try { while (shouldDoWork()) { doWork(); } } catch (Exception e) { logger.error(e, "Exception doing work"); exception.set(e); } this.status = Status.SHUTTING_DOWN; doShutdown(); this.status = Status.SHUT_DOWN; logger.info("Shutdown %s", this); }
@PostConstruct public void start() { logger.info("Starting %s", this); synchronized (this.statusLock) { if (this.status.compareTo(Status.SHUTDOWN_REQUEST) >= 0) { doShutdown(); this.status = Status.SHUT_DOWN; this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.ACTIVE) == 0) { this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.INACTIVE) != 0) { throw new IllegalStateException("Illegal state: " + this.status); } exceptionIfDependenciesNotActive(); this.status = Status.ACTIVE; } userExecutor.execute(this); }
/** * @return false if any dependencies are inactive, or we are inactive, or we have a global * exception. */ protected boolean shouldDoWork() { try { exceptionIfDependenciesNotActive(); } catch (IllegalStateException e) { return false; } return status.equals(Status.ACTIVE) && exception.get() == null; }
public void shutdown(long waitMs) { synchronized (this.statusLock) { if (this.status.compareTo(Status.ACTIVE) > 0) { return; } this.status = Status.SHUTDOWN_REQUEST; try { awaitShutdown(waitMs); } catch (InterruptedException ignore) { } } }
public void run() { try { while (shouldDoWork()) { doWork(); } } catch (Exception e) { logger.error(e, "Exception doing work"); exception.set(e); } this.status = Status.SHUTTING_DOWN; doShutdown(); this.status = Status.SHUT_DOWN; logger.info("Shutdown %s", this); }
@PostConstruct public void start() { logger.info("Starting %s", this); synchronized (this.statusLock) { if (this.status.compareTo(Status.SHUTDOWN_REQUEST) >= 0) { doShutdown(); this.status = Status.SHUT_DOWN; this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.ACTIVE) == 0) { this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.INACTIVE) != 0) { throw new IllegalStateException("Illegal state: " + this.status); } exceptionIfDependenciesNotActive(); this.status = Status.ACTIVE; } userExecutor.execute(this); }
/** * @return false if any dependencies are inactive, or we are inactive, or we have a global * exception. */ protected boolean shouldDoWork() { try { exceptionIfDependenciesNotActive(); } catch (IllegalStateException e) { return false; } return status.equals(Status.ACTIVE) && exception.get() == null; }
public void shutdown(long waitMs) { synchronized (this.statusLock) { if (this.status.compareTo(Status.ACTIVE) > 0) { return; } this.status = Status.SHUTDOWN_REQUEST; try { awaitShutdown(waitMs); } catch (InterruptedException ignore) { } } }
public void run() { try { while (shouldDoWork()) { doWork(); } } catch (Exception e) { logger.error(e, "Exception doing work"); exception.set(e); } this.status = Status.SHUTTING_DOWN; doShutdown(); this.status = Status.SHUT_DOWN; logger.info("Shutdown %s", this); }
@PostConstruct public void start() { logger.info("Starting %s", this); synchronized (this.statusLock) { if (this.status.compareTo(Status.SHUTDOWN_REQUEST) >= 0) { doShutdown(); this.status = Status.SHUT_DOWN; this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.ACTIVE) == 0) { this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.INACTIVE) != 0) { throw new IllegalStateException("Illegal state: " + this.status); } exceptionIfDependenciesNotActive(); this.status = Status.ACTIVE; } userExecutor.execute(this); }
/** * @return false if any dependencies are inactive, or we are inactive, or we have a global * exception. */ protected boolean shouldDoWork() { try { exceptionIfDependenciesNotActive(); } catch (IllegalStateException e) { return false; } return status.equals(Status.ACTIVE) && exception.get() == null; }
public void shutdown(long waitMs) { synchronized (this.statusLock) { if (this.status.compareTo(Status.ACTIVE) > 0) { return; } this.status = Status.SHUTDOWN_REQUEST; try { awaitShutdown(waitMs); } catch (InterruptedException ignore) { } } }
@PreDestroy public void shutdown() { shutdown(2000); }
protected void awaitShutdown(long timeout) throws InterruptedException { awaitStatus(Status.SHUT_DOWN, timeout); }
public void run() { try { while (shouldDoWork()) { doWork(); } } catch (Exception e) { logger.error(e, "Exception doing work"); exception.set(e); } this.status = Status.SHUTTING_DOWN; doShutdown(); this.status = Status.SHUT_DOWN; logger.info("Shutdown %s", this); }
@PostConstruct public void start() { logger.info("Starting %s", this); synchronized (this.statusLock) { if (this.status.compareTo(Status.SHUTDOWN_REQUEST) >= 0) { doShutdown(); this.status = Status.SHUT_DOWN; this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.ACTIVE) == 0) { this.statusLock.notifyAll(); return; } if (this.status.compareTo(Status.INACTIVE) != 0) { throw new IllegalStateException("Illegal state: " + this.status); } exceptionIfDependenciesNotActive(); this.status = Status.ACTIVE; } userExecutor.execute(this); }
/** * @return false if any dependencies are inactive, or we are inactive, or we have a global * exception. */ protected boolean shouldDoWork() { try { exceptionIfDependenciesNotActive(); } catch (IllegalStateException e) { return false; } return status.equals(Status.ACTIVE) && exception.get() == null; }
public void shutdown(long waitMs) { synchronized (this.statusLock) { if (this.status.compareTo(Status.ACTIVE) > 0) { return; } this.status = Status.SHUTDOWN_REQUEST; try { awaitShutdown(waitMs); } catch (InterruptedException ignore) { } } }