use of edu.iu.dsc.tws.executor.model.Task in project twister2 by DSC-SPIDAL.
the class BlockQueueMain method main.
public static void main(String[] args) throws InterruptedException {
BlockingQueue q1 = new PriorityBlockingQueue();
BlockingQueue q = new ArrayBlockingQueue(5);
Task task1 = new Task(1001, "Task 1", new Date(), "scripts/task_scripts/run-task1.sh", "Thread 1");
Task task2 = new Task(1002, "Task 2", new Date(), "scripts/task_scripts/run-task2.sh", "Thread 1");
Task task3 = new Task(1003, "Task 3", new Date(), "scripts/task_scripts/run-task3.sh", "Thread 1");
Task task4 = new Task(1004, "Task 4", new Date(), "scripts/task_scripts/run-task4.sh", "Thread 1");
Task task5 = new Task(1005, "Task 5", new Date(), "scripts/task_scripts/run-task5.sh", "Thread 1");
ArrayList<Task> taskArrayList = new ArrayList<>();
taskArrayList.add(task1);
taskArrayList.add(task2);
taskArrayList.add(task3);
taskArrayList.add(task4);
taskArrayList.add(task5);
// Demo Pub/Sup BlockingQueue
/*Producer p = new Producer(q);
Consumer c1 = new Consumer(q);
Consumer c2 = new Consumer(q);
Thread t = new Thread(p);
t.start();
Thread t1 = new Thread(c1);
t1.start();
System.out.println("Consumer : "+t1.getState());
System.out.println("Producer : "+t.getState());
*/
// Producing and Consuming real resources
/*Producer p = new Producer(q, task1);
Consumer c1 = new Consumer(q);
Consumer c2 = new Consumer(q);
Thread t = new Thread(p);
t.start();
Thread t1 = new Thread(c1);
t1.start();
System.out.println("Consumer : "+t1.getState());
System.out.println("Producer : "+t.getState());
*/
// consuming list of tasks
StaticProducer p = new StaticProducer(q, taskArrayList, TaskOps.LIST);
p.create();
q = p.getQueue();
System.out.println("Generated Queue : " + q.size());
Consumer c1 = new Consumer(q, TaskOps.LIST);
// Consumer c2 = new Consumer(q, TaskOps.LIST);
Thread t1 = new Thread(c1);
t1.start();
System.out.println("Consumer : " + t1.getState());
}
use of edu.iu.dsc.tws.executor.model.Task in project twister2 by DSC-SPIDAL.
the class Producer method run.
public void run() {
try {
if (executableType == TaskOps.SINGLE) {
// queue.put(produce("Process : "+i+" - "+"Task Descriptor : "+i));
queue.put(produceTask(this.task));
}
if (executableType == TaskOps.LIST) {
int i = 0;
for (Task task : taskList) {
System.out.println("Task " + i + " executing");
queue.put(produceTask(task));
i++;
}
}
if (executableType == TaskOps.CONTINUES) {
}
} catch (InterruptedException ex) {
System.err.println(ex.getMessage());
}
}
use of edu.iu.dsc.tws.executor.model.Task in project twister2 by DSC-SPIDAL.
the class StaticProducer method create.
public void create() throws InterruptedException {
if (executableType == TaskOps.SINGLE) {
// queue.put(produce("Process : "+i+" - "+"Task Descriptor : "+i));
queue.put(produceTask(this.task));
}
if (executableType == TaskOps.LIST) {
int i = 0;
for (Task task : taskList) {
System.out.println("Task " + i + " executing");
queue.put(produceTask(task));
i++;
}
}
if (executableType == TaskOps.CONTINUES) {
}
}
use of edu.iu.dsc.tws.executor.model.Task in project twister2 by DSC-SPIDAL.
the class TaskManager method run.
@Override
public void run() {
System.out.println("Running Task Manager : Thread Id = " + this.threadId);
taskHandler.addTask(new Task(1000, "Task 1", new Date(), "Demo Task 1 to handle the queue", threadId));
// taskHandler.addTask(new Task(1002,"Task 2", new Date(), "Demo Task 2 to handle the queue",threadId));
// taskHandler.addTask(new Task(1003,"Task 3", new Date(), "Demo Task 3 to handle the queue",threadId));
}
Aggregations