}
private SynthesizedPlanFragment[] generateReplicatedToReplicatedPlan() {
SynthesizedPlanFragment[] restore_plan = null;
SystemProcedureExecutionContext context = this.getSystemProcedureExecutionContext();
assert (context != null);
Host catalog_host = context.getHost();
Collection<Site> catalog_sites = CatalogUtil.getSitesForHost(catalog_host);
Set<Integer> execution_site_ids = new TreeSet<Integer>();
Set<Integer> execution_partition_ids = new TreeSet<Integer>();
for (Site catalog_site : catalog_sites) {
execution_site_ids.add(catalog_site.getId());
for(Partition pt : catalog_site.getPartitions()){
execution_partition_ids.add(pt.getId());
}
}
//LOG.trace("Sites Size ::"+execution_site_ids.size());
//LOG.trace("Partitions Size ::"+execution_partition_ids.size());
Set<Integer> sites_missing_table = getSitesMissingTable(execution_site_ids);
// not sure we want to deal with handling expected load failures,
// so let's send an individual load to each site with the table
// and then pick sites to send the table to those without it
restore_plan = new SynthesizedPlanFragment[execution_partition_ids.size() + 1];
int restore_plan_index = 0;
//LOG.trace("getSitesMissingTable :");
//for(Integer ii : sites_missing_table ) LOG.trace(" "+ii);
for (Integer site_id : m_sitesWithThisTable) {
for(Partition pt : CatalogUtil.getSiteFromId(context.getHost(),site_id).getPartitions()){
restore_plan[restore_plan_index] = constructLoadReplicatedTableFragment();
// XXX restore_plan[restore_plan_index].siteId = site_id;
restore_plan[restore_plan_index].destPartitionId = pt.getId();
++restore_plan_index;
}
}
for (Integer site_id : sites_missing_table) {
LOG.trace("m_sites_missing_table :: site_id :"+site_id);
int source_site_id = m_sitesWithThisTable.iterator().next(); // XXX hacky
for(Partition pt : CatalogUtil.getSiteFromId(context.getHost(), source_site_id).getPartitions()){
restore_plan[restore_plan_index] = constructDistributeReplicatedTableFragment(source_site_id, site_id);
++restore_plan_index;
}
}
//LOG.trace("restore_plan_index :"+restore_plan_index+" execution_partition_ids :"+execution_partition_ids.size());