use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.
the class LuceneIndex method getWriter.
private IndexWriter getWriter(String store) throws StorageException {
Preconditions.checkArgument(writerLock.isHeldByCurrentThread());
IndexWriter writer = writers.get(store);
if (writer == null) {
IndexWriterConfig iwc = new IndexWriterConfig(LUCENE_VERSION, analyzer);
iwc.setOpenMode(IndexWriterConfig.OpenMode.CREATE_OR_APPEND);
try {
writer = new IndexWriter(getStoreDirectory(store), iwc);
writers.put(store, writer);
} catch (IOException e) {
throw new PermanentStorageException("Could not create writer", e);
}
}
return writer;
}
use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.
the class LuceneIndex method getStoreDirectory.
private Directory getStoreDirectory(String store) throws StorageException {
Preconditions.checkArgument(StringUtils.isAlphanumeric(store), "Invalid store name: %s", store);
String dir = basePath + File.separator + store;
try {
File path = new File(dir);
if (!path.exists())
path.mkdirs();
if (!path.exists() || !path.isDirectory() || !path.canWrite())
throw new PermanentStorageException("Cannot access or write to directory: " + dir);
log.debug("Opening store directory [{}]", path);
return FSDirectory.open(path);
} catch (IOException e) {
throw new PermanentStorageException("Could not open directory: " + dir, e);
}
}
use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.
the class PersistitKeyValueStore method clear.
/**
* Clears the contents of this kv store
*/
public void clear() throws StorageException {
try {
Exchange exchange = persistit.getExchange(VOLUME_NAME, name, true);
exchange.removeTree();
} catch (PersistitException ex) {
throw new PermanentStorageException(ex);
}
}
use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.
the class PersistitKeyValueStore method get.
@Override
public StaticBuffer get(final StaticBuffer key, StoreTransaction txh) throws StorageException {
final PersistitTransaction tx = (PersistitTransaction) txh;
synchronized (tx) {
tx.assign();
final Exchange exchange = tx.getExchange(name);
try {
toKey(exchange, key);
exchange.fetch();
if (exchange.getValue().isDefined()) {
return getValue(exchange);
} else {
return null;
}
} catch (PersistitException ex) {
throw new PermanentStorageException(ex);
} finally {
tx.releaseExchange(exchange);
}
}
}
use of com.thinkaurelius.titan.diskstorage.PermanentStorageException in project titan by thinkaurelius.
the class PersistitKeyValueStore method containsKey.
@Override
public boolean containsKey(final StaticBuffer key, StoreTransaction txh) throws StorageException {
final PersistitTransaction tx = (PersistitTransaction) txh;
synchronized (tx) {
tx.assign();
final Exchange exchange = tx.getExchange(name);
try {
toKey(exchange, key);
return exchange.isValueDefined();
} catch (PersistitException ex) {
throw new PermanentStorageException(ex);
} finally {
tx.releaseExchange(exchange);
}
}
}
Aggregations