Return-Path: X-Original-To: apmail-manifoldcf-commits-archive@www.apache.org Delivered-To: apmail-manifoldcf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7B40410173 for ; Wed, 3 Jun 2015 01:48:23 +0000 (UTC) Received: (qmail 925 invoked by uid 500); 3 Jun 2015 01:48:23 -0000 Delivered-To: apmail-manifoldcf-commits-archive@manifoldcf.apache.org Received: (qmail 876 invoked by uid 500); 3 Jun 2015 01:48:23 -0000 Mailing-List: contact commits-help@manifoldcf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@manifoldcf.apache.org Delivered-To: mailing list commits@manifoldcf.apache.org Received: (qmail 867 invoked by uid 99); 3 Jun 2015 01:48:23 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Jun 2015 01:48:23 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 43B00AC026E for ; Wed, 3 Jun 2015 01:48:23 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1683208 - in /manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler: interfaces/ jobs/ notifications/ system/ Date: Wed, 03 Jun 2015 01:48:22 -0000 To: commits@manifoldcf.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150603014823.43B00AC026E@hades.apache.org> Author: kwright Date: Wed Jun 3 01:48:22 2015 New Revision: 1683208 URL: http://svn.apache.org/r1683208 Log: Add stop reasons to INotificationConnector interface. Part of CONNECTORS-1208. Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IJobManager.java manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobStartThread.java Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IJobManager.java URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IJobManager.java?rev=1683208&r1=1683207&r2=1683208&view=diff ============================================================================== --- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IJobManager.java (original) +++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/IJobManager.java Wed Jun 3 01:48:22 2015 @@ -19,7 +19,7 @@ package org.apache.manifoldcf.crawler.interfaces; import org.apache.manifoldcf.core.interfaces.*; -import java.util.ArrayList; +import java.util.List; /** This manager deals with jobs. Each job is associated with a repository connection, and has a number * of scheduling options: starting every n hours/days/weeks/months, on specific dates, or "continuous" (which basically @@ -819,7 +819,7 @@ public interface IJobManager *@param currentTime is the current time in milliseconds since epoch. *@param unwaitList is filled in with the set of job id's that were resumed (Long's). */ - public void startJobs(long currentTime, ArrayList unwaitList) + public void startJobs(long currentTime, List unwaitList) throws ManifoldCFException; @@ -827,7 +827,7 @@ public interface IJobManager *@param currentTime is the current time in milliseconds since epoch. *@param waitList is filled in with the set of job id's that were put into a wait state (Long's). */ - public void waitJobs(long currentTime, ArrayList waitList) + public void waitJobs(long currentTime, List waitList) throws ManifoldCFException; /** Get the list of jobs that are ready for seeding. @@ -1102,8 +1102,9 @@ public interface IJobManager * and will record the jobs that have been so modified. *@param timestamp is the current time in milliseconds since epoch. *@param modifiedJobs is filled in with the set of IJobDescription objects that were stopped. + *@param stopNotificationTypes is filled in with the type of stop notification. */ - public void finishJobStops(long timestamp, ArrayList modifiedJobs) + public void finishJobStops(long timestamp, List modifiedJobs, List stopNotificationTypes) throws ManifoldCFException; /** Complete the sequence that resumes jobs, either from a pause or from a scheduling window @@ -1112,7 +1113,7 @@ public interface IJobManager *@param timestamp is the current time in milliseconds since epoch. *@param modifiedJobs is filled in with the set of IJobDescription objects that were resumed. */ - public void finishJobResumes(long timestamp, ArrayList modifiedJobs) + public void finishJobResumes(long timestamp, List modifiedJobs) throws ManifoldCFException; /** Put all eligible jobs in the "shutting down" state. @@ -1129,7 +1130,7 @@ public interface IJobManager *@param currentTime is the current time in milliseconds since epoch. *@param resetJobs is filled in with the set of IJobDescription objects that were reset. */ - public void resetJobs(long currentTime, ArrayList resetJobs) + public void resetJobs(long currentTime, List resetJobs) throws ManifoldCFException; Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java?rev=1683208&r1=1683207&r2=1683208&view=diff ============================================================================== --- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java (original) +++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/interfaces/INotificationConnector.java Wed Jun 3 01:48:22 2015 @@ -48,6 +48,13 @@ public interface INotificationConnector { public static final String _rcsid = "@(#)$Id$"; + // Job stop reasons + public final int STOP_ERRORABORT = 0; + public final int STOP_MANUALABORT = 1; + public final int STOP_MANUALPAUSE = 2; + public final int STOP_SCHEDULEPAUSE = 3; + public final int STOP_RESTART = 4; + /** Request arbitrary connector information. * This method is called directly from the API in order to allow API users to perform any one of several * connector-specific queries. These are usually used to create external UI's. The connector will be @@ -61,8 +68,9 @@ public interface INotificationConnector /** Notify of job stop *@param spec is the notification specification. + *@param stopReason is the reason for the stop. */ - public void notifyOfJobStop(Specification spec) + public void notifyOfJobStop(Specification spec, int stopReason) throws ManifoldCFException, ServiceInterruption; /** Notify of job end Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java?rev=1683208&r1=1683207&r2=1683208&view=diff ============================================================================== --- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java (original) +++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/jobs/JobManager.java Wed Jun 3 01:48:22 2015 @@ -5859,7 +5859,7 @@ public class JobManager implements IJobM *@param unwaitList is filled in with the set of job ID objects that were resumed. */ @Override - public void startJobs(long currentTime, ArrayList unwaitList) + public void startJobs(long currentTime, List unwaitList) throws ManifoldCFException { // This method should compare the lasttime field against the current time, for all @@ -6097,7 +6097,7 @@ public class JobManager implements IJobM *@param waitList is filled in with the set of job ID's that were put into a wait state. */ @Override - public void waitJobs(long currentTime, ArrayList waitList) + public void waitJobs(long currentTime, List waitList) throws ManifoldCFException { // This method assesses jobs that are ACTIVE or PAUSED to see if they should be @@ -8148,7 +8148,7 @@ public class JobManager implements IJobM *@param modifiedJobs is filled in with the set of IJobDescription objects that were resumed. */ @Override - public void finishJobResumes(long timestamp, ArrayList modifiedJobs) + public void finishJobResumes(long timestamp, List modifiedJobs) throws ManifoldCFException { // Alternative to using a write lock here: Put this in a transaction, with a "FOR UPDATE" on the first query. @@ -8196,9 +8196,10 @@ public class JobManager implements IJobM * and will record the jobs that have been so modified. *@param timestamp is the current time in milliseconds since epoch. *@param modifiedJobs is filled in with the set of IJobDescription objects that were stopped. + *@param stopNotificationTypes is filled in with the type of stop notification. */ @Override - public void finishJobStops(long timestamp, ArrayList modifiedJobs) + public void finishJobStops(long timestamp, List modifiedJobs, List stopNotificationTypes) throws ManifoldCFException { // Alternative to using a write lock here: Put this in a transaction, with a "FOR UPDATE" on the first query. @@ -8215,7 +8216,7 @@ public class JobManager implements IJobM StringBuilder sb = new StringBuilder("SELECT "); ArrayList list = new ArrayList(); - sb.append(jobs.idField) + sb.append(jobs.idField).append(",").append(jobs.statusField).append(",").append(jobs.errorField) .append(" FROM ").append(jobs.getTableName()).append(" WHERE ") .append(database.buildConjunctionClause(list,new ClauseDescription[]{ new MultiClause(jobs.statusField,new Object[]{ @@ -8238,7 +8239,9 @@ public class JobManager implements IJobM { IResultRow row = set.getRow(i++); Long jobID = (Long)row.getValue(jobs.idField); - + int jobStatus = jobs.stringToStatus((String)row.getValue(jobs.statusField)); + String errorText = (String)row.getValue(jobs.errorField); + sb = new StringBuilder("SELECT "); list.clear(); @@ -8266,7 +8269,8 @@ public class JobManager implements IJobM IJobDescription jobDesc = jobs.load(jobID,true); modifiedJobs.add(jobDesc); - + stopNotificationTypes.add(mapToNotificationType(jobStatus,(errorText==null || errorText.length() == 0))); + jobs.finishStopJob(jobID,timestamp); Logging.jobs.info("Stopped job "+jobID); @@ -8278,6 +8282,29 @@ public class JobManager implements IJobM } } + protected static Integer mapToNotificationType(int jobStatus, boolean noErrorText) + { + switch (jobStatus) + { + case Jobs.STATUS_ABORTING: + case Jobs.STATUS_ABORTINGSHUTTINGDOWN: + return noErrorText?INotificationConnector.STOP_MANUALABORT:INotificationConnector.STOP_ERRORABORT; + case Jobs.STATUS_ABORTINGFORRESTART: + case Jobs.STATUS_ABORTINGFORRESTARTMINIMAL: + return INotificationConnector.STOP_RESTART; + case Jobs.STATUS_PAUSING: + case Jobs.STATUS_PAUSINGSEEDING: + case Jobs.STATUS_PAUSINGWAITING: + case Jobs.STATUS_PAUSINGWAITINGSEEDING: + return INotificationConnector.STOP_MANUALPAUSE; + case Jobs.STATUS_ACTIVEWAITING: + case Jobs.STATUS_ACTIVEWAITINGSEEDING: + return INotificationConnector.STOP_SCHEDULEPAUSE; + default: + throw new RuntimeException("Unexpected job status: "+jobStatus); + } + } + protected void noDocPriorities(Long jobID) throws ManifoldCFException { @@ -8333,7 +8360,7 @@ public class JobManager implements IJobM *@param resetJobs is filled in with the set of IJobDescription objects that were reset. */ @Override - public void resetJobs(long currentTime, ArrayList resetJobs) + public void resetJobs(long currentTime, List resetJobs) throws ManifoldCFException { // Alternative to using a write lock here: Put this in a transaction, with a "FOR UPDATE" on the first query. Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java?rev=1683208&r1=1683207&r2=1683208&view=diff ============================================================================== --- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java (original) +++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/notifications/BaseNotificationConnector.java Wed Jun 3 01:48:22 2015 @@ -64,10 +64,19 @@ public abstract class BaseNotificationCo return false; } + /** Notify of job stop + *@param spec is the notification specification. + *@param stopReason is the reason for the stop. + */ + public void notifyOfJobStop(Specification spec, int stopReason) + throws ManifoldCFException, ServiceInterruption + { + notifyOfJobStop(spec); + } + /** Notify of job stop. *@param spec is the notification specification. */ - @Override public void notifyOfJobStop(Specification spec) throws ManifoldCFException, ServiceInterruption { Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java?rev=1683208&r1=1683207&r2=1683208&view=diff ============================================================================== --- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java (original) +++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobResetThread.java Wed Jun 3 01:48:22 2015 @@ -68,11 +68,12 @@ public class JobResetThread extends Thre // See if there are any completed jobs long currentTime = System.currentTimeMillis(); - ArrayList jobStops = new ArrayList(); - jobManager.finishJobStops(currentTime,jobStops); - ArrayList jobResumes = new ArrayList(); + List jobStops = new ArrayList(); + List jobStopNotifications = new ArrayList(); + jobManager.finishJobStops(currentTime,jobStops,jobStopNotifications); + List jobResumes = new ArrayList(); jobManager.finishJobResumes(currentTime,jobResumes); - ArrayList jobCompletions = new ArrayList(); + List jobCompletions = new ArrayList(); jobManager.resetJobs(currentTime,jobCompletions); // If there were any job aborts, we must reprioritize all active documents, since we've done something @@ -92,18 +93,20 @@ public class JobResetThread extends Thre int k = 0; while (k < jobStops.size()) { - IJobDescription desc = (IJobDescription)jobStops.get(k++); + IJobDescription desc = jobStops.get(k); + Integer notificationType = jobStopNotifications.get(k); connectionManager.recordHistory(desc.getConnectionName(), null,connectionManager.ACTIVITY_JOBSTOP,null, desc.getID().toString()+"("+desc.getDescription()+")",null,null,null); // As a courtesy, call all the notification connections (if any) - doStopNotifications(desc,notificationManager,notificationPool); + doStopNotifications(desc,notificationType,notificationManager,notificationPool); + k++; } k = 0; while (k < jobResumes.size()) { - IJobDescription desc = (IJobDescription)jobResumes.get(k++); + IJobDescription desc = jobResumes.get(k++); connectionManager.recordHistory(desc.getConnectionName(), null,connectionManager.ACTIVITY_JOBCONTINUE,null, desc.getID().toString()+"("+desc.getDescription()+")",null,null,null); @@ -112,7 +115,7 @@ public class JobResetThread extends Thre k = 0; while (k < jobCompletions.size()) { - IJobDescription desc = (IJobDescription)jobCompletions.get(k++); + IJobDescription desc = jobCompletions.get(k++); connectionManager.recordHistory(desc.getConnectionName(), null,connectionManager.ACTIVITY_JOBEND,null, desc.getID().toString()+"("+desc.getDescription()+")",null,null,null); @@ -179,7 +182,7 @@ public class JobResetThread extends Thre } } - protected static void doStopNotifications(IJobDescription jobDescription, INotificationConnectionManager notificationManager, + protected static void doStopNotifications(IJobDescription jobDescription, int notificationType, INotificationConnectionManager notificationManager, INotificationConnectorPool notificationPool) throws ManifoldCFException { @@ -196,7 +199,7 @@ public class JobResetThread extends Thre { try { - connector.notifyOfJobStop(jobDescription.getNotificationSpecification(j)); + connector.notifyOfJobStop(jobDescription.getNotificationSpecification(j),notificationType); } finally { Modified: manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobStartThread.java URL: http://svn.apache.org/viewvc/manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobStartThread.java?rev=1683208&r1=1683207&r2=1683208&view=diff ============================================================================== --- manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobStartThread.java (original) +++ manifoldcf/trunk/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/JobStartThread.java Wed Jun 3 01:48:22 2015 @@ -68,25 +68,25 @@ public class JobStartThread extends Thre if (Logging.threads.isDebugEnabled()) Logging.threads.debug("Job start thread - checking for jobs to start at "+new Long(currentTime).toString()); // Start any waiting jobs - ArrayList unwaitJobs = new ArrayList(); + List unwaitJobs = new ArrayList(); jobManager.startJobs(currentTime,unwaitJobs); // Log these events in the event log int k = 0; while (k < unwaitJobs.size()) { - Long jobID = (Long)unwaitJobs.get(k++); + Long jobID = unwaitJobs.get(k++); IJobDescription desc = jobManager.load(jobID); connectionManager.recordHistory(desc.getConnectionName(), null,connectionManager.ACTIVITY_JOBUNWAIT,null, desc.getID().toString()+"("+desc.getDescription()+")",null,null,null); } // Cause jobs out of window to stop. - ArrayList waitJobs = new ArrayList(); + List waitJobs = new ArrayList(); jobManager.waitJobs(currentTime,waitJobs); k = 0; while (k < waitJobs.size()) { - Long jobID = (Long)waitJobs.get(k++); + Long jobID = waitJobs.get(k++); IJobDescription desc = jobManager.load(jobID); connectionManager.recordHistory(desc.getConnectionName(), null,connectionManager.ACTIVITY_JOBWAIT,null,