use of org.apache.drill.common.concurrent.AutoCloseableLock in project drill by apache.
the class NoWriteLocalStore method close.
@Override
public void close() throws Exception {
try (AutoCloseableLock lock = writeLock.open()) {
store.clear();
version = -1;
}
}
use of org.apache.drill.common.concurrent.AutoCloseableLock in project drill by apache.
the class NoWriteLocalStore method delete.
@Override
public void delete(final String key) {
try (AutoCloseableLock lock = writeLock.open()) {
store.remove(key);
version++;
}
}
use of org.apache.drill.common.concurrent.AutoCloseableLock in project drill by apache.
the class NoWriteLocalStore method put.
@Override
public void put(final String key, final V value, final DataChangeVersion dataChangeVersion) {
try (AutoCloseableLock lock = writeLock.open()) {
if (dataChangeVersion != null && dataChangeVersion.getVersion() != version) {
throw new VersionMismatchException("Version mismatch detected", dataChangeVersion.getVersion());
}
store.put(key, value);
version++;
}
}
use of org.apache.drill.common.concurrent.AutoCloseableLock in project drill by apache.
the class InMemoryStore method close.
@Override
public void close() throws Exception {
try (AutoCloseableLock lock = writeLock.open()) {
store.clear();
version = -1;
}
}
use of org.apache.drill.common.concurrent.AutoCloseableLock in project drill by apache.
the class LocalPersistentStore method putIfAbsent.
@Override
public boolean putIfAbsent(String key, V value) {
try (AutoCloseableLock lock = writeLock.open()) {
try {
Path p = makePath(key);
if (fs.exists(p)) {
return false;
} else {
try (OutputStream os = fs.create(makePath(key))) {
IOUtils.write(config.getSerializer().serialize(value), os);
version++;
}
return true;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
Aggregations