com.scudata.server.unit.UnitServer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of esproc Show documentation
Show all versions of esproc Show documentation
SPL(Structured Process Language) A programming language specially for structured data computing.
package com.scudata.server.unit;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.UUID;
import com.scudata.app.common.Section;
import com.scudata.app.config.RaqsoftConfig;
import com.scudata.common.*;
import com.scudata.dm.*;
import com.scudata.ide.common.AppFrame;
import com.scudata.parallel.*;
import com.scudata.resources.ParallelMessage;
import com.scudata.server.IServer;
import com.scudata.server.StartUnitListener;
import java.text.*;
/**
* ??ͼ?η?????
* ???ܵ???GM??ide???࣬ ?ֻ?
*
* @author Joancy
*
*/
public class UnitServer implements IServer {
public static UnitServer instance;
public static String version = AppFrame.RELEASE_DATE;
ServerSocket serverSocket = null;
UnitContext unitContext=null;
TempFileMonitor tempFileMonitor = null;
ProxyMonitor proxyMonitor;
private volatile boolean stop = true;
// exe????ʱָ??????
private String specifyHost=null;
private int specifyPort = 0;
StartUnitListener listener = null;
HostManager hostManager = HostManager.instance();
private RaqsoftConfig rc = null;
private static Object initLock = new Object();
private static boolean isIniting = false;
private static Response initResult = new Response();
/**
* ???û???????
*/
public void setRaqsoftConfig(RaqsoftConfig rc){
this.rc = rc;
}
/**
* ??ȡ???????????ö???
*/
public RaqsoftConfig getRaqsoftConfig(){
return rc;
}
/**
* ???÷?????״̬??????
*/
public void setStartUnitListener(StartUnitListener listen){
listener = listen;
}
/**
* ??ȡ???㻷????????
* @return
*/
public UnitContext getUnitContext() {
return unitContext;
}
static int objectId = 0;
static Object idLock = new Object();
private UnitServer(){
}
private UnitServer(String host, int port) throws Exception{
this.specifyHost = host;
this.specifyPort = port;
}
/**
* ?ֻ????????ڲ?????Ψһ???
* ???ڴ????ŵȸ??ֲ???ͬ?ŵĵط?
* @return ????????Ψһ???
*/
public static int nextId() {
synchronized (idLock) {
int c = ++objectId;
if (c == Integer.MAX_VALUE) {
objectId = 1;
c = 1;
}
return c;
}
}
/**
* ????ڴ?ռ???ʣ????ڵ???
* @param msg ??ʾ????Ϣ
*/
public static void debugMemory(String msg) {
DecimalFormat df = new DecimalFormat("###,###");
System.gc();
long tmp = Runtime.getRuntime().freeMemory();
String buf = ParallelMessage.get().getMessage("UnitServer.memory",msg,df.format(tmp / 1024));
Logger.debug( buf );
}
private String getArgDesc(List argValues) {
if (argValues == null || argValues.size() == 0) {
return "";
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < argValues.size(); i++) {
if (i > 0) {
sb.append(";");
}
sb.append(argValues.get(i));
}
return sb.toString();
}
/**
* ִ?зֻ???????
* @param req ???????
* @return ??Ӧ???
*/
public Response execute(Request req) {
Response res = new Response();
switch (req.getAction()) {
case Request.SERVER_LISTTASK:
List list = TaskManager.getTaskList();
Table table = new Table(new String[] {"Port", "TaskId", "SPLXName",
"ArgDesc", "BeginTime", "FinishTime" });
for (int i = 0; i < list.size(); i++) {
Task t = (Task) list.get(i);
if (t.getFinishTime() > 0 || t.isProcessCaller()) {
continue;
}
table.newLast(new Object[] { hostManager.getPort(), new Integer(t.getTaskID()),
t.getDfxName(), getArgDesc(t.getArgList()),
new Long(t.getCallTime()), new Long(t.getFinishTime()) });
}
res.setResult(table);
break;
case Request.SERVER_LISTPARAM:
Table tableParam = new Table(new String[] {"Port", "SpaceName", "ParamName","ParamValue"});
HashMap hm = JobSpaceManager.listSpaceParams();
Iterator it = hm.keySet().iterator();
while (it.hasNext()) {
String id = it.next();
Param[] params = hm.get(id);
if (params != null)
for (int i = 0; i < params.length; i++) {
Param p = params[i];
tableParam.newLast(new Object[] { hostManager.getPort(), id,
p.getName(),p.getValue() });
}
}
ParamList gList = Env.getParamList();
for(int i=0;i args = new ArrayList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy