You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/08/24 11:15:03 UTC

[GitHub] [nifi-minifi-cpp] fgerlits commented on a change in pull request #877: MINIFICPP-1339 - Reopen rocksdb database when space becomes available on the disk

fgerlits commented on a change in pull request #877:
URL: https://github.com/apache/nifi-minifi-cpp/pull/877#discussion_r475487913



##########
File path: extensions/rocksdb-repos/RocksDatabase.h
##########
@@ -0,0 +1,98 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <mutex>
+
+#include "utils/OptionalUtils.h"
+#include "rocksdb/db.h"
+#include "rocksdb/options.h"
+#include "rocksdb/slice.h"
+#include "rocksdb/utilities/checkpoint.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace internal {
+
+class RocksDatabase;
+
+// Not thread safe
+class OpenRocksDB {

Review comment:
       `OpenRocksDB` could be non-copyable, as the intended use seems to be obtain_from_open() -> use -> discard.

##########
File path: extensions/rocksdb-repos/FlowFileRepository.cpp
##########
@@ -71,7 +75,7 @@ void FlowFileRepository::flush() {
     batch.Delete(keys[i]);
   }
 
-  auto operation = [this, &batch]() { return db_->Write(rocksdb::WriteOptions(), &batch); };
+  auto operation = [this, &batch, &opendb]() { return opendb->Write(rocksdb::WriteOptions(), &batch); };

Review comment:
       I think `this` does not need to be captured any longer (also at a few other places)

##########
File path: extensions/rocksdb-repos/RocksDbStream.h
##########
@@ -160,7 +160,7 @@ class RocksDbStream : public io::BaseStream {
 
   std::string value_;
 
-  rocksdb::DB *db_;
+  gsl::not_null<minifi::internal::RocksDatabase*> db_;

Review comment:
       Could the type of the field (and the constructor parameter) be `RocksDatabase&`?  Then we could call the constructor with `*db_` instead of `gsl::make_not_null<minifi::internal::RocksDatabase*>(db_.get())`.

##########
File path: extensions/rocksdb-repos/RocksDatabase.h
##########
@@ -0,0 +1,98 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+#include <mutex>
+
+#include "utils/OptionalUtils.h"
+#include "rocksdb/db.h"
+#include "rocksdb/options.h"
+#include "rocksdb/slice.h"
+#include "rocksdb/utilities/checkpoint.h"
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace internal {
+
+class RocksDatabase;
+
+// Not thread safe
+class OpenRocksDB {
+  friend class RocksDatabase;
+
+  OpenRocksDB(gsl::not_null<RocksDatabase*> db, gsl::not_null<std::shared_ptr<rocksdb::DB>> impl);
+
+ public:
+  rocksdb::Status Put(const rocksdb::WriteOptions& options, const rocksdb::Slice& key, const rocksdb::Slice& value);
+
+  rocksdb::Status Get(const rocksdb::ReadOptions& options, const rocksdb::Slice& key, std::string* value);
+
+  std::vector<rocksdb::Status> MultiGet(const rocksdb::ReadOptions& options, const std::vector<rocksdb::Slice>& keys, std::vector<std::string>* values);
+
+  rocksdb::Status Write(const rocksdb::WriteOptions& options, rocksdb::WriteBatch* updates);
+
+  rocksdb::Status Delete(const rocksdb::WriteOptions& options, const rocksdb::Slice& key);
+
+  rocksdb::Status Merge(const rocksdb::WriteOptions& options, const rocksdb::Slice& key, const rocksdb::Slice& value);
+
+  bool GetProperty(const rocksdb::Slice& property, std::string* value);
+
+  rocksdb::Iterator* NewIterator(const rocksdb::ReadOptions& options);

Review comment:
       this could return a `unique_ptr`, as we always wrap the result into one

##########
File path: extensions/rocksdb-repos/FlowFileRepository.cpp
##########
@@ -134,14 +142,18 @@ void FlowFileRepository::prune_stored_flowfiles() {
     if (status.ok()) {

Review comment:
       Can we wrap `OpenForReadOnly` into a `RocksDatabase::openForReadOnly()`, too?  I think that would help simplify this code, and we could have one variable referring to the DB instead of three.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org