wt.scheduler
Class StandardSchedulingService

java.lang.Object
  extended bywt.services.StandardManager
      extended bywt.scheduler.StandardSchedulingService
All Implemented Interfaces:
Manager, NetFactor, SchedulingService, Serializable

public class StandardSchedulingService
extends StandardManager
implements SchedulingService, Serializable

Standard implementation of the scheduling service. Contains an implementation of the client and server APIs.

Use the newStandardSchedulingService static factory method(s), not the StandardSchedulingService constructor, to construct instances of this class. Instances must be constructed using the static factory(s), in order to ensure proper initialization of the instance.



Supported API: false

Extendable: false

See Also:
Serialized Form

Nested Class Summary
(package private) static class StandardSchedulingService.ScheduleHistoryPurging
          Class for thread spawning of ScheduleHistoryPurging.
In order to enable threading mechanism, verify spawnScheduleHistoryPurging method.
(package private)  class StandardSchedulingService.SchedulerEventListener
           
(package private)  class StandardSchedulingService.SchedulerMultiObjectEventListener
           
 
Field Summary
private static String CLASSNAME
           
private static boolean DEBUG_FULL_INFO
           
private static int DELAY_QUEUE_ENTRY_EXEC
           
private static ScheduleItem g_scheduledHistoryPurging
           
private static int HISTORY_PURGING_QUERY_SIZE
           
private static boolean HISTORY_PURGING_USING_THREAD
           
private static int LOCK_RETRY_TIMES
           
private static int LOCK_TIMEOUT
           
private static boolean PURGE_EXECUTING_HISTORIES
           
private static String PURGE_HISTORY_SCHEDULE_ITEM_NAME
           
private static boolean PURGE_INTERVAL_IN_SECONDS
           
private static int PURGE_OLD_HISTORY_INTERVAL
           
private static boolean PURGE_OLD_HISTORY_ITEMS
           
private static int PURGE_OLD_HISTORY_OLDER_THAN
           
private static String PURGE_SCHEDULE_HISTORY_QUEUE_NAME
           
private static String REGULAR_EXECUTION_METHOD
           
private static String RESOURCE
           
private static long SLEEP_PURGING_THREAD
           
private static boolean VERBOSE
           
 
Fields inherited from class wt.services.StandardManager
 
Fields inherited from interface wt.services.Manager
MANAGER_SERVICE, STARTUP_AUTOMATIC, STARTUP_MANUAL, STATUS_EMERGENCY_SHUTDOWN, STATUS_EMERGENCY_SHUTTING_DOWN, STATUS_SHUTDOWN, STATUS_SHUTDOWN_ERRORS, STATUS_SHUTDOWN_FAILURE, STATUS_SHUTTING_DOWN, STATUS_STARTED, STATUS_STARTED_ERRORS, STATUS_STARTING_UP, STATUS_STARTUP_FAILURE
 
Constructor Summary
StandardSchedulingService()
           
 
Method Summary
 int abortExecutingItems(ScheduleItem item)
          Aborts all running (executing) and ready items associated with the provided ScheduleItem.
private static ScheduleItem activateScheduleHistoryPurging()
          Adds the History purging process to the queue.
private static ScheduleQueueEntry addEntryToQueue(ScheduleItem scheduleItem, String method)
           
 ScheduleItem addItem(ScheduleItem newItem, ScheduleMethodArg[] itemArgs)
          This adds a ScheduleItem to the system.
static ScheduleItem addItemUnique(ScheduleItem newItem, ScheduleMethodArg[] itemArgs, String host)
          Adds a ScheduleItem to the Scheduler making sure no other equal item is already into the scheduler in that specific host.

If a Schedule Item with same name in the same queue already exists, it's returned instead, therefore this method can be used to retrieve an existing item.
Please note this method does NOT modify an existing item.
private  boolean cancelHistoryPurging()
          Cancels History Purging process.
 void cancelItem(ScheduleItem theItem)
          Cancels a schedule item.
private static Timestamp computeNextTime(ScheduleItem item)
           
private static void createScheduleHistory(ScheduleItem scheduleItem)
           
 ScheduleItem executeItemImmediately(ScheduleItem item)
          Executes an existing Schedule Item immediately. If item doesn't exist, it raises WTException.
static StatusInfo executeScheduledItem(ObjectIdentifier scheduleItemOID)
          Given an object ID of a ScheduleItem, invoke its method.
private static StatusInfo executionKernel(ObjectIdentifier scheduleItemOID, boolean adjustNextTime)
          This is the method that actually executes the items.
An inner level of abstraction provided.
 String getConceptualClassname()
          Deprecated.  
 Enumeration getItemHistories(ScheduleItem theItem)
          Returns an enumeration containing all the history items for a given schedule item.
 Enumeration getItemMethodArgs(ScheduleItem theItem)
          Returns an Enumeration of the ScheduleMethodArgs referred to by the argument ScheduleItem.
 MethodArgument[] getItemMethodArguments(ScheduleItem theItem)
          

