diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-11-30 18:06:54 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-12-12 02:55:41 +0100 |
commit | 602bb910df6998d0f7c56a67d2707c9c6c2e7d58 (patch) | |
tree | bb0d0f57b4de9e3ef8ea03d29929747f586e8d40 | |
parent | c650f2f379179780d428fb5505a0ed3d52f48ba4 (diff) |
Targeted include
51 files changed, 678 insertions, 551 deletions
diff --git a/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp b/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp index e24819204a8..405bcb93947 100644 --- a/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp +++ b/document/src/vespa/document/fieldvalue/structuredfieldvalue.cpp @@ -1,6 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/document/fieldvalue/structuredfieldvalue.h> +#include <vespa/document/fieldvalue/structuredfieldvalue.hpp> #include <vespa/document/base/field.h> #include <vespa/document/fieldvalue/fieldvalues.h> #include <vespa/vespalib/util/exceptions.h> @@ -172,4 +172,10 @@ StructuredFieldValue::onIterateNested( } } +using ConstCharP = const char *; +template void StructuredFieldValue::set(const vespalib::stringref & field, const int32_t & value); +template void StructuredFieldValue::set(const vespalib::stringref & field, const int64_t & value); +template void StructuredFieldValue::set(const vespalib::stringref & field, const double & value); +template void StructuredFieldValue::set(const vespalib::stringref & field, const ConstCharP & value); + } // document diff --git a/metrics/src/vespa/metrics/printutils.h b/metrics/src/vespa/metrics/printutils.h index 845804267bf..10925864824 100644 --- a/metrics/src/vespa/metrics/printutils.h +++ b/metrics/src/vespa/metrics/printutils.h @@ -12,6 +12,7 @@ #include <vespa/vespalib/text/stringtokenizer.h> #include <vespa/metrics/metricmanager.h> +#include <vespa/vespalib/util/exceptions.h> namespace metrics { namespace printutils { diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp index a4e43324c8f..11ff8474e88 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastore.cpp @@ -1,8 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.documentmetastore.documentmetastore"); #include "documentmetastore.h" #include "search_context.h" @@ -15,6 +12,7 @@ LOG_SETUP(".proton.documentmetastore.documentmetastore"); #include <vespa/searchlib/btree/btreeroot.hpp> #include <vespa/searchlib/btree/btreebuilder.hpp> #include <vespa/vespalib/data/fileheader.h> +#include <vespa/vespalib/util/exceptions.h> #include <vespa/searchcore/proton/bucketdb/bucketsessionbase.h> #include <vespa/searchcore/proton/bucketdb/joinbucketssession.h> #include <vespa/searchcore/proton/bucketdb/splitbucketsession.h> diff --git a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreattribute.cpp b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreattribute.cpp index 3de5c4c84d1..4105f3e1f9b 100644 --- a/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreattribute.cpp +++ b/searchcore/src/vespa/searchcore/proton/documentmetastore/documentmetastoreattribute.cpp @@ -1,9 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.documentmetastore.documentmetastoreattribute"); #include "documentmetastoreattribute.h" +#include <vespa/vespalib/util/exceptions.h> namespace proton { @@ -30,12 +28,10 @@ DocumentMetaStoreAttribute::notImplemented() const DocumentMetaStoreAttribute::DocumentMetaStoreAttribute(const vespalib::string &name) : NotImplementedAttribute(name, Config(BasicType::NONE)) -{ -} +{ } DocumentMetaStoreAttribute::~DocumentMetaStoreAttribute() -{ -} +{ } } diff --git a/searchcore/src/vespa/searchcore/proton/server/replaypacketdispatcher.cpp b/searchcore/src/vespa/searchcore/proton/server/replaypacketdispatcher.cpp index 394292f86e6..e4db294eb3c 100644 --- a/searchcore/src/vespa/searchcore/proton/server/replaypacketdispatcher.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/replaypacketdispatcher.cpp @@ -1,10 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.server.replaypacketdispatcher"); #include "replaypacketdispatcher.h" #include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/exceptions.h> +#include <vespa/document/util/serializableexceptions.h> using vespalib::make_string; using vespalib::IllegalStateException; diff --git a/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp b/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp index afab869e177..2b7f5ff7944 100644 --- a/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp +++ b/searchcore/src/vespa/searchcore/proton/server/transactionlogmanagerbase.cpp @@ -1,11 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".proton.server.transactionlogmanagerbase"); #include "transactionlogmanagerbase.h" #include <vespa/searchcore/proton/common/eventlogger.h> #include <stdexcept> +#include <vespa/vespalib/util/stringfmt.h> + +#include <vespa/log/log.h> +LOG_SETUP(".proton.server.transactionlogmanagerbase"); using search::transactionlog::TransLogClient; diff --git a/searchcorespi/src/vespa/searchcorespi/index/indexwriteutilities.cpp b/searchcorespi/src/vespa/searchcorespi/index/indexwriteutilities.cpp index 731e233d289..334eeebe9e3 100644 --- a/searchcorespi/src/vespa/searchcorespi/index/indexwriteutilities.cpp +++ b/searchcorespi/src/vespa/searchcorespi/index/indexwriteutilities.cpp @@ -1,17 +1,17 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP(".searchcorespi.index.indexwriteutilities"); - #include "indexwriteutilities.h" #include "indexdisklayout.h" #include "indexreadutilities.h" #include <vespa/searchlib/common/serialnumfileheadercontext.h> #include <vespa/searchlib/index/schemautil.h> #include <vespa/vespalib/data/fileheader.h> -#include <vespa/vespalib/util/exception.h> +#include <vespa/vespalib/util/exceptions.h> #include <sstream> +#include <vespa/log/log.h> +LOG_SETUP(".searchcorespi.index.indexwriteutilities"); + + using search::FixedSourceSelector; using search::TuneFileAttributes; using search::common::FileHeaderContext; diff --git a/searchlib/src/tests/transactionlogstress/translogstress.cpp b/searchlib/src/tests/transactionlogstress/translogstress.cpp index 1c51c81e633..1199ff48843 100644 --- a/searchlib/src/tests/transactionlogstress/translogstress.cpp +++ b/searchlib/src/tests/transactionlogstress/translogstress.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> #include <vespa/vespalib/util/buffer.h> +#include <vespa/vespalib/util/stringfmt.h> #include <vespa/searchlib/transactionlog/translogserver.h> #include <vespa/searchlib/transactionlog/translogclient.h> #include <vespa/searchlib/util/rand48.h> @@ -10,6 +9,7 @@ #include <iostream> #include <stdexcept> +#include <vespa/log/log.h> LOG_SETUP("translogstress"); using document::ByteBuffer; diff --git a/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt b/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt index 2bda7e9fdd6..a44fbf7025c 100644 --- a/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt +++ b/searchlib/src/vespa/searchlib/attribute/CMakeLists.txt @@ -63,6 +63,7 @@ vespa_add_library(searchlib_attribute OBJECT multistringpostattribute.cpp multivalueattribute.cpp multivalueattributesaver.cpp + not_implemented_attribute.cpp numericbase.cpp postingchange.cpp postinglistattribute.cpp diff --git a/searchlib/src/vespa/searchlib/attribute/floatbase.cpp b/searchlib/src/vespa/searchlib/attribute/floatbase.cpp index daf07a1879c..dd1206b500e 100644 --- a/searchlib/src/vespa/searchlib/attribute/floatbase.cpp +++ b/searchlib/src/vespa/searchlib/attribute/floatbase.cpp @@ -1,14 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include "floatbase.h" +#include "floatbase.hpp" +#include "attributevector.hpp" #include <vespa/searchlib/common/sort.h> -#include <vespa/searchlib/attribute/attributevector.hpp> #include <vespa/document/fieldvalue/fieldvalue.h> -#include <vespa/log/log.h> -LOG_SETUP(".searchlib.attribute.floatbase"); - namespace search { IMPLEMENT_IDENTIFIABLE_ABSTRACT(FloatingPointAttribute, NumericAttribute); @@ -87,4 +83,13 @@ bool FloatingPointAttribute::apply(DocId doc, const ArithmeticValueUpdate & op) return retval; } +const char * +FloatingPointAttribute::getString(DocId doc, char * s, size_t sz) const { + double v = getFloat(doc); + snprintf(s, sz, "%g", v); + return s; +} + +template class FloatingPointAttributeTemplate<float>; +template class FloatingPointAttributeTemplate<double>; } diff --git a/searchlib/src/vespa/searchlib/attribute/floatbase.h b/searchlib/src/vespa/searchlib/attribute/floatbase.h index e802fd9675a..e34701a47cb 100644 --- a/searchlib/src/vespa/searchlib/attribute/floatbase.h +++ b/searchlib/src/vespa/searchlib/attribute/floatbase.h @@ -1,10 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/searchlib/attribute/numericbase.h> -#include <vespa/searchlib/attribute/multivalue.h> -#include <vespa/searchlib/attribute/loadednumericvalue.h> -#include <vespa/searchlib/attribute/changevector.h> +#include "numericbase.h" +#include "multivalue.h" +#include "loadednumericvalue.h" +#include "changevector.h" namespace search { @@ -30,20 +30,20 @@ public: return AttributeVector::update(_changes, doc, NumericChangeData<double>(v)); } bool apply(DocId doc, const ArithmeticValueUpdate & op); - virtual bool applyWeight(DocId doc, const FieldValue & fv, const ArithmeticValueUpdate & wAdjust); - virtual uint32_t clearDoc(DocId doc); + bool applyWeight(DocId doc, const FieldValue & fv, const ArithmeticValueUpdate & wAdjust) override; + uint32_t clearDoc(DocId doc) override; protected: - virtual const char * getString(DocId doc, char * s, size_t sz) const { double v = getFloat(doc); snprintf(s, sz, "%g", v); return s; } + const char * getString(DocId doc, char * s, size_t sz) const override; FloatingPointAttribute(const vespalib::string & name, const Config & c); typedef ChangeTemplate<NumericChangeData<double> > Change; typedef ChangeVectorT< Change > ChangeVector; ChangeVector _changes; private: - virtual uint32_t get(DocId doc, vespalib::string * v, uint32_t sz) const; - virtual uint32_t get(DocId doc, const char ** v, uint32_t sz) const; - virtual uint32_t get(DocId doc, WeightedString * v, uint32_t sz) const; - virtual uint32_t get(DocId doc, WeightedConstChar * v, uint32_t sz) const; + uint32_t get(DocId doc, vespalib::string * v, uint32_t sz) const override; + uint32_t get(DocId doc, const char ** v, uint32_t sz) const override; + uint32_t get(DocId doc, WeightedString * v, uint32_t sz) const override; + uint32_t get(DocId doc, WeightedConstChar * v, uint32_t sz) const override; virtual double getFloatFromEnum(EnumHandle e) const = 0; }; @@ -63,60 +63,25 @@ public: typedef T BaseType; typedef T LoadedValueType; typedef SequentialReadModifyWriteInterface<LoadedNumericValueT> LoadedVector; - virtual uint32_t getRawValues(DocId doc, const multivalue::Value<T> * & values) const { - (void) doc; - (void) values; - throw std::runtime_error(getNativeClassName() + "::getRawValues() not implemented."); - } + virtual uint32_t getRawValues(DocId doc, const multivalue::Value<T> * & values) const; protected: - FloatingPointAttributeTemplate(const vespalib::string & name) : - FloatingPointAttribute(name, BasicType::fromType(T())), - _defaultValue(ChangeBase::UPDATE, 0, attribute::getUndefined<T>()) - { } - FloatingPointAttributeTemplate(const vespalib::string & name, const Config & c) : - FloatingPointAttribute(name, c), - _defaultValue(ChangeBase::UPDATE, 0, attribute::getUndefined<T>()) - { assert(c.basicType() == BasicType::fromType(T())); } + FloatingPointAttributeTemplate(const vespalib::string & name); + FloatingPointAttributeTemplate(const vespalib::string & name, const Config & c); + ~FloatingPointAttributeTemplate(); static T defaultValue() { return attribute::getUndefined<T>(); } virtual bool findEnum(T v, EnumHandle & e) const = 0; - virtual largeint_t getDefaultValue() const { return static_cast<largeint_t>(-std::numeric_limits<T>::max()); } + largeint_t getDefaultValue() const override { return static_cast<largeint_t>(-std::numeric_limits<T>::max()); } Change _defaultValue; private: - virtual bool findEnum(const char *value, EnumHandle &e) const { - vespalib::asciistream iss(value); - T fvalue = 0; - try { - iss >> fvalue; - } catch (const vespalib::IllegalArgumentException &) { - } - return findEnum(fvalue, e); - } - virtual bool isUndefined(DocId doc) const { return attribute::isUndefined(get(doc)); } + bool findEnum(const char *value, EnumHandle &e) const override; + bool isUndefined(DocId doc) const override; virtual T get(DocId doc) const = 0; virtual T getFromEnum(EnumHandle e) const = 0; - virtual double getFloatFromEnum(EnumHandle e) const { return getFromEnum(e); } - virtual long onSerializeForAscendingSort(DocId doc, void * serTo, long available, const common::BlobConverter * bc) const { - (void) bc; - if (available >= long(sizeof(T))) { - T origValue(get(doc)); - vespalib::serializeForSort< vespalib::convertForSort<T, true> >(origValue, serTo); - } else { - return -1; - } - return sizeof(T); - } - virtual long onSerializeForDescendingSort(DocId doc, void * serTo, long available, const common::BlobConverter * bc) const { - (void) bc; - if (available >= long(sizeof(T))) { - T origValue(get(doc)); - vespalib::serializeForSort< vespalib::convertForSort<T, false> >(origValue, serTo); - } else { - return -1; - } - return sizeof(T); - } + double getFloatFromEnum(EnumHandle e) const override; + long onSerializeForAscendingSort(DocId doc, void * serTo, long available, const common::BlobConverter * bc) const override; + long onSerializeForDescendingSort(DocId doc, void * serTo, long available, const common::BlobConverter * bc) const override; }; } diff --git a/searchlib/src/vespa/searchlib/attribute/floatbase.hpp b/searchlib/src/vespa/searchlib/attribute/floatbase.hpp new file mode 100644 index 00000000000..316967a425c --- /dev/null +++ b/searchlib/src/vespa/searchlib/attribute/floatbase.hpp @@ -0,0 +1,84 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +#pragma once + +#include "floatbase.h" +#include <vespa/vespalib/util/exceptions.h> + +namespace search { + +template<typename T> +uint32_t +FloatingPointAttributeTemplate<T>::getRawValues(DocId doc, const multivalue::Value<T> * & values) const { + (void) doc; + (void) values; + throw std::runtime_error(getNativeClassName() + "::getRawValues() not implemented."); +} + +template<typename T> +FloatingPointAttributeTemplate<T>::FloatingPointAttributeTemplate(const vespalib::string & name) : + FloatingPointAttribute(name, BasicType::fromType(T())), + _defaultValue(ChangeBase::UPDATE, 0, attribute::getUndefined<T>()) +{ } + +template<typename T> +FloatingPointAttributeTemplate<T>::FloatingPointAttributeTemplate(const vespalib::string & name, const Config & c) : + FloatingPointAttribute(name, c), + _defaultValue(ChangeBase::UPDATE, 0, attribute::getUndefined<T>()) +{ + assert(c.basicType() == BasicType::fromType(T())); +} + +template<typename T> +FloatingPointAttributeTemplate<T>::~FloatingPointAttributeTemplate() { } + +template<typename T> +bool +FloatingPointAttributeTemplate<T>::findEnum(const char *value, EnumHandle &e) const { + vespalib::asciistream iss(value); + T fvalue = 0; + try { + iss >> fvalue; + } catch (const vespalib::IllegalArgumentException &) { + } + return findEnum(fvalue, e); +} + +template<typename T> +bool +FloatingPointAttributeTemplate<T>::isUndefined(DocId doc) const { + return attribute::isUndefined(get(doc)); +} + +template<typename T> +double +FloatingPointAttributeTemplate<T>::getFloatFromEnum(EnumHandle e) const { + return getFromEnum(e); +} + +template<typename T> +long +FloatingPointAttributeTemplate<T>::onSerializeForAscendingSort(DocId doc, void * serTo, long available, const common::BlobConverter * bc) const { + (void) bc; + if (available >= long(sizeof(T))) { + T origValue(get(doc)); + vespalib::serializeForSort< vespalib::convertForSort<T, true> >(origValue, serTo); + } else { + return -1; + } + return sizeof(T); +} + +template<typename T> +long +FloatingPointAttributeTemplate<T>::onSerializeForDescendingSort(DocId doc, void * serTo, long available, const common::BlobConverter * bc) const { + (void) bc; + if (available >= long(sizeof(T))) { + T origValue(get(doc)); + vespalib::serializeForSort< vespalib::convertForSort<T, false> >(origValue, serTo); + } else { + return -1; + } + return sizeof(T); +} + +} diff --git a/searchlib/src/vespa/searchlib/attribute/integerbase.cpp b/searchlib/src/vespa/searchlib/attribute/integerbase.cpp index 81cd7a5bb53..8057b152e99 100644 --- a/searchlib/src/vespa/searchlib/attribute/integerbase.cpp +++ b/searchlib/src/vespa/searchlib/attribute/integerbase.cpp @@ -1,8 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "integerbase.hpp" +#include "attributevector.hpp" #include <vespa/searchlib/common/sort.h> -#include <vespa/searchlib/attribute/attributevector.hpp> #include <vespa/document/fieldvalue/fieldvalue.h> namespace search { @@ -83,4 +83,9 @@ bool IntegerAttribute::apply(DocId doc, const ArithmeticValueUpdate & op) return retval; } +template class IntegerAttributeTemplate<int8_t>; +template class IntegerAttributeTemplate<int16_t>; +template class IntegerAttributeTemplate<int32_t>; +template class IntegerAttributeTemplate<int64_t>; + } diff --git a/searchlib/src/vespa/searchlib/attribute/integerbase.hpp b/searchlib/src/vespa/searchlib/attribute/integerbase.hpp index a218cd11264..dc6df880f49 100644 --- a/searchlib/src/vespa/searchlib/attribute/integerbase.hpp +++ b/searchlib/src/vespa/searchlib/attribute/integerbase.hpp @@ -1,10 +1,13 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include "integerbase.hpp" +#include "integerbase.h" +#include <vespa/vespalib/util/exceptions.h> namespace search { +using largeint_t = attribute::IAttributeVector::largeint_t; + template<typename T> uint32_t IntegerAttributeTemplate<T>::getRawValues(DocId, const multivalue::Value<T> * &) const { diff --git a/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.cpp b/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.cpp new file mode 100644 index 00000000000..dba2082ab5b --- /dev/null +++ b/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.cpp @@ -0,0 +1,153 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "not_implemented_attribute.h" +#include <vespa/vespalib/util/exceptions.h> + +namespace search { + +using largeint_t = attribute::IAttributeVector::largeint_t; +using SearchContext = AttributeVector::SearchContext; + +void +NotImplementedAttribute::notImplemented() const { + throw vespalib::IllegalStateException("The function is not implemented."); +} + +uint32_t +NotImplementedAttribute::getValueCount(DocId) const { + notImplemented(); + return 0; +} + +largeint_t +NotImplementedAttribute::getInt(DocId) const { + notImplemented(); + return 0; +} + +double +NotImplementedAttribute::getFloat(DocId) const { + notImplemented(); + return 0; +} + +const char * +NotImplementedAttribute::getString(DocId, char *, size_t) const { + notImplemented(); + return NULL; +} + +uint32_t +NotImplementedAttribute::get(DocId, largeint_t *, uint32_t) const { + notImplemented(); + return 0; +} + +uint32_t +NotImplementedAttribute::get(DocId, double *, uint32_t) const { + notImplemented(); + return 0; +} + +uint32_t +NotImplementedAttribute::get(DocId, vespalib::string *, uint32_t) const { + notImplemented(); + return 0; +} + +uint32_t +NotImplementedAttribute::get(DocId, const char **, uint32_t) const { + notImplemented(); + return 0; +} + +uint32_t +NotImplementedAttribute::get(DocId, EnumHandle *, uint32_t) const { + notImplemented(); + return 0; +} + +uint32_t +NotImplementedAttribute::get(DocId, WeightedInt *, uint32_t) const { + notImplemented(); + return 0; +} + +uint32_t +NotImplementedAttribute::get(DocId, WeightedFloat *, uint32_t) const { + notImplemented(); + return 0; +} + +uint32_t +NotImplementedAttribute::get(DocId, WeightedString *, uint32_t) const { + notImplemented(); + return 0; +} + +uint32_t +NotImplementedAttribute::get(DocId, WeightedConstChar *, uint32_t) const { + notImplemented(); + return 0; +} + +uint32_t +NotImplementedAttribute::get(DocId, WeightedEnum *, uint32_t) const { + notImplemented(); + return 0; +} + +bool +NotImplementedAttribute::findEnum(const char *, EnumHandle &) const { + notImplemented(); + return false; +} + +long +NotImplementedAttribute::onSerializeForAscendingSort(DocId, void *, long, const common::BlobConverter *) const { + notImplemented(); + return 0; +} + +long +NotImplementedAttribute::onSerializeForDescendingSort(DocId, void *, long, const common::BlobConverter *) const { + notImplemented(); + return 0; +} + +uint32_t +NotImplementedAttribute::clearDoc(DocId) { + notImplemented(); + return 0; +} + +int64_t +NotImplementedAttribute::getDefaultValue() const { + notImplemented(); + return 0; +} + +uint32_t +NotImplementedAttribute::getEnum(DocId) const { + notImplemented(); + return 0; +} + +void +NotImplementedAttribute::getEnumValue(const EnumHandle *, uint32_t *, uint32_t) const { + notImplemented(); +} + +bool +NotImplementedAttribute::addDoc(DocId &) { + notImplemented(); + return false; +} + +SearchContext::UP +NotImplementedAttribute::getSearch(QueryTermSimple::UP, const SearchContext::Params &) const { + notImplemented(); + return SearchContext::UP(); +} + +} diff --git a/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h b/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h index 73f0491d808..a7d1e8fde30 100644 --- a/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h +++ b/searchlib/src/vespa/searchlib/attribute/not_implemented_attribute.h @@ -9,173 +9,32 @@ namespace search { struct NotImplementedAttribute : AttributeVector { using AttributeVector::AttributeVector; - virtual void notImplemented() const __attribute__((noinline)) { - assert(false); - throw vespalib::IllegalStateException( - "The function is not implemented."); - } - - virtual uint32_t - getValueCount(DocId) const - { - notImplemented(); - return 0; - } - - virtual largeint_t - getInt(DocId) const - { - notImplemented(); - return 0; - } - - virtual double - getFloat(DocId) const - { - notImplemented(); - return 0; - } - - virtual const char * - getString(DocId, char *, size_t) const - { - notImplemented(); - return NULL; - } - - virtual uint32_t - get(DocId, largeint_t *, uint32_t) const - { - notImplemented(); - return 0; - } - - virtual uint32_t - get(DocId, double *, uint32_t) const - { - notImplemented(); - return 0; - } - - virtual uint32_t - get(DocId, vespalib::string *, uint32_t) const - { - notImplemented(); - return 0; - } - - virtual uint32_t - get(DocId, const char **, uint32_t) const - { - notImplemented(); - return 0; - } - - virtual uint32_t - get(DocId, EnumHandle *, uint32_t) const - { - notImplemented(); - return 0; - } - - virtual uint32_t - get(DocId, WeightedInt *, uint32_t) const - { - notImplemented(); - return 0; - } - - virtual uint32_t - get(DocId, WeightedFloat *, uint32_t) const - { - notImplemented(); - return 0; - } - - virtual uint32_t - get(DocId, WeightedString *, uint32_t) const - { - notImplemented(); - return 0; - } - - virtual uint32_t - get(DocId, WeightedConstChar *, uint32_t) const - { - notImplemented(); - return 0; - } - - virtual uint32_t - get(DocId, WeightedEnum *, uint32_t) const - { - notImplemented(); - return 0; - } - - virtual bool - findEnum(const char *, EnumHandle &) const - { - notImplemented(); - return false; - } - - virtual long - onSerializeForAscendingSort(DocId, void *, long, - const common::BlobConverter *) const - { - notImplemented(); - return 0; - } - - virtual long - onSerializeForDescendingSort(DocId, void *, long, - const common::BlobConverter *) const - { - notImplemented(); - return 0; - } - - virtual uint32_t - clearDoc(DocId) - { - notImplemented(); - return 0; - } - - virtual int64_t - getDefaultValue() const - { - notImplemented(); - return 0; - } - - virtual uint32_t - getEnum(DocId) const - { - notImplemented(); - return 0; - } - - virtual void - getEnumValue(const EnumHandle *, uint32_t *, uint32_t) const - { - notImplemented(); - } - - virtual bool - addDoc(DocId &) - { - notImplemented(); - return false; - } - - SearchContext::UP - getSearch(QueryTermSimple::UP, const SearchContext::Params &) const override - { - notImplemented(); - return SearchContext::UP(); - } + virtual void notImplemented() const ; + + uint32_t getValueCount(DocId) const override; + largeint_t getInt(DocId) const override; + double getFloat(DocId) const override; + const char * getString(DocId, char *, size_t) const override; + uint32_t get(DocId, largeint_t *, uint32_t) const override; + uint32_t get(DocId, double *, uint32_t) const override; + uint32_t get(DocId, vespalib::string *, uint32_t) const override; + uint32_t get(DocId, const char **, uint32_t) const override; + uint32_t get(DocId, EnumHandle *, uint32_t) const override; + uint32_t get(DocId, WeightedInt *, uint32_t) const; + uint32_t get(DocId, WeightedFloat *, uint32_t) const override; + uint32_t get(DocId, WeightedString *, uint32_t) const override; + uint32_t get(DocId, WeightedConstChar *, uint32_t) const override; + uint32_t get(DocId, WeightedEnum *, uint32_t) const override; + bool findEnum(const char *, EnumHandle &) const override; + long onSerializeForAscendingSort(DocId, void *, long, const common::BlobConverter *) const override; + long onSerializeForDescendingSort(DocId, void *, long, const common::BlobConverter *) const override; + uint32_t clearDoc(DocId) override; + int64_t getDefaultValue() const override; + uint32_t getEnum(DocId) const override; + void getEnumValue(const EnumHandle *, uint32_t *, uint32_t) const override; + bool addDoc(DocId &) override; + + SearchContext::UP getSearch(QueryTermSimple::UP, const SearchContext::Params &) const override; }; } // namespace search diff --git a/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp b/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp index 6e923cc8969..23d515ce4c8 100644 --- a/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp +++ b/searchlib/src/vespa/searchlib/tensor/generic_tensor_store.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include "generic_tensor_store.h" #include <vespa/vespalib/tensor/tensor.h> #include <vespa/vespalib/tensor/serialization/typed_binary_format.h> @@ -8,6 +7,7 @@ #include <vespa/vespalib/util/stringfmt.h> #include <vespa/vespalib/util/macro.h> #include <vespa/document/util/serializable.h> +#include <vespa/document/util/serializableexceptions.h> #include <vespa/searchlib/datastore/datastore.hpp> using document::DeserializeException; diff --git a/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp b/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp index 47a2897fba6..df3aa1404ae 100644 --- a/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp +++ b/searchlib/src/vespa/searchlib/transactionlog/translogclient.cpp @@ -1,9 +1,9 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/searchlib/transactionlog/translogclient.h> -#include <vespa/log/log.h> +#include "translogclient.h" #include <stdexcept> +#include <vespa/vespalib/util/stringfmt.h> +#include <vespa/log/log.h> LOG_SETUP(".translogclient"); namespace search { diff --git a/searchlib/src/vespa/searchlib/util/rawbuf.h b/searchlib/src/vespa/searchlib/util/rawbuf.h index 70778abcd1a..5639914bc80 100644 --- a/searchlib/src/vespa/searchlib/util/rawbuf.h +++ b/searchlib/src/vespa/searchlib/util/rawbuf.h @@ -5,6 +5,9 @@ #pragma once #include <vespa/searchlib/common/hitrank.h> +#include <stdint.h> +#include <assert.h> +#include <sys/types.h> class FastOS_FileInterface; diff --git a/searchsummary/src/vespa/searchsummary/docsummary/docsumconfig.cpp b/searchsummary/src/vespa/searchsummary/docsummary/docsumconfig.cpp index 18d383d5bfd..b334319d89c 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/docsumconfig.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/docsumconfig.cpp @@ -2,8 +2,6 @@ // Copyright (C) 1998-2003 Fast Search & Transfer ASA // Copyright (C) 2003 Overture Services Norway AS -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> #include <vespa/searchsummary/docsummary/docsumconfig.h> #include <vespa/searchsummary/docsummary/rankfeaturesdfw.h> #include <vespa/searchsummary/docsummary/summaryfeaturesdfw.h> @@ -12,9 +10,7 @@ #include <vespa/searchsummary/docsummary/positionsdfw.h> #include <vespa/searchsummary/docsummary/juniperdfw.h> #include <vespa/vespalib/util/vstringfmt.h> - -LOG_SETUP(".searchlib.docsummary.docsumconfig"); - +#include <vespa/vespalib/util/exceptions.h> namespace search { namespace docsummary { diff --git a/slobrok/src/apps/slobrok/slobrok.cpp b/slobrok/src/apps/slobrok/slobrok.cpp index 53d2a61001c..6258ab18c90 100644 --- a/slobrok/src/apps/slobrok/slobrok.cpp +++ b/slobrok/src/apps/slobrok/slobrok.cpp @@ -1,11 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> -LOG_SETUP("slobrok"); - #include <vespa/fnet/fnet.h> - #include <vespa/slobrok/server/sbenv.h> +#include <vespa/vespalib/util/exceptions.h> + +#include <vespa/log/log.h> +LOG_SETUP("slobrok"); /** * @brief namespace for the actual slobrok application. diff --git a/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp b/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp index 42e1a069ebf..bced837e3a1 100644 --- a/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp +++ b/staging_vespalib/src/vespa/vespalib/util/xmlserializable.cpp @@ -441,6 +441,7 @@ template XmlAttribute::XmlAttribute(const std::string &, const vespalib::string template XmlAttribute::XmlAttribute(const std::string &, const vespalib::stringref &, unsigned int); template XmlAttribute::XmlAttribute(const std::string &, const CharP &, unsigned int); template XmlAttribute::XmlAttribute(const std::string &, const ConstCharP &, unsigned int); +template XmlAttribute::XmlAttribute(const std::string &, const bool &, unsigned int); template XmlAttribute::XmlAttribute(const std::string &, const int16_t &, unsigned int); template XmlAttribute::XmlAttribute(const std::string &, const int32_t &, unsigned int); template XmlAttribute::XmlAttribute(const std::string &, const int64_t &, unsigned int); diff --git a/storage/src/vespa/storage/bucketdb/bucketcopy.cpp b/storage/src/vespa/storage/bucketdb/bucketcopy.cpp index 8bd2a4ff08f..23919791592 100644 --- a/storage/src/vespa/storage/bucketdb/bucketcopy.cpp +++ b/storage/src/vespa/storage/bucketdb/bucketcopy.cpp @@ -1,6 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/storage/bucketdb/bucketcopy.h> +#include "bucketcopy.h" +#include <sstream> namespace storage { @@ -17,4 +17,11 @@ BucketCopy::print(std::ostream& out, bool /*verbose*/, const std::string&) const << ")"; } +std::string +BucketCopy::toString() const { + std::ostringstream ost; + print(ost, true, ""); + return ost.str(); +} + } diff --git a/storage/src/vespa/storage/bucketdb/bucketcopy.h b/storage/src/vespa/storage/bucketdb/bucketcopy.h index 7230c28eb74..1d96a739d10 100644 --- a/storage/src/vespa/storage/bucketdb/bucketcopy.h +++ b/storage/src/vespa/storage/bucketdb/bucketcopy.h @@ -92,11 +92,7 @@ public: void print(std::ostream&, bool verbose, const std::string& indent) const; - std::string toString() const { - std::ostringstream ost; - print(ost, true, ""); - return ost.str(); - } + std::string toString() const; bool operator==(const BucketCopy& other) const { return diff --git a/storage/src/vespa/storage/bucketdb/bucketdatabase.cpp b/storage/src/vespa/storage/bucketdb/bucketdatabase.cpp index 4a17c2aab59..2c229052fc5 100644 --- a/storage/src/vespa/storage/bucketdb/bucketdatabase.cpp +++ b/storage/src/vespa/storage/bucketdb/bucketdatabase.cpp @@ -1,6 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/storage/bucketdb/bucketdatabase.h> +#include "bucketdatabase.h" +#include <sstream> namespace storage { diff --git a/storage/src/vespa/storage/bucketdb/bucketinfo.cpp b/storage/src/vespa/storage/bucketdb/bucketinfo.cpp index 45e5a860d14..cbf39bef65f 100644 --- a/storage/src/vespa/storage/bucketdb/bucketinfo.cpp +++ b/storage/src/vespa/storage/bucketdb/bucketinfo.cpp @@ -1,13 +1,20 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/storage/bucketdb/bucketinfo.h> +#include "bucketinfo.h" #include <vespa/storage/storageutil/utils.h> namespace storage { BucketInfo::BucketInfo() : _lastGarbageCollection(0) -{ +{ } + +BucketInfo::~BucketInfo() { } + +std::string +BucketInfo::toString() const { + std::ostringstream ost; + print(ost, true, ""); + return ost.str(); } bool diff --git a/storage/src/vespa/storage/bucketdb/bucketinfo.h b/storage/src/vespa/storage/bucketdb/bucketinfo.h index f7b52640de9..2bdd4e65cff 100644 --- a/storage/src/vespa/storage/bucketdb/bucketinfo.h +++ b/storage/src/vespa/storage/bucketdb/bucketinfo.h @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #pragma once -#include <vespa/storage/bucketdb/bucketcopy.h> +#include "bucketcopy.h" namespace storage { @@ -17,6 +17,7 @@ private: public: BucketInfo(); + ~BucketInfo(); /** * @return Returns the last time when this bucket was "garbage collected". @@ -137,11 +138,7 @@ public: */ void clear() { _nodes.clear(); } - std::string toString() const { - std::ostringstream ost; - print(ost, true, ""); - return ost.str(); - }; + std::string toString() const; bool verifyLegal() const { return true; } diff --git a/storage/src/vespa/storage/common/storagelinkqueued.cpp b/storage/src/vespa/storage/common/storagelinkqueued.cpp index 49d1d8f9592..3f320439411 100644 --- a/storage/src/vespa/storage/common/storagelinkqueued.cpp +++ b/storage/src/vespa/storage/common/storagelinkqueued.cpp @@ -1,12 +1,19 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include "storagelinkqueued.h" +#include "storagelinkqueued.hpp" #include <vespa/log/log.h> LOG_SETUP(".application.link.queued"); namespace storage { +StorageLinkQueued::StorageLinkQueued(const std::string& name, framework::ComponentRegister& cr) + : StorageLink(name), + _compReg(cr), + _replyDispatcher(*this), + _commandDispatcher(*this), + _closeState(0) +{ } + StorageLinkQueued::~StorageLinkQueued() { if (_closeState != 7) { @@ -61,4 +68,6 @@ void StorageLinkQueued::logDebug(const char* err) { LOG(info, "%s", err); }; +template class StorageLinkQueued::Dispatcher<storage::api::StorageMessage>; + } // storage diff --git a/storage/src/vespa/storage/common/storagelinkqueued.h b/storage/src/vespa/storage/common/storagelinkqueued.h index 982cf66e3cb..2d3d8abd925 100644 --- a/storage/src/vespa/storage/common/storagelinkqueued.h +++ b/storage/src/vespa/storage/common/storagelinkqueued.h @@ -16,9 +16,6 @@ #include <vespa/vespalib/util/document_runnable.h> #include <deque> -#include <sstream> -#include <memory> -#include <list> #include <limits> #include <vespa/storageframework/storageframework.h> #include <vespa/storage/common/storagelink.h> @@ -27,12 +24,7 @@ namespace storage { class StorageLinkQueued : public StorageLink { public: - StorageLinkQueued(const std::string& name, framework::ComponentRegister& cr) - : StorageLink(name), - _compReg(cr), - _replyDispatcher(*this), - _commandDispatcher(*this), - _closeState(0) {} + StorageLinkQueued(const std::string& name, framework::ComponentRegister& cr); virtual ~StorageLinkQueued(); /** @@ -82,38 +74,12 @@ private: bool _replyDispatcher; framework::Component::UP _component; framework::Thread::UP _thread; - void terminate() { - if (_thread.get()) { - _thread->interrupt(); - { - vespalib::MonitorGuard sync(_sync); - sync.signal(); - } - _thread->join(); - _thread.reset(0); - } - } + void terminate(); public: - Dispatcher(StorageLinkQueued& parent, unsigned int maxQueueSize, - bool replyDispatcher) - : _parent(parent), - _maxQueueSize(maxQueueSize), - _sync(), - _messages(), - _replyDispatcher(replyDispatcher) - { - std::ostringstream name; - name << "Queued storage " << (_replyDispatcher ? "up" : "down") - << "link - " << _parent.getName(); - _component.reset(new framework::Component( - parent.getComponentRegister(), - name.str())); - } + Dispatcher(StorageLinkQueued& parent, unsigned int maxQueueSize, bool replyDispatcher); - virtual ~Dispatcher() { - terminate(); - } + virtual ~Dispatcher(); void start(); void run(framework::ThreadHandle&); @@ -167,81 +133,4 @@ protected: }; -template<typename Message> -void StorageLinkQueued::Dispatcher<Message>::start() -{ - assert(_thread.get() == 0); - framework::MilliSecTime maxProcessTime(5 * 1000); - framework::MilliSecTime waitTime(100); - _thread = _component->startThread(*this, maxProcessTime, waitTime); } - -template<typename Message> -void StorageLinkQueued::Dispatcher<Message>::add( - const std::shared_ptr<Message>& m) -{ - vespalib::MonitorGuard sync(_sync); - - if (_thread.get() == 0) start(); - while ((_messages.size() > _maxQueueSize) && !_thread->interrupted()) { - sync.wait(100); - } - _messages.push_back(m); - sync.signal(); -} - -template<typename Message> -void StorageLinkQueued::Dispatcher<Message>::addWithoutLocking( - const std::shared_ptr<Message>& m) -{ - if (_thread.get() == 0) start(); - _messages.push_back(m); -} - -template<typename Message> -void StorageLinkQueued::Dispatcher<Message>::run(framework::ThreadHandle& h) -{ - while (!h.interrupted()) { - h.registerTick(framework::PROCESS_CYCLE); - std::shared_ptr<Message> message; - { - vespalib::MonitorGuard sync(_sync); - while (!h.interrupted() && _messages.empty()) { - sync.wait(100); - h.registerTick(framework::WAIT_CYCLE); - } - if (h.interrupted()) break; - message.swap(_messages.front()); - } - try { - send(message); - } catch (std::exception& e) { - _parent.logError(vespalib::make_string( - "When running command %s, caught exception %s. " - "Discarding message", - message->toString().c_str(), - e.what()).c_str()); - } - - { - // Since flush() only waits for stack to be empty, we must - // pop stack AFTER send have been called. - vespalib::MonitorGuard sync(_sync); - _messages.pop_front(); - sync.signal(); - } - } - _parent.logDebug("Finished storage link queued thread"); -} - -template<typename Message> -void StorageLinkQueued::Dispatcher<Message>::flush() -{ - vespalib::MonitorGuard sync(_sync); - while (!_messages.empty()) { - sync.wait(100); - } -} - -} - diff --git a/storage/src/vespa/storage/common/storagelinkqueued.hpp b/storage/src/vespa/storage/common/storagelinkqueued.hpp new file mode 100644 index 00000000000..daca4bac5c5 --- /dev/null +++ b/storage/src/vespa/storage/common/storagelinkqueued.hpp @@ -0,0 +1,123 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#pragma once + +#include "storagelinkqueued.h" +#include <vespa/vespalib/util/stringfmt.h> +#include <sstream> + +namespace storage { + +template<typename Message> +void +StorageLinkQueued::Dispatcher<Message>::terminate() { + if (_thread.get()) { + _thread->interrupt(); + { + vespalib::MonitorGuard sync(_sync); + sync.signal(); + } + _thread->join(); + _thread.reset(0); + } +} + +template<typename Message> +StorageLinkQueued::Dispatcher<Message>::Dispatcher(StorageLinkQueued& parent, unsigned int maxQueueSize, bool replyDispatcher) + : _parent(parent), + _maxQueueSize(maxQueueSize), + _sync(), + _messages(), + _replyDispatcher(replyDispatcher) +{ + std::ostringstream name; + name << "Queued storage " << (_replyDispatcher ? "up" : "down") + << "link - " << _parent.getName(); + _component.reset(new framework::Component( + parent.getComponentRegister(), + name.str())); +} + +template<typename Message> +StorageLinkQueued::Dispatcher<Message>::~Dispatcher() { + terminate(); +} + +template<typename Message> +void StorageLinkQueued::Dispatcher<Message>::start() +{ + assert(_thread.get() == 0); + framework::MilliSecTime maxProcessTime(5 * 1000); + framework::MilliSecTime waitTime(100); + _thread = _component->startThread(*this, maxProcessTime, waitTime); +} + +template<typename Message> +void StorageLinkQueued::Dispatcher<Message>::add( + const std::shared_ptr<Message>& m) +{ + vespalib::MonitorGuard sync(_sync); + + if (_thread.get() == 0) start(); + while ((_messages.size() > _maxQueueSize) && !_thread->interrupted()) { + sync.wait(100); + } + _messages.push_back(m); + sync.signal(); +} + +template<typename Message> +void StorageLinkQueued::Dispatcher<Message>::addWithoutLocking( + const std::shared_ptr<Message>& m) +{ + if (_thread.get() == 0) start(); + _messages.push_back(m); +} + +template<typename Message> +void StorageLinkQueued::Dispatcher<Message>::run(framework::ThreadHandle& h) +{ + while (!h.interrupted()) { + h.registerTick(framework::PROCESS_CYCLE); + std::shared_ptr<Message> message; + { + vespalib::MonitorGuard sync(_sync); + while (!h.interrupted() && _messages.empty()) { + sync.wait(100); + h.registerTick(framework::WAIT_CYCLE); + } + if (h.interrupted()) break; + message.swap(_messages.front()); + } + try { + send(message); + } catch (std::exception& e) { + _parent.logError(vespalib::make_string( + "When running command %s, caught exception %s. " + "Discarding message", + message->toString().c_str(), + e.what()).c_str()); + } + + { + // Since flush() only waits for stack to be empty, we must + // pop stack AFTER send have been called. + vespalib::MonitorGuard sync(_sync); + _messages.pop_front(); + sync.signal(); + } + } + _parent.logDebug("Finished storage link queued thread"); +} + +template<typename Message> +void StorageLinkQueued::Dispatcher<Message>::flush() +{ + vespalib::MonitorGuard sync(_sync); + while (!_messages.empty()) { + sync.wait(100); + } +} + +} + diff --git a/storage/src/vespa/storage/distributor/bucketdbupdater.cpp b/storage/src/vespa/storage/distributor/bucketdbupdater.cpp index 11d1a7fc0ef..b88a22c8042 100644 --- a/storage/src/vespa/storage/distributor/bucketdbupdater.cpp +++ b/storage/src/vespa/storage/distributor/bucketdbupdater.cpp @@ -555,6 +555,14 @@ BucketDBUpdater::getReportContentType(const framework::HttpUrlPath&) const return "text/xml"; } +namespace { + +const vespalib::string ALL = "all"; +const vespalib::string BUCKETDB = "bucketdb"; +const vespalib::string BUCKETDB_UPDATER = "Bucket Database Updater"; + +} + bool BucketDBUpdater::reportStatus(std::ostream& out, const framework::HttpUrlPath& path) const @@ -565,8 +573,8 @@ BucketDBUpdater::reportStatus(std::ostream& out, // directly from XmlStatusReporter due to data races when BucketDBUpdater // gets status requests directly. xos << XmlTag("status") - << XmlAttribute("id", "bucketdb") - << XmlAttribute("name", "Bucket Database Updater"); + << XmlAttribute("id", BUCKETDB) + << XmlAttribute("name", BUCKETDB_UPDATER); reportXmlStatus(xos, path); xos << XmlEndTag(); return true; @@ -601,7 +609,7 @@ BucketDBUpdater::reportXmlStatus(vespalib::xml::XmlOutputStream& xos, xos << XmlTag("storagenode") << XmlAttribute("index", iter->second.targetNode); if (iter->second.bucket.getRawId() == 0) { - xos << XmlAttribute("bucket", "all"); + xos << XmlAttribute("bucket", ALL); } else { xos << XmlAttribute("bucket", iter->second.bucket.getId(), XmlAttribute::HEX); diff --git a/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.cpp b/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.cpp index c9f1d157557..eaeb82d69f9 100644 --- a/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.cpp +++ b/storage/src/vespa/storage/distributor/operations/external/statbucketlistoperation.cpp @@ -1,9 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <iostream> +#include "statbucketlistoperation.h" #include <vespa/storageapi/message/stat.h> -#include <vespa/storage/distributor/operations/external/statbucketlistoperation.h> #include <vespa/storage/distributor/maintenance/maintenanceoperationgenerator.h> +#include <sstream> namespace storage { namespace distributor { diff --git a/storage/src/vespa/storage/distributor/operationtargetresolverimpl.cpp b/storage/src/vespa/storage/distributor/operationtargetresolverimpl.cpp index 0ea85c47f75..6f71abaabb8 100644 --- a/storage/src/vespa/storage/distributor/operationtargetresolverimpl.cpp +++ b/storage/src/vespa/storage/distributor/operationtargetresolverimpl.cpp @@ -1,6 +1,8 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/storage/distributor/operationtargetresolverimpl.h> +#include "operationtargetresolverimpl.h" +#include <vespa/vespalib/util/exceptions.h> +#include <sstream> namespace storage { namespace distributor { diff --git a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp index 656a0a89c3c..5fc9c27c639 100644 --- a/storage/src/vespa/storage/distributor/pendingclusterstate.cpp +++ b/storage/src/vespa/storage/distributor/pendingclusterstate.cpp @@ -1,13 +1,13 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include <vespa/storage/distributor/pendingclusterstate.h> -#include <vespa/log/log.h> #include <vespa/storage/distributor/bucketdbupdater.h> #include <vespa/storage/distributor/distributormessagesender.h> #include <vespa/storage/storageutil/utils.h> #include <vespa/storageframework/defaultimplementation/clock/realclock.h> #include <vespa/storage/common/bucketoperationlogger.h> +#include <vespa/vespalib/util/xmlserializable.hpp> +#include <vespa/log/log.h> LOG_SETUP(".pendingclusterstate"); namespace storage { diff --git a/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.cpp b/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.cpp index 5bbc26aa6e5..aa9512ebd27 100644 --- a/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.cpp +++ b/storage/src/vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.cpp @@ -1,12 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include <vespa/fastos/fastos.h> -#include <vespa/storage/frameworkimpl/component/distributorcomponentregisterimpl.h> - -#include <vespa/log/log.h> +#include "distributorcomponentregisterimpl.h" #include <vespa/vdslib/distribution/idealnodecalculatorimpl.h> - -LOG_SETUP(".storage.component.register.distributor"); +#include <vespa/vespalib/util/exceptions.h> namespace storage { @@ -25,8 +20,7 @@ DistributorComponentRegisterImpl::handleNewState() } void -DistributorComponentRegisterImpl::registerDistributorComponent( - DistributorManagedComponent& smc) +DistributorComponentRegisterImpl::registerDistributorComponent(DistributorManagedComponent& smc) { vespalib::LockGuard lock(_componentLock); _components.push_back(&smc); @@ -53,8 +47,7 @@ DistributorComponentRegisterImpl::setTimeCalculator(UniqueTimeCalculator& utc) } void -DistributorComponentRegisterImpl::setDistributorConfig( - const DistributorConfig& c) +DistributorComponentRegisterImpl::setDistributorConfig(const DistributorConfig& c) { vespalib::LockGuard lock(_componentLock); _distributorConfig = c; diff --git a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp index 376fefa3c76..51a30d26def 100644 --- a/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp +++ b/storage/src/vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.cpp @@ -1,7 +1,7 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/storage/frameworkimpl/component/storagecomponentregisterimpl.h> +#include "storagecomponentregisterimpl.h" +#include <vespa/vespalib/util/exceptions.h> #include <vespa/log/log.h> @@ -19,8 +19,7 @@ StorageComponentRegisterImpl::StorageComponentRegisterImpl() } void -StorageComponentRegisterImpl::registerStorageComponent( - StorageComponent& smc) +StorageComponentRegisterImpl::registerStorageComponent(StorageComponent& smc) { vespalib::LockGuard lock(_componentLock); _components.push_back(&smc); @@ -67,8 +66,7 @@ StorageComponentRegisterImpl::setNodeStateUpdater(NodeStateUpdater& updater) } void -StorageComponentRegisterImpl::setDocumentTypeRepo( - document::DocumentTypeRepo::SP repo) +StorageComponentRegisterImpl::setDocumentTypeRepo(document::DocumentTypeRepo::SP repo) { vespalib::LockGuard lock(_componentLock); _docTypeRepo = repo; @@ -78,8 +76,7 @@ StorageComponentRegisterImpl::setDocumentTypeRepo( } void -StorageComponentRegisterImpl::setLoadTypes( - documentapi::LoadTypeSet::SP loadTypes) +StorageComponentRegisterImpl::setLoadTypes(documentapi::LoadTypeSet::SP loadTypes) { vespalib::LockGuard lock(_componentLock); _loadTypes = loadTypes; @@ -99,8 +96,7 @@ StorageComponentRegisterImpl::setPriorityConfig(const PriorityConfig& config) } void -StorageComponentRegisterImpl::setBucketIdFactory( - const document::BucketIdFactory& factory) +StorageComponentRegisterImpl::setBucketIdFactory(const document::BucketIdFactory& factory) { vespalib::LockGuard lock(_componentLock); _bucketIdFactory = factory; @@ -110,8 +106,7 @@ StorageComponentRegisterImpl::setBucketIdFactory( } void -StorageComponentRegisterImpl::setDistribution( - lib::Distribution::SP distribution) +StorageComponentRegisterImpl::setDistribution(lib::Distribution::SP distribution) { vespalib::LockGuard lock(_componentLock); _distribution = distribution; diff --git a/storage/src/vespa/storage/storageutil/utils.h b/storage/src/vespa/storage/storageutil/utils.h index 357063ff29b..ab55d9371a0 100644 --- a/storage/src/vespa/storage/storageutil/utils.h +++ b/storage/src/vespa/storage/storageutil/utils.h @@ -2,6 +2,7 @@ #pragma once #include <vector> +#include <sstream> namespace storage { diff --git a/storage/src/vespa/storage/tools/analyzedistribution.cpp b/storage/src/vespa/storage/tools/analyzedistribution.cpp index c665cb7b29a..07aef4eea14 100644 --- a/storage/src/vespa/storage/tools/analyzedistribution.cpp +++ b/storage/src/vespa/storage/tools/analyzedistribution.cpp @@ -10,6 +10,7 @@ #include <vespa/vdslib/state/nodestate.h> #include <vespa/storage/bucketdb/judyarray.h> #include <iostream> +#include <sstream> namespace storage { @@ -285,21 +286,16 @@ std::vector<std::string> getFileNames(const std::string& testdir) { std::string name(reinterpret_cast<char*>(&entry->d_name)); assert(name.size() > 0); if (name.size() < 27) { - // std::cerr << "Ignoring file with too short name: " << name - // << "\n"; continue; } if (name.substr(0, 8) != "storage.") { - // std::cerr << "Ignoring non-storage file: " << name << "\n"; continue; } std::string::size_type pos = name.find('.', 8); if (pos == std::string::npos) { - // std::cerr << "Ignoring file without two dots: " << name << "\n"; continue; } if (name.substr(pos) != ".shell.filelist.gz") { - // std::cerr << "Ignoring file not filelisting: " << name << "\n"; continue; } files.push_back(name); @@ -359,8 +355,6 @@ struct Analyzer { uint16_t nodeIndex, uint16_t diskIndex) { (void) name; (void) size; (void) nodeIndex; (void) diskIndex; - //std::cerr << "Recording dir " << nodeIndex << " " << diskIndex << ": " - // << size << ' ' << name << "\n"; } void report() { std::cout << "Found " << bucketdb.size() << " buckets\n"; diff --git a/storage/src/vespa/storage/tools/getidealstate.cpp b/storage/src/vespa/storage/tools/getidealstate.cpp index 47e431fedde..2ee8e479da8 100644 --- a/storage/src/vespa/storage/tools/getidealstate.cpp +++ b/storage/src/vespa/storage/tools/getidealstate.cpp @@ -6,8 +6,9 @@ #include <vespa/vdslib/state/clusterstate.h> #include <vespa/vespalib/util/programoptions.h> #include <vespa/config/config.h> -#include <iostream> #include <vespa/config/print/ostreamconfigwriter.h> +#include <iostream> +#include <sstream> namespace storage { diff --git a/storage/src/vespa/storage/visiting/CMakeLists.txt b/storage/src/vespa/storage/visiting/CMakeLists.txt index 87406a0b6bb..eb426a1a770 100644 --- a/storage/src/vespa/storage/visiting/CMakeLists.txt +++ b/storage/src/vespa/storage/visiting/CMakeLists.txt @@ -4,6 +4,7 @@ vespa_add_library(storage_visitor OBJECT ${CMAKE_CURRENT_BINARY_DIR}/config-stor-visitor.h visitor.cpp visitormanager.cpp + visitormetrics.cpp visitorthread.cpp testvisitor.cpp recoveryvisitor.cpp diff --git a/storage/src/vespa/storage/visiting/visitormetrics.cpp b/storage/src/vespa/storage/visiting/visitormetrics.cpp new file mode 100644 index 00000000000..a134a743f96 --- /dev/null +++ b/storage/src/vespa/storage/visiting/visitormetrics.cpp @@ -0,0 +1,51 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "visitormetrics.h" +#include <vespa/vespalib/util/exceptions.h> + +namespace storage { + +VisitorMetrics::VisitorMetrics() + : metrics::MetricSet("visitor", "visitor", ""), + queueSize("cv_queuesize", "", "Size of create visitor queue", this), + queueSkips("cv_skipqueue", "", + "Number of times we could skip queue as we had free visitor " + "spots", this), + queueFull("cv_queuefull", "", + "Number of create visitor messages failed as queue is full", + this), + queueWaitTime("cv_queuewaittime", "", + "Milliseconds waiting in create visitor queue, for visitors " + "that was added to visitor queue but scheduled later", this), + queueTimeoutWaitTime("cv_queuetimeoutwaittime", "", + "Milliseconds waiting in create visitor queue, for visitors " + "that timed out while in the visitor quueue", this), + queueEvictedWaitTime("cv_queueevictedwaittime", "", + "Milliseconds waiting in create visitor queue, for visitors " + "that was evicted from queue due to higher priority visitors " + "coming", this), + threads(), + sum("allthreads", "sum", "", this) +{ + queueSize.unsetOnZeroValue(); +} + +VisitorMetrics::~VisitorMetrics() { } + +void +VisitorMetrics::initThreads(uint16_t threadCount, const metrics::LoadTypeSet& loadTypes) { + if (!threads.empty()) { + throw vespalib::IllegalStateException("Cannot initialize visitor metrics twice", VESPA_STRLOC); + } + threads.clear(); + threads.resize(threadCount); + for (uint32_t i=0; i<threads.size(); ++i) { + vespalib::asciistream ost; + ost << "visitor_thread_" << i; + threads[i].reset(new VisitorThreadMetrics( ost.str(), ost.str(), loadTypes)); + registerMetric(*threads[i]); + sum.addMetricToSum(*threads[i]); + } +} + +} diff --git a/storage/src/vespa/storage/visiting/visitormetrics.h b/storage/src/vespa/storage/visiting/visitormetrics.h index 8e0971ff1ab..569aa39e607 100644 --- a/storage/src/vespa/storage/visiting/visitormetrics.h +++ b/storage/src/vespa/storage/visiting/visitormetrics.h @@ -10,7 +10,7 @@ #pragma once #include <vespa/metrics/metrics.h> -#include <vespa/storage/visiting/visitorthreadmetrics.h> +#include "visitorthreadmetrics.h" namespace storage { @@ -25,51 +25,10 @@ struct VisitorMetrics : public metrics::MetricSet std::vector<std::shared_ptr<VisitorThreadMetrics> > threads; metrics::SumMetric<MetricSet> sum; - VisitorMetrics() - : metrics::MetricSet("visitor", "visitor", ""), - queueSize("cv_queuesize", "", "Size of create visitor queue", this), - queueSkips("cv_skipqueue", "", - "Number of times we could skip queue as we had free visitor " - "spots", this), - queueFull("cv_queuefull", "", - "Number of create visitor messages failed as queue is full", - this), - queueWaitTime("cv_queuewaittime", "", - "Milliseconds waiting in create visitor queue, for visitors " - "that was added to visitor queue but scheduled later", this), - queueTimeoutWaitTime("cv_queuetimeoutwaittime", "", - "Milliseconds waiting in create visitor queue, for visitors " - "that timed out while in the visitor quueue", this), - queueEvictedWaitTime("cv_queueevictedwaittime", "", - "Milliseconds waiting in create visitor queue, for visitors " - "that was evicted from queue due to higher priority visitors " - "coming", this), - threads(), - sum("allthreads", "sum", "", this) - { - queueSize.unsetOnZeroValue(); - } + VisitorMetrics(); + ~VisitorMetrics(); - void initThreads(uint16_t threadCount, - const metrics::LoadTypeSet& loadTypes) - { - if (!threads.empty()) { - throw vespalib::IllegalStateException( - "Cannot initialize visitor metrics twice", VESPA_STRLOC); - } - threads.clear(); - threads.resize(threadCount); - for (uint32_t i=0; i<threads.size(); ++i) { - std::ostringstream ost; - ost << "visitor_thread_" << i; - threads[i].reset(new VisitorThreadMetrics( - ost.str(), - ost.str(), - loadTypes)); - registerMetric(*threads[i]); - sum.addMetricToSum(*threads[i]); - } - } + void initThreads(uint16_t threadCount, const metrics::LoadTypeSet& loadTypes); }; } // storage diff --git a/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp b/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp index e4c89b81f18..0304da45a38 100644 --- a/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp +++ b/storageapi/src/vespa/storageapi/buckets/bucketinfo.cpp @@ -1,6 +1,5 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/storageapi/buckets/bucketinfo.h> +#include "bucketinfo.h" namespace storage { namespace api { @@ -92,9 +91,7 @@ BucketInfo::print(vespalib::asciistream& out, const PrintProperties&) const { out << "BucketInfo("; if (valid()) { - std::ostringstream ost; - ost << std::hex << _checksum; - out << "crc 0x" << ost.str() + out << "crc 0x" << vespalib::hex << _checksum << vespalib::dec << ", docCount " << _docCount << ", totDocSize " << _totDocSize; if (_totDocSize != _usedFileSize) { diff --git a/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.cpp b/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.cpp index 7e1e3815dc5..27fb603db24 100644 --- a/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.cpp +++ b/storageapi/src/vespa/storageapi/mbusprot/storageprotocol.cpp @@ -1,14 +1,13 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/storageapi/mbusprot/storageprotocol.h> - -#include <vespa/log/log.h> -#include <vespa/storageapi/mbusprot/protocolserialization.h> -#include <vespa/storageapi/mbusprot/serializationhelper.h> -#include <vespa/storageapi/mbusprot/storagecommand.h> -#include <vespa/storageapi/mbusprot/storagereply.h> +#include "storageprotocol.h" +#include "protocolserialization.h" +#include "serializationhelper.h" +#include "storagecommand.h" +#include "storagereply.h" #include <vespa/vespalib/util/exceptions.h> +#include <vespa/document/util/stringutil.h> +#include <vespa/log/log.h> LOG_SETUP(".storage.api.mbusprot.protocol"); namespace storage { diff --git a/storageframework/src/tests/memory/memorystatetest.cpp b/storageframework/src/tests/memory/memorystatetest.cpp index 9703d7d0133..6099745e30b 100644 --- a/storageframework/src/tests/memory/memorystatetest.cpp +++ b/storageframework/src/tests/memory/memorystatetest.cpp @@ -1,10 +1,10 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include <vespa/storageframework/defaultimplementation/clock/realclock.h> #include <vespa/storageframework/defaultimplementation/memory/memorystate.h> #include <vespa/storageframework/generic/memory/memorymanagerinterface.h> #include <vespa/vdstestlib/cppunit/macros.h> +#include <vespa/vespalib/util/exceptions.h> namespace storage { namespace framework { diff --git a/storageframework/src/tests/thread/tickingthreadtest.cpp b/storageframework/src/tests/thread/tickingthreadtest.cpp index ca15263d446..3c3c23d244f 100644 --- a/storageframework/src/tests/thread/tickingthreadtest.cpp +++ b/storageframework/src/tests/thread/tickingthreadtest.cpp @@ -1,14 +1,12 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> -#include <vespa/log/log.h> +#include <vespa/vespalib/util/stringfmt.h> +#include <vespa/vespalib/util/exception.h> #include <vespa/storageframework/defaultimplementation/clock/realclock.h> #include <vespa/storageframework/defaultimplementation/component/testcomponentregister.h> #include <vespa/storageframework/generic/thread/tickingthread.h> #include <vespa/vdstestlib/cppunit/macros.h> -LOG_SETUP(".tickingthreadtest"); - namespace storage { namespace framework { namespace defaultimplementation { diff --git a/vdslib/src/tests/state/clusterstatetest.cpp b/vdslib/src/tests/state/clusterstatetest.cpp index c2abfef8403..712de5ae881 100644 --- a/vdslib/src/tests/state/clusterstatetest.cpp +++ b/vdslib/src/tests/state/clusterstatetest.cpp @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include <vespa/vdslib/state/clusterstate.h> - +#include <vespa/vespalib/util/exception.h> #include <list> #include <vespa/document/bucket/bucketidfactory.h> #include <cmath> diff --git a/vdslib/src/vespa/vdslib/distribution/CMakeLists.txt b/vdslib/src/vespa/vdslib/distribution/CMakeLists.txt index 0f86ffee0b8..1f1516025be 100644 --- a/vdslib/src/vespa/vdslib/distribution/CMakeLists.txt +++ b/vdslib/src/vespa/vdslib/distribution/CMakeLists.txt @@ -1,8 +1,9 @@ # Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. vespa_add_library(vdslib_distribution OBJECT SOURCES - group.cpp distribution.cpp + group.cpp + idealnodecalculatorimpl.cpp redundancygroupdistribution.cpp DEPENDS ) diff --git a/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp new file mode 100644 index 00000000000..86c63f289e4 --- /dev/null +++ b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.cpp @@ -0,0 +1,57 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include "idealnodecalculatorimpl.h" +#include <vespa/vespalib/util/exceptions.h> + +namespace storage { +namespace lib { + +IdealNodeCalculatorImpl::IdealNodeCalculatorImpl() + : _distribution(0), + _clusterState(0) +{ + initUpStateMapping(); +} + +IdealNodeCalculatorImpl::~IdealNodeCalculatorImpl() { } + +void +IdealNodeCalculatorImpl::setDistribution(const Distribution& d) { + _distribution = &d; +} +void +IdealNodeCalculatorImpl::setClusterState(const ClusterState& cs) { + _clusterState = &cs; +} + +IdealNodeList +IdealNodeCalculatorImpl::getIdealNodes(const NodeType& nodeType, + const document::BucketId& bucket, + UpStates upStates) const +{ + assert(_clusterState != 0); + assert(_distribution != 0); + std::vector<uint16_t> nodes; + _distribution->getIdealNodes(nodeType, *_clusterState, bucket, nodes, _upStates[upStates]); + IdealNodeList list; + for (uint32_t i=0; i<nodes.size(); ++i) { + list.push_back(Node(nodeType, nodes[i])); + } + return list; +} + +void +IdealNodeCalculatorImpl::initUpStateMapping() { + _upStates.clear(); + _upStates.resize(UP_STATE_COUNT); + _upStates[UpInit] = "ui"; + _upStates[UpInitMaintenance] = "uim"; + for (uint32_t i=0; i<_upStates.size(); ++i) { + if (_upStates[i] == 0) throw vespalib::IllegalStateException( + "Failed to initialize up state. Code likely not updated " + "after another upstate was added.", VESPA_STRLOC); + } +} + +} // lib +} // storage diff --git a/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.h b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.h index 43619c4a419..a5a7e70db72 100644 --- a/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.h +++ b/vdslib/src/vespa/vdslib/distribution/idealnodecalculatorimpl.h @@ -5,7 +5,7 @@ */ #pragma once -#include <vespa/vdslib/distribution/idealnodecalculator.h> +#include "idealnodecalculator.h" namespace storage { namespace lib { @@ -16,48 +16,17 @@ class IdealNodeCalculatorImpl : public IdealNodeCalculatorConfigurable { const ClusterState* _clusterState; public: - IdealNodeCalculatorImpl() - : _distribution(0), - _clusterState(0) - { - initUpStateMapping(); - } + IdealNodeCalculatorImpl(); + ~IdealNodeCalculatorImpl(); - virtual void setDistribution(const Distribution& d) { - _distribution = &d; - } - virtual void setClusterState(const ClusterState& cs) { - _clusterState = &cs; - } - - virtual IdealNodeList getIdealNodes(const NodeType& nodeType, - const document::BucketId& bucket, - UpStates upStates) const - { - assert(_clusterState != 0); - assert(_distribution != 0); - std::vector<uint16_t> nodes; - _distribution->getIdealNodes(nodeType, *_clusterState, bucket, nodes, - _upStates[upStates]); - IdealNodeList list; - for (uint32_t i=0; i<nodes.size(); ++i) { - list.push_back(Node(nodeType, nodes[i])); - } - return list; - } + void setDistribution(const Distribution& d) override; + void setClusterState(const ClusterState& cs) override; + IdealNodeList getIdealNodes(const NodeType& nodeType, + const document::BucketId& bucket, + UpStates upStates) const override; private: - void initUpStateMapping() { - _upStates.clear(); - _upStates.resize(UP_STATE_COUNT); - _upStates[UpInit] = "ui"; - _upStates[UpInitMaintenance] = "uim"; - for (uint32_t i=0; i<_upStates.size(); ++i) { - if (_upStates[i] == 0) throw vespalib::IllegalStateException( - "Failed to initialize up state. Code likely not updated " - "after another upstate was added.", VESPA_STRLOC); - } - } + void initUpStateMapping(); }; } // lib diff --git a/vespaclient/src/vespa/vespaclient/vespadoclocator/application.cpp b/vespaclient/src/vespa/vespaclient/vespadoclocator/application.cpp index 48e837dbe03..303d929f992 100644 --- a/vespaclient/src/vespa/vespaclient/vespadoclocator/application.cpp +++ b/vespaclient/src/vespa/vespaclient/vespadoclocator/application.cpp @@ -1,6 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include <vespa/fastos/fastos.h> #include <boost/program_options.hpp> +#include <vespa/vespalib/util/exceptions.h> #include <vespa/config/common/exceptions.h> #include "application.h" #include <iostream> |