Exemple #1
0
int ZHTClient::initialize(string configFilePath, string memberListFilePath,
                          bool tcp) {

    this->TCP = tcp;
    //read cfg file
    this->memberList = getMembership(memberListFilePath);

    FILE *fp;
    char line[100], *key, *svalue;
    int ivalue;

    fp = fopen(configFilePath.c_str(), "r");
    if (fp == NULL) {
        cout << "Error opening the config file." << endl;
        return -1;
    }
    while (fgets(line, 100, fp) != NULL) {
        key = strtok(line, "=");
        svalue = strtok(NULL, "=");
        ivalue = atoi(svalue);

        if ((strcmp(key, "REPLICATION_TYPE")) == 0) {
            this->REPLICATION_TYPE = ivalue;
            //cout<<"REPLICATION_TYPE = "<< REPLICATION_TYPE <<endl;
        } //other config options follow this way(if).

        else if ((strcmp(key, "NUM_REPLICAS")) == 0) {
            this->NUM_REPLICAS = ivalue + 1; //note: +1 is must
            //cout<<"NUM_REPLICAS = "<< NUM_REPLICAS <<endl;
        }

        else if ((strcmp(key, "WORK_STEAL")) == 0) {
            this->WORK_STEAL = ivalue;
            //cout<<"WORK_STEAL = "<< WORK_STEAL <<endl;
        } else {
            cout << "Config file is not correct." << endl;
            return -2;
        }

    }

    return 0;

}
 bool QueueMemberEvent::isDynamic() const {
     return (boost::iequals(getMembership(), MEMBERSHIP_DYNAMIC));
 }
 bool QueueMemberEvent::isStatic() const {
     return (boost::iequals(getMembership(), MEMBERSHIP_STATIC));
 }