parent
3a86783da5
commit
b8ca6891d2
File diff suppressed because it is too large
Load Diff
@ -1,142 +1,138 @@
|
||||
package eva2.server;
|
||||
/*
|
||||
* Title: EvA2
|
||||
* Description:
|
||||
* Copyright: Copyright (c) 2003
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
|
||||
* @version: $Revision: 320 $
|
||||
* $Date: 2007-12-06 16:05:11 +0100 (Thu, 06 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
* Title: EvA2 Description: Copyright: Copyright (c) 2003 Company: University of
|
||||
* Tuebingen, Computer Architecture @author Holger Ulmer, Felix Streichert,
|
||||
* Hannes Planatscher @version: $Revision: 320 $ $Date: 2007-12-06 16:05:11
|
||||
* +0100 (Thu, 06 Dec 2007) $ $Author: mkron $
|
||||
*/
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import eva2.EvAInfo;
|
||||
import java.io.*;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class EvAServer {
|
||||
public static boolean TRACE = false;
|
||||
/* MainAdapterImp object. This is need for the first
|
||||
connection between the server and the client program. */
|
||||
public EvAMainAdapter m_MainRemoteObject;
|
||||
//private EvAComAdapter m_ComAdapter;
|
||||
public static String m_UserName;
|
||||
public static int m_NumberOfVM =0;
|
||||
private RMIServerEvA m_RMIServer;
|
||||
/**
|
||||
* Constructor of EvAServer.
|
||||
* Calls RMIConnection().
|
||||
*/
|
||||
public EvAServer(boolean insideClient, boolean Restart) {
|
||||
System.out.println ("Number of CPUs :" +Runtime.getRuntime().availableProcessors());
|
||||
// m_InsideClient = insideClient;
|
||||
// m_Restart = Restart;
|
||||
System.out.println ("*******************************************************************************");
|
||||
System.out.println ("This is EvA Server Version: "+ EvAInfo.getVersion());
|
||||
//System.out.println ("Java Version: " + System.getProperty("java.version") );
|
||||
System.out.println ("*******************************************************************************");
|
||||
m_UserName = System.getProperty("user.name");
|
||||
/*
|
||||
* MainAdapterImp object. This is need for the first connection between the
|
||||
* server and the client program.
|
||||
*/
|
||||
public EvAMainAdapter m_MainRemoteObject;
|
||||
//private EvAComAdapter m_ComAdapter;
|
||||
public static String m_UserName;
|
||||
public static int m_NumberOfVM = 0;
|
||||
private RMIServerEvA m_RMIServer;
|
||||
|
||||
/**
|
||||
* Constructor of EvAServer. Calls RMIConnection().
|
||||
*/
|
||||
public EvAServer(boolean insideClient, boolean Restart) {
|
||||
System.out.println("Number of CPUs :" + Runtime.getRuntime().availableProcessors());
|
||||
System.out.println("*******************************************************************************");
|
||||
System.out.println("This is EvA Server Version: " + EvAInfo.getVersion());
|
||||
//System.out.println ("Java Version: " + System.getProperty("java.version") );
|
||||
System.out.println("*******************************************************************************");
|
||||
m_UserName = System.getProperty("user.name");
|
||||
// RMIConnection();
|
||||
// m_ComAdapter = new EvAComAdapter();
|
||||
// RMIProxyRemote.setComAdaper(m_ComAdapter);
|
||||
m_RMIServer = RMIServerEvA.getInstance();
|
||||
}
|
||||
/**
|
||||
* Main method of this class.
|
||||
* Is the starting point of the server application.
|
||||
*/
|
||||
static public void main ( String[] args ){
|
||||
boolean Restart = false;
|
||||
boolean nomulti = false;
|
||||
for (int i=0;i<args.length;i++) {
|
||||
System.out.println("args = "+args[i]);
|
||||
if (args[i].equals("restart"))
|
||||
Restart = true;
|
||||
if (args[i].equals("nomulti"))
|
||||
nomulti = true;
|
||||
m_RMIServer = RMIServerEvA.getInstance();
|
||||
}
|
||||
|
||||
}
|
||||
//Runtime.getRuntime().addShutdownHook(new ExitThread());
|
||||
if (Restart== true) {
|
||||
String MyHostName = "Host";
|
||||
try {
|
||||
MyHostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (Exception e) {
|
||||
System.out.println("ERROR getting HostName (EvAServer.main) "+e.getMessage());
|
||||
}
|
||||
try {Thread.sleep(2000);}
|
||||
catch(Exception e) {
|
||||
System.out.println("Error in sleep of ExitThread");
|
||||
}
|
||||
try {
|
||||
System.setOut(new PrintStream(
|
||||
new FileOutputStream(MyHostName+"_server.txt")));
|
||||
} catch (Exception e) {
|
||||
System.out.println("System.setOut"+e.getMessage());
|
||||
}
|
||||
}
|
||||
EvAServer Application = new EvAServer(false,Restart); // false => started not inside the client, solo server
|
||||
/**
|
||||
* Main method of this class. Is the starting point of the server
|
||||
* application.
|
||||
*/
|
||||
static public void main(String[] args) {
|
||||
boolean restart = false;
|
||||
boolean noMulti = false;
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
System.out.println("args = " + args[i]);
|
||||
if (args[i].equals("restart")) {
|
||||
restart = true;
|
||||
}
|
||||
if (args[i].equals("nomulti")) {
|
||||
noMulti = true;
|
||||
}
|
||||
|
||||
}
|
||||
//Runtime.getRuntime().addShutdownHook(new ExitThread());
|
||||
if (restart == true) {
|
||||
String hostName = "Host";
|
||||
try {
|
||||
hostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
System.out.println("ERROR getting HostName (EvAServer.main) " + e.getMessage());
|
||||
}
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Error in sleep of ExitThread");
|
||||
}
|
||||
|
||||
try {
|
||||
System.setOut(new PrintStream(
|
||||
new FileOutputStream(hostName + "_server.txt")));
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("System.setOut" + e.getMessage());
|
||||
}
|
||||
}
|
||||
EvAServer evaServer = new EvAServer(false, restart); // false => started not inside the client, solo server
|
||||
// if (nomulti==false)
|
||||
// Application.multiServers(1);
|
||||
// evaServer.multiServers(1);
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void multiServers(int size) {
|
||||
for (int i =0;i<size;i++) {
|
||||
try {Thread.sleep(4000);}
|
||||
catch(Exception e) {
|
||||
System.out.println("Error in sleep of ExitThread");
|
||||
}
|
||||
if (TRACE) System.out.println(" start multiServers int i= "+i);
|
||||
try {
|
||||
String cmd = "java -cp \".\" eva2.server.EvAServer nomulti";
|
||||
System.out.println("Calling the command:"+cmd);
|
||||
Process pro = Runtime.getRuntime().exec(cmd);
|
||||
//Process pro = Runtime.getRuntime().exec("server");
|
||||
BufferedReader in = new BufferedReader ( new InputStreamReader (pro.getInputStream()));
|
||||
//pro
|
||||
String line = null;
|
||||
while (true) {
|
||||
while((line = in.readLine()) != null ) {
|
||||
System.out.println(line);
|
||||
}
|
||||
}
|
||||
//System.out.println("");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error in calling the command:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public RMIServerEvA getRMIServer() {
|
||||
return m_RMIServer;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private int getNumberOfVM(String[] list) {
|
||||
int ret = 0;
|
||||
for (int i=0;i<list.length;i++) {
|
||||
if (list[i].indexOf(EvAMainAdapterImpl.MAIN_ADAPTER_NAME)!= -1)
|
||||
ret++;
|
||||
}
|
||||
if (TRACE) System.out.println(" getNumberOfVM() NumberOfVM ="+ret);
|
||||
return ret;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void multiServers(int size) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException e) {
|
||||
System.out.println("Error in sleep of ExitThread");
|
||||
}
|
||||
try {
|
||||
String cmd = "java -cp \".\" eva2.server.EvAServer nomulti";
|
||||
System.out.println("Calling the command:" + cmd);
|
||||
Process pro = Runtime.getRuntime().exec(cmd);
|
||||
//Process pro = Runtime.getRuntime().exec("server");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(pro.getInputStream()));
|
||||
//pro
|
||||
String line = null;
|
||||
while (true) {
|
||||
while ((line = in.readLine()) != null) {
|
||||
System.out.println(line);
|
||||
}
|
||||
}
|
||||
//System.out.println("");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Error in calling the command:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public RMIServerEvA getRMIServer() {
|
||||
return m_RMIServer;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private int getNumberOfVM(String[] list) {
|
||||
int ret = 0;
|
||||
for (int i = 0; i < list.length; i++) {
|
||||
if (list[i].indexOf(EvAMainAdapterImpl.MAIN_ADAPTER_NAME) != -1) {
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,11 @@
|
||||
package eva2.server.go.operators.constraint;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import eva2.gui.GenericObjectEditor;
|
||||
import eva2.server.go.individuals.AbstractEAIndividual;
|
||||
import eva2.server.go.operators.paramcontrol.ConstantParameters;
|
||||
import eva2.server.go.operators.paramcontrol.GenericParamAdaption;
|
||||
import eva2.server.go.operators.paramcontrol.InterfaceParameterControl;
|
||||
import eva2.server.go.operators.paramcontrol.NoParamAdaption;
|
||||
import eva2.server.go.operators.paramcontrol.ParamAdaption;
|
||||
import eva2.server.go.operators.paramcontrol.ParameterControlManager;
|
||||
import eva2.server.go.operators.paramcontrol.*;
|
||||
import eva2.server.go.problems.AbstractProblemDouble;
|
||||
import eva2.tools.EVAERROR;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* An abstract constraint contains a penalty factor with control strategy (for dynamic penalties)
|
||||
|
@ -1,8 +1,7 @@
|
||||
package eva2.tools.jproxy;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/*
|
||||
* ==========================================================================*
|
||||
@ -17,7 +16,6 @@ public class XThread extends Thread implements Serializable {
|
||||
private static XThread[] m_Instances;
|
||||
private static int m_MAXinstances = 10;
|
||||
private static int m_index = 0;
|
||||
public static boolean TRACE = false;
|
||||
|
||||
public static void init(int x) {
|
||||
m_MAXinstances = x;
|
||||
@ -47,8 +45,7 @@ public class XThread extends Thread implements Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static XThread getXThread(Object x, Method m, Object[] Para, int MAXinstances) {
|
||||
if (TRACE) System.out.println("getXThread2 CALLLED");
|
||||
public static XThread getXThread(Object x, Method m, Object[] Para, int MAXinstances) {
|
||||
//System.out.println("waiting "+m_instances+ " on "+x.hashCode()+ " m "+m.getName()+" m_MAXinstances " +MAXinstances);
|
||||
XThread ret = null;
|
||||
if (m_Instances == null)
|
||||
@ -88,46 +85,12 @@ public class XThread extends Thread implements Serializable {
|
||||
}
|
||||
|
||||
} // end of while true
|
||||
|
||||
// int i=1;
|
||||
// while (m_instances >= MAXinstances) {
|
||||
// // if (i>200)
|
||||
// // System.out.println(i+ " waiting "+m_instances+ " on "+x.hashCode()+ " m "+m.getName()+" m_MAXinstances " +MAXinstances);
|
||||
// // pleasewait();
|
||||
// try {
|
||||
// Thread.sleep(i);
|
||||
// i=2*i; //System.out.println(""+i);
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Error in sleep of XThread");
|
||||
// }
|
||||
// }
|
||||
// instup();//m_instances++;
|
||||
// if (
|
||||
// XThread ret = new XThread(x, m, Para);
|
||||
// // m_ThreadContainer.add(ret);
|
||||
// return ret;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static XThread getXThread(Object x, String m, Object[] Para, int MAXinstances) {
|
||||
if (TRACE) System.out.println("getXThread1 CALLLED");
|
||||
// while (m_instances >= MAXinstances) {
|
||||
// //System.out.println("waiting "+m_instances);
|
||||
// //pleasewait();
|
||||
// try {
|
||||
// Thread.sleep(50);
|
||||
// } catch (Exception e) {
|
||||
// System.out.println("Error in sleep of XThread");
|
||||
// }
|
||||
// }
|
||||
// instup(); //m_instances++;
|
||||
// //System.out.println("XThread ++"+m_instances+" m_MAXinstances " +m_MAXinstances);
|
||||
// XThread ret = new XThread(x, Method, Para);
|
||||
// // m_ThreadContainer.add(ret);
|
||||
// return ret;
|
||||
XThread ret = null;
|
||||
if (m_Instances == null)
|
||||
init(MAXinstances);
|
||||
@ -169,27 +132,10 @@ public class XThread extends Thread implements Serializable {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
// public static synchronized void pleasewait() {
|
||||
// for (int i = 0; i < m_ThreadContainer.size(); i++) {
|
||||
// try {
|
||||
// if (((Thread) m_ThreadContainer.get(i)).isAlive()==false)
|
||||
// m_ThreadContainer.remove(i);
|
||||
// } catch (InterruptedException e) {
|
||||
// e.printStackTrace();
|
||||
// System.out.println("Error");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private void removemyself() {
|
||||
for (int i = 0; i < m_Instances.length; i++) {
|
||||
// if (TRACE) System.out.println("TRYING TO REMOVE");
|
||||
if (this.m_Instances[i] == this) {
|
||||
this.m_Instances[i] = null;
|
||||
if (TRACE) System.out.println("REMOVED THREAD");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -199,7 +145,6 @@ public class XThread extends Thread implements Serializable {
|
||||
*
|
||||
*/
|
||||
private XThread(Object object, Method method, Object[] Para) {
|
||||
if (TRACE) System.out.println("XTHREAD INSTANZIERT");
|
||||
m_Object = object;
|
||||
m_Para = Para;
|
||||
m_Method = method;
|
||||
@ -210,7 +155,6 @@ public class XThread extends Thread implements Serializable {
|
||||
*
|
||||
*/
|
||||
private XThread(Object x, String method, Object[] Para) {
|
||||
if (TRACE) System.out.println("XTHREAD INSTANZIERT");
|
||||
m_Object = x;
|
||||
m_Para = Para;
|
||||
try {
|
||||
@ -232,18 +176,10 @@ public class XThread extends Thread implements Serializable {
|
||||
*
|
||||
*/
|
||||
public void run() {
|
||||
if (TRACE) System.out.println("XTHREAD CALLED RUN on " + this);
|
||||
if (m_Method != null) {
|
||||
//setPriority(Thread.MAX_PRIORITY);
|
||||
try {
|
||||
if (TRACE) System.out.println("XTHREAD calling m_Method "+m_Method.getName());
|
||||
//System.out.print("--->");
|
||||
//this.setPriority(Thread.MAX_PRIORITY);
|
||||
m_Method.invoke(m_Object, m_Para);
|
||||
|
||||
//instdown(); //m_instances--;
|
||||
//System.out.println("<--");
|
||||
//System.out.println("XThread --"+m_instances+" m_MAXinstances " +m_MAXinstances);
|
||||
} catch (Exception e) {
|
||||
System.err.println("ERROR +" + e.getMessage());
|
||||
e.printStackTrace();
|
||||
|
Loading…
x
Reference in New Issue
Block a user