Supported API: false
protected  WTCollection getItemsHistories(WTCollection items)
          Returns a WTCollection containing all the history items for a given schedule items WTCollection.
protected  WTCollection getItemsMethodArgs(WTCollection items)
          Returns a WTCollection of the ScheduleMethodArgs referred to by the ScheduleItem objects in argiment WTCollection items.
 Enumeration getScheduleItems(QuerySpec filter)
          Returns schedule items which satisfy the query spec.
 ScheduleItem modifyItem(ScheduleItem theItem)
          

Supported API: false
static StandardSchedulingService newStandardSchedulingService()
          Default factory for the class.
protected  void performStartupProcess()
          

Supported API: false
static long purgeOldHistories(Long secondsBack, Boolean deleteExecuting)
          Delete old entries from ScheduleHistory.
 void registerEvents(ManagerService manager)
          

Supported API: false
 void removeItem(ScheduleItem item)
          Removes a Schedule item

Supported API: false
 boolean removeMethodFromScheduleQueue(ScheduleItem schedItem)
          Eliminates method from ScheduleQueueEntry associated with the specific ScheduleItem.
static ScheduleItem retrieveScheduleItem(String itemName, String schedQueue)
          Retrieves a Schedule Item according to its name and queue.
Note: there can be more than one existing item.
static void setNextTime(ScheduleItem item, Timestamp nextTime)
          Sets the next time of execution for a given schedule item.
private static ScheduleQueueEntry setQueueEntryExecutionTime(ScheduleItem item, Timestamp nextTime)
          Sets an existing Schedule Queue entry execution time.
It makes sure the Queue gets awaken and executes the item properly.
private  void spawnScheduleHistoryPurging(boolean bPurge)
          Spawns process for running Schedule History Purging.
It can be through threading or direct call (see HISTORY_PURGING_USING_THREAD attribute).
 void startExecution(ScheduleItem item)
          

Supported API: false
 
Methods inherited from class wt.services.StandardManager
emergencyShutdown, emergencyShutdownComplete, emergencyShuttingDown, getClassInfo, getManagerService, getManagerStatus, getName, getStartupType, init, initialize, initialize, isStarted, newStandardManager, newStandardManager, performEmergencyShutdownProcess, performShutdownProcess, setManagerService, shutdown, shutdownFailure, shutdownSuccess, shuttingDown, started, startedErrors, startingUp, startup, startupFailure, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

RESOURCE

private static final String RESOURCE
See Also:
Constant Field Values

CLASSNAME

private static final String CLASSNAME

VERBOSE

private static boolean VERBOSE

DEBUG_FULL_INFO

private static boolean DEBUG_FULL_INFO

REGULAR_EXECUTION_METHOD

private static final String REGULAR_EXECUTION_METHOD
See Also:
Constant Field Values

LOCK_TIMEOUT

private static final int LOCK_TIMEOUT
See Also:
Constant Field Values

LOCK_RETRY_TIMES

private static int LOCK_RETRY_TIMES

DELAY_QUEUE_ENTRY_EXEC

private static final int DELAY_QUEUE_ENTRY_EXEC
See Also:
Constant Field Values

HISTORY_PURGING_USING_THREAD

private static final boolean HISTORY_PURGING_USING_THREAD
See Also:
Constant Field Values

PURGE_OLD_HISTORY_ITEMS

private static boolean PURGE_OLD_HISTORY_ITEMS

PURGE_EXECUTING_HISTORIES

private static boolean PURGE_EXECUTING_HISTORIES

PURGE_OLD_HISTORY_OLDER_THAN

private static int PURGE_OLD_HISTORY_OLDER_THAN

PURGE_OLD_HISTORY_INTERVAL

private static int PURGE_OLD_HISTORY_INTERVAL

PURGE_INTERVAL_IN_SECONDS

private static boolean PURGE_INTERVAL_IN_SECONDS

g_scheduledHistoryPurging

private static ScheduleItem g_scheduledHistoryPurging

HISTORY_PURGING_QUERY_SIZE

private static final int HISTORY_PURGING_QUERY_SIZE
See Also:
Constant Field Values

PURGE_HISTORY_SCHEDULE_ITEM_NAME

private static final String PURGE_HISTORY_SCHEDULE_ITEM_NAME
See Also:
Constant Field Values

PURGE_SCHEDULE_HISTORY_QUEUE_NAME

private static final String PURGE_SCHEDULE_HISTORY_QUEUE_NAME
See Also:
Constant Field Values

SLEEP_PURGING_THREAD

private static final long SLEEP_PURGING_THREAD
See Also:
Constant Field Values
Constructor Detail

