From 7b9dd4b44b8d84f901b2bb496c7d7f7ca01028ba Mon Sep 17 00:00:00 2001 From: Tor Egge Date: Thu, 1 Feb 2018 14:55:54 +0000 Subject: Move FixedBucketSpaces to document module. --- persistence/src/tests/spi/CMakeLists.txt | 1 - .../src/tests/spi/fixed_bucket_spaces_test.cpp | 64 ---------------------- .../src/vespa/persistence/spi/CMakeLists.txt | 1 - .../vespa/persistence/spi/fixed_bucket_spaces.cpp | 33 ----------- .../vespa/persistence/spi/fixed_bucket_spaces.h | 30 ---------- 5 files changed, 129 deletions(-) delete mode 100644 persistence/src/tests/spi/fixed_bucket_spaces_test.cpp delete mode 100644 persistence/src/vespa/persistence/spi/fixed_bucket_spaces.cpp delete mode 100644 persistence/src/vespa/persistence/spi/fixed_bucket_spaces.h (limited to 'persistence/src') diff --git a/persistence/src/tests/spi/CMakeLists.txt b/persistence/src/tests/spi/CMakeLists.txt index c51270a420c..a130573e028 100644 --- a/persistence/src/tests/spi/CMakeLists.txt +++ b/persistence/src/tests/spi/CMakeLists.txt @@ -2,7 +2,6 @@ vespa_add_library(persistence_testspi SOURCES clusterstatetest.cpp - fixed_bucket_spaces_test.cpp DEPENDS persistence_persistence_conformancetest persistence diff --git a/persistence/src/tests/spi/fixed_bucket_spaces_test.cpp b/persistence/src/tests/spi/fixed_bucket_spaces_test.cpp deleted file mode 100644 index 7e36d80248a..00000000000 --- a/persistence/src/tests/spi/fixed_bucket_spaces_test.cpp +++ /dev/null @@ -1,64 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. - -#include -#include - -namespace storage::spi { - -struct FixedBucketSpacesTest : CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(FixedBucketSpacesTest); - CPPUNIT_TEST(bucket_space_from_name_is_defined_for_default_space); - CPPUNIT_TEST(bucket_space_from_name_is_defined_for_global_space); - CPPUNIT_TEST(bucket_space_from_name_throws_exception_for_unknown_space); - CPPUNIT_TEST(name_from_bucket_space_is_defined_for_default_space); - CPPUNIT_TEST(name_from_bucket_space_is_defined_for_global_space); - CPPUNIT_TEST(name_from_bucket_space_throws_exception_for_unknown_space); - CPPUNIT_TEST_SUITE_END(); - - void bucket_space_from_name_is_defined_for_default_space(); - void bucket_space_from_name_is_defined_for_global_space(); - void bucket_space_from_name_throws_exception_for_unknown_space(); - void name_from_bucket_space_is_defined_for_default_space(); - void name_from_bucket_space_is_defined_for_global_space(); - void name_from_bucket_space_throws_exception_for_unknown_space(); -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(FixedBucketSpacesTest); - -using document::BucketSpace; - -void FixedBucketSpacesTest::bucket_space_from_name_is_defined_for_default_space() { - CPPUNIT_ASSERT_EQUAL(FixedBucketSpaces::default_space(), FixedBucketSpaces::from_string("default")); -} - -void FixedBucketSpacesTest::bucket_space_from_name_is_defined_for_global_space() { - CPPUNIT_ASSERT_EQUAL(FixedBucketSpaces::global_space(), FixedBucketSpaces::from_string("global")); -} - -void FixedBucketSpacesTest::bucket_space_from_name_throws_exception_for_unknown_space() { - try { - FixedBucketSpaces::from_string("banana"); - CPPUNIT_FAIL("Expected exception on unknown bucket space name"); - } catch (spi::UnknownBucketSpaceException& e) { - } -} - -void FixedBucketSpacesTest::name_from_bucket_space_is_defined_for_default_space() { - CPPUNIT_ASSERT_EQUAL(vespalib::stringref("default"), - FixedBucketSpaces::to_string(FixedBucketSpaces::default_space())); -} - -void FixedBucketSpacesTest::name_from_bucket_space_is_defined_for_global_space() { - CPPUNIT_ASSERT_EQUAL(vespalib::stringref("global"), - FixedBucketSpaces::to_string(FixedBucketSpaces::global_space())); -} - -void FixedBucketSpacesTest::name_from_bucket_space_throws_exception_for_unknown_space() { - try { - FixedBucketSpaces::to_string(BucketSpace(4567)); - CPPUNIT_FAIL("Expected exception on unknown bucket space value"); - } catch (spi::UnknownBucketSpaceException& e) { - } -} - -} \ No newline at end of file diff --git a/persistence/src/vespa/persistence/spi/CMakeLists.txt b/persistence/src/vespa/persistence/spi/CMakeLists.txt index a2b8fa7a79c..f9146c5a833 100644 --- a/persistence/src/vespa/persistence/spi/CMakeLists.txt +++ b/persistence/src/vespa/persistence/spi/CMakeLists.txt @@ -8,7 +8,6 @@ vespa_add_library(persistence_spi OBJECT context.cpp docentry.cpp exceptions.cpp - fixed_bucket_spaces.cpp metricpersistenceprovider.cpp partitionstate.cpp persistenceprovider.cpp diff --git a/persistence/src/vespa/persistence/spi/fixed_bucket_spaces.cpp b/persistence/src/vespa/persistence/spi/fixed_bucket_spaces.cpp deleted file mode 100644 index 6a8ec0f18f7..00000000000 --- a/persistence/src/vespa/persistence/spi/fixed_bucket_spaces.cpp +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#include "fixed_bucket_spaces.h" - -namespace storage::spi { - -VESPA_IMPLEMENT_EXCEPTION(UnknownBucketSpaceException, vespalib::IllegalArgumentException) - -// Some sanity checks to ensure we don't mess up any legacy mappings. -static_assert(document::BucketSpace::placeHolder() != document::BucketSpace::invalid()); -static_assert(FixedBucketSpaces::default_space() == document::BucketSpace::placeHolder()); -static_assert(FixedBucketSpaces::global_space() != FixedBucketSpaces::default_space()); - -document::BucketSpace FixedBucketSpaces::from_string(vespalib::stringref name) { - if (name == "default") { - return default_space(); - } else if (name == "global") { - return global_space(); - } else { - throw UnknownBucketSpaceException("Unknown bucket space name: " + vespalib::string(name), VESPA_STRLOC); - } -} - -vespalib::stringref FixedBucketSpaces::to_string(document::BucketSpace space) { - if (space == default_space()) { - return "default"; - } else if (space == global_space()) { - return "global"; - } else { - throw UnknownBucketSpaceException("Unknown bucket space: " + space.toString(), VESPA_STRLOC); - } -} - -} diff --git a/persistence/src/vespa/persistence/spi/fixed_bucket_spaces.h b/persistence/src/vespa/persistence/spi/fixed_bucket_spaces.h deleted file mode 100644 index c2e97407797..00000000000 --- a/persistence/src/vespa/persistence/spi/fixed_bucket_spaces.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -#pragma once - -#include -#include -#include - -namespace storage::spi { - -VESPA_DEFINE_EXCEPTION(UnknownBucketSpaceException, vespalib::IllegalArgumentException); - -/** - * Minimal repository/factory of bucket spaces hard coded for default and global - * distributions. - */ -struct FixedBucketSpaces { - static constexpr document::BucketSpace default_space() { return document::BucketSpace(1); }; - static constexpr document::BucketSpace global_space() { return document::BucketSpace(2); } - - // Post-condition: returned space has valid() == true iff name - // is either "default" or "global". - // Throws UnknownBucketSpaceException if name does not map to a known bucket space. - static document::BucketSpace from_string(vespalib::stringref name); - // Post-condition: returned string can be losslessly passed to from_string() - // iff space is equal to default_space() or global_space(). - // Throws UnknownBucketSpaceException if space does not map to a known name. - static vespalib::stringref to_string(document::BucketSpace space); -}; - -} -- cgit v1.2.3