Skip to content

Commit

Permalink
Fixed NAS-2421. Now sets the harvestnamePrefix at job create time in …
Browse files Browse the repository at this point in the history
…the JobDBDAO.create method
  • Loading branch information
svcarlsen committed Jun 29, 2015
1 parent 7abd378 commit f13e750
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,79 +278,10 @@ public Job(Long harvestID, DomainConfiguration cfg, HeritrixTemplate orderXMLdoc
setMaxJobRunningTime(forceMaxJobRunningTime);

setArchiveFormatInTemplate(Settings.get(HarvesterSettings.HERITRIX_ARCHIVE_FORMAT));

status = JobStatus.NEW;
}


// /**
// * Package private constructor for common initialisation.
// *
// * @param harvestID the id of the harvestdefinition
// * @param cfg the configuration to base the Job on
// * @param channel the channel on which the job will be submitted.
// * @param forceMaxObjectsPerDomain the maximum number of objects harvested from a domain, overrides individual
// * configuration settings. -1 means no limit
// * @param forceMaxBytesPerDomain The maximum number of objects harvested from a domain, or -1 for no limit.
// * @param forceMaxJobRunningTime The max time in seconds given to the harvester for this job
// * @param harvestNum the run number of the harvest definition
// * @throws ArgumentNotValid if cfg or priority is null or harvestID is invalid, or if any limit < -1
// */
// public Job(Long harvestID, DomainConfiguration cfg, HarvestChannel channel,
// long forceMaxObjectsPerDomain,
// long forceMaxBytesPerDomain, long forceMaxJobRunningTime, int harvestNum) throws ArgumentNotValid {
// ArgumentNotValid.checkNotNull(cfg, "cfg");
// ArgumentNotValid.checkNotNull(harvestID, "harvestID");
// ArgumentNotValid.checkNotNegative(harvestID, "harvestID");
// ArgumentNotValid.checkNotNull(channel, "channel");
//
// if (forceMaxObjectsPerDomain < -1) {
// String msg = "forceMaxObjectsPerDomain must be either -1 or positive";
// log.debug(msg);
// throw new ArgumentNotValid(msg);
// }
// if (forceMaxBytesPerDomain < -1) {
// String msg = "forceMaxBytesPerDomain must be either -1 or positive";
// log.debug(msg);
// throw new ArgumentNotValid(msg);
// }
//
// if (forceMaxBytesPerDomain == 0L) {
// log.warn("forceMaxBytesPerDomain should probably not be 0.Means 0 bytes downloaded per domain");
// }
//
// if (forceMaxObjectsPerDomain == 0L) {
// log.warn("forceMaxObjectsPerDomain should probably not be 0.Means 0 objects downloaded per domain");
// }
//
// // setup initial members
// domainConfigurationMap = new HashMap<>();
// origHarvestDefinitionID = harvestID;
// orderXMLname = cfg.getOrderXmlName();
// orderXMLdoc = TemplateDAO.getInstance().read(cfg.getOrderXmlName());
//
//
// setHarvestChannel(channel);
//
// long maxObjects = NumberUtils.minInf(forceMaxObjectsPerDomain, cfg.getMaxObjects());
// setMaxObjectsPerDomain(maxObjects);
// configurationSetsObjectLimit = (maxObjects != forceMaxObjectsPerDomain);
//
// long maxBytes = NumberUtils.minInf(forceMaxBytesPerDomain, cfg.getMaxBytes());
// setMaxBytesPerDomain(maxBytes);
// configurationSetsByteLimit = (maxBytes != forceMaxBytesPerDomain);
//
// long expectation = cfg.getExpectedNumberOfObjects(forceMaxObjectsPerDomain, forceMaxBytesPerDomain);
// maxCountObjects = expectation;
// minCountObjects = expectation;
// this.harvestNum = harvestNum;
//
// addConfiguration(cfg);
//
// setMaxJobRunningTime(forceMaxJobRunningTime);
// setArchiveFormatInTemplate(Settings.get(HarvesterSettings.HERITRIX_ARCHIVE_FORMAT));
// status = JobStatus.NEW;
// }

/**
* Update the order template according to the chosen archive format (arc/warc).
*/
Expand Down Expand Up @@ -396,6 +327,7 @@ private void setArchiveFormatInTemplate(String archiveFormat) {
this.setSeedList(seedlist);
this.harvestNum = harvestNum;
this.continuationOF = continuationOf;

underConstruction = false;
}

Expand Down Expand Up @@ -1107,11 +1039,15 @@ public long getTotalCountObjects() {
}

void setDefaultHarvestNamePrefix() {
ArchiveFileNaming naming = ArchiveFileNamingFactory.getInstance();
log.debug("Applying the default ArchiveFileNaming class '{}'.", naming.getClass().getName());
final String prefix = naming.getPrefix(this);
setHarvestFilenamePrefix(prefix);
log.debug("The harvestPrefix of this job is: {}", prefix);
if (getJobID() != null) {
ArchiveFileNaming naming = ArchiveFileNamingFactory.getInstance();
log.debug("Applying the default ArchiveFileNaming class '{}'.", naming.getClass().getName());
final String prefix = naming.getPrefix(this);
setHarvestFilenamePrefix(prefix);
log.debug("The harvestPrefix of this job is: {}", prefix);
} else {
log.warn("The harvestnamePrefix is not set now, as it depends on the JobID, which is not set yet");
}
}

/** @return the harvest-audience. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ public synchronized void create(Job job) {
} else {
job.setJobID(generateNextID(connection));
}

// Set the harvestNamePrefix. Every current implementation depends on the JobID being set before
// being initialized.
job.setDefaultHarvestNamePrefix();


if (job.getCreationDate() != null) {
log.warn("The creation time for the job is already set. This should probably never happen.");
} else {
Expand Down

0 comments on commit f13e750

Please sign in to comment.