Example usage for org.apache.lucene.store AlreadyClosedException AlreadyClosedException

List of usage examples for org.apache.lucene.store AlreadyClosedException AlreadyClosedException

Introduction

In this page you can find the example usage for org.apache.lucene.store AlreadyClosedException AlreadyClosedException.

Prototype

public AlreadyClosedException(String message) 

Source Link

Usage

From source file:cn.codepub.redis.directory.RedisLockFactory.java

License:Apache License

private static void clearLockHeld(Path realPath) {
    boolean remove = LOCK_HELD.remove(realPath.toString());
    if (!remove) {
        throw new AlreadyClosedException("Lock path was cleared but never marked as held: " + realPath);
    }/*w w  w.j  a v  a2  s.  c  o m*/
}

From source file:com.bah.lucene.blockcache_v2.CacheIndexInput.java

License:Apache License

private void ensureOpen() {
    if (_isClosed) {
        throw new AlreadyClosedException("Already closed: " + this);
    }/*  w ww  .  ja  va  2 s .  c  o  m*/
}

From source file:com.core.nlp.index.IndexReader.java

License:Apache License

/**
 * Expert: decreases the refCount of this IndexReader
 * instance.  If the refCount drops to 0, then this
 * reader is closed.  If an exception is hit, the refCount
 * is unchanged.//www .j a v  a  2 s  .  c  o  m
 *
 * @throws IOException in case an IOException occurs in  doClose()
 *
 * @see #incRef
 */
public final void decRef() throws IOException {
    // only check refcount here (don't call ensureOpen()), so we can
    // still close the reader if it was made invalid by a child:
    if (refCount.get() <= 0) {
        throw new AlreadyClosedException("this IndexReader is closed");
    }

    final int rc = refCount.decrementAndGet();
    if (rc == 0) {
        closed = true;
        Throwable throwable = null;
        try {
            doClose();
        } catch (Throwable th) {
            throwable = th;
        } finally {
            try {
                reportCloseToParentReaders();
            } finally {
                notifyReaderClosedListeners(throwable);
            }
        }
    } else if (rc < 0) {
        throw new IllegalStateException("too many decRef calls: refCount is " + rc + " after decrement");
    }
}

From source file:com.core.nlp.index.IndexReader.java

License:Apache License

/**
 * Throws AlreadyClosedException if this IndexReader or any
 * of its child readers is closed, otherwise returns.
 *///from w  w w. j  a va  2 s  . c  o  m
protected final void ensureOpen() throws AlreadyClosedException {
    if (refCount.get() <= 0) {
        throw new AlreadyClosedException("this IndexReader is closed");
    }
    // the happens before rule on reading the refCount, which must be after the fake write,
    // ensures that we see the value:
    if (closedByChild) {
        throw new AlreadyClosedException(
                "this IndexReader cannot be used anymore as one of its child readers was closed");
    }
}

From source file:com.gentics.cr.lucene.indexaccessor.IndexAccessorFactory.java

License:Apache License

/**
 * Get an {@link IndexAccessor} for the specified {@link Directory}.
 * @param indexDir {@link Directory} to get the {@link IndexAccessor} for.
 * @return {@link IndexAccessor} for the {@link Directory}.
 *///  w  w  w  .j a  v a2  s . c o m
public IndexAccessor getAccessor(final Directory indexDir) throws AlreadyClosedException {
    if (wasClosed) {
        throw new AlreadyClosedException(
                "IndexAccessorFactory was already closed" + ". Maybe there is a shutdown in progress.");
    }
    IndexAccessor indexAccessor = indexAccessors.get(indexDir);
    if (indexAccessor == null) {
        throw new IllegalStateException("Requested Accessor does not exist");
    }
    return indexAccessor;
}

From source file:com.github.lucene.store.jdbc.lock.PhantomReadLock.java

License:Apache License

@Override
public void close() throws IOException {
    if (!jdbcDirectory.fileExists(name)) {
        throw new AlreadyClosedException("Lock was already released: " + this);
    }//from w w  w. j  a v  a  2 s  .  c  o  m
    jdbcDirectory.getJdbcTemplate().executeUpdate(jdbcDirectory.getTable().sqlDeleteByName(),
            new JdbcTemplate.PrepateStatementAwareCallback() {
                @Override
                public void fillPrepareStatement(final PreparedStatement ps) throws Exception {
                    ps.setFetchSize(1);
                    ps.setString(1, name);
                }
            });
}

From source file:com.github.lucene.store.jdbc.lock.PhantomReadLock.java

License:Apache License

@Override
public void ensureValid() throws IOException {
    if (!jdbcDirectory.fileExists(name)) {
        // TODO should throw AlreadyClosedException??
        throw new AlreadyClosedException("Lock instance already released: " + this);
    }/*  w w w .ja  v  a2 s .  c  o  m*/
}

From source file:com.lucure.core.codec.CompressingStoredFieldsReader.java

License:Apache License

/**
 * @throws AlreadyClosedException if this FieldsReader is closed
 *//*  ww w  . j av a 2 s.c om*/
private void ensureOpen() throws AlreadyClosedException {
    if (closed) {
        throw new AlreadyClosedException("this FieldsReader is closed");
    }
}

From source file:com.nearinfinity.blur.manager.writer.nrt.SearcherManager.java

License:Apache License

/**
 * Obtain the current IndexSearcher. You must match every call to acquire with
 * one call to {@link #release}; it's best to do so in a finally clause.
 *//*from   w  w  w  .j a v  a2s. c  om*/
public IndexSearcher acquire() {
    IndexSearcher searcher;
    do {
        if ((searcher = currentSearcher) == null) {
            throw new AlreadyClosedException("this SearcherManager is closed");
        }
    } while (!searcher.getIndexReader().tryIncRef());
    return searcher;
}

From source file:com.nearinfinity.blur.manager.writer.nrt.SearcherManager.java

License:Apache License

private void ensureOpen() {
    if (currentSearcher == null) {
        throw new AlreadyClosedException("this SearcherManager is closed");
    }// w w  w  .j  a v  a2 s . c o  m
}