return 0;
}
-int DBObjectMap::write_state() {
+int DBObjectMap::sync() {
+ return write_state(true);
+}
+
+int DBObjectMap::write_state(bool sync) {
dout(20) << "dbobjectmap: seq is " << next_seq << dendl;
KeyValueDB::Transaction t = db->get_transaction();
State state;
map<string, bufferlist> to_write;
to_write[GLOBAL_STATE_KEY] = bl;
t->set(SYS_PREFIX, to_write);
- return db->submit_transaction(t);
+ return sync ? db->submit_transaction_sync(t) : db->submit_transaction(t);
}
/// Consistency check, debug, there must be no parallel writes
bool check(std::ostream &out);
+ /// Ensure that all previous operations are durable
+ int sync();
+
ObjectMapIterator get_iterator(const hobject_t &hoid,
CollectionIndex::IndexedPath path);
KeyValueDB::Transaction t);
/// Writes out State (mainly next_seq)
- int write_state();
+ int write_state(bool sync = false);
/// 0 if the complete set now contains all of key space, < 0 on error, 1 else
int need_parent(DBObjectMapIterator iter);
virtual Transaction get_transaction() = 0;
virtual int submit_transaction(Transaction) = 0;
+ virtual int submit_transaction_sync(Transaction t) {
+ return submit_transaction(t);
+ }
/// Retrieve Keys
virtual int get(
return s.ok() ? 0 : -1;
}
+ int submit_transaction_sync(KeyValueDB::Transaction t) {
+ LevelDBTransactionImpl * _t =
+ static_cast<LevelDBTransactionImpl *>(t.get());
+ leveldb::WriteOptions options;
+ options.sync = true;
+ leveldb::Status s = db->Write(options, &(_t->bat));
+ return s.ok() ? 0 : -1;
+ }
+
int get(
const string &prefix,
const std::set<string> &key,
CollectionIndex::IndexedPath target_path ///< [in] path to target
) { return 0; }
+ /// Ensure all previous writes are durable
+ virtual int sync() { return 0; }
+
virtual bool check(std::ostream &out) { return true; }
class ObjectMapIteratorImpl {