Skip to content

Commit

Permalink
#349 changed the remove function, initial index creation: append afte…
Browse files Browse the repository at this point in the history
…r each mailbox
  • Loading branch information
jrse committed Nov 20, 2022
1 parent 38e7e7b commit 603dae5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/librmb/rados-storage-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ std::set<std::string> RadosStorageImpl::ceph_index_read() {
index = RadosUtils::ceph_index_to_set(bl.c_str());
return index;
}
int RadosStorageImpl::ceph_index_delete(const std::set<std::string> &oids) {
int RadosStorageImpl::ceph_index_delete() {
return get_recovery_io_ctx().remove(get_namespace());
}

2 changes: 1 addition & 1 deletion src/librmb/rados-storage-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class RadosStorageImpl : public RadosStorage {
int ceph_index_append(const std::set<std::string> &oids) override;
int ceph_index_overwrite(const std::set<std::string> &oids) override;
std::set<std::string> ceph_index_read() override;
int ceph_index_delete(const std::set<std::string> &oids) override;
int ceph_index_delete() override;

private:
int create_connection(const std::string &poolname,const std::string &index_pool);
Expand Down
2 changes: 1 addition & 1 deletion src/librmb/rados-storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ underTest.ceph_index_add("dkfkjdf")
/**
* remove oids from index object
*/
virtual int ceph_index_delete(const std::set<std::string> &oids) = 0;
virtual int ceph_index_delete() = 0;


/*! read the complete mail object into bufferlist
Expand Down
7 changes: 7 additions & 0 deletions src/librmb/tools/rmb/rmb-commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,13 @@ std::set<std::string> RmbCommands::load_objects(){
}
return mail_list;
}
int RmbCommands::remove_ceph_object_index(){
return storage->ceph_index_delete();
}
int RmbCommands::append_ceph_object_index(const std::set<std::string> &mail_oids){
return storage->ceph_index_append(mail_oids);
}

int RmbCommands::load_objects(librmb::RadosStorageMetadataModule *ms, std::list<librmb::RadosMail *> &mail_objects,
std::string &sort_string, bool load_metadata) {
time_t begin = time(NULL);
Expand Down
2 changes: 2 additions & 0 deletions src/librmb/tools/rmb/rmb-commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class RmbCommands {

int overwrite_ceph_object_index(std::set<std::string> &mail_oids);
std::set<std::string> load_objects();
int remove_ceph_object_index();
int append_ceph_object_index(const std::set<std::string> &mail_oids);
private:
std::map<std::string, std::string> *opts;
librmb::RadosStorage *storage;
Expand Down
30 changes: 18 additions & 12 deletions src/storage-rbox/doveadm-rbox-plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,11 @@ static int cmd_rmb_create_ceph_index_run(struct doveadm_mail_cmd_context *_ctx,
delete ms;
return -1;
}
if(rmb_cmds.remove_ceph_object_index() < 0){
i_error(" Error overwriting ceph object index");
delete ms;
return -1;
}

if (user->namespaces != NULL) {
struct mail_namespace *ns = mail_namespace_find_inbox(user->namespaces);
Expand All @@ -824,25 +829,26 @@ static int cmd_rmb_create_ceph_index_run(struct doveadm_mail_cmd_context *_ctx,
}

//append to index.

i_info("found %d mails in namespace",mail_objects.size());
if(rmb_cmds.append_ceph_object_index(mail_objects) < 0){
i_error(" Error overwriting ceph object index");
delete ms;
return -1;
}
mail_objects.clear();
}
}
} // end of for
}else{
mail_objects = rmb_cmds.load_objects();
if(rmb_cmds.overwrite_ceph_object_index(mail_objects) < 0){
i_error(" Error overwriting ceph object index");
delete ms;
return -1;
}
i_info("found %d mails in namespace",mail_objects.size());
}

if(mail_objects.empty()){
i_info("refreshing the index with full object search!!!!");
mail_objects = rmb_cmds.load_objects();
}

i_info("found %d mails in namespace",mail_objects.size());
if(rmb_cmds.overwrite_ceph_object_index(mail_objects) < 0){
i_error(" Error overwriting ceph object index");
delete ms;
return -1;
}
i_info("index created");

delete ms;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/mocks/mock_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class RadosStorageMock : public RadosStorage {
MOCK_METHOD1(ceph_index_append,int(const std::set<std::string> &oids));
MOCK_METHOD1(ceph_index_overwrite,int(const std::set<std::string> &oids));
MOCK_METHOD0(ceph_index_read,std::set<std::string>());
MOCK_METHOD1(ceph_index_delete,int(const std::set<std::string> &oids));
MOCK_METHOD0(ceph_index_delete,int());
};

class RadosStorageMetadataMock : public RadosStorageMetadataModule {
Expand Down

0 comments on commit 603dae5

Please sign in to comment.