Task Manager - Demos | |||||
Home | Task Manager | Simple example | Manual | Demo | Other Products |
Task Manager - Demos
A number of demo classes are provided which demonstrate the functionality in Virtual Machinery's Task manager classes -
An application which provides a visual interface to a demonstration tasks is also provided - JTaskManDemoView
All of these classes can be found in the package com.virtualmachinery.taskmanager.demos.
TaskDemo
The output from running this task combines all the outputs from the tasks described below
NormalDemoNormal Demo - Demonstrates the features of the Task Manager using a normal scenario with 4 tasks, 1 with sequence number 1, 2 with 2 and 1 with 4.
The output from running this demonstration is as follows -
Running Code for Task 1
Completed Code for Task 1
Running Success Code for Task 1
Running Code for Task 2a
Running Code for Task 2b
Completed Code for Task 2b
Running Success Code for Task 2b
Completed Code for Task 2a
Running Success Code for Task 2a
Running Code for Task 4
Completed Code for Task 4
Running Success Code for Task 4
Current status of tasks (name, sequence number, status, execution time
TASK 1 1 SUCCESSFUL 5000ms
TASK 2a 2 SUCCESSFUL 49980ms
TASK 2b 2 SUCCESSFUL 5000ms
TASK 4 4 SUCCESSFUL 5000ms
Non Fatal Error demo - Creates and runs a set of tasks one of which (task2a) contains an error. Since this task is not marked as fatal the other tasks will be run as normal
The output from running this demonstration is as follows -
Running Code for Task 1
Completed Code for Task 1
Running Success Code for Task 1
Running Code for Task 2a with non fatal error
Running Code for Task 2b
Running Failure Code for Task 2a
Completed Code for Task 2b
Running Success Code for Task 2b
Running Code for Task 4
Completed Code for Task 4
Running Success Code for Task 4
Current status of tasks (name, sequence number, status, execution time)
TASK 1 1 SUCCESSFUL 5050ms
TASK 2a 2 FAILED -1ms
TASK 2b 2 SUCCESSFUL 5050ms
TASK 4 4 SUCCESSFUL 5000ms
Fatal Error demo - Creates and runs a set of tasks one of which (task2a) contains an error. Since this task is marked as fatal no other tasks will be started after this
The output from running this demonstration is as follows -
Running Code for Task 1
Completed Code for Task 1
Running Success Code for Task 1
Running Code for Task 2a with fatal error
Running Code for Task 2b
Running Failure Code for Task 2a
Completed Code for Task 2b
Running Success Code for Task 2b
Fatal Failure - task execution halted com.virtualmachinery.taskmanagerexceptions.TaskManagerFatalFailureException
Current status of tasks (name, sequence number, status, execution time)
TASK 1 1 SUCCESSFUL 5000ms
TASK 2a 2 FAILED -1ms
TASK 2b 2 SUCCESSFUL 5050ms
TASK 4 4 WAITING -1ms
Stop code demo - Send the signal to stop the execution of the tasks. All currently running tasks will run to completion and no other tasks will be started
The output from running this demonstration is as follows -
Waiting in stop code
Running Code for Task 1
Completed Code for Task 1
Running Success Code for Task 1
Running Code for Task 2a
Running Code for Task 2b
Stop signal sent
Completed Code for Task 2b
Running Success Code for Task 2b
Completed Code for Task 2a
Running Success Code for Task 2a
Current status of tasks (name, sequence number, status, execution time)
TASK 1 1 SUCCESSFUL 5050ms
TASK 2a 2 SUCCESSFUL 50150ms
TASK 2b 2 SUCCESSFUL 5000ms
TASK 4 4 WAITING -1ms
Pause Demo - Demonstrates the use of the pause and restartAfterPause methods to create a pause in the midst of running a set of tasks
The output from running this demonstration is as follows -
Waiting in pause code 1
Running Code for Task 1
Pause 1 signal sent
Pausing for 8000ms
Completed Code for Task 1
Running Success Code for Task 1
Sending restart after pause 1
Restart signal sent
Running Code for Task 2a
Running Code for Task 2b
Completed Code for Task 2b
Running Success Code for Task 2b
Completed Code for Task 2a
Running Success Code for Task 2a
Running Code for Task 4
Completed Code for Task 4
Running Success Code for Task 4
Current status of tasks (name, sequence number, status, execution time)
TASK 1 1 SUCCESSFUL 5050ms
TASK 2a 2 SUCCESSFUL 50030ms
TASK 2b 2 SUCCESSFUL 4990ms
TASK 4 4 SUCCESSFUL 5000ms
Timed Pause Demo - Demonstrates the use of the Pause(milliseconds) method to pause in the midst of the execution of a set of tasks.
The output from running this demonstration is as follows -
Waiting in pause code 2
Running Code for Task 1
Pause 2 signal sent - wait 16000ms
Restarting after pause 2
Completed Code for Task 1
Running Success Code for Task 1
Running Code for Task 2a
Running Code for Task 2b
Completed Code for Task 2b
Running Success Code for Task 2b
Completed Code for Task 2a
Running Success Code for Task 2a
Running Code for Task 4
Completed Code for Task 4
Running Success Code for Task 4
Current status of tasks (name, sequence number, status, execution time)
TASK 1 1 SUCCESSFUL 5050ms
TASK 2a 2 SUCCESSFUL 50040ms
TASK 2b 2 SUCCESSFUL 5000ms
TASK 4 4 SUCCESSFUL 5050ms
Restart Tasks Demo - Create and run a set of tasks one of which (task2b) has been marked as FAILED, starting them at a particular point in the sequence (in this case at sequence 2). The failed task will not be attempted again
The output from running this demonstration is as follows -
Running Code for Task 2a
Completed Code for Task 2a
Running Success Code for Task 2a
Running Code for Task 4
Completed Code for Task 4
Running Success Code for Task 4
Current status of tasks (name, sequence number, status, execution time)
TASK 1 1 WAITING -1ms
TASK 2a 2 SUCCESSFUL 49980ms
TASK 2b 2 FAILED -1ms
TASK 4 4 SUCCESSFUL 5050ms
Restart Retry Failed Demo - Create and run a set of tasks one of which (task2b) has been marked as FAILED, starting them at a particular point in the sequence (in this case at sequence 2). The failed task will be attempted again.
The output from running this demonstration is as follows -
Running Code for Task 2a
Running Code for Task 2b
Completed Code for Task 2b
Running Success Code for Task 2b
Completed Code for Task 2a
Running Success Code for Task 2a
Running Code for Task 4
Completed Code for Task 4
Running Success Code for Task 4
Current status of tasks (name, sequence number, status, execution time)
TASK 1 1 WAITING -1ms
TASK 2a 2 SUCCESSFUL 50030ms
TASK 2b 2 SUCCESSFUL 5050ms
TASK 4 4 SUCCESSFUL 5000ms
The demonstration application provided in the class com.virtualmachinery.taskmanager.demos.JTaskManDemoView illustrates the use of a visual application which can be used to observe the progress of a number of tasks running on the Java platform controlled by Virtual Machinery's Task Manager. Start the demo by running the classes 'main' method (you can use the CompileVisualDemo.bat and RunVisualDemo.bat files supplied with the distribution). You will then see a screen like this -
Press the 'Start Task Manager' button and watch the progress bars as the tasks proceed. The tasks are orgainsed as Task 1 in sequence 1, Tasks 2,3 and 4 in sequence 2 and task 5 in sequence 3. As the tasks proceed the screen will look something like this -
If you want to demonstrate the pause and restart functionality you can do so using the buttons provided. Note that all the tasks in the current sequence will continue to completion before the pause takes effect. Pressing restart will restart the tasks at the next sequence number.
There are a number of interesting methods in the code for the JTaskManDemoView class which may help you when you wish to modify this code for your own purposes.
startTasks() - This initialises the progress bars and the status text pane. The code is all enclosed in a thread to ensure that the user interface is updated when the values in the progress bars and text panes are changed.
createTask*() - These methods all initialise instances of objects which implement the TaskInterface interface. In this case the class used is Task - if you wish to change the class used all you have tto do is change the instance returned by the createTask() method which is called by all the createTask* methods to create an initialised instance of the Task class. Notice that all external variables used in the code in the Threads have to be declared as final. Note also the append() and setValue() methods used to update the status pane and progress bars. The default range of the progress bars is 0 to 100.