diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-02 17:42:13 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-02 17:42:13 +0000 |
commit | 436529ac12c2396e64f8c1e53b568deea167685f (patch) | |
tree | d3c4b93804f71363c6f48ca28907ef08d6e0572c /searchcorespi | |
parent | 0020a4283b1d89b56c9b84e8a5c2f28754f64220 (diff) |
Use WarmupConfig class all the way.
Diffstat (limited to 'searchcorespi')
7 files changed, 42 insertions, 37 deletions
diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp index 1d726a61807..36d42e245e1 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp +++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.cpp @@ -365,17 +365,12 @@ IndexMaintainer::swapInNewIndex(LockGuard & guard, { assert(indexes->valid()); (void) guard; - if (_diskIndexWarmupTime > 0) { + if (_warmupConfig.getDuration() > 0) { if (dynamic_cast<const IDiskIndex *>(&source) != NULL) { LOG(debug, "Warming up a disk index."); indexes = std::make_shared<WarmupIndexCollection> - (_diskIndexWarmupTime, - getLeaf(guard, _source_list, true), - indexes, - static_cast<IDiskIndex &>(source), - _ctx.getWarmupExecutor(), - *this, - _unpackAtWarmup); + (_warmupConfig, getLeaf(guard, _source_list, true), indexes, + static_cast<IDiskIndex &>(source), _ctx.getWarmupExecutor(), *this); } else { LOG(debug, "No warmup needed as it is a memory index that is mapped in."); } @@ -791,8 +786,7 @@ IndexMaintainer::IndexMaintainer(const IndexMaintainerConfig &config, const IndexMaintainerContext &ctx, IIndexMaintainerOperations &operations) : _base_dir(config.getBaseDir()), - _diskIndexWarmupTime(config.getWarmup().getDuration()), - _unpackAtWarmup(config.getWarmup().getUnpack()), + _warmupConfig(config.getWarmup()), _active_indexes(new ActiveDiskIndexes()), _layout(config.getBaseDir()), _schema(config.getSchema()), diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h index cdd87096287..537dc39f3ce 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h +++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainer.h @@ -87,8 +87,7 @@ class IndexMaintainer : public boost::noncopyable, typedef std::vector<FrozenMemoryIndexRef> FrozenMemoryIndexRefs; typedef search::queryeval::ISourceSelector ISourceSelector; const vespalib::string _base_dir; - const double _diskIndexWarmupTime; - const bool _unpackAtWarmup; + const WarmupConfig _warmupConfig; ActiveDiskIndexes::SP _active_indexes; IndexDiskLayout _layout; Schema _schema; // Protected by SL + IUL diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainerconfig.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainerconfig.cpp index e1e88652bd4..3041de1a950 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainerconfig.cpp +++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainerconfig.cpp @@ -12,7 +12,7 @@ namespace searchcorespi { namespace index { IndexMaintainerConfig::IndexMaintainerConfig(const vespalib::string &baseDir, - WarmupConfig warmup, + const WarmupConfig & warmup, size_t maxFlushed, const Schema &schema, const Schema &fusionSchema, diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainerconfig.h b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainerconfig.h index 4f7411b0e44..227141ee2dd 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/indexmaintainerconfig.h +++ b/searchcorespi/src/vespa/searchcorespi/index/indexmaintainerconfig.h @@ -4,21 +4,11 @@ #include <vespa/searchcommon/common/schema.h> #include <vespa/searchlib/common/tunefileinfo.h> #include <vespa/vespalib/stllike/string.h> +#include "warmupconfig.h" namespace searchcorespi { namespace index { -class WarmupConfig { -public: - WarmupConfig() : _duration(0.0), _unpack(false) { } - WarmupConfig(double duration, bool unpack) : _duration(duration), _unpack(unpack) { } - double getDuration() const { return _duration; } - bool getUnpack() const { return _unpack; } -private: - double _duration; - bool _unpack; -}; - /** * Class that keeps the config used when constructing an index maintainer. */ @@ -33,7 +23,7 @@ private: public: IndexMaintainerConfig(const vespalib::string &baseDir, - WarmupConfig warmup, + const WarmupConfig & warmup, size_t maxFlushed, const search::index::Schema &schema, const search::index::Schema &fusionSchema, diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupconfig.h b/searchcorespi/src/vespa/searchcorespi/index/warmupconfig.h new file mode 100644 index 00000000000..adfd8f9e6b3 --- /dev/null +++ b/searchcorespi/src/vespa/searchcorespi/index/warmupconfig.h @@ -0,0 +1,22 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +namespace searchcorespi { +namespace index { + +/** + * Keeps all config for controlling warmup. + **/ +class WarmupConfig { +public: + WarmupConfig() : _duration(0.0), _unpack(false) { } + WarmupConfig(double duration, bool unpack) : _duration(duration), _unpack(unpack) { } + double getDuration() const { return _duration; } + bool getUnpack() const { return _unpack; } +private: + const double _duration; + const bool _unpack; +}; + +} +} diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp index 083db213a46..333e7c731ce 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp +++ b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.cpp @@ -21,28 +21,27 @@ using index::IDiskIndex; using fastos::TimeStamp; using fastos::ClockSystem; -WarmupIndexCollection::WarmupIndexCollection(double warmupSeconds, +WarmupIndexCollection::WarmupIndexCollection(const WarmupConfig & warmupConfig, ISearchableIndexCollection::SP prev, ISearchableIndexCollection::SP next, IndexSearchable & warmup, vespalib::ThreadExecutor & executor, - IWarmupDone & warmupDone, - bool doUnpack) : + IWarmupDone & warmupDone) : + _warmupConfig(warmupConfig), _prev(prev), _next(next), _warmup(warmup), _executor(executor), _warmupDone(warmupDone), - _warmupEndTime(ClockSystem::now() + TimeStamp::Seconds(warmupSeconds)), - _handledTerms(), - _doUnpack(doUnpack) + _warmupEndTime(ClockSystem::now() + TimeStamp::Seconds(warmupConfig.getDuration())), + _handledTerms() { if (next->valid()) { setCurrentIndex(next->getCurrentIndex()); } else { LOG(warning, "Next index is not valid, Dangerous !! : %s", next->toString().c_str()); } - LOG(debug, "For %g seconds I will warm up %s.", warmupSeconds, typeid(_warmup).name()); + LOG(debug, "For %g seconds I will warm up %s.", warmupConfig.getDuration(), typeid(_warmup).name()); LOG(debug, "%s", toString().c_str()); } diff --git a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h index 426d0a778ce..a304b3b9df2 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h +++ b/searchcorespi/src/vespa/searchcorespi/index/warmupindexcollection.h @@ -5,6 +5,7 @@ #include <vespa/searchcorespi/index/isearchableindexcollection.h> #include <vespa/vespalib/util/threadexecutor.h> #include <vespa/searchlib/queryeval/fake_requestcontext.h> +#include "warmupconfig.h" namespace searchcorespi { @@ -20,15 +21,15 @@ public: class WarmupIndexCollection : public ISearchableIndexCollection, public std::enable_shared_from_this<WarmupIndexCollection> { + using WarmupConfig = index::WarmupConfig; public: typedef std::shared_ptr<WarmupIndexCollection> SP; - WarmupIndexCollection(double warmupSeconds, + WarmupIndexCollection(const WarmupConfig & warmupConfig, ISearchableIndexCollection::SP prev, ISearchableIndexCollection::SP next, IndexSearchable & warmup, vespalib::ThreadExecutor & executor, - IWarmupDone & warmupDone, - bool doUnpack); + IWarmupDone & warmupDone); ~WarmupIndexCollection(); // Implements IIndexCollection const ISourceSelector &getSourceSelector() const override; @@ -57,7 +58,7 @@ public: const ISearchableIndexCollection::SP & getNextIndexCollection() const { return _next; } vespalib::string toString() const override; - bool doUnpack() const { return _doUnpack; } + bool doUnpack() const { return _warmupConfig.getUnpack(); } private: typedef search::fef::MatchData MatchData; typedef search::queryeval::FakeRequestContext FakeRequestContext; @@ -97,6 +98,7 @@ private: void fireWarmup(Task::UP task); bool handledBefore(uint32_t fieldId, const Node &term); + const WarmupConfig _warmupConfig; ISearchableIndexCollection::SP _prev; ISearchableIndexCollection::SP _next; IndexSearchable & _warmup; @@ -107,7 +109,6 @@ private: typedef vespalib::hash_set<vespalib::string> TermMap; typedef vespalib::hash_map<uint32_t, TermMap> FieldTermMap; FieldTermMap _handledTerms; - bool _doUnpack; }; } // namespace searchcorespi |