All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.scudata.dm.UnitTasks Maven / Gradle / Ivy

Go to download

SPL(Structured Process Language) A programming language specially for structured data computing.

There is a newer version: 20241126
Show newest version
package com.scudata.dm;

import java.util.ArrayList;

import com.scudata.common.MessageManager;
import com.scudata.parallel.UnitClient;
import com.scudata.resources.ParallelMessage;

/**
 * ??Ӧ??callx?Ķ??????
 * @author Joancy
 *
 */
public class UnitTasks {
	ArrayList uts = new ArrayList();
	static MessageManager mm = ParallelMessage.get();
	
	/**
	 * ???캯??
	 * @param ucs ?ڵ???б?
	 * @throws Exception ????????ӳ??쳣
	 */
	public UnitTasks(ArrayList ucs) throws Exception{
		int len = ucs.size();
		for(int i=0;i ucIndexes){
		UnitTask ut = getMaxCapacityUT(ucIndexes);
		int prefer = ut.preferredNum;
		ut.addTaskNum(prefer);
		return ut.getUnitClient();
	}
	
	/**
	 * ??ȡ?ڵ?????
	 * utIndexΪ Sequence?????õ?1??ʼ????ţ?????????Ҫ??ȥ1
	 * @param utIndex
	 * @return
	 */
	public UnitTask getUnitTask(int utIndex){
		return uts.get(utIndex-1);
	}

	/**
	 * ʵ?ִ????ӿ?
	 */
	public String toString(){
		StringBuffer sb = new StringBuffer();
		for(UnitTask ut:uts){
			if(sb.length()>0){
				sb.append(",");
			}
			sb.append(ut);
		}
		return sb.toString();
	}
	/**
	 * ??ȡ??ָ????Χ?Ļ??????ҳ?????????Ľڵ?????
	 * ?÷??????ؽڵ?????󣬲??Զ????ӽڵ??????????????Ҫ??????
	 * UnitTask.addTaskNum(n)??????????
	 * @param ucIndexes??ָ????Χ?ķֻ?????б?
	 * @return ?ڵ?????
	 */
	public UnitTask getMaxCapacityUT(ArrayList ucIndexes){
		if(ucIndexes==null){
			return getMaxCapacityUT();
		}
		UnitTask ut = uts.get(ucIndexes.get(0));
		double c = ut.capacity();
		for(int i=1;ic){
				c = dc;
				ut = tmp;
			}
		}
		return ut;
	}
	
	/**
	 * ?ڵ?ǰȫ????Χ?Ļ??????ҳ?????????
	 * @return ?ڵ?????
	 */
	public UnitTask getMaxCapacityUT(){
		UnitTask ut = uts.get(0);
		double c = ut.capacity();
		for(int i=1;ic){
				c = dc;
				ut = tmp;
			}
		}
		return ut;
	}
	
	
	class UnitTask{
		int preferredNum = 0;
		int currentNum = 0;
		UnitClient uc;
		
		UnitTask(UnitClient uc) throws Exception{
			this.uc = uc;
			if(uc!=null){
				int[] tasks = uc.getTaskNums();
				preferredNum = tasks[0];
				currentNum = tasks[1];
			}
		}
		
		UnitClient getUnitClient(){
			return uc;
		}
		
		public String toString(){
			return uc.toString();
		}
		
		double capacity(){
			return preferredNum*1.0f/(currentNum+0.5f);
		}
		
		public void addTaskNum(int tasks){
			currentNum += tasks;
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy