in loader/lib/Controller.js [33:92]
function Controller(job, session, finalCallback) {
this.session = session;
this.options = job.controller;
this.destination = job.destination;
this.plugin = job.plugin;
this.finalCallback = finalCallback;
this.dataSource = null;
this.writer = null;
this.badRecordLogger = null;
this.stats = {
rowsProcessed : 0, // all rows processed by data source
rowsSkipped : 0, // rows procesed by data source but skipped
rowsComplete : 0, // all rows completed by loader (success or failure)
rowsError : 0, // rows failed by loader
tickNumber : 0
};
this.shutdown = 0;
this.ticker = null; // interval timer
this.fatalError = null;
/* If the data source is maxLead rows ahead of the loader, pause it.
When the difference shrinks to minLead, resume it.
*/
this.maxLead = 2000;
this.minLead = 1000;
/* Data Source */
if(this.options.randomData) {
this.dataSource = new RandomDataSource(job, this);
} else {
this.dataSource = new FileDataSource(job, this);
}
/* Data Writer */
this.writer = new DbWriter(job.dataLoader, session, this);
if(this.options.inOneTransaction) {
this.writer.beginAtomic();
}
/* Bad Record Logger */
this.badRecordLogger = new BadRecordLogger(this);
/* Set singleton */
theController = this;
// Adjustments
if(this.options.skipRows && this.options.maxRows) {
this.options.maxRows += this.options.skipRows;
}
// Sanity Checks
if(this.options.inOneTransaction && this.options.randomData &&
(! this.options.maxRows)) {
this.fatalError = new Error("This job would attempt to build a single " +
"transaction of infinite size.");
this.finalCallback(this.fatalError, null);
}
process.on('exit', function() { udebug.log(theController.stats); });
}