Skip to content
Permalink
Browse files

Added more logging to RunningJobs classes. Removed requirement of JDK…

… 1.8 to build
  • Loading branch information...
svcarlsen committed Sep 30, 2016
1 parent 18d3e08 commit 640d8b3730cd7454dc9795c7d6fc18b28bf1b2b0
@@ -71,7 +71,7 @@ public void shutdown() {
super.shutdown();
HarvestDBConnection.cleanup();
}

/*
public static Provider<JMSConnection> getJMSConnectionProvider() {
return () -> JMSConnectionFactory.getInstance();
}
@@ -84,9 +84,8 @@ public void shutdown() {
public static Provider<Notifications> getNotificationsProvider() {
return () -> NotificationsFactory.getInstance();
}
*/


/*
public static Provider<JMSConnection> getJMSConnectionProvider() {
return new Provider<JMSConnection>() {

@@ -119,5 +118,5 @@ public Notifications get() {
return NotificationsFactory.getInstance();
}};
}
*/

}
@@ -229,7 +229,7 @@ public synchronized void store(StartedJobInfo startedJobInfo) {
if (!shouldSample) {
return; // we're done
}

log.debug("Adding history Record for job {} to runningJobsHistory table", startedJobInfo.getJobId());
try {
c.setAutoCommit(false);

@@ -491,7 +491,7 @@ public StartedJobInfo getMostRecentByJobId(long jobId) {
sji.setActiveToeCount(rs.getInt(HM_COLUMN.activeToeCount.rank()));
sji.setStatus(CrawlStatus.values()[rs.getInt(HM_COLUMN.status.rank())]);
sji.setTimestamp(new Date(rs.getTimestamp(HM_COLUMN.tstamp.rank()).getTime()));

log.debug("getMostRecentByJobId for {}:{}", jobId, sji);
return sji;
}

@@ -31,6 +31,7 @@

import javax.jms.MessageListener;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@@ -64,18 +65,24 @@

/** Singleton instance of the monitor. */
private static HarvestMonitor instance;
/** Harvest Monitor refresh Interval. */
private int refreshInterval;

/** The JMS channel on which to listen for {@link CrawlProgressMessage}s. */
public static final ChannelID HARVEST_MONITOR_CHANNEL_ID = HarvesterChannels.getHarvestMonitorChannel();

private Map<Long, StartedJobHistoryChartGen> chartGenByJobId = new HashMap<Long, StartedJobHistoryChartGen>();

private HarvestMonitor() {
refreshInterval = Settings.getInt(HarvesterSettings.HARVEST_MONITOR_REFRESH_INTERVAL);
LOG.info("Initializing HarvestMonitor with refreshInterval={} seconds", refreshInterval);

// Perform initial cleanup (in case apps crashed)
cleanOnStartup();

// Register for listening JMS messages
JMSConnectionFactory.getInstance().setListener(HARVEST_MONITOR_CHANNEL_ID, this);
LOG.info("Started listening to queue {}", HARVEST_MONITOR_CHANNEL_ID);
}

/**
@@ -97,7 +104,7 @@ public void cleanup() {
/**
* @return the singleton instance for this class.
*/
public static HarvestMonitor getInstance() {
public static synchronized HarvestMonitor getInstance() {
if (instance == null) {
instance = new HarvestMonitor();
}
@@ -107,15 +114,16 @@ public static HarvestMonitor getInstance() {
@Override
public void visit(CrawlProgressMessage msg) {
ArgumentNotValid.checkNotNull(msg, "msg");

Long jobId = Long.valueOf(msg.getJobID());

JobStatus jobStatus = JobDAO.getInstance().read(jobId).getStatus();
if (!JobStatus.STARTED.equals(jobStatus)) {
LOG.warn("Receiving CrawlProgressMessage for job {} registered as state {} instead of STARTED. Ignoring message", jobId, jobStatus);
return;
}

StartedJobInfo info = StartedJobInfo.build(msg);
LOG.trace("Received CrawlProgressMessage for jobId {}: {}", jobId, info);
RunningJobsInfoDAO.getInstance().store(info);

// Start a chart generator if none has been started yet
@@ -139,7 +147,7 @@ public void visit(JobEndedMessage msg) {
// Delete records in the DB
RunningJobsInfoDAO dao = RunningJobsInfoDAO.getInstance();
int delCount = dao.removeInfoForJob(jobId);
LOG.info("Deleted {} running job info records for job ID {} on transition to status {}", delCount, jobId,
LOG.info("Processing JobEndedMessage. Deleted {} running job info records for job ID {} on transition to status {}", delCount, jobId,
newStatus.name());

// Stop chart generation
@@ -267,7 +275,7 @@ private void cleanOnStartup() {
delCount += dao.deleteFrontierReports(jobId);
}
if (delCount > 0) {
LOG.info("Cleaned up {} obsolete history records.", delCount);
LOG.info("Cleaned up {} obsolete history records for finished jobs {}", delCount, StringUtils.join(idsToRemove, ","));
}

}
@@ -28,6 +28,9 @@

import javax.servlet.ServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import dk.netarkivet.common.exceptions.UnknownID;
import dk.netarkivet.harvester.datamodel.DomainDAO;
import dk.netarkivet.harvester.datamodel.Job;
@@ -40,6 +43,8 @@
*/
public class FindRunningJobQuery {

static final Logger log = LoggerFactory.getLogger(FindRunningJobQuery.class);

/**
* Defines the UI fields and their default values.
*/
@@ -84,7 +89,7 @@ public Object getDefaultValue() {
private Set<Long> runningJobIds = new TreeSet<Long>();

/**
* Builds a request to find a running job. UI fileds values will be extracted from the given {@link ServletRequest}.
* Builds a request to find a running job. UI field values will be extracted from the given {@link ServletRequest}.
*
* @param req the {@link ServletRequest} to parse.
*/
@@ -107,6 +112,7 @@ public FindRunningJobQuery(ServletRequest req) {
if (domains.contains(domainName)) {
runningJobIds.add(jobId);
}
log.info("Found {} jobs in status STARTED harvesting domain {}", runningJobIds.size(), domainName);
}
}

@@ -28,7 +28,8 @@
import dk.netarkivet.common.utils.TableSort;

/**
* class used to manage the sort of tables in the harvest status running screen.
* Class used to manage the sort of tables in the harvest status running screen.
* Used only by History/Harveststatus-running.jsp
*/
public class HarvestStatusRunningTablesSort {
/** list of the column id. */
@@ -13,8 +13,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- maven-java-formatter-plugin -->
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<slf4j.version>1.7.7</slf4j.version>
<logback.version>1.0.13</logback.version>
<webarchive-commons.version>1.1.5</webarchive-commons.version>

0 comments on commit 640d8b3

Please sign in to comment.
You can’t perform that action at this time.