StandardSchedulingService

public StandardSchedulingService()
Method Detail

getConceptualClassname

public String getConceptualClassname()
Deprecated.  

Returns the conceptual (modeled) name for the class.

Supported API: false

Specified by:
getConceptualClassname in interface NetFactor
Overrides:
getConceptualClassname in class StandardManager
Returns:
String

performStartupProcess

protected void performStartupProcess()


Supported API: false

Overrides:
performStartupProcess in class StandardManager

registerEvents

public void registerEvents(ManagerService manager)


Supported API: false

Specified by:
registerEvents in interface Manager
Overrides:
registerEvents in class StandardManager
Parameters:
manager -

executeScheduledItem

public static StatusInfo executeScheduledItem(ObjectIdentifier scheduleItemOID)
Given an object ID of a ScheduleItem, invoke its method.

Supported API: false

Parameters:
scheduleItemOID -
Returns:
StatusInfo

newStandardSchedulingService

public static StandardSchedulingService newStandardSchedulingService()
                                                              throws WTException
Default factory for the class.

Supported API: false

Returns:
StandardSchedulingService
Throws:
WTException

getScheduleItems

public Enumeration getScheduleItems(QuerySpec filter)
                             throws WTException
Returns schedule items which satisfy the query spec. If the filter is null, it returns all ScheduleItems in the system.

Supported API: false

Specified by:
getScheduleItems in interface SchedulingService
Parameters:
filter -
Returns:
Enumeration
Throws:
WTException

addItem

public ScheduleItem addItem(ScheduleItem newItem,
                            ScheduleMethodArg[] itemArgs)
                     throws WTException
This adds a ScheduleItem to the system. Its argument was created by the client.

Supported API: false

Specified by:
addItem in interface SchedulingService
Parameters:
newItem -
itemArgs -
Returns:
ScheduleItem
Throws:
WTException

cancelItem

public void cancelItem(ScheduleItem theItem)
                throws WTException
Cancels a schedule item. This will not cause a deletion of the schedule item or its history.

Supported API: false

Specified by:
cancelItem in interface SchedulingService
Parameters:
theItem -
Throws:
WTException

modifyItem

public ScheduleItem modifyItem(ScheduleItem theItem)
                        throws WTException


Supported API: false

Specified by:
modifyItem in interface SchedulingService
Parameters:
theItem -
Returns:
ScheduleItem
Throws:
WTException

startExecution

public void startExecution(ScheduleItem item)
                    throws WTException


Supported API: false

Specified by:
startExecution in interface SchedulingService
Parameters:
item -
Throws:
WTException

getItemMethodArguments

public MethodArgument[] getItemMethodArguments(ScheduleItem theItem)
                                        throws WTException


Supported API: false

Specified by:
getItemMethodArguments in interface SchedulingService
Parameters:
theItem -
Returns:
MethodArgument[]
Throws:
WTException

getItemMethodArgs

public Enumeration getItemMethodArgs(ScheduleItem theItem)
                              throws WTException
Returns an Enumeration of the ScheduleMethodArgs referred to by the argument ScheduleItem.

Supported API: false

Specified by:
getItemMethodArgs in interface SchedulingService
Parameters:
theItem -
Returns:
Enumeration
Throws:
WTException

getItemHistories

public Enumeration getItemHistories(ScheduleItem theItem)
                             throws WTException
Returns an enumeration containing all the history items for a given schedule item. If the filter is null, it returns the ScheduleHistory for all Schedule items in the system.

Supported API: false

Specified by:
getItemHistories in interface SchedulingService
Parameters:
theItem -
Returns:
Enumeration
Throws:
WTException

removeItem

public void removeItem(ScheduleItem item)
                throws WTException
Removes a Schedule item

Supported API: false

Specified by:
removeItem in interface SchedulingService
Parameters:
item -
Throws:
WTException

executeItemImmediately

public ScheduleItem executeItemImmediately(ScheduleItem item)
                                    throws WTException
Executes an existing Schedule Item immediately. If item doesn't exist, it raises WTException.

Supported API: false

Specified by:
executeItemImmediately in interface SchedulingService
Parameters:
item -
Returns:
ScheduleItem
Throws:
WTException

getItemsHistories

protected WTCollection getItemsHistories(WTCollection items)
                                  throws WTException
Returns a WTCollection containing all the history items for a given schedule items WTCollection.

Supported API: false

Parameters:
items - Collection of ScheduleItem objects
Returns:
WTCollection
Throws:
WTException

getItemsMethodArgs

protected WTCollection getItemsMethodArgs(WTCollection items)
                                   throws WTException
Returns a WTCollection of the ScheduleMethodArgs referred to by the ScheduleItem objects in argiment WTCollection items.

Supported API: false

