IClusterSPtr ServersManager::createCluster(IClusterSettingsBaseSPtr settings) { DCHECK(settings); IClusterSPtr cl; connectionTypes conT = settings->connectionType(); if(conT == REDIS){ IConnectionSettingsBaseSPtr root = settings->root(); if(!root){ return IClusterSPtr(); } cl.reset(new RedisCluster(settings->connectionName())); IClusterSettingsBase::cluster_connection_type nodes = settings->nodes(); for(int i = 0; i < nodes.size(); ++i){ IConnectionSettingsBaseSPtr nd = nodes[i]; if(nd){ IServerSPtr serv = createServer(nd); cl->addServer(serv); } } IDriverSPtr drv = cl->root()->driver(); DCHECK(drv->settings() == root); } else{ NOTREACHED(); } return cl; }
IClusterSPtr ServersManager::createCluster(IClusterSettingsBaseSPtr settings) { if (!settings) { NOTREACHED(); return IClusterSPtr(); } connectionTypes conT = settings->type(); #ifdef BUILD_WITH_REDIS if (conT == REDIS) { IClusterSPtr cl(new redis::RedisCluster(settings->name())); IClusterSettingsBase::cluster_connection_type nodes = settings->nodes(); for (size_t i = 0; i < nodes.size(); ++i) { IConnectionSettingsBaseSPtr nd = nodes[i]; IServerSPtr serv = createServer(nd); cl->addServer(serv); } return cl; } #endif NOTREACHED(); return IClusterSPtr(); }