Skip to content

Commit 31ea135

Browse files
committed
Make hostname strategy more resilient to missing host info
1 parent a70e170 commit 31ea135

1 file changed

Lines changed: 23 additions & 6 deletions

File tree

src/ChunkInfo.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,29 @@ namespace chunk_assignment
192192
std::map< std::string, ChunkTable > chunkGroups;
193193
ChunkTable & sourceChunks = res.notAssigned;
194194
ChunkTable & sinkChunks = res.assigned;
195-
for( auto const & chunk : sourceChunks )
196195
{
197-
std::string hostname = in.at( chunk.sourceID );
198-
ChunkTable & chunksOnHost = chunkGroups[ hostname ];
199-
chunksOnHost.push_back( std::move( chunk ) );
196+
ChunkTable leftover;
197+
for( auto const & chunk : sourceChunks )
198+
{
199+
auto it = in.find( chunk.sourceID );
200+
if( it == in.end() )
201+
{
202+
leftover.push_back( std::move( chunk ) );
203+
}
204+
else
205+
{
206+
std::string hostname = it->second;
207+
ChunkTable & chunksOnHost = chunkGroups[ hostname ];
208+
chunksOnHost.push_back( std::move( chunk ) );
209+
}
210+
}
211+
// undistributed chunks will be put back in later on
212+
sourceChunks.clear();
213+
for( auto & chunk : leftover )
214+
{
215+
sourceChunks.push_back( std::move( chunk ) );
216+
}
200217
}
201-
// undistributed chunks will be put back in later on
202-
sourceChunks.clear();
203218
// chunkGroups will now contain chunks by hostname
204219
// the ranks are the source ranks
205220

@@ -426,6 +441,8 @@ namespace chunk_assignment
426441
outer_loop:;
427442
}
428443

444+
std::cout << "BYCOBOIDSLICE assigned " << res.assigned.size() << " chunks" << std::endl;
445+
429446
return res.assigned;
430447
}
431448

0 commit comments

Comments
 (0)