Parameters:
items - Collection of ScheduleItem objects
Returns:
WTCollection
Throws:
WTException

executionKernel

private static StatusInfo executionKernel(ObjectIdentifier scheduleItemOID,
                                          boolean adjustNextTime)
This is the method that actually executes the items.
An inner level of abstraction provided.

Parameters:
scheduleItemOID - ObjectIdentifier of the Schdule item to be executed
adjustNextTime - boolean signalizing if it modifies or not item next time of execution

addEntryToQueue

private static ScheduleQueueEntry addEntryToQueue(ScheduleItem scheduleItem,
                                                  String method)
                                           throws WTException
Throws:
WTException

createScheduleHistory

private static void createScheduleHistory(ScheduleItem scheduleItem)
                                   throws WTException
Throws:
WTException

computeNextTime

private static Timestamp computeNextTime(ScheduleItem item)

addItemUnique

public static ScheduleItem addItemUnique(ScheduleItem newItem,
                                         ScheduleMethodArg[] itemArgs,
                                         String host)
                                  throws WTException
Adds a ScheduleItem to the Scheduler making sure no other equal item is already into the scheduler in that specific host.

If a Schedule Item with same name in the same queue already exists, it's returned instead, therefore this method can be used to retrieve an existing item.
Please note this method does NOT modify an existing item. For that intent, see modifyItem.

Item arguments created by the client.

Note:
Temporarily modeled as static method to avoid last minute Rose Model changes.

Supported API: false

Parameters:
newItem - schedule item to be inserted into the System
itemArgs - method arguments of schedule item
host - name of host of the schedule queue
if null, it looks for schedule item localy
Returns:
the inserted schedule item or previously existing item
Throws:
WTException
Since:
Windchill R6 - build 26

setQueueEntryExecutionTime

private static ScheduleQueueEntry setQueueEntryExecutionTime(ScheduleItem item,
                                                             Timestamp nextTime)
                                                      throws WTException
Sets an existing Schedule Queue entry execution time.
It makes sure the Queue gets awaken and executes the item properly.

Parameters:
item - Schedule item whose Queue entry will be modified
nextTime - Timstamp with execution time to be set
Returns:
the Schedule Queue entry associated with the Schedule item
Throws:
WTException

setNextTime

public static void setNextTime(ScheduleItem item,
                               Timestamp nextTime)
Sets the next time of execution for a given schedule item.

Note:
Temporarily modeled as static method to avoid last minute Rose Model changes.
This method creates its own transaction.

Supported API: false

Parameters:
item - schedule item to have the next executing time modified
nextTime - next executing time. If parameter null, sets current time
Since:
Windchill R6 - build 34

retrieveScheduleItem

public static ScheduleItem retrieveScheduleItem(String itemName,
                                                String schedQueue)
Retrieves a Schedule Item according to its name and queue.
Note: there can be more than one existing item. It returns the first found.

Parameters:
itemName - Schedule item name to look for
schedQueue - name of the Queue of the item
Returns:
the first found schedule item or null if none
Since:
Windchill R6 - build 36

abortExecutingItems

public int abortExecutingItems(ScheduleItem item)
                        throws WTException
Aborts all running (executing) and ready items associated with the provided ScheduleItem.

Parameters:
item - the ScheduleItem to look for associated queue items
Returns:
the number of aborted items
Throws:
WTException - If problems occur during operation.
Since:
Windchill R6 - build 26

removeMethodFromScheduleQueue

public boolean removeMethodFromScheduleQueue(ScheduleItem schedItem)
Eliminates method from ScheduleQueueEntry associated with the specific ScheduleItem.

Parameters:
schedItem - the ScheduleItem to look for associated methods in the queue
Returns:
true   if found and removed the method
false   otherwise
Since:
Windchill R6 - build 26

spawnScheduleHistoryPurging

private void spawnScheduleHistoryPurging(boolean bPurge)
Spawns process for running Schedule History Purging.
It can be through threading or direct call (see HISTORY_PURGING_USING_THREAD attribute).

Returns:
the added Schedule Item
Since:
Windchill R6 - build 36

activateScheduleHistoryPurging

private static ScheduleItem activateScheduleHistoryPurging()
Adds the History purging process to the queue.

Returns:
the added Schedule Item
Since:
Windchill R6 - build 36

cancelHistoryPurging

private boolean cancelHistoryPurging()
Cancels History Purging process.

Returns:
true   if found and cancelled the item
false   otherwise
Since:
Windchill R6 - build 36

purgeOldHistories

public static long purgeOldHistories(Long secondsBack,
                                     Boolean deleteExecuting)
Delete old entries from ScheduleHistory.

Parameters:
secondsBack - number of seconds back, before that time, items are deleted.
deleteExecuting - if also deletes Executing items.
Returns:
total number of items deleted
Since:
Windchill R6 - build 36