Commit ba7bf254 authored by David Auer's avatar David Auer
Browse files

Automatic relocation on startup

parent aed0771f
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -24,12 +24,23 @@ namespace gkfs::config {

constexpr auto hostfile_path = "./gkfs_hosts.txt";
constexpr auto forwarding_file_path = "./gkfs_forwarding.map";

/*
 * Enables adding/removing daemons to the running file system and
 * switches distribution function to Random Slicing.
 * switches distribution algorithm to Random Slicing.
 */
constexpr auto dynamic_placement = true;

/*
 * Only effective with dynamic_placement = true:
 * Trigger reconfiguration and relocation after regular daemon startup. Useful
 * for CI runs. Each newly started daemon automatically adds itself to the
 * cluster.
 * TODO: Also relocate during extra graceful shutdown. (i.e. remove myself from
 * cluster)
 */
constexpr auto auto_relocate = true;

namespace io {
/*
 * Zero buffer before read. This is relevant if sparse files are used.
+4 −0
Original line number Diff line number Diff line
@@ -631,6 +631,10 @@ main(int argc, const char* argv[]) {
    signal(SIGTERM, shutdown_handler);
    signal(SIGKILL, shutdown_handler);

    if(gkfs::config::dynamic_placement && gkfs::config::auto_relocate) {
        auto trigger_hosts = gkfs::relocation::calculate_random_slicing();
        gkfs::relocation::do_relocation(trigger_hosts);
    }

    unique_lock<mutex> lk(mtx);
    // Wait for shutdown signal to initiate shutdown protocols