Commit 0985e51f authored by Matthieu Dorier's avatar Matthieu Dorier
Browse files

added migrate_target

parent a28d22f6
......@@ -254,7 +254,7 @@ class BakeProviderHandle():
ret = _pybakeclient.remove(self._ph, rid._rid)
return (ret == 0)
def migrate(self, source_rid, dest_addr, dest_provider_id, dest_target, remove_source=True):
def migrate_region(self, source_rid, dest_addr, dest_provider_id, dest_target, remove_source=True):
Migrates a give region from its source to a destination designated by
an address, a provider id, and a target id. This function will also remove
......@@ -269,8 +269,26 @@ class BakeProviderHandle():
The resulting BakeRegionID if successful, None otherwise.
ret = _pybakeclient.migrate(self._ph, source_rid._rid, remove_source,
ret = _pybakeclient.migrate_region(self._ph, source_rid._rid, remove_source,
str(dest_addr), int(dest_provider_id), dest_target._tid)
if(ret == None):
return ret
return BakeRegionID(ret)
def migrate_target(self, source_tid, dest_addr, dest_provider_id, dest_root, remove_source=True):
Migrates a given target from its source to a destination designated by
an address, and a provider id. This function will also remove the original region
if remove_source is set to True.
source_tid (BakeTargetID): source target to move.
dest_addr (str): destination address.
dest_provider_id (int): destination provider id.
dest_root (str): destination root where to migrate the target.
remove_source (bool) whether to remove the source region or not.
True if the target was correctly migrated.
return _pybakeclient.migrate_target(self._ph, source_tid._tid, remove_source,
str(dest_addr), int(dest_provider_id), str(dest_root))
......@@ -209,7 +209,7 @@ static py11::object pybake_read(
return py11::bytes(result);
static py11::object pybake_migrate(
static py11::object pybake_migrate_region(
pybake_provider_handle_t source_ph,
const bake_region_id_t& source_rid,
bool remove_source,
......@@ -219,7 +219,7 @@ static py11::object pybake_migrate(
bake_region_id_t dest_rid;
int ret;
ret = bake_migrate(source_ph, source_rid,
ret = bake_migrate_region(source_ph, source_rid,
remove_source, dest_addr.c_str(), dest_provider_id,
dest_target_id, &dest_rid);
......@@ -227,6 +227,23 @@ static py11::object pybake_migrate(
return py11::cast(dest_rid);
static py11::object pybake_migrate_target(
pybake_provider_handle_t source_ph,
const bake_target_id_t& source_tid,
bool remove_source,
const std::string& dest_addr,
uint16_t dest_provider_id,
const std::string& dest_root) {
int ret;
ret = bake_migrate_target(source_ph, source_tid,
remove_source, dest_addr.c_str(), dest_provider_id,
if(ret != BAKE_SUCCESS) return py11::cast(false);
return py11::cast(true);
static py11::object pybake_read_numpy(
pybake_provider_handle_t ph,
......@@ -282,7 +299,8 @@ PYBIND11_MODULE(_pybakeclient, m)
m.def("read", &pybake_read);
m.def("remove", [](pybake_provider_handle_t pbph, bake_region_id_t rid) {
return bake_remove(pbph, rid);} );
m.def("migrate", &pybake_migrate);
m.def("migrate_region", &pybake_migrate_region);
m.def("migrate_target", &pybake_migrate_target);
m.def("shutdown_service", [](pybake_client_t client, pymargo_addr addr) {
return bake_shutdown_service(client, addr); });
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment