Files
scylladb/sstables/progress_monitor.hh
Glauber Costa 86d7c160fd sstables: notify about end of data component write
We need to notify the monitor that the offset tracker that we are using is
about to be destroyed and will no longer be valid.

While we could modify the file_writer interface so that we could capture
the offset_tracker and take ownership of it - guaranteeing it is alive
until we reach the existing on_write_completed(), this feels like a
layer violation.

It is also potentially useful in general to offer the monitor callers
with knowledge that writing the data portion is done.

Signed-off-by: Glauber Costa <glauber@scylladb.com>
2018-01-02 18:43:07 -05:00

86 lines
2.4 KiB
C++

/*
* Copyright (C) 2017 ScyllaDB
*
*/
/*
* This file is part of Scylla.
*
* Scylla is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Scylla is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Scylla. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <seastar/core/shared_ptr.hh>
#include "shared_sstable.hh"
namespace sstables {
struct writer_offset_tracker {
uint64_t offset = 0;
};
class write_monitor {
public:
virtual ~write_monitor() { }
virtual void on_write_started(const writer_offset_tracker&) = 0;
virtual void on_data_write_completed() = 0;
virtual void on_write_completed() = 0;
virtual void on_flush_completed() = 0;
};
struct noop_write_monitor final : public write_monitor {
virtual void on_write_started(const writer_offset_tracker&) { };
virtual void on_data_write_completed() override { }
virtual void on_write_completed() override { }
virtual void on_flush_completed() override { }
};
write_monitor& default_write_monitor();
struct reader_position_tracker {
uint64_t position = 0;
uint64_t total_read_size = 0;
};
class read_monitor {
public:
virtual ~read_monitor() { }
// parameters are the current position in the data file
virtual void on_read_started(const reader_position_tracker&) = 0;
virtual void on_read_completed() = 0;
};
struct noop_read_monitor final : public read_monitor {
virtual void on_read_started(const reader_position_tracker&) override {}
virtual void on_read_completed() override {}
};
read_monitor& default_read_monitor();
struct read_monitor_generator {
virtual read_monitor& operator()(shared_sstable sst) = 0;
virtual ~read_monitor_generator() {}
};
struct no_read_monitoring final : public read_monitor_generator {
virtual read_monitor& operator()(shared_sstable sst) override {
return default_read_monitor();
};
};
read_monitor_generator& default_read_monitor_generator();
}