Commit 19e94887 authored by Nafi3's avatar Nafi3 Committed by Marc Vef
Browse files

Separate metadir and datadir if user sets argument

This commit gives new options regarding separation of metadir and rootdir location. If only rootdir destination is given both metadata and data is stored at the same path
parent 2df9e3ed
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ private:
    // paths
    std::string rootdir_;
    std::string mountdir_;
    std::string metadir_;
    std::string inode_path_;
    std::string dentry_path_;
    std::string chunk_path_;
@@ -108,7 +109,11 @@ public:

    const std::string& mountdir() const;

    void mountdir(const std::string& mountdir);
    void mountdir(const std::string& mountdir_);

    const std::string& metadir() const;

    void metadir(const std::string& metadir_);

    const std::string& inode_path() const;

+15 −11
Original line number Diff line number Diff line
@@ -32,12 +32,13 @@ def check_dependencies():
    exit(1)


def init_system(daemon_path, rootdir, mountdir, nodelist, cleanroot, numactl):
def init_system(daemon_path, rootdir, metadir, mountdir, nodelist, cleanroot, numactl):
    """Initializes ADAFS on specified nodes.

    Args:
        daemon_path (str): Path to daemon executable
        rootdir (str): Path to root directory for fs data
        metadir (str): Path to metadata directory where metadata is stored
        mountdir (str): Path to mount directory where adafs is used in
        nodelist (str): Comma-separated list of nodes where adafs is launched on
    """
@@ -47,6 +48,7 @@ def init_system(daemon_path, rootdir, mountdir, nodelist, cleanroot, numactl):
    # get absolute paths
    daemon_path = os.path.realpath(os.path.expanduser(daemon_path))
    mountdir = os.path.realpath(os.path.expanduser(mountdir))
    metadir = os.path.realpath(os.path.expanduser(metadir))
    rootdir = os.path.realpath(os.path.expanduser(rootdir))
    pssh_nodelist = ''
    nodefile = False
@@ -62,23 +64,23 @@ def init_system(daemon_path, rootdir, mountdir, nodelist, cleanroot, numactl):
    else:
        pssh = '%s -O StrictHostKeyChecking=no -i -H "%s"' % (PSSH_PATH, nodelist.replace(',', ' '))

    # clean root dir if needed
    # clean root and metadata dir if needed
    if cleanroot:
        cmd_rm_str = '%s "rm -rf %s/* && truncate -s 0 /tmp/adafs_daemon.log /tmp/adafs_preload.log"' % (pssh, rootdir)
        cmd_rm_str = '%s "rm -rf %s/* %s/* && truncate -s 0 /tmp/adafs_daemon.log /tmp/adafs_preload.log"' % (pssh, rootdir, metadir)
        if PRETEND:
            print 'Pretending: %s' % cmd_rm_str
        else:
            print 'Running: %s' % cmd_rm_str
            pssh_ret = util.exec_shell(cmd_rm_str, True)
            err = False
            for line in pssh_ret:
            for line in pssh_ret:  pi
                if 'FAILURE' in line.strip()[:30]:
                    err = True
                    print '------------------------- ERROR pssh -- Host "%s" -------------------------' % \
                          (line[line.find('FAILURE'):].strip().split(' ')[1])
                    print line
            if not err:
                print 'pssh daemon launch successfully executed. Root dir is cleaned.\n'
                print 'pssh daemon launch successfully executed. Root and Metadata dir are cleaned.\n'
            else:
                print '[ERR] with pssh. Aborting!'
                exit(1)
@@ -87,18 +89,18 @@ def init_system(daemon_path, rootdir, mountdir, nodelist, cleanroot, numactl):
    if nodefile:
        if len(numactl) == 0:
            cmd_str = '%s "nohup %s -r %s -m %s --hostfile %s > /tmp/adafs_daemon.log 2>&1 &"' \
                      % (pssh, daemon_path, rootdir, mountdir, nodelist)
                      % (pssh, daemon_path, rootdir, metadir, mountdir, nodelist)
        else:
            cmd_str = '%s "nohup numactl %s %s -r %s -m %s --hostfile %s > /tmp/adafs_daemon.log 2>&1 &"' \
                      % (pssh, numactl, daemon_path, rootdir, mountdir, nodelist)
                      % (pssh, numactl, daemon_path, rootdir, metadir, mountdir, nodelist)

    else:
        if len(numactl) == 0:
            cmd_str = '%s "nohup %s -r %s -m %s --hosts %s > /tmp/adafs_daemon.log 2>&1 &"' \
                      % (pssh, daemon_path, rootdir, mountdir, nodelist)
                      % (pssh, daemon_path, rootdir, metadir, mountdir, nodelist)
        else:
            cmd_str = '%s "nohup numactl %s %s -r %s -m %s --hosts %s > /tmp/adafs_daemon.log 2>&1 &"' \
                      % (pssh, numactl, daemon_path, rootdir, mountdir, nodelist)
                      % (pssh, numactl, daemon_path, rootdir, metadir, mountdir, nodelist)

    if PRETEND:
        print 'Pretending: %s' % cmd_str
