summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@yahoo-inc.com>2017-04-21 13:28:20 +0000
committerTor Egge <Tor.Egge@yahoo-inc.com>2017-04-24 09:25:29 +0000
commitc2a6df2cd34f8a9f989d47f422939a7ab6874c91 (patch)
treec647e3f7d3fdcc89a2b4afc9698cf4aaaf2ebba8
parent6bec213608e394bf3913decefa6fc0aa983ac757 (diff)
Remove dead code for handling config being rejected.
-rw-r--r--searchcore/CMakeLists.txt1
-rw-r--r--searchcore/src/testlist.txt1
-rw-r--r--searchcore/src/tests/proton/documentdb/configvalidator/.gitignore1
-rw-r--r--searchcore/src/tests/proton/documentdb/configvalidator/CMakeLists.txt8
-rw-r--r--searchcore/src/tests/proton/documentdb/configvalidator/DESC1
-rw-r--r--searchcore/src/tests/proton/documentdb/configvalidator/FILES1
-rw-r--r--searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp380
-rw-r--r--searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp40
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt3
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.cpp86
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.h21
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/config_validator_result.h34
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/config_validator_result_type.h27
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/configvalidator.cpp28
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/configvalidator.h46
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/ddbstate.cpp30
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/ddbstate.h20
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.cpp7
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/documentdb.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp33
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/i_feed_handler_owner.h1
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/schema_config_validator.cpp345
-rw-r--r--searchcore/src/vespa/searchcore/proton/server/schema_config_validator.h23
23 files changed, 2 insertions, 1136 deletions
diff --git a/searchcore/CMakeLists.txt b/searchcore/CMakeLists.txt
index 3e7dfc1f45c..4fc000e5a49 100644
--- a/searchcore/CMakeLists.txt
+++ b/searchcore/CMakeLists.txt
@@ -84,7 +84,6 @@ vespa_define_module(
src/tests/proton/documentdb/clusterstatehandler
src/tests/proton/documentdb/combiningfeedview
src/tests/proton/documentdb/configurer
- src/tests/proton/documentdb/configvalidator
src/tests/proton/documentdb/document_scan_iterator
src/tests/proton/documentdb/document_subdbs
src/tests/proton/documentdb/documentbucketmover
diff --git a/searchcore/src/testlist.txt b/searchcore/src/testlist.txt
index b87a95c2cda..bbe72775946 100644
--- a/searchcore/src/testlist.txt
+++ b/searchcore/src/testlist.txt
@@ -21,7 +21,6 @@ tests/proton/documentdb/buckethandler
tests/proton/documentdb/clusterstatehandler
tests/proton/documentdb/combiningfeedview
tests/proton/documentdb/configurer
-tests/proton/documentdb/configvalidator
tests/proton/documentdb/document_scan_iterator
tests/proton/documentdb/document_subdbs
tests/proton/documentdb/documentbucketmover
diff --git a/searchcore/src/tests/proton/documentdb/configvalidator/.gitignore b/searchcore/src/tests/proton/documentdb/configvalidator/.gitignore
deleted file mode 100644
index 2a8675dad8d..00000000000
--- a/searchcore/src/tests/proton/documentdb/configvalidator/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-searchcore_configvalidator_test_app
diff --git a/searchcore/src/tests/proton/documentdb/configvalidator/CMakeLists.txt b/searchcore/src/tests/proton/documentdb/configvalidator/CMakeLists.txt
deleted file mode 100644
index cea6144fd99..00000000000
--- a/searchcore/src/tests/proton/documentdb/configvalidator/CMakeLists.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-vespa_add_executable(searchcore_configvalidator_test_app TEST
- SOURCES
- configvalidator_test.cpp
- DEPENDS
- searchcore_server
-)
-vespa_add_test(NAME searchcore_configvalidator_test_app COMMAND searchcore_configvalidator_test_app)
diff --git a/searchcore/src/tests/proton/documentdb/configvalidator/DESC b/searchcore/src/tests/proton/documentdb/configvalidator/DESC
deleted file mode 100644
index 9263515a290..00000000000
--- a/searchcore/src/tests/proton/documentdb/configvalidator/DESC
+++ /dev/null
@@ -1 +0,0 @@
-configvalidator test. Take a look at configvalidator_test.cpp for details.
diff --git a/searchcore/src/tests/proton/documentdb/configvalidator/FILES b/searchcore/src/tests/proton/documentdb/configvalidator/FILES
deleted file mode 100644
index a7acf2f384c..00000000000
--- a/searchcore/src/tests/proton/documentdb/configvalidator/FILES
+++ /dev/null
@@ -1 +0,0 @@
-configvalidator_test.cpp
diff --git a/searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp b/searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp
deleted file mode 100644
index 7fcdf4981bd..00000000000
--- a/searchcore/src/tests/proton/documentdb/configvalidator/configvalidator_test.cpp
+++ /dev/null
@@ -1,380 +0,0 @@
-// 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/vespalib/testkit/testapp.h>
-#include <vespa/searchcore/proton/server/configvalidator.h>
-
-using namespace proton;
-using namespace search::index;
-
-using proton::configvalidator::Result;
-using proton::configvalidator::ResultType;
-using search::index::schema::CollectionType;
-using search::index::schema::DataType;
-using vespa::config::search::AttributesConfig;
-using vespa::config::search::AttributesConfigBuilder;
-
-typedef Schema::AttributeField AField;
-typedef Schema::IndexField IField;
-typedef Schema::SummaryField SField;
-
-const ResultType OK = ResultType::OK;
-const ResultType DTC = ResultType::DATA_TYPE_CHANGED;
-const ResultType CTC = ResultType::COLLECTION_TYPE_CHANGED;
-const ResultType IAA = ResultType::INDEX_ASPECT_ADDED;
-const ResultType IAR = ResultType::INDEX_ASPECT_REMOVED;
-const ResultType AAA = ResultType::ATTRIBUTE_ASPECT_ADDED;
-const ResultType AAR = ResultType::ATTRIBUTE_ASPECT_REMOVED;
-const ResultType AFAA = ResultType::ATTRIBUTE_FAST_ACCESS_ADDED;
-const ResultType AFAR = ResultType::ATTRIBUTE_FAST_ACCESS_REMOVED;
-const ResultType ATTC = ResultType::ATTRIBUTE_TENSOR_TYPE_CHANGED;
-
-enum FType {
- INDEX,
- ATTRIBUTE,
- SUMMARY
-};
-
-namespace std {
-
-std::ostream &operator<<(std::ostream &os, const ResultType &value)
-{
- os << static_cast<int>(value);
- return os;
-}
-
-}
-
-struct SchemaBuilder
-{
- Schema _schema;
- SchemaBuilder() : _schema() {}
- SchemaBuilder &add(const vespalib::string &name, FType ftype,
- schema::DataType dtype, schema::CollectionType ctype = schema::CollectionType::SINGLE) {
- switch (ftype) {
- case INDEX:
- _schema.addIndexField(IField(name, dtype, ctype));
- break;
- case ATTRIBUTE:
- _schema.addAttributeField(AField(name, dtype, ctype));
- break;
- case SUMMARY:
- _schema.addSummaryField(SField(name, dtype, ctype));
- break;
- }
- return *this;
- }
- const Schema &schema() const { return _schema; }
-};
-
-Schema
-create(FType ftype, Schema::DataType dtype, Schema::CollectionType ctype)
-{
- SchemaBuilder bld;
- return bld.add("f1", ftype, dtype, ctype).schema();
-}
-
-Schema
-created(FType ftype, schema::DataType dtype)
-{
- return create(ftype, dtype, CollectionType::SINGLE);
-}
-
-Schema
-createc(FType ftype, schema::CollectionType ctype)
-{
- return create(ftype, DataType::STRING, ctype);
-}
-
-ResultType
-checkSchema(const Schema &newSchema,
- const Schema &oldSchema,
- const Schema &oldHistory)
-{
- return ConfigValidator::validate(ConfigValidator::Config(newSchema, AttributesConfig()),
- ConfigValidator::Config(oldSchema, AttributesConfig()), oldHistory).type();
-}
-
-ResultType
-checkAttribute(const AttributesConfig &newCfg,
- const AttributesConfig &oldCfg)
-{
- return ConfigValidator::validate(ConfigValidator::Config(Schema(), newCfg),
- ConfigValidator::Config(Schema(), oldCfg), Schema()).type();
-}
-
-void
-requireThatChangedDataTypeIsDiscovered(FType ftype)
-{
- EXPECT_EQUAL(DTC,
- checkSchema(created(ftype, DataType::INT32),
- created(ftype, DataType::STRING),
- Schema()));
- EXPECT_EQUAL(DTC,
- checkSchema(created(ftype, DataType::INT32),
- Schema(),
- created(ftype, DataType::STRING)));
-}
-
-TEST("require that changed data type is discovered")
-{
- requireThatChangedDataTypeIsDiscovered(INDEX);
- requireThatChangedDataTypeIsDiscovered(ATTRIBUTE);
- requireThatChangedDataTypeIsDiscovered(SUMMARY);
-}
-
-void
-requireThatChangedCollectionTypeIsDiscovered(FType ftype)
-{
- EXPECT_EQUAL(CTC,
- checkSchema(createc(ftype, CollectionType::ARRAY),
- createc(ftype, CollectionType::SINGLE),
- Schema()));
- EXPECT_EQUAL(CTC,
- checkSchema(createc(ftype, CollectionType::ARRAY),
- Schema(),
- createc(ftype, CollectionType::SINGLE)));
-}
-
-TEST("require that changed collection type is discovered")
-{
- requireThatChangedCollectionTypeIsDiscovered(INDEX);
- requireThatChangedCollectionTypeIsDiscovered(ATTRIBUTE);
- requireThatChangedCollectionTypeIsDiscovered(SUMMARY);
-}
-
-TEST("require that changed index aspect is discovered")
-{
- Schema s1 = created(SUMMARY, DataType::STRING);
- s1.addIndexField(IField("f1", DataType::STRING));
- Schema s2 = created(SUMMARY, DataType::STRING);
- Schema s2h = created(INDEX, DataType::STRING);
-
- Schema s3 = created(ATTRIBUTE, DataType::STRING);
- s3.addIndexField(IField("f1", DataType::STRING));
- Schema s4 = created(ATTRIBUTE, DataType::STRING);
- Schema s4h = created(INDEX, DataType::STRING);
- { // remove as index field
- EXPECT_EQUAL(IAR, checkSchema(s2, s1, Schema()));
- EXPECT_EQUAL(IAR, checkSchema(s2, Schema(), s1));
- EXPECT_EQUAL(IAR, checkSchema(s4, s3, Schema()));
- EXPECT_EQUAL(IAR, checkSchema(s4, Schema(), s3));
- }
- {
- // undo field removal
- EXPECT_EQUAL(OK, checkSchema(s1, Schema(), s1));
- EXPECT_EQUAL(OK, checkSchema(s3, Schema(), s3));
- }
- { // add as index field
- EXPECT_EQUAL(IAA, checkSchema(s1, s2, Schema()));
- EXPECT_EQUAL(IAA, checkSchema(s1, s2, s2h));
- EXPECT_EQUAL(IAA, checkSchema(s1, Schema(), s2));
- EXPECT_EQUAL(IAA, checkSchema(s3, s4, Schema()));
- EXPECT_EQUAL(IAA, checkSchema(s3, s4, s4h));
- EXPECT_EQUAL(IAA, checkSchema(s3, Schema(), s4));
- }
-}
-
-TEST("require that changed attribute aspect is discovered")
-{
- Schema s1 = created(SUMMARY, DataType::STRING);
- s1.addAttributeField(AField("f1", DataType::STRING));
- Schema s2 = created(SUMMARY, DataType::STRING);
- Schema s2h = created(ATTRIBUTE, DataType::STRING);
-
- Schema s3 = created(INDEX, DataType::STRING);
- s3.addAttributeField(AField("f1", DataType::STRING));
- Schema s4 = created(INDEX, DataType::STRING);
- Schema s4h = created(ATTRIBUTE, DataType::STRING);
-
- Schema s5 = created(INDEX, DataType::STRING);
- s5.addSummaryField(SField("f1", DataType::STRING));
- s5.addAttributeField(AField("f1", DataType::STRING));
- Schema s6 = created(INDEX, DataType::STRING);
- s6.addSummaryField(SField("f1", DataType::STRING));
- { // remove as attribute field
- EXPECT_EQUAL(AAR, checkSchema(s2, s1, Schema()));
- EXPECT_EQUAL(AAR, checkSchema(s2, Schema(), s1));
- // remove as attribute is allowed when still existing as index.
- EXPECT_EQUAL(OK, checkSchema(s4, s3, Schema()));
- EXPECT_EQUAL(OK, checkSchema(s6, s5, Schema()));
- EXPECT_EQUAL(IAA, checkSchema(s4, Schema(), s3));
- }
- {
- // undo field removal
- EXPECT_EQUAL(OK, checkSchema(s1, Schema(), s1));
- EXPECT_EQUAL(OK, checkSchema(s3, Schema(), s3));
- }
- { // add as attribute field
- EXPECT_EQUAL(AAA, checkSchema(s1, s2, Schema()));
- EXPECT_EQUAL(AAA, checkSchema(s1, s2, s2h));
- EXPECT_EQUAL(AAA, checkSchema(s1, Schema(), s2));
- EXPECT_EQUAL(AAA, checkSchema(s3, s4, Schema()));
- EXPECT_EQUAL(AAA, checkSchema(s3, s4, s4h));
- EXPECT_EQUAL(AAA, checkSchema(s3, Schema(), s4));
- }
-}
-
-TEST("require that changed summary aspect is allowed")
-{
- Schema s1 = created(INDEX, DataType::STRING);
- s1.addSummaryField(SField("f1", DataType::STRING));
- Schema s2 = created(INDEX, DataType::STRING);
- Schema s2h = created(SUMMARY, DataType::STRING);
-
- Schema s3 = created(ATTRIBUTE, DataType::STRING);
- s3.addSummaryField(SField("f1", DataType::STRING));
- Schema s4 = created(ATTRIBUTE, DataType::STRING);
- Schema s4h = created(SUMMARY, DataType::STRING);
- { // remove as summary field
- EXPECT_EQUAL(OK, checkSchema(s2, s1, Schema()));
- EXPECT_EQUAL(IAA, checkSchema(s2, Schema(), s1));
- EXPECT_EQUAL(OK, checkSchema(s4, s3, Schema()));
- EXPECT_EQUAL(AAA, checkSchema(s4, Schema(), s3));
- }
- { // add as summary field
- EXPECT_EQUAL(OK, checkSchema(s1, s2, Schema()));
- EXPECT_EQUAL(OK, checkSchema(s1, s2, s2h));
- EXPECT_EQUAL(OK, checkSchema(s1, Schema(), s2));
- EXPECT_EQUAL(OK, checkSchema(s3, s4, Schema()));
- EXPECT_EQUAL(OK, checkSchema(s3, s4, s4h));
- EXPECT_EQUAL(OK, checkSchema(s3, Schema(), s4));
- }
-}
-
-TEST("require that fields can be added and removed")
-{
- Schema e;
- Schema s1 = created(INDEX, DataType::STRING);
- Schema s2 = created(ATTRIBUTE, DataType::STRING);
- Schema s3 = created(SUMMARY, DataType::STRING);
- Schema s4 = created(SUMMARY, DataType::STRING);
- s4.addIndexField(IField("f1", DataType::STRING));
- Schema s5 = created(SUMMARY, DataType::STRING);
- s5.addAttributeField(AField("f1", DataType::STRING));
- Schema s6 = created(SUMMARY, DataType::STRING);
- s6.addIndexField(IField("f1", DataType::STRING));
- s6.addAttributeField(AField("f1", DataType::STRING));
- { // addition of field
- EXPECT_EQUAL(OK, checkSchema(s1, e, e));
- EXPECT_EQUAL(OK, checkSchema(s2, e, e));
- EXPECT_EQUAL(OK, checkSchema(s3, e, e));
- EXPECT_EQUAL(OK, checkSchema(s4, e, e));
- EXPECT_EQUAL(OK, checkSchema(s5, e, e));
- EXPECT_EQUAL(OK, checkSchema(s6, e, e));
- }
- { // removal of field
- EXPECT_EQUAL(OK, checkSchema(e, s1, e));
- EXPECT_EQUAL(OK, checkSchema(e, e, s1));
- EXPECT_EQUAL(OK, checkSchema(e, s2, e));
- EXPECT_EQUAL(OK, checkSchema(e, e, s2));
- EXPECT_EQUAL(OK, checkSchema(e, s3, e));
- EXPECT_EQUAL(OK, checkSchema(e, e, s3));
- EXPECT_EQUAL(OK, checkSchema(e, s4, e));
- EXPECT_EQUAL(OK, checkSchema(e, e, s4));
- EXPECT_EQUAL(OK, checkSchema(e, s5, e));
- EXPECT_EQUAL(OK, checkSchema(e, e, s5));
- EXPECT_EQUAL(OK, checkSchema(e, s6, e));
- EXPECT_EQUAL(OK, checkSchema(e, e, s6));
- }
-}
-
-TEST("require that data type changed precedes collection type changed")
-{
- Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING).
- add("f2", FType::INDEX, DataType::STRING).schema();
- Schema news = SchemaBuilder().add("f1", FType::SUMMARY, DataType::INT32).
- add("f2", FType::INDEX, DataType::STRING, CollectionType::ARRAY).schema();
- EXPECT_EQUAL(DTC, checkSchema(news, olds, Schema()));
-}
-
-TEST("require that collection type change precedes index aspect added")
-{
- Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING).
- add("f2", FType::SUMMARY, DataType::STRING).schema();
- Schema news = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING, CollectionType::ARRAY).
- add("f2", FType::SUMMARY, DataType::STRING).
- add("f2", FType::INDEX, DataType::STRING).schema();
- EXPECT_EQUAL(CTC, checkSchema(news, olds, Schema()));
-}
-
-TEST("require that index aspect added precedes index aspect removed")
-{
- Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING).
- add("f2", FType::SUMMARY, DataType::STRING).
- add("f2", FType::INDEX, DataType::STRING).schema();
- Schema news = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING).
- add("f1", FType::INDEX, DataType::STRING).
- add("f2", FType::SUMMARY, DataType::STRING).schema();
- EXPECT_EQUAL(IAA, checkSchema(news, olds, Schema()));
-}
-
-TEST("require that index aspect removed precedes attribute aspect removed")
-{
- Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING).
- add("f1", FType::INDEX, DataType::STRING).
- add("f2", FType::SUMMARY, DataType::STRING).
- add("f2", FType::ATTRIBUTE, DataType::STRING).schema();
- Schema news = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING).
- add("f2", FType::SUMMARY, DataType::STRING).schema();
- EXPECT_EQUAL(IAR, checkSchema(news, olds, Schema()));
-}
-
-TEST("require that attribute aspect removed precedes attribute aspect added")
-{
- Schema olds = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING).
- add("f1", FType::ATTRIBUTE, DataType::STRING).
- add("f2", FType::SUMMARY, DataType::STRING).schema();
- Schema news = SchemaBuilder().add("f1", FType::SUMMARY, DataType::STRING).
- add("f2", FType::SUMMARY, DataType::STRING).
- add("f2", FType::ATTRIBUTE, DataType::STRING).schema();
- EXPECT_EQUAL(AAR, checkSchema(news, olds, Schema()));
-}
-
-AttributesConfigBuilder::Attribute
-createAttribute(const vespalib::string &name, bool fastAccess)
-{
- AttributesConfigBuilder::Attribute attr;
- attr.name = name;
- attr.fastaccess = fastAccess;
- return attr;
-}
-
-AttributesConfigBuilder
-createAttributesConfig(const AttributesConfigBuilder::Attribute &attribute)
-{
- AttributesConfigBuilder result;
- result.attribute.push_back(attribute);
- return result;
-}
-
-TEST("require that adding attribute fast-access is discovered")
-{
- EXPECT_EQUAL(AFAA, checkAttribute(createAttributesConfig(createAttribute("a1", true)),
- createAttributesConfig(createAttribute("a1", false))));
-}
-
-TEST("require that removing attribute fast-access is discovered")
-{
- EXPECT_EQUAL(AFAR, checkAttribute(createAttributesConfig(createAttribute("a1", false)),
- createAttributesConfig(createAttribute("a1", true))));
-}
-
-AttributesConfigBuilder::Attribute
-createTensorAttribute(const vespalib::string &name, const vespalib::string &tensorType)
-{
- AttributesConfigBuilder::Attribute attr;
- attr.name = name;
- attr.tensortype = tensorType;
- return attr;
-}
-
-TEST("require that changing attribute tensor type is discovered")
-{
- EXPECT_EQUAL(ATTC, checkAttribute(createAttributesConfig(createTensorAttribute("a1", "tensor(x[10])")),
- createAttributesConfig(createTensorAttribute("a1", "tensor(x[11])"))));
-}
-
-TEST_MAIN()
-{
- TEST_RUN_ALL();
-}
diff --git a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
index 6e2df00b162..5e3b576cf9c 100644
--- a/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
+++ b/searchcore/src/tests/proton/documentdb/feedhandler/feedhandler_test.cpp
@@ -97,13 +97,11 @@ struct Rendezvous {
struct MyOwner : public IFeedHandlerOwner
{
- bool rejected_config;
bool _allowPrune;
int wipe_history_count;
MyOwner()
:
- rejected_config(false),
_allowPrune(false),
wipe_history_count(0)
{
@@ -114,7 +112,6 @@ struct MyOwner : public IFeedHandlerOwner
}
virtual void enterRedoReprocessState() override {}
virtual void onPerformPrune(SerialNum) override {}
- virtual bool isFeedBlockedByRejectedConfig() override { return rejected_config; }
virtual bool
getAllowPrune(void) const override
@@ -514,43 +511,6 @@ TEST_F("require that heartBeat calls FeedView's heartBeat",
EXPECT_EQUAL(1, f.feedView.heartbeat_count);
}
-TEST_F("require that rejected config disables operations and heartbeat",
- FeedHandlerFixture)
-{
- f.owner.rejected_config = true;
- f.handler.changeToNormalFeedState();
- f.owner._allowPrune = true;
-
- DocumentContext doc_context("doc:test:foo", *f.schema.builder);
- FeedOperation::UP op(new PutOperation(doc_context.bucketId,
- Timestamp(10), doc_context.doc));
- FeedTokenContext token1;
- f.handler.performOperation(std::move(token1.token_ap), std::move(op));
- EXPECT_EQUAL(0, f.feedView.put_count);
- EXPECT_EQUAL(Result::PERMANENT_ERROR, token1.getResult()->getErrorCode());
-
- FeedTokenContext token2(DocumentProtocol::REPLY_REMOVEDOCUMENT);
- op.reset(new RemoveOperation(doc_context.bucketId, Timestamp(10),
- doc_context.doc->getId()));
- f.handler.performOperation(std::move(token2.token_ap), std::move(op));
- EXPECT_EQUAL(0, f.feedView.remove_count);
- EXPECT_TRUE(dynamic_cast<const RemoveResult *>(token2.getResult()));
- EXPECT_EQUAL(Result::PERMANENT_ERROR, token2.getResult()->getErrorCode());
-
- FeedTokenContext token3(DocumentProtocol::REPLY_UPDATEDOCUMENT);
- op.reset(new UpdateOperation(doc_context.bucketId, Timestamp(10),
- document::DocumentUpdate::SP()));
- f.handler.performOperation(std::move(token3.token_ap), std::move(op));
- EXPECT_EQUAL(0, f.feedView.update_count);
- EXPECT_TRUE(dynamic_cast<const UpdateResult *>(token3.getResult()));
- EXPECT_EQUAL(Result::PERMANENT_ERROR, token3.getResult()->getErrorCode());
-
- f.runAsMaster([&]() { f.handler.heartBeat(); });
- EXPECT_EQUAL(0, f.feedView.heartbeat_count);
-
- EXPECT_EQUAL(0, f.tls_writer.store_count);
-}
-
TEST_F("require that outdated remove is ignored", FeedHandlerFixture)
{
DocumentContext doc_context("doc:test:foo", *f.schema.builder);
diff --git a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt
index 8e9141d0b40..2bccad4f824 100644
--- a/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt
+++ b/searchcore/src/vespa/searchcore/proton/server/CMakeLists.txt
@@ -1,14 +1,12 @@
# Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
vespa_add_library(searchcore_server STATIC
SOURCES
- attribute_config_validator.cpp
bootstrapconfig.cpp
bootstrapconfigmanager.cpp
buckethandler.cpp
bucketmovejob.cpp
clusterstatehandler.cpp
combiningfeedview.cpp
- configvalidator.cpp
data_directory_upgrader.cpp
ddbstate.cpp
disk_mem_usage_filter.cpp
@@ -83,7 +81,6 @@ vespa_add_library(searchcore_server STATIC
resource_usage_explorer.cpp
rpc_hooks.cpp
sample_attribute_usage_job.cpp
- schema_config_validator.cpp
searchable_doc_subdb_configurer.cpp
searchable_feed_view.cpp
searchabledocsubdb.cpp
diff --git a/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.cpp b/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.cpp
deleted file mode 100644
index 0c29d3436bc..00000000000
--- a/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-// 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.attribute_config_validator");
-#include "attribute_config_validator.h"
-#include <vespa/eval/eval/value_type.h>
-#include <vespa/vespalib/util/stringfmt.h>
-
-
-using vespa::config::search::AttributesConfig;
-using vespalib::make_string;
-using vespalib::eval::ValueType;
-using proton::configvalidator::ResultType;
-using proton::configvalidator::Result;
-
-namespace proton {
-
-namespace {
-
-Result
-checkFastAccess(const AttributesConfig &cfg1,
- const AttributesConfig &cfg2,
- ResultType type,
- const vespalib::string &typeStr)
-{
- for (const auto &attr1 : cfg1.attribute) {
- if (attr1.fastaccess) {
- for (const auto &attr2 : cfg2.attribute) {
- if (attr1.name == attr2.name && !attr2.fastaccess) {
- return Result(type,
- make_string("Trying to %s 'fast-access' to attribute '%s'",
- typeStr.c_str(), attr1.name.c_str()));
- }
- }
- }
- }
- return Result();
-}
-
-Result
-checkFastAccessAdded(const AttributesConfig &newCfg,
- const AttributesConfig &oldCfg)
-{
- return checkFastAccess(newCfg, oldCfg, ResultType::ATTRIBUTE_FAST_ACCESS_ADDED, "add");
-}
-
-Result
-checkFastAccessRemoved(const AttributesConfig &newCfg,
- const AttributesConfig &oldCfg)
-{
- return checkFastAccess(oldCfg, newCfg, ResultType::ATTRIBUTE_FAST_ACCESS_REMOVED, "remove");
-}
-
-Result
-checkTensorTypeChanged(const AttributesConfig &newCfg,
- const AttributesConfig &oldCfg)
-{
- for (const auto &newAttr : newCfg.attribute) {
- for (const auto &oldAttr : oldCfg.attribute) {
- if ((newAttr.name == oldAttr.name) &&
- (ValueType::from_spec(newAttr.tensortype) != ValueType::from_spec(oldAttr.tensortype)))
- {
- return Result(ResultType::ATTRIBUTE_TENSOR_TYPE_CHANGED,
- make_string("Tensor type has changed from '%s' -> '%s' for attribute '%s'",
- oldAttr.tensortype.c_str(), newAttr.tensortype.c_str(), newAttr.name.c_str()));
- }
- }
- }
- return Result();
-}
-
-}
-
-Result
-AttributeConfigValidator::validate(const AttributesConfig &newCfg,
- const AttributesConfig &oldCfg)
-{
- Result res;
- if (!(res = checkFastAccessAdded(newCfg, oldCfg)).ok()) return res;
- if (!(res = checkFastAccessRemoved(newCfg, oldCfg)).ok()) return res;
- if (!(res = checkTensorTypeChanged(newCfg, oldCfg)).ok()) return res;
- return Result();
-}
-
-} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.h b/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.h
deleted file mode 100644
index 76cabf8c4b2..00000000000
--- a/searchcore/src/vespa/searchcore/proton/server/attribute_config_validator.h
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#pragma once
-
-#include "config_validator_result.h"
-#include <vespa/config-attributes.h>
-
-namespace proton {
-
-/**
- * Class used to validate new attribute config before starting using it.
- **/
-struct AttributeConfigValidator
-{
- static configvalidator::Result
- validate(const vespa::config::search::AttributesConfig &newCfg,
- const vespa::config::search::AttributesConfig &oldCfg);
-};
-
-} // namespace proton
-
diff --git a/searchcore/src/vespa/searchcore/proton/server/config_validator_result.h b/searchcore/src/vespa/searchcore/proton/server/config_validator_result.h
deleted file mode 100644
index 0d362f7d97e..00000000000
--- a/searchcore/src/vespa/searchcore/proton/server/config_validator_result.h
+++ /dev/null
@@ -1,34 +0,0 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#pragma once
-
-#include "config_validator_result_type.h"
-#include <vespa/vespalib/stllike/string.h>
-
-namespace proton {
-namespace configvalidator {
-
-/*
- * The result of a schema check, with message string for more detailed info.
- */
-class Result
-{
-private:
- ResultType _type;
- vespalib::string _what;
-public:
- Result()
- : _type(ResultType::OK),
- _what("")
- {}
- Result(ResultType type_, const vespalib::string &what_)
- : _type(type_),
- _what(what_)
- {}
- ResultType type() const { return _type; }
- const vespalib::string &what() const { return _what; }
- bool ok() const { return type() == ResultType::OK; }
-};
-
-} // namespace proton::configvalidator
-} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/config_validator_result_type.h b/searchcore/src/vespa/searchcore/proton/server/config_validator_result_type.h
deleted file mode 100644
index b114735319a..00000000000
--- a/searchcore/src/vespa/searchcore/proton/server/config_validator_result_type.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#pragma once
-
-namespace proton {
-namespace configvalidator {
-
-/**
- * The various results of a schema check.
- * All but OK means that the new schema should be rejected.
- */
-enum class ResultType
-{
- OK,
- DATA_TYPE_CHANGED,
- COLLECTION_TYPE_CHANGED,
- INDEX_ASPECT_ADDED,
- INDEX_ASPECT_REMOVED,
- ATTRIBUTE_ASPECT_ADDED,
- ATTRIBUTE_ASPECT_REMOVED,
- ATTRIBUTE_FAST_ACCESS_ADDED,
- ATTRIBUTE_FAST_ACCESS_REMOVED,
- ATTRIBUTE_TENSOR_TYPE_CHANGED
-};
-
-} // namespace proton::configvalidator
-} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/configvalidator.cpp b/searchcore/src/vespa/searchcore/proton/server/configvalidator.cpp
deleted file mode 100644
index d57e6e256e4..00000000000
--- a/searchcore/src/vespa/searchcore/proton/server/configvalidator.cpp
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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.configvalidator");
-#include "configvalidator.h"
-
-#include "schema_config_validator.h"
-#include "attribute_config_validator.h"
-
-using proton::configvalidator::Result;
-
-namespace proton {
-
-Result
-ConfigValidator::validate(const ConfigValidator::Config &newCfg,
- const ConfigValidator::Config &oldCfg,
- const search::index::Schema &oldHistory)
-{
- Result res;
- if (!(res = SchemaConfigValidator::validate(newCfg.getSchema(),
- oldCfg.getSchema(), oldHistory)).ok()) return res;
- if (!(res = AttributeConfigValidator::validate(newCfg.getAttributeConfig(),
- oldCfg.getAttributeConfig())).ok()) return res;
- return Result();
-}
-
-} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/configvalidator.h b/searchcore/src/vespa/searchcore/proton/server/configvalidator.h
deleted file mode 100644
index d659317e6bb..00000000000
--- a/searchcore/src/vespa/searchcore/proton/server/configvalidator.h
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#pragma once
-
-#include "config_validator_result_type.h"
-#include "config_validator_result.h"
-#include <vespa/searchcommon/common/schema.h>
-#include <vespa/config-attributes.h>
-
-namespace proton {
-
-/**
- * Class used to validate new document db config before starting using it.
- **/
-class ConfigValidator {
-public:
- class Config
- {
- private:
- const search::index::Schema &_schema;
- const vespa::config::search::AttributesConfig &_attributeCfg;
- public:
- Config(const search::index::Schema &schema,
- const vespa::config::search::AttributesConfig &attributeCfg)
- : _schema(schema),
- _attributeCfg(attributeCfg)
- {}
- const search::index::Schema &getSchema() const {
- return _schema;
- }
- const vespa::config::search::AttributesConfig &getAttributeConfig() const {
- return _attributeCfg;
- }
- };
-
- /**
- * Check if new schema can be applied or not.
- */
- static configvalidator::Result
- validate(const Config &newCfg,
- const Config &oldCfg,
- const search::index::Schema &oldHistory);
-};
-
-} // namespace proton
-
diff --git a/searchcore/src/vespa/searchcore/proton/server/ddbstate.cpp b/searchcore/src/vespa/searchcore/proton/server/ddbstate.cpp
index b190d5e32dc..9b9a06fc2e2 100644
--- a/searchcore/src/vespa/searchcore/proton/server/ddbstate.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/ddbstate.cpp
@@ -5,7 +5,6 @@
LOG_SETUP(".proton.server.ddbstate");
#include "ddbstate.h"
-using proton::configvalidator::ResultType;
namespace proton {
@@ -26,8 +25,7 @@ std::vector<vespalib::string> DDBState::_stateNames =
std::vector<vespalib::string> DDBState::_configStateNames =
{
"OK",
- "NEED_RESTART",
- "REJECT"
+ "NEED_RESTART"
};
DDBState::DDBState()
@@ -164,32 +162,6 @@ DDBState::clearRejectedConfig()
}
-DDBState::ConfigState
-DDBState::calcConfigState(const ResultType &cvr)
-{
- if (_state < State::APPLY_LIVE_CONFIG) {
- // Config has been accepted, placed in transaction log and
- // activated by earlier instance. Rejecting config would cause
- // a divergent state.
- return ConfigState::OK;
- }
- switch (cvr) {
- case ResultType::OK:
- return ConfigState::OK;
- case ResultType::ATTRIBUTE_ASPECT_ADDED:
- case ResultType::ATTRIBUTE_FAST_ACCESS_ADDED:
- case ResultType::ATTRIBUTE_ASPECT_REMOVED:
- case ResultType::ATTRIBUTE_FAST_ACCESS_REMOVED:
- if (_state == State::APPLY_LIVE_CONFIG) {
- return ConfigState::OK;
- }
- return ConfigState::NEED_RESTART;
- default:
- return ConfigState::REJECT;
- }
-}
-
-
vespalib::string
DDBState::getStateString(State state)
{
diff --git a/searchcore/src/vespa/searchcore/proton/server/ddbstate.h b/searchcore/src/vespa/searchcore/proton/server/ddbstate.h
index 4371e80ddcd..eff49c2b1d1 100644
--- a/searchcore/src/vespa/searchcore/proton/server/ddbstate.h
+++ b/searchcore/src/vespa/searchcore/proton/server/ddbstate.h
@@ -1,7 +1,6 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
-#include "config_validator_result_type.h"
#include <vespa/vespalib/stllike/string.h>
#include <mutex>
#include <condition_variable>
@@ -35,8 +34,7 @@ public:
enum class ConfigState
{
OK,
- NEED_RESTART,
- REJECT
+ NEED_RESTART
};
private:
@@ -131,19 +129,6 @@ public:
return getRejectedConfig(state);
}
- static bool
- isFeedBlockedByRejectedConfig(ConfigState state)
- {
- return state == ConfigState::REJECT;
- }
-
- bool
- isFeedBlockedByRejectedConfig() const
- {
- ConfigState state(_configState);
- return isFeedBlockedByRejectedConfig(state);
- }
-
void
clearRejectedConfig();
@@ -159,9 +144,6 @@ public:
void
setConfigState(ConfigState newConfigState);
- ConfigState
- calcConfigState(const configvalidator::ResultType &cvr);
-
void
waitForOnlineState();
};
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
index 4b6ced83e16..c639b36b592 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.cpp
@@ -715,13 +715,6 @@ DocumentDB::getAllowPrune(void) const
}
-bool
-DocumentDB::isFeedBlockedByRejectedConfig()
-{
- return _state.isFeedBlockedByRejectedConfig();
-}
-
-
void
DocumentDB::start()
{
diff --git a/searchcore/src/vespa/searchcore/proton/server/documentdb.h b/searchcore/src/vespa/searchcore/proton/server/documentdb.h
index 371b1c31c70..3705c8d786d 100644
--- a/searchcore/src/vespa/searchcore/proton/server/documentdb.h
+++ b/searchcore/src/vespa/searchcore/proton/server/documentdb.h
@@ -202,7 +202,6 @@ private:
*/
virtual void onTransactionLogReplayDone() override __attribute__((noinline));
virtual void onPerformPrune(SerialNum flushedSerial) override;
- virtual bool isFeedBlockedByRejectedConfig() override;
/**
* Implements IFeedHandlerOwner
diff --git a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp
index f2d17df16bf..00eeb91f8eb 100644
--- a/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp
+++ b/searchcore/src/vespa/searchcore/proton/server/feedhandler.cpp
@@ -126,33 +126,6 @@ FeedHandler::doHandleOperation(FeedToken token, FeedOperation::UP op)
_feedState->handleOperation(token, std::move(op));
}
-namespace {
-template <typename ResultType>
-void configRejected(FeedToken *token, DocTypeName docTypeName) {
- if (token) {
- vespalib::string str =
- make_string("Feed rejected for documenttype '%s'"
- " due to incompatible changes to search definition.",
- docTypeName.toString().c_str());
- token->setResult(
- ResultUP(new ResultType(Result::PERMANENT_ERROR, str)), false);
- token->fail(documentapi::DocumentProtocol::ERROR_REJECTED, str);
- }
-}
-
-void notifyConfigRejected(FeedToken *token, FeedOperation::Type type,
- DocTypeName docTypeName) {
- if (type == FeedOperation::REMOVE) {
- configRejected<RemoveResult>(token, docTypeName);
- } else if ((type == FeedOperation::UPDATE_42) || (type == FeedOperation::UPDATE)) {
- configRejected<UpdateResult>(token, docTypeName);
- } else {
- configRejected<Result>(token, docTypeName);
- }
-}
-} // namespace
-
-
void FeedHandler::performPut(FeedToken::UP token, PutOperation &op) {
op.assertValid();
_activeFeedView->preparePut(op);
@@ -702,10 +675,6 @@ notifyFeedOperationRejected(FeedToken *token, const FeedOperation &op,
bool
FeedHandler::considerWriteOperationForRejection(FeedToken *token, const FeedOperation &op)
{
- if (_owner.isFeedBlockedByRejectedConfig()) {
- notifyConfigRejected(token, op.getType(), _docTypeName);
- return true;
- }
if (!_writeFilter.acceptWriteOperation() && isRejectableFeedOperation(op.getType())) {
IResourceWriteFilter::State state = _writeFilter.getAcceptState();
if (!state.acceptWriteOperation()) {
@@ -778,8 +747,6 @@ void
FeedHandler::heartBeat(void)
{
assert(_writeService.master().isCurrentThread());
- if (_owner.isFeedBlockedByRejectedConfig())
- return;
_activeFeedView->heartBeat(_serialNum);
}
diff --git a/searchcore/src/vespa/searchcore/proton/server/i_feed_handler_owner.h b/searchcore/src/vespa/searchcore/proton/server/i_feed_handler_owner.h
index 639cfdba42f..3a6d903df7a 100644
--- a/searchcore/src/vespa/searchcore/proton/server/i_feed_handler_owner.h
+++ b/searchcore/src/vespa/searchcore/proton/server/i_feed_handler_owner.h
@@ -16,7 +16,6 @@ struct IFeedHandlerOwner {
virtual void onTransactionLogReplayDone() = 0;
virtual void enterRedoReprocessState() = 0;
virtual void onPerformPrune(search::SerialNum flushedSerial) = 0;
- virtual bool isFeedBlockedByRejectedConfig() = 0;
virtual bool getAllowPrune() const = 0;
};
diff --git a/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.cpp b/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.cpp
deleted file mode 100644
index 5d4beb8c045..00000000000
--- a/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.cpp
+++ /dev/null
@@ -1,345 +0,0 @@
-// 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 "schema_config_validator.h"
-#include <vespa/vespalib/util/stringfmt.h>
-#include <vespa/searchcommon/common/schema.h>
-#include <vespa/log/log.h>
-LOG_SETUP(".proton.server.schema_config_validator");
-
-using namespace search::index;
-using vespalib::make_string;
-
-using proton::configvalidator::ResultType;
-using proton::configvalidator::Result;
-
-namespace proton {
-
-namespace {
-
-const vespalib::string INDEX_TYPE_NAME = "index";
-const vespalib::string ATTRIBUTE_TYPE_NAME = "attribute";
-const vespalib::string SUMMARY_TYPE_NAME = "summary";
-
-struct SchemaSpec
-{
- const Schema &_newSchema;
- const Schema &_oldSchema;
- const Schema &_oldHistory;
- SchemaSpec(const Schema &newSchema,
- const Schema &oldSchema,
- const Schema &oldHistory)
- : _newSchema(newSchema),
- _oldSchema(oldSchema),
- _oldHistory(oldHistory)
- {
- }
-};
-
-struct IndexChecker {
- static vespalib::string TypeName;
- static ResultType AspectAdded;
- static ResultType AspectRemoved;
-
- static bool
- inSchema(const vespalib::string &name,
- const Schema &schema,
- const Schema &hSchema)
- {
- return (schema.isIndexField(name) || hSchema.isIndexField(name)) &&
- (schema.isAttributeField(name) || schema.isSummaryField(name) ||
- hSchema.isAttributeField(name) || hSchema.isSummaryField(name));
- }
- static bool
- notInSchema(const vespalib::string &name,
- const Schema &schema,
- const Schema &hSchema)
- {
- return !schema.isIndexField(name) &&
- (schema.isAttributeField(name) || schema.isSummaryField(name) ||
- hSchema.isAttributeField(name) || hSchema.isSummaryField(name));
- }
-};
-vespalib::string IndexChecker::TypeName = INDEX_TYPE_NAME;
-ResultType IndexChecker::AspectAdded = ResultType::INDEX_ASPECT_ADDED;
-ResultType IndexChecker::AspectRemoved = ResultType::INDEX_ASPECT_REMOVED;
-
-struct AttributeChecker {
- static vespalib::string TypeName;
- static ResultType AspectAdded;
- static ResultType AspectRemoved;
-
- static bool
- inSchema(const vespalib::string &name,
- const Schema &schema,
- const Schema &hSchema)
- {
- return (schema.isAttributeField(name) ||
- hSchema.isAttributeField(name)) &&
- (schema.isSummaryField(name) ||
- hSchema.isSummaryField(name));
- }
- static bool
- notInSchema(const vespalib::string &name,
- const Schema &schema,
- const Schema &hSchema)
- {
- return !schema.isAttributeField(name) &&
- (schema.isIndexField(name) || schema.isSummaryField(name) ||
- hSchema.isIndexField(name) || hSchema.isSummaryField(name));
- }
-};
-vespalib::string AttributeChecker::TypeName = ATTRIBUTE_TYPE_NAME;
-ResultType AttributeChecker::AspectAdded = ResultType::ATTRIBUTE_ASPECT_ADDED;
-ResultType AttributeChecker::AspectRemoved = ResultType::ATTRIBUTE_ASPECT_REMOVED;
-
-bool
-unchangedAspects(const vespalib::string &fieldName,
- const Schema &newSchema,
- const Schema &oldSchema,
- const Schema &oldHistory)
-{
- if (oldSchema.isIndexField(fieldName) ||
- oldSchema.isAttributeField(fieldName) ||
- oldSchema.isSummaryField(fieldName))
- return false; // field not removed
- return (newSchema.isIndexField(fieldName) ==
- oldHistory.isIndexField(fieldName) &&
- newSchema.isAttributeField(fieldName) ==
- oldHistory.isAttributeField(fieldName) &&
- newSchema.isSummaryField(fieldName) ==
- oldHistory.isSummaryField(fieldName));
-}
-
-template <typename Checker>
-Result
-checkAspectAdded(const Schema::Field &field,
- const SchemaSpec &spec)
-{
- // Special check for undo scenarios.
- if (unchangedAspects(field.getName(), spec._newSchema, spec._oldSchema, spec._oldHistory)) {
- return Result();
- }
- if (Checker::notInSchema(field.getName(), spec._oldSchema, spec._oldHistory)) {
- return Result(Checker::AspectAdded,
- make_string("Trying to add %s field `%s', but it has existed as a field before",
- Checker::TypeName.c_str(), field.getName().c_str()));
- }
- return Result();
-}
-
-template <typename Checker>
-Result
-checkAspectRemoved(const Schema::Field &field,
- const SchemaSpec &spec)
-{
- // Special check for undo scenarios.
- if (unchangedAspects(field.getName(), spec._newSchema, spec._oldSchema, spec._oldHistory)) {
- return Result();
- }
- if (Checker::inSchema(field.getName(), spec._oldSchema, spec._oldHistory)) {
- return Result(Checker::AspectRemoved,
- make_string("Trying to remove %s field `%s', but it still exists as a field",
- Checker::TypeName.c_str(), field.getName().c_str()));
- }
- return Result();
-}
-
-struct IndexTraits
-{
- static vespalib::string TypeName;
- static uint32_t getFieldId(const vespalib::string &name, const Schema &schema) {
- return schema.getIndexFieldId(name);
- }
- static const Schema::Field &getField(uint32_t fieldId, const Schema &schema) {
- return schema.getIndexField(fieldId);
- }
-};
-vespalib::string IndexTraits::TypeName = INDEX_TYPE_NAME;
-
-struct AttributeTraits
-{
- static vespalib::string TypeName;
- static uint32_t getFieldId(const vespalib::string &name, const Schema &schema) {
- return schema.getAttributeFieldId(name);
- }
- static const Schema::Field &getField(uint32_t fieldId, const Schema &schema) {
- return schema.getAttributeField(fieldId);
- }
-};
-vespalib::string AttributeTraits::TypeName = ATTRIBUTE_TYPE_NAME;
-
-struct SummaryTraits
-{
- static vespalib::string TypeName;
- static uint32_t getFieldId(const vespalib::string &name, const Schema &schema) {
- return schema.getSummaryFieldId(name);
- }
- static const Schema::Field &getField(uint32_t fieldId, const Schema &schema) {
- return schema.getSummaryField(fieldId);
- }
-};
-vespalib::string SummaryTraits::TypeName = SUMMARY_TYPE_NAME;
-
-Result
-checkDataTypeFunc(const Schema::Field &oldField,
- const Schema::Field &newField,
- const vespalib::string &fieldClass)
-{
- if (oldField.getDataType() != newField.getDataType()) {
- return Result(ResultType::DATA_TYPE_CHANGED,
- make_string("Trying to add %s field `%s' of data type %s, "
- "but it has been of of data type %s earlier",
- fieldClass.c_str(), newField.getName().c_str(),
- schema::getTypeName(newField.getDataType()).c_str(),
- schema::getTypeName(oldField.getDataType()).c_str()));
- }
- return Result();
-}
-
-Result
-checkCollectionTypeFunc(const Schema::Field &oldField,
- const Schema::Field &newField,
- const vespalib::string &fieldClass)
-{
- if (oldField.getCollectionType() != newField.getCollectionType()) {
- return Result(ResultType::COLLECTION_TYPE_CHANGED,
- make_string("Trying to add %s field `%s' of collection type %s, "
- "but it has been of of collection type %s earlier",
- fieldClass.c_str(), newField.getName().c_str(),
- schema::getTypeName(newField.getCollectionType()).c_str(),
- schema::getTypeName(oldField.getCollectionType()).c_str()));
- }
- return Result();
-}
-
-template <typename T, typename CheckFunc>
-Result
-checkType(const Schema::Field &field, const Schema &oldSchema, CheckFunc func)
-{
- uint32_t oFieldId = T::getFieldId(field.getName(), oldSchema);
- if (oFieldId != Schema::UNKNOWN_FIELD_ID) {
- const Schema::Field &oField = T::getField(oFieldId, oldSchema);
- Result res = func(oField, field, T::TypeName);
- if (!res.ok()) {
- return res;
- }
- }
- return Result();
-}
-
-template <typename T, typename CheckFunc>
-Result
-checkType(const Schema::Field &field, const SchemaSpec &spec, CheckFunc func)
-{
- Result res;
- if (!(res = checkType<T>(field, spec._oldSchema, func)).ok()) return res;
- if (!(res = checkType<T>(field, spec._oldHistory, func)).ok()) return res;
- return Result();
-}
-
-template <typename CheckFunc>
-Result
-checkType(const SchemaSpec &spec, CheckFunc func)
-{
- Result res;
- for (const auto &f : spec._newSchema.getIndexFields()) {
- if (!(res = checkType<IndexTraits>(f, spec, func)).ok()) return res;
- }
- for (const auto &f : spec._newSchema.getAttributeFields()) {
- if (!(res = checkType<AttributeTraits>(f, spec, func)).ok()) return res;
- }
- for (const auto &f : spec._newSchema.getSummaryFields()) {
- if (!(res = checkType<SummaryTraits>(f, spec, func)).ok()) return res;
- }
- return Result();
-}
-
-Result
-checkDataType(const SchemaSpec &spec)
-{
- return checkType(spec, checkDataTypeFunc);
-}
-
-Result
-checkCollectionType(const SchemaSpec &spec)
-{
- return checkType(spec, checkCollectionTypeFunc);
-}
-
-Result
-checkIndexAspectAdded(const SchemaSpec &spec)
-{
- Result res;
- for (const auto &f : spec._newSchema.getIndexFields()) {
- if (!(res = checkAspectAdded<IndexChecker>(f, spec)).ok()) return res;
- }
- return Result();
-}
-
-Result
-checkIndexAspectRemoved(const SchemaSpec &spec)
-{
- Result res;
- for (const auto &f : spec._newSchema.getAttributeFields()) {
- if (!spec._newSchema.isIndexField(f.getName())) {
- if (!(res = checkAspectRemoved<IndexChecker>(f, spec)).ok()) return res;
- }
- }
- for (const auto &f : spec._newSchema.getSummaryFields()) {
- if (!spec._newSchema.isIndexField(f.getName())) {
- if (!(res = checkAspectRemoved<IndexChecker>(f, spec)).ok()) return res;
- }
- }
- return Result();
-}
-
-Result
-checkAttributeAspectAdded(const SchemaSpec &spec)
-{
- Result res;
- for (const auto &f : spec._newSchema.getAttributeFields()) {
- if (!(res = checkAspectAdded<AttributeChecker>(f, spec)).ok()) return res;
- }
- return Result();
-}
-
-Result
-checkAttributeAspectRemoved(const SchemaSpec &spec)
-{
- Result res;
- // Note: remove as attribute is allowed when still existing as index
- // so no need to iterator all index fields.
-
- for (const auto &f : spec._newSchema.getSummaryFields()) {
- if (!spec._newSchema.isAttributeField(f.getName()) &&
- !spec._newSchema.isIndexField(f.getName()) &&
- !spec._oldSchema.isIndexField(f.getName()))
- {
- if (!(res = checkAspectRemoved<AttributeChecker>(f, spec)).ok()) return res;
- }
- }
- return Result();
-}
-
-}
-
-Result
-SchemaConfigValidator::validate(const Schema &newSchema,
- const Schema &oldSchema,
- const Schema &oldHistory)
-{
- LOG(debug, "validate(): newSchema='%s', oldSchema='%s', oldHistory='%s'",
- newSchema.toString().c_str(), oldSchema.toString().c_str(), oldHistory.toString().c_str());
- Result res;
- SchemaSpec spec(newSchema, oldSchema, oldHistory);
- if (!(res = checkDataType(spec)).ok()) return res;
- if (!(res = checkCollectionType(spec)).ok()) return res;
- if (!(res = checkIndexAspectAdded(spec)).ok()) return res;
- if (!(res = checkIndexAspectRemoved(spec)).ok()) return res;
- if (!(res = checkAttributeAspectRemoved(spec)).ok()) return res;
- if (!(res = checkAttributeAspectAdded(spec)).ok()) return res;
- return Result();
-}
-
-} // namespace proton
diff --git a/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.h b/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.h
deleted file mode 100644
index a97cd612f30..00000000000
--- a/searchcore/src/vespa/searchcore/proton/server/schema_config_validator.h
+++ /dev/null
@@ -1,23 +0,0 @@
-// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-
-#pragma once
-
-#include "config_validator_result.h"
-
-namespace search { namespace index { class Schema; } }
-
-namespace proton {
-
-/**
- * Class used to validate new schema before starting using it.
- **/
-struct SchemaConfigValidator
-{
- static configvalidator::Result
- validate(const search::index::Schema &newSchema,
- const search::index::Schema &oldSchema,
- const search::index::Schema &oldHistory);
-};
-
-} // namespace proton
-