Index: DCWoRMS/trunk/src/example/localplugin/coolemall/recs/RECS_Random_SP.java
===================================================================
--- DCWoRMS/trunk/src/example/localplugin/coolemall/recs/RECS_Random_SP.java	(revision 851)
+++ DCWoRMS/trunk/src/example/localplugin/coolemall/recs/RECS_Random_SP.java	(revision 851)
@@ -0,0 +1,76 @@
+package example.localplugin.coolemall.recs;
+
+import java.util.List;
+import java.util.Random;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.UserResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class RECS_Random_SP extends BaseLocalSchedulingPlugin {
+
+	private Random rand;
+	
+	public RECS_Random_SP () {
+		rand = new Random(47);
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					String nodeName = chooseRandomProvider(resourceManager);
+					if (nodeName != null) {
+						addToSchedulingPlan(plan, task, nodeName);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private String chooseRandomProvider(ClusterResourceManager resourceManager) {
+		List<ComputingResource> nodes = null;
+		try {
+			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(new UserResourceType("Node"));
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		int nodeIdx = rand.nextInt(nodes.size());
+		return nodes.get(nodeIdx).getName();
+	}
+
+}
+
Index: DCWoRMS/trunk/src/example/localplugin/coolemall/recs/RECS_LB_SP.java
===================================================================
--- DCWoRMS/trunk/src/example/localplugin/coolemall/recs/RECS_LB_SP.java	(revision 851)
+++ DCWoRMS/trunk/src/example/localplugin/coolemall/recs/RECS_LB_SP.java	(revision 851)
@@ -0,0 +1,90 @@
+package example.localplugin.coolemall.recs;
+
+import java.util.List;
+
+import schedframe.events.scheduling.SchedulingEvent;
+import schedframe.exceptions.ResourceException;
+import schedframe.resources.UserResourceType;
+import schedframe.resources.computing.ComputingResource;
+import schedframe.resources.computing.recs.Node;
+import schedframe.scheduling.manager.resources.ClusterResourceManager;
+import schedframe.scheduling.manager.resources.ResourceManager;
+import schedframe.scheduling.manager.tasks.JobRegistry;
+import schedframe.scheduling.manager.tasks.JobRegistryImpl;
+import schedframe.scheduling.plan.SchedulingPlanInterface;
+import schedframe.scheduling.plan.impl.SchedulingPlan;
+import schedframe.scheduling.plugin.grid.ModuleList;
+import schedframe.scheduling.queue.TaskQueue;
+import schedframe.scheduling.queue.TaskQueueList;
+import schedframe.scheduling.tasks.TaskInterface;
+import example.localplugin.BaseLocalSchedulingPlugin;
+import gridsim.dcworms.DCWormsTags;
+
+public class RECS_LB_SP extends BaseLocalSchedulingPlugin {
+
+	public RECS_LB_SP () {
+	}
+
+	public SchedulingPlanInterface<?> schedule(SchedulingEvent event, TaskQueueList queues, JobRegistry jobRegistry,
+			 ResourceManager resManager, ModuleList modules) {
+
+		ClusterResourceManager resourceManager = (ClusterResourceManager) resManager;
+		SchedulingPlan plan = new SchedulingPlan();
+		// choose the events types to serve.
+		// Different actions for different events are possible.
+		switch (event.getType()) {
+		case START_TASK_EXECUTION:
+		case TASK_FINISHED:
+		//case TIMER:
+			// our tasks are placed only in first queue (see
+			// BaseLocalSchedulingPlugin.placeJobsInQueues() method)
+			TaskQueue q = queues.get(0);
+			
+			// check all tasks in queue
+			for (int i = 0; i < q.size(); i++) {
+				TaskInterface<?> task = q.get(i);
+				// if status of the tasks in READY
+				if (task.getStatus() == DCWormsTags.READY) {
+
+					String nodeName = chooseProvider(resourceManager);
+					if (nodeName != null) {
+						addToSchedulingPlan(plan, task, nodeName);
+					}
+				}
+			}
+			break;
+		}
+		return plan;
+	}
+
+	@SuppressWarnings("unchecked")
+	private String chooseProvider(ClusterResourceManager resourceManager) {
+		List<ComputingResource> nodes = null;
+		try {
+			nodes = (List<ComputingResource>) resourceManager.getResourcesOfType(new UserResourceType("Node"));
+		} catch (ResourceException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		int nodeIdx = findLeastLoadedResourceIdx(nodes);
+		return nodes.get(nodeIdx).getName();
+	}
+	
+	private int findLeastLoadedResourceIdx(List<ComputingResource> nodes ){
+		int resourceIdx = -1;
+		int minLoad = Integer.MAX_VALUE;
+		
+		for(int i = 0; i < nodes.size(); i++){
+			Node node = (Node) nodes.get(i);
+			JobRegistry jr = new JobRegistryImpl(node.getName());
+			int totalLoad = jr.getRunningTasks().size(); 
+			if(totalLoad < minLoad){
+				resourceIdx = i;
+				minLoad = totalLoad;
+			}
+		}
+		return resourceIdx;
+	}
+
+}
+