@@ -164,6 +166,8 @@ if __name__ == "__main__":
                        help='path to the daemon executable')
    parser.add_argument('rootdir', type=str,
                        help='path to the root directory where all data will be stored')
    parser.add_argument('metadir', type=str,
                        help='Path to metadata directory where metadata is stored')
    parser.add_argument('mountdir', type=str,
                        help='path to the mount directory of the file system')
    parser.add_argument('nodelist', type=str,
@@ -178,7 +182,7 @@ or a path to a nodefile (one node per line)''')
    parser.add_argument('-J', '--jobid', metavar='<JOBID>', type=str, default='',
                        help='Jobid for cluster batch system. Used for a unique hostfile used for pssh.')
    parser.add_argument('-c', '--cleanroot', action='store_true',
                        help='Removes contents of root directory before starting ADA-FS Daemon. Be careful!')
                        help='Removes contents of root and metadata directory before starting ADA-FS Daemon. Be careful!')
    parser.add_argument('-n', '--numactl', metavar='<numactl_args>', type=str, default='',
                        help='If adafs daemon should be pinned to certain cores, set numactl arguments here.')
    args = parser.parse_args()
@@ -192,6 +196,6 @@ or a path to a nodefile (one node per line)''')
        PSSH_HOSTFILE_PATH = '/tmp/hostfile_pssh_%s' % args.jobid
    PSSH_PATH = args.pssh
    WAITTIME = 5
    init_system(args.daemonpath, args.rootdir, args.mountdir, args.nodelist, args.cleanroot, args.numactl)
    init_system(args.daemonpath, args.rootdir, args.metadir, args.mountdir, args.nodelist, args.cleanroot, args.numactl)

    print '\nNothing left to do; exiting. :)'
+10 −3
Original line number Diff line number Diff line
@@ -310,6 +310,7 @@ int main(int argc, const char* argv[]) {
            ("help,h", "Help message")
            ("mountdir,m", po::value<string>()->required(), "User Fuse mountdir.")
            ("rootdir,r", po::value<string>()->required(), "ADA-FS data directory")
            ("metadir,d", po::value<string>(), "ADA-FS meta-data directory, if not provided rootdir will be automatically selected ")
            ("hostfile", po::value<string>(), "Path to the hosts_file for all fs participants")
            ("hosts,h", po::value<string>(), "Comma separated list of hosts_ for all fs participants");
    po::variables_map vm;
@@ -332,6 +333,12 @@ int main(int argc, const char* argv[]) {
    if (vm.count("rootdir")) {
        ADAFS_DATA->rootdir(vm["rootdir"].as<string>());
    }
    if (vm.count("metadir")) {
        ADAFS_DATA->metadir(vm["metadir"].as<string>());
    } else if (vm.count("rootdir")) {
        ADAFS_DATA->metadir(vm["rootdir"].as<string>());
    }

    // parse host parameters
    vector<string> hosts{};
    if (vm.count("hostfile")) {
@@ -400,8 +407,8 @@ int main(int argc, const char* argv[]) {


    //set all paths
    ADAFS_DATA->inode_path(ADAFS_DATA->rootdir() + "/meta/inodes"s); // XXX prob not needed anymore
    ADAFS_DATA->dentry_path(ADAFS_DATA->rootdir() + "/meta/dentries"s); // XXX prob not needed anymore
    ADAFS_DATA->inode_path(ADAFS_DATA->metadir() + "/meta/inodes"s); // XXX prob not needed anymore
    ADAFS_DATA->dentry_path(ADAFS_DATA->metadir() + "/meta/dentries"s); // XXX prob not needed anymore
    ADAFS_DATA->chunk_path(ADAFS_DATA->rootdir() + "/data/chunks"s);
    ADAFS_DATA->mgmt_path(ADAFS_DATA->rootdir() + "/mgmt"s);

+8 −0
Original line number Diff line number Diff line
@@ -62,6 +62,14 @@ void FsData::mountdir(const std::string& mountdir) {
    FsData::mountdir_ = mountdir;
}

const std::string& FsData::metadir() const {
    return metadir_;
}

void FsData::metadir(const std::string& metadir) {
    FsData::metadir_ = metadir;
}

const std::string& FsData::inode_path() const {
    return inode_path_;
}
+2 −2
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ using namespace std;

bool init_rocksdb() {
    rocksdb::DB* db;
    ADAFS_DATA->rdb_path(ADAFS_DATA->rootdir() + "/meta/rocksdb"s);
    ADAFS_DATA->rdb_path(ADAFS_DATA->metadir() + "/meta/rocksdb"s);
    rocksdb::Options options;
    // Optimize RocksDB. This is the easiest way to get RocksDB to perform well
    options.IncreaseParallelism();