Changeset 1009 for XIOS/dev/dev_olga/src/object_template_impl.hpp
- Timestamp:
- 12/05/16 17:47:54 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/dev_olga/src/object_template_impl.hpp
r987 r1009 168 168 169 169 // Use correct context client to send message 170 CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 171 172 std::map<int, size_t> minimumSizes; 173 174 if (contextClientTmp->isServerLeader()) 170 // CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 171 int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 172 for (int i = 0; i < nbSrvPools; ++i) 175 173 { 176 size_t minimumSize = 0; 177 CAttributeMap& attrMap = *this; 178 CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end(); 179 for (; it != itE; ++it) 174 CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] : context->client; 175 176 std::map<int, size_t> minimumSizes; 177 178 if (contextClientTmp->isServerLeader()) 180 179 { 181 if (!it->second->isEmpty()) 180 size_t minimumSize = 0; 181 CAttributeMap& attrMap = *this; 182 CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end(); 183 for (; it != itE; ++it) 182 184 { 183 size_t size = it->second->getName().size() + sizeof(size_t) + it->second->size(); 184 if (size > minimumSize) 185 minimumSize = size; 185 if (!it->second->isEmpty()) 186 { 187 size_t size = it->second->getName().size() + sizeof(size_t) + it->second->size(); 188 if (size > minimumSize) 189 minimumSize = size; 190 } 191 } 192 193 if (minimumSize) 194 { 195 // Account for extra header info 196 minimumSize += CEventClient::headerSize + getIdServer().size() + sizeof(size_t); 197 198 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 199 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 200 minimumSizes.insert(std::make_pair(*itRank, minimumSize)); 186 201 } 187 202 } 188 189 if (minimumSize)190 {191 // Account for extra header info192 minimumSize += CEventClient::headerSize + getIdServer().size() + sizeof(size_t);193 194 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader();195 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank)196 minimumSizes.insert(std::make_pair(*itRank, minimumSize));197 }198 }199 203 200 204 // if (client->isServerLeader()) … … 224 228 // } 225 229 226 return minimumSizes; 230 return minimumSizes; 231 } 227 232 } 228 233 … … 238 243 } 239 244 245 template<typename T> 246 void CObjectTemplate<T>::sendAllAttributesToServer(const int srvPool) 247 { 248 CAttributeMap& attrMap = *this; 249 CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end(); 250 for (; it != itE; ++it) 251 { 252 if (!(it->second)->isEmpty()) sendAttributToServer(*(it->second), srvPool); 253 } 254 } 255 240 256 template <class T> 241 257 void CObjectTemplate<T>::sendAttributToServer(const string& id) … … 244 260 CAttribute* attr=attrMap[id]; 245 261 sendAttributToServer(*attr); 262 } 263 264 template <class T> 265 void CObjectTemplate<T>::sendAttributToServer(const string& id, const int srvPool) 266 { 267 CAttributeMap & attrMap = *this; 268 CAttribute* attr=attrMap[id]; 269 sendAttributToServer(*attr, srvPool); 246 270 } 247 271 … … 252 276 253 277 // Use correct context client to send message 254 CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 255 256 // if (!context->hasServer) 278 // CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 257 279 if (context->hasClient) 258 280 { 259 // CContextClient* contextClientTmp=context->contextClientTmp; 260 261 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); 262 if (contextClientTmp->isServerLeader()) 263 { 264 CMessage msg; 265 // msg << this->getId(); 266 msg << this->getIdServer(); 267 msg << attr.getName(); 268 msg << attr; 269 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 270 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 271 event.push(*itRank,1,msg); 272 contextClientTmp->sendEvent(event); 273 } 274 else contextClientTmp->sendEvent(event); 281 int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 282 for (int i = 0; i < nbSrvPools; ++i) 283 { 284 CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] : context->client; 285 // CContextClient* contextClientTmp=context->contextClientTmp; 286 287 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); 288 if (contextClientTmp->isServerLeader()) 289 { 290 CMessage msg; 291 // if (context->hasServer) 292 // { 293 // StdString tmp = this->getIdServer() + "_" +boost::lexical_cast<string>(i); 294 // msg<<tmp; 295 // } 296 // else 297 msg<<this->getIdServer(); 298 299 msg << attr.getName(); 300 msg << attr; 301 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 302 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 303 event.push(*itRank,1,msg); 304 contextClientTmp->sendEvent(event); 305 } 306 else contextClientTmp->sendEvent(event); 307 } 275 308 } 276 277 309 // // if (!context->hasServer) 278 310 // if (context->hasClient) … … 298 330 } 299 331 332 template <class T> 333 void CObjectTemplate<T>::sendAttributToServer(CAttribute& attr, const int srvPool) 334 { 335 CContext* context=CContext::getCurrent(); 336 CContextClient* contextClientTmp = context->clientPrimServer[srvPool]; 337 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); 338 if (contextClientTmp->isServerLeader()) 339 { 340 CMessage msg; 341 msg<<this->getIdServer(); 342 msg << attr.getName(); 343 msg << attr; 344 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 345 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 346 event.push(*itRank,1,msg); 347 contextClientTmp->sendEvent(event); 348 } 349 else contextClientTmp->sendEvent(event); 350 } 351 352 300 353 /*! 301 354 This generic funtion only provides instance for sending, for receving, each … … 312 365 { 313 366 // Use correct context client to send message 314 CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 315 CEventClient event(this->getType(),ItemType(itemType)); 316 if (contextClientTmp->isServerLeader()) 317 { 318 CMessage msg; 319 msg << this->getId(); 320 msg << id; 321 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 322 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 323 event.push(*itRank,1,msg); 324 contextClientTmp->sendEvent(event); 325 } 326 else contextClientTmp->sendEvent(event); 367 // CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 368 int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 369 for (int i = 0; i < nbSrvPools; ++i) 370 { 371 CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] : context->client; 372 CEventClient event(this->getType(),ItemType(itemType)); 373 if (contextClientTmp->isServerLeader()) 374 { 375 CMessage msg; 376 msg << this->getId(); 377 msg << id; 378 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 379 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 380 event.push(*itRank,1,msg); 381 contextClientTmp->sendEvent(event); 382 } 383 else contextClientTmp->sendEvent(event); 384 } 327 385 } 386 } 387 388 template<class T> 389 void CObjectTemplate<T>::sendAddItem(const StdString& id, int itemType, const int srvPool) 390 { 391 CContext* context = CContext::getCurrent(); 392 typedef typename T::EEventId ItemType; 393 CContextClient* contextClientTmp = context->clientPrimServer[srvPool]; 394 CEventClient event(this->getType(),ItemType(itemType)); 395 if (contextClientTmp->isServerLeader()) 396 { 397 CMessage msg; 398 msg << this->getId(); 399 msg << id; 400 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 401 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 402 event.push(*itRank,1,msg); 403 contextClientTmp->sendEvent(event); 404 } 405 else contextClientTmp->sendEvent(event); 328 406 } 329 407
Note: See TracChangeset
for help on using the changeset viewer.