arpadboda commented on a change in pull request #605: MINIFICPP-550 - Implement 
RocksDB controller service and component st…
URL: https://github.com/apache/nifi-minifi-cpp/pull/605#discussion_r393361527
 
 

 ##########
 File path: 
extensions/rocksdb-repos/controllers/RocksDbPersistableKeyValueStoreService.cpp
 ##########
 @@ -0,0 +1,200 @@
+/**
+ * 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.
+ */
+
+#include "RocksDbPersistableKeyValueStoreService.h"
+
+#include "utils/StringUtils.h"
+
+#include <fstream>
+
+namespace org {
+namespace apache {
+namespace nifi {
+namespace minifi {
+namespace controllers {
+
+core::Property RocksDbPersistableKeyValueStoreService::Directory(
+    core::PropertyBuilder::createProperty("Directory")->withDescription("Path 
to a directory for the database")
+        ->isRequired(true)->build());
+
+RocksDbPersistableKeyValueStoreService::RocksDbPersistableKeyValueStoreService(const
 std::string& name, const std::string& id)
+    : controllers::KeyValueStoreService(name, id)
+    , controllers::AbstractAutoPersistingKeyValueStoreService(name, id)
+    , db_valid_(false)
+    , 
logger_(logging::LoggerFactory<RocksDbPersistableKeyValueStoreService>::getLogger())
 {
+}
+
+RocksDbPersistableKeyValueStoreService::RocksDbPersistableKeyValueStoreService(const
 std::string& name, utils::Identifier uuid /*= utils::Identifier()*/)
+    : controllers::KeyValueStoreService(name, uuid)
+    , controllers::AbstractAutoPersistingKeyValueStoreService(name, uuid)
+    , db_valid_(false)
+    , 
logger_(logging::LoggerFactory<RocksDbPersistableKeyValueStoreService>::getLogger())
 {
+}
+
+RocksDbPersistableKeyValueStoreService::~RocksDbPersistableKeyValueStoreService()
 {
+  if (db_valid_) {
+    delete db_;
+  }
+}
+
+void RocksDbPersistableKeyValueStoreService::initialize() {
+  AbstractAutoPersistingKeyValueStoreService::initialize();
+  std::set<core::Property> supportedProperties;
+  supportedProperties.insert(Directory);
+  updateSupportedProperties(supportedProperties);
+}
+
+void RocksDbPersistableKeyValueStoreService::onEnable() {
+  if (configuration_ == nullptr) {
+    logger_->log_debug("Cannot enable RocksDbPersistableKeyValueStoreService");
+    return;
+  }
+
+  AbstractAutoPersistingKeyValueStoreService::onEnable();
+
+  if (!getProperty(Directory.getName(), directory_)) {
+    logger_->log_error("Invalid or missing property: Directory");
+    return;
+  }
+
+  if (db_valid_) {
+    db_valid_ = false;
+    delete db_;
+  }
+  rocksdb::Options options;
+  options.create_if_missing = true;
 
 Review comment:
   We will need the buffer options to be set here the same way as we did for FF 
repo, otherwise the persistent storage will slowly generate the same 64 
megabyte peaks we just got rid of. 

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to