use of org.iq80.leveldb.WriteOptions in project camel by apache.
the class LevelDBFile method getWriteOptions.
public WriteOptions getWriteOptions() {
WriteOptions options = new WriteOptions();
options.sync(sync);
return options;
}
use of org.iq80.leveldb.WriteOptions in project jesos by groupon.
the class JLevelDBState method expunge.
@Override
public Future<Boolean> expunge(final Variable variable) {
checkNotNull(variable, "variable is null");
checkState(!closed.get(), "already closed");
checkState(variable instanceof JVariable, "can not process native variable, use JVariable");
final JVariable v = (JVariable) variable;
return executor.submit(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
final WriteOptions writeOptions = new WriteOptions();
writeOptions.sync(true);
final String internedName = v.getName().intern();
synchronized (internedName) {
final JVariable current = load(internedName);
if (current != null && current.getUuid().equals(v.getUuid())) {
db.delete(bytes(internedName));
return Boolean.TRUE;
} else {
return Boolean.FALSE;
}
}
}
});
}
use of org.iq80.leveldb.WriteOptions in project jesos by groupon.
the class JLevelDBState method store.
@Override
public Future<Variable> store(final Variable variable) {
checkNotNull(variable, "variable is null");
checkState(!closed.get(), "already closed");
checkState(variable instanceof JVariable, "can not process native variable, use JVariable");
final JVariable v = (JVariable) variable;
return executor.submit(new Callable<Variable>() {
@Override
public Variable call() throws Exception {
final WriteOptions writeOptions = new WriteOptions();
writeOptions.sync(true);
final String internedName = v.getName().intern();
synchronized (internedName) {
final JVariable current = load(internedName);
if (current == null || current.getUuid().equals(v.getUuid())) {
final JVariable update = new JVariable(internedName, v.value());
final WriteBatch writeBatch = db.createWriteBatch();
writeBatch.delete(bytes(internedName));
writeBatch.put(bytes(internedName), update.getEntry().toByteArray());
db.write(writeBatch, writeOptions);
return update;
} else {
return null;
}
}
}
});
}
Aggregations