Esempio n. 1
0
 virtual void handle() {
     HOST* h = new HOST;
     h->t = t + ran_exp(HOST_LIFE_MEAN);
     hosts.insert(h);
     sim.insert(h);
     t += ran_exp(86400./HOSTS_PER_DAY);
     sim.insert(this);
 }
Esempio n. 2
0
int main() {
    HOST_ARRIVAL *h = new HOST_ARRIVAL;
    h->t = 0;
    sim.insert(h);
    REPORT_STATS* r = new REPORT_STATS;
    r->t = 0;
    sim.insert(r);

    sim.simulate(200*86400);
}
Esempio n. 3
0
int main(int argc, char** argv) {
    POLICY policy;

    // default policy
    //
    policy.replication = 2;
    policy.coding_levels = 2;
    policy.codings[0].n = 10;
    policy.codings[0].k = 6;
    policy.codings[0].m = 16;
    policy.codings[0].n_upload = 12;
    policy.codings[1].n = 10;
    policy.codings[1].k = 6;
    policy.codings[1].m = 16;
    policy.codings[1].n_upload = 12;

    for (int i=1; i<argc; i++) {
        if (!strcmp(argv[i], "--policy")) {
            int retval = policy.parse(argv[++i]);
            if (retval) exit(1);
        } else if (!strcmp(argv[i], "--host_life_mean")) {
            params.host_life_mean = atof(argv[++i]);
        } else if (!strcmp(argv[i], "--connect_interval")) {
            params.connect_interval = atof(argv[++i]);
        } else if (!strcmp(argv[i], "--mean_xfer_rate")) {
            params.mean_xfer_rate = atof(argv[++i]);
        } else if (!strcmp(argv[i], "--file_size")) {
            params.file_size = atof(argv[++i]);
        } else {
            fprintf(stderr, "bad arg %s\n", argv[i]);
            exit(1);
        }
    }
#if 0
    HOST_ARRIVAL *h = new HOST_ARRIVAL;
    h->t = 0;
    sim.insert(h);
#endif

#if 0
    for (int i=0; i<500; i++) {
        sim.insert(new SIM_HOST);
    }
#endif
    SIM_FILE* dfile = new SIM_FILE(params.file_size);
    dfile->policy = policy;
    sim.insert(dfile);

    sim.simulate(params.sim_duration);

    printf("%s: simulation finished\n", now_str());
    dfile->print_stats(sim.now);
}
Esempio n. 4
0
// if there aren't enough replicas of this chunk,
// pick new hosts and start downloads
//
void CHUNK::assign() {
    if (!present_on_server) return;
    while ((int)(hosts.size()) < p.replication) {
#if 0
        if (parent->dfile->unused_hosts.size() == 0) {
            die("no more hosts!\n");
        }
        set<HOST*>::iterator i = parent->dfile->unused_hosts.begin();
        HOST* h = *i;
        parent->dfile->unused_hosts.erase(i);
#else
        HOST* h = new HOST;
        sim.insert(h);
#endif
        CHUNK_ON_HOST *c = new CHUNK_ON_HOST();
        sprintf(c->name, "chunk %s on host %d", name, h->id);
#ifdef EVENT_DEBUG
        printf("%s: assigning chunk %s to host %d\n", now_str(), name, h->id);
#endif
        c->host = h;
        c->chunk = this;
        h->chunks.insert(c);
        hosts.insert(c);
        c->start_download();
    }
}
Esempio n. 5
0
// if there aren't enough replicas of this chunk,
// pick new hosts and start downloads
//
int CHUNK::assign() {
    if (!present_on_server) return 0;
    VDA_FILE_AUX* fp = parent->dfile;
    while ((int)(hosts.size()) < fp->policy.replication) {
#if 0
        if (parent->dfile->unused_hosts.size() == 0) {
            die("no more hosts!\n");
        }
        set<SIM_HOST*>::iterator i = fp->unused_hosts.begin();
        SIM_HOST* h = *i;
        fp->unused_hosts.erase(i);
#else
        SIM_HOST* h = new SIM_HOST;
        sim.insert(h);
#endif
        CHUNK_ON_HOST *c = new CHUNK_ON_HOST();
        sprintf(c->physical_file_name, "chunk %s on host %d", name, h->id);
#ifdef EVENT_DEBUG
        printf("%s: assigning chunk %s to host %d\n", now_str(), name, h->id);
#endif
        c->host = h;
        c->chunk = this;
        h->chunks.insert(c);
        hosts.insert(c);
        c->start_download();
    }
    return 0;
}
Esempio n. 6
0
void CHUNK_ON_HOST::start_download() {
    transfer_in_progress = true;
    transfer_wait = true;
    t = sim.now + drand()*p.connect_interval;
#ifdef EVENT_DEBUG
    printf("%s: waiting to start download of %s\n", now_str(), name);
#endif
    sim.insert(this);
}
Esempio n. 7
0
int main() {
#if 0
    HOST_ARRIVAL *h = new HOST_ARRIVAL;
    h->t = 0;
    sim.insert(h);
#endif

#if 0
    for (int i=0; i<500; i++) {
        sim.insert(new HOST);
    }
#endif
    DFILE* dfile = new DFILE(1e2);
    sim.insert(dfile);

    sim.simulate(200*86400);

    printf("%s: simulation finished\n", now_str());
    dfile->print_stats();
}
Esempio n. 8
0
// transfer or transfer wait has finished
//
void CHUNK_ON_HOST::handle() {
    if (transfer_wait) {
        transfer_wait = false;
        if (present_on_host) {
#ifdef EVENT_DEBUG
            printf("%s: starting upload of %s\n", now_str(), physical_file_name);
#endif
            chunk->parent->dfile->upload_rate.sample_inc(
                host->transfer_rate,
                chunk->parent->dfile->collecting_stats(),
                sim.now
            );
        } else {
#ifdef EVENT_DEBUG
            printf("%s: starting download of %s\n", now_str(), physical_file_name);
#endif
            chunk->parent->dfile->download_rate.sample_inc(
                host->transfer_rate,
                chunk->parent->dfile->collecting_stats(),
                sim.now
            );
        }
        t = sim.now + chunk->size/host->transfer_rate;
        sim.insert(this);
        return;
    }
    transfer_in_progress = false;
    if (present_on_host) {
        // it was an upload
#ifdef EVENT_DEBUG
        printf("%s: upload of %s completed\n", now_str(), physical_file_name);
#endif
        chunk->parent->dfile->upload_rate.sample_inc(
            -host->transfer_rate,
            chunk->parent->dfile->collecting_stats(),
            sim.now
        );
        chunk->upload_complete();
    } else {
        present_on_host = true;
#ifdef EVENT_DEBUG
        printf("%s: download of %s completed\n", now_str(), physical_file_name);
#endif
        chunk->parent->dfile->download_rate.sample_inc(
            -host->transfer_rate,
            chunk->parent->dfile->collecting_stats(),
            sim.now
        );
        chunk->download_complete();
    }
}
Esempio n. 9
0
    // the first event is the creation of a file;
    // the 2nd is its retrieval
    //
    virtual void handle() {
        if (meta_chunk) {
            printf("%s: Retrieving file\n", now_str());
            meta_chunk->data_needed = true;
        } else {
            meta_chunk = new META_CHUNK(this, NULL, size, 0, id);
#ifdef EVENT_DEBUG
            printf("created file %d: size %f GB encoded size %f GB\n",
                id, size/1e9, disk_usage.value/1e9
            );
            t = sim.now + 500.*86400;
            sim.insert(this);
#endif
        }
        meta_chunk->recovery_plan();
        meta_chunk->recovery_action(sim.now);
        if (meta_chunk->data_now_present) {
            printf("File is present on server\n");
        }
    }
Esempio n. 10
0
 virtual void handle() {
     sim.insert(new HOST);
     t += ran_exp(86400./HOSTS_PER_DAY);
     sim.insert(this);
 }
Esempio n. 11
0
 virtual void handle() {
     printf("%f: %d hosts\n", t, hosts.size());
     t += 86400;
     sim.insert(this);
 }