forked from walidbosso/Java_Task_Scheduling
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskScheduler.java
More file actions
77 lines (54 loc) · 1.99 KB
/
TaskScheduler.java
File metadata and controls
77 lines (54 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package Classes;
import java.awt.image.BufferedImage;
import java.io.File;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
public class TaskScheduler extends UnicastRemoteObject implements TaskSchedulerInterface {
Object result ;
Taskqueue taskQueue;
int ID;
MatrixTask matrixtask;
FilterTask filtertask ;
CovolutionTask covolutiontask;
ArrayList<TaskResult> BD;
public TaskScheduler(Taskqueue taskQueue, ArrayList<TaskResult> BD) throws RemoteException {
this.taskQueue = taskQueue;
this.BD = BD;
}
@Override
public int submitTask(Task task) throws RemoteException {
try {
taskQueue.add(task);
if ("Classes.CovolutionTask" == task.getClass().getName()) {
covolutiontask = (CovolutionTask) task;
ID = covolutiontask.ID;
}
if ("Classes.MatrixTask" == task.getClass().getName()) {
matrixtask = (MatrixTask) task;
ID = matrixtask.ID;
}
if ("Classes.FilterTask" == task.getClass().getName()) {
filtertask = (FilterTask) task;
ID = filtertask.ID;
}
} catch (InterruptedException ex) {
Logger.getLogger(TaskScheduler.class.getName()).log(
Level.SEVERE, null, ex);
}
return ID;
}
@Override
public Object getResult(int taskId) throws RemoteException {
for (int i = 0; i < BD.size(); i++) {
if (taskId == BD.get(i).getTaskId()) {
result = BD.get(i).getResult();
System.out.println("show your result ");
BD.remove(i);
}
}
return result;
}
}