// Initialize on other sites
m_filePath = (String) params.toArray()[0];
m_fileNonce = (String) params.toArray()[1];
}
return new DependencySet(DEP_restoreScan, result);
} else if (fragmentId == SysProcFragmentId.PF_restoreScanResults) {
LOG.trace("Aggregating saved table state");
assert (dependencies.size() > 0);
List<VoltTable> dep = dependencies.get(DEP_restoreScan);
VoltTable result = ClusterSaveFileState.constructEmptySaveFileStateVoltTable();
for (VoltTable table : dep) {
while (table.advanceRow()) {
// the actually adds the active row... weird...
result.add(table);
}
}
return new DependencySet(DEP_restoreScanResults, result);
} else if (fragmentId == SysProcFragmentId.PF_restoreLoadReplicatedTable) {
assert (params.toArray()[0] != null);
assert (params.toArray()[1] != null);
assert (params.toArray()[2] != null);
String table_name = (String) params.toArray()[0];
int dependency_id = (Integer) params.toArray()[1];
int allowExport = (Integer) params.toArray()[2];
LOG.trace("restoreLoadReplicatedTable :: Partition id :" + context.getPartitionExecutor().getPartitionId());
//LOG.trace("Dependency_id :" + dependency_id + " - Loading replicated table: " + table_name);
String result_str = "SUCCESS";
String error_msg = "";
TableSaveFile savefile = null;
/**
* For replicated tables this will do the slow thing and read the
* file once for each ExecutionSite. This could use optimization
* like is done with the partitioned tables.
*/
try {
savefile = getTableSaveFile(getSaveFileForReplicatedTable(table_name), 3, null);
assert (savefile.getCompleted());
} catch (IOException e) {
VoltTable result = constructResultsTable();
result.addRow(m_hostId, hostname, m_siteId, table_name, -1, "FAILURE", "Unable to load table: " + table_name + " error: " + e.getMessage());
return new DependencySet(dependency_id, result);
}
try {
while (savefile.hasMoreChunks()) {
VoltTable table = null;
final org.voltdb.utils.DBBPool.BBContainer c = savefile.getNextChunk();
if (c == null) {
continue;// Should be equivalent to break
}
VoltTable old_table = PrivateVoltTableFactory.createVoltTableFromBuffer(c.b, true);
Table new_catalog_table = getCatalogTable(table_name);
table = SavedTableConverter.convertTable(old_table, new_catalog_table);
c.discard();
try {
LOG.trace("LoadTable " + table_name);
this.executor.loadTable(ts, context.getCluster().getTypeName(), context.getDatabase().getTypeName(), table_name, table, allowExport);
} catch (VoltAbortException e) {
result_str = "FAILURE";
error_msg = e.getMessage();
break;
}
}
} catch (IOException e) {
VoltTable result = constructResultsTable();
result.addRow(m_hostId, hostname, m_siteId, table_name, -1, "FAILURE", "Unable to load table: " + table_name + " error: " + e.getMessage());
return new DependencySet(dependency_id, result);
} catch (VoltTypeException e) {
VoltTable result = constructResultsTable();
result.addRow(m_hostId, hostname, m_siteId, table_name, -1, "FAILURE", "Unable to load table: " + table_name + " error: " + e.getMessage());
return new DependencySet(dependency_id, result);
}
VoltTable result = constructResultsTable();
result.addRow(m_hostId, hostname, m_siteId, table_name, -1, result_str, error_msg);
try {
savefile.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new DependencySet(dependency_id, result);
} else if (fragmentId == SysProcFragmentId.PF_restoreDistributeReplicatedTable) {
// XXX I tested this with a hack that cannot be replicated
// in a unit test since it requires hacks to this sysproc that
// effectively break it
assert (params.toArray()[0] != null);
assert (params.toArray()[1] != null);
assert (params.toArray()[2] != null);
assert (params.toArray()[3] != null);
String table_name = (String) params.toArray()[0];
int site_id = (Integer) params.toArray()[1];
int dependency_id = (Integer) params.toArray()[2];
int allowExport = (Integer) params.toArray()[3];
LOG.trace("Distributing replicated table: " + table_name + " to: " + site_id);
VoltTable result = performDistributeReplicatedTable(table_name, site_id, context, allowExport);
return new DependencySet(dependency_id, result);
} else if (fragmentId == SysProcFragmentId.PF_restoreSendReplicatedTable) {
assert (params.toArray()[0] != null);
assert (params.toArray()[1] != null);
assert (params.toArray()[2] != null);
assert (params.toArray()[3] != null);
String table_name = (String) params.toArray()[0];
int dependency_id = (Integer) params.toArray()[1];
VoltTable table = (VoltTable) params.toArray()[2];
int allowExport = (Integer) params.toArray()[3];
LOG.trace("Received replicated table: " + table_name);
String result_str = "SUCCESS";
String error_msg = "";
try {
this.executor.loadTable(ts, context.getCluster().getTypeName(), context.getDatabase().getTypeName(), table_name, table, allowExport);
} catch (VoltAbortException e) {
result_str = "FAILURE";
error_msg = e.getMessage();
}
VoltTable result = constructResultsTable();
result.addRow(m_hostId, hostname, m_siteId, table_name, -1, result_str, error_msg);
return new DependencySet(dependency_id, result);
} else if (fragmentId == SysProcFragmentId.PF_restoreSendReplicatedTableResults) {
assert (params.toArray()[0] != null);
int dependency_id = (Integer) params.toArray()[0];
LOG.trace("Received confirmmation of successful replicated table load");
VoltTable result = constructResultsTable();
for (int dep_id : dependencies.keySet()) {
List<VoltTable> table_list = dependencies.get(dep_id);
assert (table_list.size() == 1);
VoltTable t = table_list.get(0);
while (t.advanceRow()) {
// this will actually add the active row of t
result.add(t);
}
}
return new DependencySet(dependency_id, result);
} else if (fragmentId == SysProcFragmentId.PF_restoreLoadReplicatedTableResults) {
LOG.trace("Aggregating replicated table restore results");
assert (params.toArray()[0] != null);
int dependency_id = (Integer) params.toArray()[0];
assert (dependencies.size() > 0);
VoltTable result = constructResultsTable();
for (int dep_id : dependencies.keySet()) {
List<VoltTable> table_list = dependencies.get(dep_id);
assert (table_list.size() == 1);
VoltTable t = table_list.get(0);
while (t.advanceRow()) {
// this will actually add the active row of t
result.add(t);
}
}
return new DependencySet(dependency_id, result);
} else if (fragmentId == SysProcFragmentId.PF_restoreDistributePartitionedTable) {
Object paramsA[] = params.toArray();
assert (paramsA[0] != null);
assert (paramsA[1] != null);
assert (paramsA[2] != null);
assert (paramsA[3] != null);
String table_name = (String) paramsA[0];
int originalHosts[] = (int[]) paramsA[1];
int relevantPartitions[] = (int[]) paramsA[2];
int dependency_id = (Integer) paramsA[3];
int allowExport = (Integer) paramsA[4];
// Using Localized Version
VoltTable result = performLoadPartitionedTable(table_name, originalHosts, relevantPartitions, context, allowExport, ts);
// Distributed Version - Invokes another round of plan fragments
// which does not work
// VoltTable result =
// performDistributePartitionedTable(table_name, originalHosts,
// relevantPartitions, context, allowExport);
return new DependencySet(dependency_id, result);
} else if (fragmentId == SysProcFragmentId.PF_restoreDistributePartitionedTableResults) {
LOG.trace("Aggregating partitioned table restore results");
assert (params.toArray()[0] != null);
int dependency_id = (Integer) params.toArray()[0];
VoltTable result = constructResultsTable();
for (int dep_id : dependencies.keySet()) {
List<VoltTable> table_list = dependencies.get(dep_id);
assert (table_list.size() == 1);
VoltTable t = table_list.get(0);
while (t.advanceRow()) {
// this will actually add the active row of t
result.add(t);
}
}
return new DependencySet(dependency_id, result);
} else if (fragmentId == SysProcFragmentId.PF_restoreSendPartitionedTable) {
assert (params.toArray()[0] != null);
assert (params.toArray()[1] != null);
assert (params.toArray()[2] != null);
assert (params.toArray()[3] != null);
assert (params.toArray()[4] != null);
String table_name = (String) params.toArray()[0];
int partition_id = (Integer) params.toArray()[1];
int dependency_id = (Integer) params.toArray()[2];
VoltTable table = (VoltTable) params.toArray()[3];
int allowExport = (Integer) params.toArray()[4];
LOG.trace("Received partitioned table: " + table_name);
String result_str = "SUCCESS";
String error_msg = "";
try {
this.executor.loadTable(ts, context.getCluster().getTypeName(), context.getDatabase().getTypeName(), table_name, table, allowExport);
} catch (VoltAbortException e) {
result_str = "FAILURE";
error_msg = e.getMessage();
}
VoltTable result = constructResultsTable();
result.addRow(m_hostId, hostname, m_siteId, table_name, partition_id, result_str, error_msg);
return new DependencySet(dependency_id, result);
} else if (fragmentId == SysProcFragmentId.PF_restoreSendPartitionedTableResults) {
assert (params.toArray()[0] != null);
int dependency_id = (Integer) params.toArray()[0];
LOG.trace("Received confirmation of successful partitioned table load");
VoltTable result = constructResultsTable();
for (int dep_id : dependencies.keySet()) {
List<VoltTable> table_list = dependencies.get(dep_id);
assert (table_list.size() == 1);
VoltTable t = table_list.get(0);
while (t.advanceRow()) {
// this will actually add the active row of t
result.add(t);
}
}
return new DependencySet(dependency_id, result);
}
assert (false);
return null;
}