Revision b38874a0

View differences:

include/LogDB.h
302 302
            time_t timestamp);
303 303
};
304 304

  
305
// -----------------------------------------------------------------------------
306
// This is a LogDB decoration, it replicates the DB write commands on slaves
307
// It should be passed as DB for federated pools.
308
// -----------------------------------------------------------------------------
309
class FedLogDB: public SqlDB
310
{
311
public:
312
    FedLogDB(LogDB *db):_logdb(db){};
313

  
314
    virtual ~FedLogDB(){};
315

  
316
    int exec_wr(ostringstream& cmd);
317

  
318
    int exec_local_wr(ostringstream& cmd)
319
    {
320
        return _logdb->exec_local_wr(cmd);
321
    }
322

  
323
    int exec_rd(ostringstream& cmd, Callbackable* obj)
324
    {
325
        return _logdb->exec_rd(cmd, obj);
326
    }
327

  
328
    char * escape_str(const string& str)
329
    {
330
        return _logdb->escape_str(str);
331
    }
332

  
333
    void free_str(char * str)
334
    {
335
        _logdb->free_str(str);
336
    }
337

  
338
    bool multiple_values_support()
339
    {
340
        return _logdb->multiple_values_support();
341
    }
342

  
343
protected:
344
    int exec(std::ostringstream& cmd, Callbackable* obj, bool quiet)
345
    {
346
        return -1;
347
    }
348

  
349
private:
350

  
351
    LogDB * _logdb;
352
}
353

  
305 354
#endif /*LOG_DB_H_*/
306 355

  
include/ZonePool.h
128 128
    };
129 129

  
130 130
    /**
131
     *  Get the servers of a zone
132
     *    @param zone_id of the zone
133
     *    @param _serv list of servers and associated xml-rpc endpoints
134
     *    @return the number of servers in the zone
135
     */
136
    unsigned int get_zone_servers(int zone_id,
137
            std::map<unsigned int, std::string>& _serv);
138

  
139
    /**
140
     *  Return the list of zones defined
141
     *    @param zone_ids of the zones
142
     *    @return 0 on success
143
     */
144
    int list_zones(vector<int>& zone_ids)
145
    {
146
        return list( zone_ids, Zone::table);
147
    }
148

  
149
    /**
131 150
     * ID for the special local zone in stand-alone mode
132 151
     */
133 152
    static const int STANDALONE_ZONE_ID;
src/raft/RaftManager.cc
101 101

  
102 102
    // -------------------------------------------------------------------------
103 103
    // Initialize Raft timers
104
    //   TODO: randomize election timeout
105 104
    // -------------------------------------------------------------------------
106 105
    purge_period_ms   = log_purge * 1000;
107 106
    xmlrpc_timeout_ms = xmlrpc;
......
173 172

  
174 173
static unsigned int get_zone_servers(std::map<unsigned int, std::string>& _serv)
175 174
{
176
    unsigned int  _num_servers;
177

  
178 175
    Nebula& nd       = Nebula::instance();
179 176
    ZonePool * zpool = nd.get_zonepool();
180 177

  
181 178
    int zone_id = nd.get_zone_id();
182 179

  
183
    ZoneServers::zone_iterator zit;
184

  
185
    Zone * zone = zpool->get(zone_id, true);
186

  
187
    if ( zone == 0 )
188
    {
189
        _serv.clear();
190
        return 0;
191
    }
192

  
193
    ZoneServers * followers = zone->get_servers();
194

  
195
    for (zit = followers->begin(); zit != followers->end(); ++zit)
196
    {
197
        unsigned int id  = (*zit)->get_id();
198
        std::string  edp = (*zit)->vector_value("ENDPOINT");
199

  
200
        _serv.insert(make_pair(id, edp));
201
    }
202

  
203
    _num_servers = zone->servers_size();
204

  
205
    zone->unlock();
206

  
207
    return _num_servers;
180
    return zpool->get_zone_servers(zone_id, _serv);
208 181
}
209 182

  
210 183
int RaftManager::get_leader_endpoint(std::string& endpoint)
src/rm/RequestManagerZone.cc
295 295

  
296 296
        NebulaLog::log("ReM", Log::INFO, oss);
297 297

  
298
        raftm->follower(leader_term);
299

  
298
        raftm->follower(candidate_term);
300 299
    }
301 300

  
302 301
    if ((log_term > candidate_log_term) || ((log_term == candidate_log_term) &&
src/sql/LogDB.cc
427 427
    return db->exec_wr(oss);
428 428
}
429 429

  
430
/* -------------------------------------------------------------------------- */
431
/* -------------------------------------------------------------------------- */
432

  
433
int FedLogDB::exec_wr(ostringstream& cmd)
434
{
435
    //FedReplicaManager * fedrm = Nebula::instance().get_fedrm();
436

  
437
    int rc = _logdb->exec_wr(cmd);
438

  
439
    if ( rc != 0 )
440
    {
441
        return rc;
442
    }
443

  
444
    //Replicate on slaves
445
    // fedrm->replicate(cmd);
446

  
447
    return rc;
448
}
449

  
src/zone/ZonePool.cc
202 202
/* -------------------------------------------------------------------------- */
203 203
/* -------------------------------------------------------------------------- */
204 204

  
205
unsigned int ZonePool::get_zone_servers(int zone_id,
206
        std::map<unsigned int, std::string>& _serv)
207
{
208
    unsigned int  _num_servers;
209

  
210
    ZoneServers::zone_iterator zit;
211

  
212
    Zone * zone = get(zone_id, true);
213

  
214
    if ( zone == 0 )
215
    {
216
        _serv.clear();
217
        return 0;
218
    }
219

  
220
    ZoneServers * followers = zone->get_servers();
221

  
222
    for (zit = followers->begin(); zit != followers->end(); ++zit)
223
    {
224
        unsigned int id  = (*zit)->get_id();
225
        std::string  edp = (*zit)->vector_value("ENDPOINT");
226

  
227
        _serv.insert(make_pair(id, edp));
228
    }
229

  
230
    _num_servers = zone->servers_size();
231

  
232
    zone->unlock();
233

  
234
    return _num_servers;
235
}
236

  

Also available in: Unified diff