| 453 | } |
| 454 | |
| 455 | Reference<LocalitySet> createTestLocalityMap(std::vector<repTestType>& indexes, |
| 456 | int dcTotal, |
| 457 | int szTotal, |
| 458 | int rackTotal, |
| 459 | int slotTotal, |
| 460 | int independentItems, |
| 461 | int independentTotal) { |
| 462 | Reference<LocalitySet> buildServer(new LocalityMap<repTestType>()); |
| 463 | LocalityMap<repTestType>* serverMap = (LocalityMap<repTestType>*)buildServer.getPtr(); |
| 464 | int serverValue; |
| 465 | std::string dcText, szText, rackText, slotText, independentName, independentText; |
| 466 | |
| 467 | // Determine the total size |
| 468 | serverValue = dcTotal * ((szTotal * rackTotal) + (szTotal + 2) * (rackTotal + 2)) * slotTotal; |
| 469 | |
| 470 | if (g_replicationdebug > 0) { |
| 471 | printf("DC:%2d SZ:%2d AZ:%2d Rack:%2d Slot:%2d Extra:%2d Xitems:%2d Size:%4d\n", |
| 472 | dcTotal, |
| 473 | szTotal, |
| 474 | szTotal + 2, |
| 475 | rackTotal, |
| 476 | slotTotal, |
| 477 | independentItems, |
| 478 | independentTotal, |
| 479 | serverValue); |
| 480 | } |
| 481 | indexes.reserve(serverValue); |
| 482 | |
| 483 | for (int dcLoop = 0; dcLoop < dcTotal; dcLoop++) { |
| 484 | serverValue = dcLoop; |
| 485 | dcText = format("dc%d", dcLoop); |
| 486 | for (int szLoop = 0; szLoop < szTotal; szLoop++) { |
| 487 | serverValue = dcLoop + szLoop * 10; |
| 488 | szText = format(".s%d", szLoop); |
| 489 | for (int rackLoop = 0; rackLoop < rackTotal; rackLoop++) { |
| 490 | serverValue = dcLoop + szLoop * 10 + rackLoop * 100; |
| 491 | rackText = format(".%d", rackLoop); |
| 492 | for (int slotLoop = 0; slotLoop < slotTotal; slotLoop++) { |
| 493 | serverValue = dcLoop + szLoop * 10 + rackLoop * 100 + slotLoop * 1000; |
| 494 | slotText = format(".%d", slotLoop); |
| 495 | LocalityData data; |
| 496 | data.set(LiteralStringRef("dc"), StringRef(dcText)); |
| 497 | data.set(LiteralStringRef("sz"), StringRef(dcText + szText)); |
| 498 | data.set(LiteralStringRef("rack"), StringRef(dcText + szText + rackText)); |
| 499 | data.set(LiteralStringRef("zoneid"), StringRef(dcText + szText + rackText + slotText)); |
| 500 | for (int independentLoop = 0; independentLoop < independentItems; independentLoop++) { |
| 501 | independentName = format("indiv%02d", independentLoop + 1); |
| 502 | for (int totalLoop = 0; totalLoop < independentTotal; totalLoop++) { |
| 503 | independentText = format("i%02d", totalLoop + 1); |
| 504 | data.set(StringRef(independentName), StringRef(independentText)); |
| 505 | } |
| 506 | } |
| 507 | indexes.push_back(convertToTestType(indexes.size())); |
| 508 | serverMap->add(data, &indexes.back()); |
| 509 | } |
| 510 | } |
| 511 | } |
| 512 |
no test coverage detected