diff --git a/src/Disks/IVolume.cpp b/src/Disks/IVolume.cpp index c135dade128..85568fdd05b 100644 --- a/src/Disks/IVolume.cpp +++ b/src/Disks/IVolume.cpp @@ -10,8 +10,6 @@ namespace DB namespace ErrorCodes { extern const int NO_ELEMENTS_IN_CONFIG; - extern const int INCONSISTENT_RESERVATIONS; - extern const int NO_RESERVATIONS_PROVIDED; } IVolume::IVolume( @@ -45,43 +43,4 @@ UInt64 IVolume::getMaxUnreservedFreeSpace() const return res; } -MultiDiskReservation::MultiDiskReservation(Reservations & reservations_, UInt64 size_) - : reservations(std::move(reservations_)) - , size(size_) -{ - if (reservations.empty()) - { - throw Exception("At least one reservation must be provided to MultiDiskReservation", ErrorCodes::NO_RESERVATIONS_PROVIDED); - } - - for (auto & reservation : reservations) - { - if (reservation->getSize() != size_) - { - throw Exception("Reservations must have same size", ErrorCodes::INCONSISTENT_RESERVATIONS); - } - } -} - -Disks MultiDiskReservation::getDisks() const -{ - Disks res; - res.reserve(reservations.size()); - for (const auto & reservation : reservations) - { - res.push_back(reservation->getDisk()); - } - return res; -} - -void MultiDiskReservation::update(UInt64 new_size) -{ - for (auto & reservation : reservations) - { - reservation->update(new_size); - } - size = new_size; -} - - } diff --git a/src/Disks/IVolume.h b/src/Disks/IVolume.h index 843ecc8f5e0..71c47a754ba 100644 --- a/src/Disks/IVolume.h +++ b/src/Disks/IVolume.h @@ -81,22 +81,4 @@ public: bool perform_ttl_move_on_insert = true; }; -/// Reservation for multiple disks at once. Can be used in RAID1 implementation. -class MultiDiskReservation : public IReservation -{ -public: - MultiDiskReservation(Reservations & reservations, UInt64 size); - - UInt64 getSize() const override { return size; } - - DiskPtr getDisk(size_t i) const override { return reservations[i]->getDisk(); } - - Disks getDisks() const override; - - void update(UInt64 new_size) override; -private: - Reservations reservations; - UInt64 size; -}; - } diff --git a/src/Disks/StoragePolicy.cpp b/src/Disks/StoragePolicy.cpp index 5993447f9f3..11f53d10fb4 100644 --- a/src/Disks/StoragePolicy.cpp +++ b/src/Disks/StoragePolicy.cpp @@ -1,6 +1,7 @@ #include "StoragePolicy.h" #include "DiskFactory.h" #include "DiskLocal.h" +#include "createVolume.h" #include #include diff --git a/src/Disks/StoragePolicy.h b/src/Disks/StoragePolicy.h index fd10ff96824..f8c40acd26a 100644 --- a/src/Disks/StoragePolicy.h +++ b/src/Disks/StoragePolicy.h @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Disks/VolumeRAID1.cpp b/src/Disks/VolumeRAID1.cpp deleted file mode 100644 index d7696ab5d2f..00000000000 --- a/src/Disks/VolumeRAID1.cpp +++ /dev/null @@ -1,29 +0,0 @@ -#include "VolumeRAID1.h" - -#include -#include - -namespace DB -{ - -ReservationPtr VolumeRAID1::reserve(UInt64 bytes) -{ - /// This volume can not store data which size is greater than `max_data_part_size` - /// to ensure that parts of size greater than that go to another volume(s). - - if (max_data_part_size != 0 && bytes > max_data_part_size) - return {}; - - Reservations res(disks.size()); - for (size_t i = 0; i < disks.size(); ++i) - { - res[i] = disks[i]->reserve(bytes); - - if (!res[i]) - return {}; - } - - return std::make_unique(res, bytes); -} - -} diff --git a/src/Disks/VolumeRAID1.h b/src/Disks/VolumeRAID1.h deleted file mode 100644 index f6f2d245a49..00000000000 --- a/src/Disks/VolumeRAID1.h +++ /dev/null @@ -1,49 +0,0 @@ -#pragma once - -#include -#include - - -namespace DB -{ - -class VolumeRAID1; - -using VolumeRAID1Ptr = std::shared_ptr; - -/// Volume which reserves space on each underlying disk. -/// -/// NOTE: Just interface implementation, doesn't used in codebase, -/// also not available for user. -class VolumeRAID1 : public VolumeJBOD -{ -public: - VolumeRAID1(String name_, Disks disks_, UInt64 max_data_part_size_, bool are_merges_avoided_in_config_) - : VolumeJBOD(name_, disks_, max_data_part_size_, are_merges_avoided_in_config_) - { - } - - VolumeRAID1( - String name_, - const Poco::Util::AbstractConfiguration & config, - const String & config_prefix, - DiskSelectorPtr disk_selector) - : VolumeJBOD(name_, config, config_prefix, disk_selector) - { - } - - VolumeRAID1( - VolumeRAID1 & volume_raid1, - const Poco::Util::AbstractConfiguration & config, - const String & config_prefix, - DiskSelectorPtr disk_selector) - : VolumeJBOD(volume_raid1, config, config_prefix, disk_selector) - { - } - - VolumeType getType() const override { return VolumeType::RAID1; } - - ReservationPtr reserve(UInt64 bytes) override; -}; - -} diff --git a/src/Disks/createVolume.cpp b/src/Disks/createVolume.cpp index a290a1d3db3..a5ca8df3920 100644 --- a/src/Disks/createVolume.cpp +++ b/src/Disks/createVolume.cpp @@ -2,7 +2,6 @@ #include #include -#include #include @@ -23,11 +22,6 @@ VolumePtr createVolumeFromReservation(const ReservationPtr & reservation, Volume /// for such type of reservation will be with one disk. return std::make_shared(other_volume->getName(), reservation->getDisk(), other_volume->max_data_part_size); } - if (other_volume->getType() == VolumeType::RAID1) - { - auto volume = std::dynamic_pointer_cast(other_volume); - return std::make_shared(volume->getName(), reservation->getDisks(), volume->max_data_part_size, volume->are_merges_avoided); - } return nullptr; } diff --git a/src/Storages/StorageReplicatedMergeTree.cpp b/src/Storages/StorageReplicatedMergeTree.cpp index 56cb03d09b6..0c12cb54911 100644 --- a/src/Storages/StorageReplicatedMergeTree.cpp +++ b/src/Storages/StorageReplicatedMergeTree.cpp @@ -59,6 +59,7 @@ #include #include #include +#include #include #include