adamdebreceni commented on code in PR #2209:
URL: https://github.com/apache/nifi-minifi-cpp/pull/2209#discussion_r3843231055
##########
extensions/rocksdb-repos/RocksDbProvenanceRepository.h:
##########
@@ -39,22 +40,22 @@ constexpr auto MAX_PROVENANCE_STORAGE_SIZE = 10_MiB;
constexpr auto MAX_PROVENANCE_ENTRY_LIFE_TIME = std::chrono::minutes(1);
constexpr auto PROVENANCE_PURGE_PERIOD = std::chrono::milliseconds(2500);
-class ProvenanceRepository : public core::repository::RocksDbRepository {
+class RocksDbProvenanceRepository : public
core::repository::RocksDbRepository, public ProvenanceRepository {
public:
- ProvenanceRepository(std::string_view name, const utils::Identifier&
/*uuid*/)
- : ProvenanceRepository(name) {
+ RocksDbProvenanceRepository(std::string_view name, const utils::Identifier&
/*uuid*/)
+ : RocksDbProvenanceRepository(name) {
}
- explicit ProvenanceRepository(std::string_view repo_name = "",
+ explicit RocksDbProvenanceRepository(std::string_view repo_name = "",
std::string directory = PROVENANCE_DIRECTORY,
std::chrono::milliseconds maxPartitionMillis =
MAX_PROVENANCE_ENTRY_LIFE_TIME,
int64_t maxPartitionBytes =
MAX_PROVENANCE_STORAGE_SIZE,
std::chrono::milliseconds purgePeriod =
PROVENANCE_PURGE_PERIOD)
Review Comment:
done
##########
extensions/rocksdb-repos/RocksDbProvenanceRepository.cpp:
##########
@@ -0,0 +1,207 @@
+/**
+ * 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 "RocksDbProvenanceRepository.h"
+
+#include <string>
+
+#include "core/Resource.h"
+
+namespace org::apache::nifi::minifi::provenance {
+
+namespace {
+class EventCursor : public ProvenanceRepository::Cursor {
+public:
+ explicit EventCursor(std::string event_id): event_id_(std::move(event_id)) {}
+ [[nodiscard]]
+ std::string toString() const override {
+ return event_id_;
+ }
+ ~EventCursor() override = default;
+
+ std::string event_id_;
+};
+} // namespace
+
+static const std::string_view NEXT_EVENT_UUID_KEY = "next_event_uuid";
+
+bool RocksDbProvenanceRepository::initialize(const
std::shared_ptr<org::apache::nifi::minifi::Configure> &config) {
+ if (!RocksDbRepository::initialize(config)) {
+ return false;
+ }
+ std::string value;
+ if (config->get(Configure::nifi_provenance_repository_directory_default,
value) && !value.empty()) {
+ directory_ = value;
+ }
+ logger_->log_debug("MiNiFi Provenance Repository Directory {}", directory_);
+ if (config->get(Configure::nifi_provenance_repository_max_storage_size,
value)) {
+ max_partition_bytes_ = gsl::narrow<int64_t>(parsing::parseDataSize(value)
| utils::orThrow("expected parsable data size"));
+ }
+ logger_->log_debug("MiNiFi Provenance Max Partition Bytes {}",
max_partition_bytes_);
+ if (config->get(Configure::nifi_provenance_repository_max_storage_time,
value)) {
+ if (auto max_partition =
utils::timeutils::StringToDuration<std::chrono::milliseconds>(value))
+ max_partition_millis_ = *max_partition;
Review Comment:
done
##########
extensions/rocksdb-repos/tests/ProvenanceTests.cpp:
##########
@@ -100,11 +100,14 @@ TEST_CASE("Test Provenance record serialization
Volatile", "[Testprovenance::Pro
auto sample = 65555ms;
- std::shared_ptr<core::Repository> testRepository =
std::make_shared<core::repository::VolatileProvenanceRepository>();
+ auto testRepository =
std::make_shared<core::repository::VolatileProvenanceRepository>();
testRepository->initialize(nullptr);
record1->setEventDuration(sample);
- testRepository->storeElement(record1);
+ testRepository->appendEvents({record1});
+
+ utils::Identifier eventId = record1->getEventId();
Review Comment:
done
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]