mirror of
https://github.com/scylladb/scylladb.git
synced 2026-04-24 10:30:38 +00:00
Merge branch 'master' of github.com:cloudius-systems/seastar into db
This commit is contained in:
@@ -495,6 +495,15 @@ reactor::open_directory(sstring name) {
|
||||
});
|
||||
}
|
||||
|
||||
future<>
|
||||
reactor::make_directory(sstring name) {
|
||||
return _thread_pool.submit<syscall_result<int>>([name = std::move(name)] {
|
||||
return wrap_syscall<int>(::mkdir(name.c_str(), S_IRWXU));
|
||||
}).then([] (syscall_result<int> sr) {
|
||||
sr.throw_if_error();
|
||||
});
|
||||
}
|
||||
|
||||
future<>
|
||||
posix_file_impl::flush(void) {
|
||||
return engine()._thread_pool.submit<syscall_result<int>>([this] {
|
||||
@@ -1722,6 +1731,10 @@ future<file> open_directory(sstring name) {
|
||||
return engine().open_directory(std::move(name));
|
||||
}
|
||||
|
||||
future<> make_directory(sstring name) {
|
||||
return engine().make_directory(std::move(name));
|
||||
}
|
||||
|
||||
future<> remove_file(sstring pathname) {
|
||||
return engine().remove_file(std::move(pathname));
|
||||
}
|
||||
|
||||
@@ -759,6 +759,7 @@ public:
|
||||
|
||||
future<file> open_file_dma(sstring name, open_flags flags);
|
||||
future<file> open_directory(sstring name);
|
||||
future<> make_directory(sstring name);
|
||||
future<std::experimental::optional<directory_entry_type>> file_type(sstring name);
|
||||
future<> remove_file(sstring pathname);
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "scollectd.hh"
|
||||
#include "core/future-util.hh"
|
||||
#include "net/api.hh"
|
||||
#include "scollectd_api.hh"
|
||||
|
||||
bool scollectd::type_instance_id::operator<(
|
||||
const scollectd::type_instance_id& id2) const {
|
||||
@@ -385,6 +386,20 @@ private:
|
||||
arm();
|
||||
});
|
||||
}
|
||||
public:
|
||||
shared_ptr<value_list> get_values(const type_instance_id & id) {
|
||||
return _values[id];
|
||||
}
|
||||
|
||||
std::vector<type_instance_id> get_instance_ids() {
|
||||
std::vector<type_instance_id> res(_values.size());
|
||||
int pos = 0;
|
||||
for (auto i: _values) {
|
||||
res[pos++] = i.first;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
value_list_map _values;
|
||||
std::vector<registration> _regs;
|
||||
@@ -451,4 +466,39 @@ boost::program_options::options_description get_options_description() {
|
||||
"collectd host name");
|
||||
return opts;
|
||||
}
|
||||
|
||||
std::vector<collectd_value> get_collectd_value(
|
||||
shared_ptr<scollectd::type_instance_id> id) {
|
||||
std::vector<collectd_value> res_values;
|
||||
auto raw_types = get_impl().get_values(*id);
|
||||
if (raw_types == nullptr) {
|
||||
return res_values;
|
||||
}
|
||||
std::vector<data_type> types(raw_types->size());
|
||||
raw_types->types(&(*types.begin()));
|
||||
std::vector<net::packed<uint64_t>> value(raw_types->size());
|
||||
raw_types->values(&(*value.begin()));
|
||||
|
||||
auto i = value.begin();
|
||||
for (auto t : types) {
|
||||
collectd_value c(t, be64toh(*i));
|
||||
res_values.push_back(c);
|
||||
}
|
||||
return res_values;
|
||||
}
|
||||
|
||||
std::vector<data_type> get_collectd_types(
|
||||
const scollectd::type_instance_id& id) {
|
||||
auto res = get_impl().get_values(id);
|
||||
if (res == nullptr) {
|
||||
return std::vector<data_type>();
|
||||
}
|
||||
std::vector<data_type> vals(res->size());
|
||||
res->types(&(*vals.begin()));
|
||||
return vals;
|
||||
}
|
||||
|
||||
std::vector<scollectd::type_instance_id> get_collectd_ids() {
|
||||
return get_impl().get_instance_ids();
|
||||
}
|
||||
}
|
||||
|
||||
58
core/scollectd_api.hh
Normal file
58
core/scollectd_api.hh
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2015 Cloudius Systems
|
||||
*/
|
||||
|
||||
#ifndef CORE_SCOLLECTD_API_HH_
|
||||
#define CORE_SCOLLECTD_API_HH_
|
||||
|
||||
#include "core/scollectd.hh"
|
||||
|
||||
namespace scollectd {
|
||||
|
||||
struct collectd_value {
|
||||
union {
|
||||
double _d;
|
||||
uint64_t _ui;
|
||||
int64_t _i;
|
||||
} u;
|
||||
scollectd::data_type _type;
|
||||
collectd_value()
|
||||
: _type(data_type::GAUGE) {
|
||||
}
|
||||
collectd_value(data_type t, uint64_t i)
|
||||
: _type(t) {
|
||||
u._ui = i;
|
||||
}
|
||||
|
||||
collectd_value& operator=(const collectd_value& c) = default;
|
||||
|
||||
collectd_value& operator+=(const collectd_value& c) {
|
||||
*this = *this + c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
collectd_value operator+(const collectd_value& c) {
|
||||
collectd_value res(*this);
|
||||
switch (_type) {
|
||||
case data_type::GAUGE:
|
||||
res.u._d += c.u._d;
|
||||
break;
|
||||
case data_type::DERIVE:
|
||||
res.u._i += c.u._i;
|
||||
break;
|
||||
default:
|
||||
res.u._ui += c.u._ui;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
std::vector<collectd_value> get_collectd_value(
|
||||
shared_ptr<scollectd::type_instance_id> id);
|
||||
|
||||
std::vector<scollectd::type_instance_id> get_collectd_ids();
|
||||
|
||||
}
|
||||
|
||||
#endif /* CORE_SCOLLECTD_API_HH_ */
|
||||
@@ -47,5 +47,6 @@ future<connected_socket> connect(socket_address sa);
|
||||
// File API
|
||||
future<file> open_file_dma(sstring name, open_flags flags);
|
||||
future<file> open_directory(sstring name);
|
||||
future<> make_directory(sstring name);
|
||||
future<> remove_file(sstring pathname);
|
||||
|
||||
|
||||
@@ -300,7 +300,7 @@ auto send_helper(MsgType t, std::index_sequence<I...>) {
|
||||
auto xargs = std::tie(m->t, m->id, std::get<I>(m->args)...); // holds references to all message elements
|
||||
promise<> sent; // will be fulfilled when data is sent
|
||||
auto fsent = sent.get_future();
|
||||
dst.out_ready() = dst.out_ready().then([&dst, xargs = std::move(xargs), m = std::move(m), sent = std::move(sent)] () mutable {
|
||||
dst.out_ready() = dst.out_ready().then([&dst, xargs = std::move(xargs), m = std::move(m)] () mutable {
|
||||
return marshall(dst.serializer(), dst.out(), std::move(xargs)).then([m = std::move(m)] {});
|
||||
}).finally([sent = std::move(sent)] () mutable {
|
||||
sent.set_value();
|
||||
|
||||
Reference in New Issue
Block a user