adamdebreceni commented on code in PR #1945: URL: https://github.com/apache/nifi-minifi-cpp/pull/1945#discussion_r2041885825
########## libminifi/test/unit/performance/VolatileRepositoryPerfTests.cpp: ########## Review Comment: added ########## cmake/FetchBenchmark.cmake: ########## @@ -0,0 +1,27 @@ +# +# 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(FetchContent) + +FetchContent_Declare( + benchmark Review Comment: added ########## libminifi/include/core/repository/LegacyVolatileContentRepository.h: ########## @@ -0,0 +1,130 @@ +/** + * 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 <map> +#include <memory> +#include <string> +#include <string_view> + +#include "AtomicRepoEntries.h" +#include "io/AtomicEntryStream.h" +#include "core/ContentRepository.h" +#include "properties/Configure.h" +#include "core/Connectable.h" +#include "core/logging/LoggerFactory.h" +#include "utils/GeneralUtils.h" +#include "VolatileRepositoryData.h" +#include "utils/Literals.h" + +namespace org::apache::nifi::minifi::core::repository { +/** + * Purpose: Stages content into a volatile area of memory. Note that when the maximum number + * of entries is consumed we will rollback a session to wait for others to be freed. + */ +class LegacyVolatileContentRepository : public core::ContentRepositoryImpl { + public: + static const char *minimal_locking; + + explicit LegacyVolatileContentRepository(std::string_view name = className<LegacyVolatileContentRepository>()) + : core::ContentRepositoryImpl(name), + repo_data_(15000, static_cast<size_t>(10_MiB * 0.75)), + minimize_locking_(true), + logger_(logging::LoggerFactory<LegacyVolatileContentRepository>::getLogger()) { + } + + ~LegacyVolatileContentRepository() override { + logger_->log_debug("Clearing repository"); + if (!minimize_locking_) { + std::lock_guard<std::mutex> lock(map_mutex_); + for (const auto &item : master_list_) { + delete item.second; + } + master_list_.clear(); + } + } + + uint64_t getRepositorySize() const override { + return repo_data_.getRepositorySize(); + } + + uint64_t getMaxRepositorySize() const override { + return repo_data_.getMaxRepositorySize(); + } + + uint64_t getRepositoryEntryCount() const override { + return master_list_.size(); + } + + bool isFull() const override { + return repo_data_.isFull(); + } + + /** + * Initialize the volatile content repo + * @param configure configuration + */ Review Comment: removed -- 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]
