use of org.exist.storage.btree.DBException in project exist by eXist-db.
the class GMLHSQLIndex method shutdownDatabase.
@Override
protected void shutdownDatabase() throws DBException {
try {
// No need to shutdown if we have opened something
if (conn != null) {
Statement stmt = conn.createStatement();
stmt.executeQuery("SHUTDOWN");
stmt.close();
conn.close();
if (LOG.isDebugEnabled())
LOG.debug("GML index: {}/{} closed", getDataDir(), db_file_name_prefix);
}
} catch (SQLException e) {
throw new DBException(e.getMessage());
} finally {
conn = null;
}
}
use of org.exist.storage.btree.DBException in project exist by eXist-db.
the class LuceneIndexWorker method removeCollection.
@Override
public void removeCollection(Collection collection, DBBroker broker, boolean reindex) {
if (LOG.isDebugEnabled())
LOG.debug("Removing collection {}", collection.getURI());
IndexWriter writer = null;
try {
writer = index.getWriter();
for (Iterator<DocumentImpl> i = collection.iterator(broker); i.hasNext(); ) {
DocumentImpl doc = i.next();
final BytesRefBuilder bytes = new BytesRefBuilder();
NumericUtils.intToPrefixCoded(doc.getDocId(), 0, bytes);
Term dt = new Term(FIELD_DOC_ID, bytes.toBytesRef());
writer.deleteDocuments(dt);
}
} catch (IOException | PermissionDeniedException | LockException e) {
LOG.error("Error while removing lucene index: {}", e.getMessage(), e);
} finally {
index.releaseWriter(writer);
if (reindex) {
try {
index.sync();
} catch (DBException e) {
LOG.warn("Exception during reindex: {}", e.getMessage(), e);
}
}
mode = ReindexMode.STORE;
}
if (LOG.isDebugEnabled())
LOG.debug("Collection removed.");
}
use of org.exist.storage.btree.DBException in project exist by eXist-db.
the class LuceneIndex method remove.
@Override
public void remove() throws DBException {
close();
Path dir = getDataDir().resolve(getDirName());
try (Stream<Path> stream = Files.list(dir)) {
stream.forEach(FileUtils::deleteQuietly);
} catch (Exception e) {
// never abort at this point, so recovery can continue
LOG.warn(e.getMessage(), e);
}
}
use of org.exist.storage.btree.DBException in project exist by eXist-db.
the class LuceneIndex method close.
@Override
public synchronized void close() throws DBException {
try {
if (searcherManager != null) {
searcherManager.close();
searcherManager = null;
}
if (readerManager != null) {
readerManager.close();
readerManager = null;
}
if (cachedWriter != null) {
commit();
cachedTaxonomyWriter.close();
cachedWriter.close();
cachedTaxonomyWriter = null;
cachedWriter = null;
}
taxoDirectory.close();
directory.close();
} catch (IOException e) {
throw new DBException("Caught exception while closing lucene indexes: " + e.getMessage());
}
}
Aggregations