Skip to content

Commit

Permalink
#38 max file size
Browse files Browse the repository at this point in the history
- read rados configuration OSD_MAX_WRITE_SIZE 
- set rados max_write_size value to RadosStorage
  • Loading branch information
jrse committed Jun 22, 2017
1 parent f84a9bd commit e0b464d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
14 changes: 13 additions & 1 deletion src/librmb/rados-cluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ using namespace librmb; // NOLINT

librados::Rados RadosCluster::cluster;
int RadosCluster::cluster_ref_count = 0;
const std::string RadosCluster::CFG_OSD_MAX_WRITE_SIZE = "osd_max_write_size";

RadosCluster::RadosCluster() {}

Expand Down Expand Up @@ -108,6 +109,8 @@ int RadosCluster::storage_create(const string &pool, const string &username, Rad
break;
}
}


if (pool_found != true) {
err = cluster.pool_create(pool.c_str());
if (err < 0) {
Expand All @@ -122,6 +125,15 @@ int RadosCluster::storage_create(const string &pool, const string &username, Rad
return err;
}

*storage = new RadosStorage(&io_ctx, username);
std::string max_write_size;
err = cluster.conf_get(RadosCluster::CFG_OSD_MAX_WRITE_SIZE.c_str(), max_write_size);
if (err < 0) {
// *error_r = t_strdup_printf("Cannot open RADOS pool %s: %s", pool.c_str(), strerror(-err));
return err;
}

//"found: max write size " << max_write_size.c_str() << "\n";

*storage = new RadosStorage(&io_ctx, username, std::stoi(max_write_size));
return 0;
}
3 changes: 3 additions & 0 deletions src/librmb/rados-cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ class RadosCluster {
private:
static librados::Rados cluster;
static int cluster_ref_count;

public:
static const std::string CFG_OSD_MAX_WRITE_SIZE;
};

} // namespace librmb
Expand Down
4 changes: 2 additions & 2 deletions src/librmb/rados-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ using std::string;

#define DICT_USERNAME_SEPARATOR '/'

RadosStorage::RadosStorage(librados::IoCtx *ctx, const string &username) : io_ctx(*ctx), username(username) {
}
RadosStorage::RadosStorage(librados::IoCtx *ctx, const string &username, const int max_write_size)
: io_ctx(*ctx), username(username), max_write_size(max_write_size) {}

RadosStorage::~RadosStorage() { get_io_ctx().close(); }
5 changes: 4 additions & 1 deletion src/librmb/rados-storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@ namespace librmb {

class RadosStorage {
public:
RadosStorage(librados::IoCtx* ctx, const std::string& username);
RadosStorage(librados::IoCtx* ctx, const std::string& username, const int max_write_size);
virtual ~RadosStorage();

librados::IoCtx& get_io_ctx() { return io_ctx; }

const std::string& get_username() const { return username; }

const int get_max_write_size() const { return max_write_size; }

private:
librados::IoCtx io_ctx;
std::string username;
int max_write_size;
};

} // namespace librmb
Expand Down

0 comments on commit e0b464d

Please sign in to comment.