List of usage examples for org.apache.lucene.util ThreadInterruptedException ThreadInterruptedException
public ThreadInterruptedException(InterruptedException ie)
From source file:com.nearinfinity.blur.manager.writer.nrt.NRTManager.java
License:Apache License
/** * Waits for a given {@link SearcherManager} target generation to be available * via {@link #getSearcherManager(boolean)}. If the current generation is less * than the given target generation this method will block until the * correspondent {@link SearcherManager} is reopened by another thread via * {@link #maybeReopen(boolean)}, the given waiting time has elapsed, or until * the {@link NRTManager} is closed.//from www .j av a 2 s . c o m * <p> * NOTE: if the waiting time elapses before the requested target generation is * available the latest {@link SearcherManager} is returned instead. * * @param targetGen * the generation to wait for * @param requireDeletes * <code>true</code> iff the generation requires deletes to be * applied otherwise <code>false</code> * @param time * the time to wait for the target generation * @param unit * the waiting time's time unit * @return the {@link SearcherManager} with the given target generation or the * latest {@link SearcherManager} if the waiting time elapsed before * the requested generation is available. */ public SearcherManager waitForGeneration(long targetGen, boolean requireDeletes, long time, TimeUnit unit) { try { final long curGen = indexingGen.get(); if (targetGen > curGen) { throw new IllegalArgumentException("targetGen=" + targetGen + " was never returned by this NRTManager instance (current gen=" + curGen + ")"); } reopenLock.lockInterruptibly(); try { if (targetGen > getCurrentSearchingGen(requireDeletes)) { for (WaitingListener listener : waitingListeners) { listener.waiting(requireDeletes, targetGen); } while (targetGen > getCurrentSearchingGen(requireDeletes)) { if (!waitOnGenCondition(time, unit)) { return getSearcherManager(requireDeletes); } } } } finally { reopenLock.unlock(); } } catch (InterruptedException ie) { throw new ThreadInterruptedException(ie); } return getSearcherManager(requireDeletes); }
From source file:com.novartis.pcs.ontology.service.search.LuceneIndexWriterXAResource.java
License:Apache License
private synchronized void setXid(Xid xid) throws XAException { // start method should have been called with TMJOIN // because isSameRM would have returned true if (currentXid != null && currentXid.equals(xid)) { throw new XAException(XAException.XAER_DUPID); }//from w ww. j a v a 2 s.com while (state != TransactionState.NONE && currentXid != null) { logger.finest("Blocking thread with transaction (id=" + xid + " ) because current transaction (id=" + currentXid + ") is still in progress"); try { wait(); } catch (InterruptedException e) { if (Thread.interrupted()) { // clears interrupted status logger.log(Level.WARNING, "Thread waiting for transaction (id=" + currentXid + ") to complete has been interrupted?", e); throw new ThreadInterruptedException(e); } } } currentXid = xid; state = TransactionState.ACTIVE; }
From source file:org.middleheaven.text.indexing.lucene.ManagedFileDirectory.java
License:Apache License
@Override public void sync(String name) throws IOException { ensureOpen();/* www .j ava2s . c om*/ ManagedFile fullFile = directory.retrive(name); boolean success = false; int retryCount = 0; IOException exc = null; while (!success && retryCount < 5) { retryCount++; RandomAccessFile file = null; try { try { file = new RandomAccessFile(fullFile.getPath().toString(), "rw"); file.getFD().sync(); success = true; } finally { if (file != null) file.close(); } } catch (IOException ioe) { if (exc == null) exc = ioe; try { // Pause 5 msec Thread.sleep(5); } catch (InterruptedException ie) { throw new ThreadInterruptedException(ie); } } } if (!success) // Throw original exception throw exc; }