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