/** * Shuts down this offline index thread.<p> */ protected void shutDown() { m_isAlive = false; interrupt(); if (m_isUpdating) { long waitTime = getOfflineUpdateFrequency() / 2; int waitSteps = 0; do { try { // wait half the time of the offline index frequency for the thread to finish Thread.sleep(waitTime); } catch (InterruptedException e) { // continue LOG.info(e.getLocalizedMessage(), e); } waitSteps++; // wait 5 times then stop waiting } while ((waitSteps < 5) && m_isUpdating); } }
/** * Updates all offline indexes.<p> * * Can be used to force an index update when it's not convenient to wait until the * offline update interval has eclipsed.<p> * * Since the offline index will still need some time to update the new resources even if it runs directly, * a wait time of 2500 or so should be given in order to make sure the index finished updating. * * @param waitTime milliseconds to wait after the offline update index was notified of the changes */ public void updateOfflineIndexes(long waitTime) { if ((m_offlineIndexThread != null) && m_offlineIndexThread.isAlive()) { // notify existing thread of update frequency change if (LOG.isDebugEnabled()) { LOG.debug(Messages.get().getBundle().key(Messages.LOG_OI_UPDATE_INTERRUPT_0)); } m_offlineIndexThread.interrupt(); if (waitTime > 0) { m_offlineIndexThread.getWaitHandle().enter(waitTime); } } }
/** * Shuts down this offline index thread.<p> */ protected void shutDown() { m_isAlive = false; interrupt(); } }