if(chunkHostMap == null) {
throw new RuntimeException("Relation '" + relation + "' is not defined in the catalog.");
}
Set<Node> usedNodes = new HashSet<Node>();
for (String chunk_id : chunkHostMap.keySet()) {
DBChunk chunk = new DBChunk(chunk_id);
if (replication) {
for (Node node : chunkHostMap.get(chunk_id)) {
chunk.addHost(new DBChunkHost(node.getLocation(),
xmlConfig.getPartitionForNodeRelation(node,
relation, chunk_id).getUrl(), node
.getUsername(), node.getPassword(), node
.getDriver()));
}
} else {
for (Node node : chunkHostMap.get(chunk_id)) {
if (usedNodes.contains(node))
;
else {
usedNodes.add(node);
chunk.addHost(new DBChunkHost(node.getLocation(),
xmlConfig.getPartitionForNodeRelation(node,
relation, chunk_id).getUrl(), node
.getUsername(), node.getPassword(),
node.getDriver()));
break;
}
}
if (chunk.getHosts().isEmpty()) {
Node node = chunkHostMap.get(chunk_id).get(0);
chunk.addHost(new DBChunkHost(node.getLocation(),
xmlConfig.getPartitionForNodeRelation(node,
relation, chunk_id).getUrl(), node
.getUsername(), node.getPassword(), node
.getDriver()));
}