Exemple #1
0
/* helper for lmt_db_insert_mdt_v1 () */
static void
_insert_mds (char *mdsname, float pct_cpu, float pct_mem, char *s)
{
    ListIterator itr;
    lmt_db_t db;
    char *op, *mdtname = NULL;
    uint64_t inodes_free, inodes_total;
    uint64_t kbytes_free, kbytes_total;
    List mdops = NULL;

    if (lmt_mdt_decode_v1_mdtinfo (s, &mdtname, &inodes_free, &inodes_total,
                                   &kbytes_free, &kbytes_total, &mdops) < 0)
        goto done;
    if (!(db = _svc_to_db (mdtname)))
        goto done;
    if (lmt_db_insert_mds_data (db, mdsname, mdtname, pct_cpu,
                                kbytes_free, kbytes_total - kbytes_free,
                                inodes_free, inodes_total - inodes_free) < 0) {
        _trigger_db_reconnect ();
        goto done;
    }
    itr = list_iterator_create (mdops);
    while ((op = list_next (itr)))
        _insert_mds_ops (db, mdtname, op);
    list_iterator_destroy (itr);        
done:
    if (mdtname)
        free (mdtname);    
    if (mdops)
        list_destroy (mdops);
}
Exemple #2
0
int
_parse_mdt_v1 (const char *s)
{
    int retval = -1;
    char *mdsname = NULL;
    char *mdtname = NULL;
    float pct_cpu, pct_mem;
    uint64_t inodes_free, inodes_total;
    uint64_t kbytes_free, kbytes_total;
    List mdtinfo = NULL;
    List mdops = NULL;
    ListIterator itr = NULL;
    char *mdi;

    if (lmt_mdt_decode_v1_v2 (s, &mdsname, &pct_cpu, &pct_mem, &mdtinfo, 1) < 0)
        goto done;
    if (!(itr = list_iterator_create (mdtinfo)))
        goto done;
    while ((mdi = list_next (itr))) {
        if (lmt_mdt_decode_v1_mdtinfo (mdi, &mdtname, &inodes_free,
                     &inodes_total, &kbytes_free, &kbytes_total, &mdops) < 0)
            goto done;
        free (mdtname);
        if (_parse_mdt_v1_mdops (mdops) < 0) {
            list_destroy (mdops); 
            goto done;
        }
        list_destroy (mdops); 
    }
    retval = 0;
done:
    if (mdsname)
        free (mdsname);
    if (itr)
        list_iterator_destroy (itr);
    if (mdtinfo)
        list_destroy (mdtinfo);
    return retval;
}