@@ -1,18 +1,12 @@
|
||||
package eva2.client;
|
||||
|
||||
/*
|
||||
* Title: EvA2
|
||||
* Description: The main client class of the EvA framework.
|
||||
* Copyright: Copyright (c) 2008
|
||||
* Company: University of Tuebingen, Computer Architecture
|
||||
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher
|
||||
* @version: $Revision: 322 $
|
||||
* $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec 2007) $
|
||||
* $Author: mkron $
|
||||
* Title: EvA2 Description: The main client class of the EvA framework.
|
||||
* Copyright: Copyright (c) 2008 Company: University of Tuebingen, Computer
|
||||
* Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher
|
||||
* @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec
|
||||
* 2007) $ $Author: mkron $
|
||||
*/
|
||||
/*==========================================================================*
|
||||
* IMPORTS
|
||||
*==========================================================================*/
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Event;
|
||||
@@ -82,6 +76,7 @@ import eva2.tools.jproxy.RemoteStateListener;
|
||||
*
|
||||
*/
|
||||
public class EvAClient implements RemoteStateListener, Serializable {
|
||||
|
||||
/**
|
||||
* Generated serial version identifier.
|
||||
*/
|
||||
@@ -89,12 +84,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
private final int splashScreenTime = 1500;
|
||||
private final int maxWindowMenuLength = 30;
|
||||
private boolean clientInited = false;
|
||||
|
||||
public static boolean TRACE = false;
|
||||
|
||||
public JEFrame m_Frame;
|
||||
Runnable initRnbl = null;
|
||||
|
||||
private Runnable initRnbl = null;
|
||||
private EvAComAdapter m_ComAdapter;
|
||||
private transient JMenuBar m_barMenu;
|
||||
private transient JExtMenu m_mnuAbout;
|
||||
@@ -103,15 +94,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
private transient JExtMenu m_mnuWindow;
|
||||
private transient JExtMenu m_mnuOptions;
|
||||
private transient JProgressBar m_ProgressBar;
|
||||
|
||||
// public ArrayList m_ModulGUIContainer = new ArrayList();
|
||||
// LogPanel
|
||||
private LogPanel m_LogPanel;
|
||||
|
||||
// Module:
|
||||
private ExtAction m_actModuleLoad;
|
||||
// GUI:
|
||||
|
||||
// Hosts:
|
||||
private ExtAction m_actHost;
|
||||
private ExtAction m_actAvailableHost;
|
||||
@@ -121,11 +109,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
// About:
|
||||
private ExtAction m_actAbout;
|
||||
private ExtAction m_actLicense;
|
||||
|
||||
// private JPanel m_panelTool;
|
||||
// private FrameCloseListener m_frameCloseListener;
|
||||
// private JFileChooser m_FileChooser;
|
||||
|
||||
// if not null, the module is loaded automatically and no other can be selected
|
||||
private String useDefaultModule = null;//"Genetic_Optimization";
|
||||
private boolean showLoadModules = false;
|
||||
@@ -137,27 +123,29 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
private long startTime = 0;
|
||||
// remember the module in use
|
||||
private transient String currentModule = null;
|
||||
|
||||
Vector<RemoteStateListener> superListenerList = null;
|
||||
private boolean withGUI = true;
|
||||
private boolean withTreeView = false;
|
||||
private EvATabbedFrameMaker frmMkr = null;
|
||||
private EvATabbedFrameMaker frameMaker = null;
|
||||
|
||||
public void addRemoteStateListener(RemoteStateListener l) {
|
||||
if (superListenerList == null) superListenerList = new Vector<RemoteStateListener>();
|
||||
if (superListenerList == null) {
|
||||
superListenerList = new Vector<RemoteStateListener>();
|
||||
}
|
||||
superListenerList.add(l);
|
||||
}
|
||||
|
||||
public boolean removeRemoteStateListener(RemoteStateListener l) {
|
||||
if (superListenerList != null) {
|
||||
return superListenerList.remove(l);
|
||||
} else return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor of GUI of EvA2.
|
||||
* Works as client for the EvA2 server.
|
||||
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||
* Constructor of GUI of EvA2. Works as client for the EvA2 server. Note
|
||||
* that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||
* to await full initialization if necessary.
|
||||
*
|
||||
*/
|
||||
@@ -166,9 +154,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* A constructor. Splash screen is optional, Gui is activated, no parent window.
|
||||
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||
* to await full initialization if necessary.
|
||||
* A constructor. Splash screen is optional, Gui is activated, no parent
|
||||
* window. Note that the EvAClient initialized multi-threaded for
|
||||
* efficiency. Use {@link #awaitGuiInitialized()} to await full
|
||||
* initialization if necessary.
|
||||
*
|
||||
* @see #EvAClient(String, Window, String, boolean, boolean, boolean)
|
||||
* @param hostName
|
||||
@@ -181,9 +170,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* A constructor with optional spash screen.
|
||||
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||
* A constructor with optional spash screen. Note that the EvAClient is
|
||||
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||
* to await full initialization if necessary.
|
||||
*
|
||||
* @see #EvAClient(String, String, boolean, boolean)
|
||||
*
|
||||
* @param hostName
|
||||
@@ -195,8 +185,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* A constructor with optional splash screen.
|
||||
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||
* A constructor with optional splash screen. Note that the EvAClient
|
||||
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||
* to await full initialization if necessary.
|
||||
*
|
||||
* @see #EvAClient(String, String, boolean, boolean)
|
||||
@@ -211,8 +201,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* A constructor with optional splash screen.
|
||||
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||
* A constructor with optional splash screen. Note that the EvAClient
|
||||
* initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||
* to await full initialization if necessary.
|
||||
*
|
||||
* @see #EvAClient(String, String, boolean, boolean)
|
||||
@@ -243,13 +233,13 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Main constructor of the EvA2 client GUI. Works as standalone verson locally or
|
||||
* as client for the EvA2 server. GO parameters may be
|
||||
* loaded from a file (paramsFile) or given directly as a java instance. Both may be null
|
||||
* to start with standard parameters. If both are non null, the java instance has the
|
||||
* higher priority.
|
||||
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
|
||||
* to await full initialization if necessary.
|
||||
* Main constructor of the EvA2 client GUI. Works as standalone verson
|
||||
* locally or as client for the EvA2 server. GO parameters may be loaded
|
||||
* from a file (paramsFile) or given directly as a java instance. Both may
|
||||
* be null to start with standard parameters. If both are non null, the java
|
||||
* instance has the higher priority. Note that the EvAClient initialized
|
||||
* multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} to
|
||||
* await full initialization if necessary.
|
||||
*
|
||||
* @param hostName
|
||||
* @param parent
|
||||
@@ -271,9 +261,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
if (!noSplash && withGUI) {
|
||||
try {
|
||||
fSplashScreen.splash();
|
||||
} catch(HeadlessException e) {
|
||||
} catch (HeadlessException e) {
|
||||
System.err.println("Error: no xserver present - deactivating GUI.");
|
||||
withGUI=false;
|
||||
withGUI = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -281,29 +271,40 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
|
||||
m_ComAdapter = EvAComAdapter.getInstance();
|
||||
|
||||
SwingUtilities.invokeLater( initRnbl = new Runnable() {
|
||||
public void run(){
|
||||
SwingUtilities.invokeLater(initRnbl = new Runnable() {
|
||||
|
||||
public void run() {
|
||||
synchronized (this) {
|
||||
long startTime = System.currentTimeMillis();
|
||||
init(hostName, paramsFile, goParams, parent); // this takes a bit
|
||||
|
||||
long wait = System.currentTimeMillis() - startTime;
|
||||
if (!autorun) {
|
||||
if (!noSplash) try {
|
||||
if (!noSplash) {
|
||||
try {
|
||||
// if splashScreenTime has not passed, sleep some more
|
||||
if (wait < splashScreenTime) Thread.sleep(splashScreenTime - wait);
|
||||
} catch (Exception e) {}
|
||||
if (wait < splashScreenTime) {
|
||||
Thread.sleep(splashScreenTime - wait);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!withGUI && (currentModuleAdapter instanceof GenericModuleAdapter)) {
|
||||
// do not save new parameters for an autorun without GUI - they werent changed manually anyways.
|
||||
((GenericModuleAdapter) currentModuleAdapter).getStatistics().setSaveParams(false);
|
||||
System.out.println("Autorun without GUI - not saving statistics parameters...");
|
||||
}
|
||||
if (withGUI) frmMkr.onUserStart();
|
||||
else currentModuleAdapter.startOpt();
|
||||
if (withGUI) {
|
||||
frameMaker.onUserStart();
|
||||
} else {
|
||||
currentModuleAdapter.startOpt();
|
||||
}
|
||||
}
|
||||
// close splash screen
|
||||
if (!noSplash && withGUI) fSplashScreen.dispose();
|
||||
if (!noSplash && withGUI) {
|
||||
fSplashScreen.dispose();
|
||||
}
|
||||
clientInited = true;
|
||||
notify();
|
||||
}
|
||||
@@ -312,17 +313,17 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Since the constructor runs multi-threaded for efficiency, this method
|
||||
* may be called to await the full initialization of a client instance.
|
||||
* As soon as it returns, the EvAClient GUI is fully initialized.
|
||||
* Since the constructor runs multi-threaded for efficiency, this method may
|
||||
* be called to await the full initialization of a client instance. As soon
|
||||
* as it returns, the EvAClient GUI is fully initialized.
|
||||
*/
|
||||
public void awaitClientInitialized() {
|
||||
if (initRnbl!=null) {
|
||||
if (initRnbl != null) {
|
||||
synchronized (initRnbl) {
|
||||
if (!clientInited) {
|
||||
try {
|
||||
initRnbl.wait();
|
||||
initRnbl=null;
|
||||
initRnbl = null;
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -332,13 +333,13 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
private void preloadClasses() {
|
||||
ClassPreloader cp = new ClassPreloader( "eva2.server.go.strategies.InterfaceOptimizer", "eva2.server.go.problems.InterfaceOptimizationProblem", "eva2.server.go.InterfaceTerminator");
|
||||
ClassPreloader cp = new ClassPreloader("eva2.server.go.strategies.InterfaceOptimizer", "eva2.server.go.problems.InterfaceOptimizationProblem", "eva2.server.go.InterfaceTerminator");
|
||||
new Thread(cp).start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to start the optimization with current parameters on the loaded module.
|
||||
* Return true on success, otherwise false.
|
||||
* Try to start the optimization with current parameters on the loaded
|
||||
* module. Return true on success, otherwise false.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -346,7 +347,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
if (currentModuleAdapter != null) {
|
||||
currentModuleAdapter.startOpt();
|
||||
return true;
|
||||
} else return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -378,7 +381,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets given hostname and tries to load GOParamsters from given file if non null.
|
||||
* Sets given hostname and tries to load GOParamsters from given file if non
|
||||
* null.
|
||||
*/
|
||||
private void init(String hostName, String paramsFile, InterfaceGOParameters goParams, final Window parent) {
|
||||
//EVA_EDITOR_PROPERTIES
|
||||
@@ -386,10 +390,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
|
||||
if (useDefaultModule != null) {
|
||||
useDefaultModule = useDefaultModule.trim();
|
||||
if (useDefaultModule.length() < 1) useDefaultModule = null;
|
||||
if (useDefaultModule.length() < 1) {
|
||||
useDefaultModule = null;
|
||||
}
|
||||
}
|
||||
|
||||
if (withGUI ) {
|
||||
if (withGUI) {
|
||||
m_Frame = new JEFrame(EvAInfo.productName + " workbench");
|
||||
m_Frame.setCloseAllOnClosed(true);
|
||||
m_Frame.setName(this.getClass().getSimpleName()); // the name is set to recognize the client window
|
||||
@@ -411,21 +417,26 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
m_ProgressBar = new JProgressBar();
|
||||
m_Frame.getContentPane().add(m_ProgressBar, BorderLayout.SOUTH);
|
||||
|
||||
if (EvAInfo.propShowModules() != null) showLoadModules = true;
|
||||
else showLoadModules = false; // may be set to true again if default module couldnt be loaded
|
||||
|
||||
if (EvAInfo.propShowModules() != null) {
|
||||
showLoadModules = true;
|
||||
} else {
|
||||
showLoadModules = false; // may be set to true again if default module couldnt be loaded
|
||||
}
|
||||
createActions();
|
||||
}
|
||||
if (useDefaultModule != null) {
|
||||
// if goParams are not defined and a params file is defined
|
||||
// try to load parameters from file
|
||||
if (goParams==null && (paramsFile!=null && (paramsFile.length()>0))) goParams = GOParameters.getInstance(paramsFile, false);
|
||||
if (goParams == null && (paramsFile != null && (paramsFile.length() > 0))) {
|
||||
goParams = GOParameters.getInstance(paramsFile, false);
|
||||
}
|
||||
loadModuleFromServer(useDefaultModule, goParams);//loadSpecificModule
|
||||
}
|
||||
|
||||
if (withGUI) {
|
||||
buildMenu();
|
||||
m_Frame.addWindowListener(new WindowAdapter() {
|
||||
|
||||
public void windowClosing(WindowEvent e) {
|
||||
System.out.println("Closing EvA2 Client. Bye!");
|
||||
m_Frame.dispose();
|
||||
@@ -433,14 +444,18 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
if (keys.contains("MATLAB")) {
|
||||
System.out.println("Seems like Ive been started from Matlab: not killing JVM");
|
||||
} else {
|
||||
if (parent == null) System.exit(1);
|
||||
if (parent == null) {
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (m_ComAdapter != null) {
|
||||
if (hostName != null) selectHost(hostName);
|
||||
if (hostName != null) {
|
||||
selectHost(hostName);
|
||||
}
|
||||
m_ComAdapter.setLogPanel(m_LogPanel);
|
||||
logMessage("Selected Host: " + m_ComAdapter.getHostName());
|
||||
}
|
||||
@@ -449,11 +464,11 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
|
||||
if (withGUI) {
|
||||
m_LogPanel.logMessage("Working directory is: " + System.getProperty("user.dir"));
|
||||
m_LogPanel.logMessage("Class path is: " + System.getProperty("java.class.path","."));
|
||||
m_LogPanel.logMessage("Class path is: " + System.getProperty("java.class.path", "."));
|
||||
|
||||
if (!(m_Frame.isVisible())) {
|
||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||
m_Frame.setLocation((int)((screenSize.width-m_Frame.getWidth())/2), (int)((screenSize.height-m_Frame.getHeight())/2.5));
|
||||
m_Frame.setLocation((int) ((screenSize.width - m_Frame.getWidth()) / 2), (int) ((screenSize.height - m_Frame.getHeight()) / 2.5));
|
||||
m_Frame.pack();
|
||||
m_Frame.setVisible(true);
|
||||
}
|
||||
@@ -462,65 +477,61 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Refresh the parameter panels (if settings have been changed outside
|
||||
* of the GUI which should be updated in the GUI.
|
||||
* Refresh the parameter panels (if settings have been changed outside of
|
||||
* the GUI which should be updated in the GUI.
|
||||
*
|
||||
*/
|
||||
public void refreshMainPanels() {
|
||||
frmMkr.refreshPanels();
|
||||
frameMaker.refreshPanels();
|
||||
}
|
||||
|
||||
/**
|
||||
* The one and only main of the client program. Possible arguments:
|
||||
* --autorun immediately starts the optimization (with parameters loaded from current
|
||||
* directory if available.
|
||||
* --hostname HOST: sets the hostname for the EvAClient to HOST
|
||||
* --nosplash: skip the splash screen.
|
||||
* --params PFILE: load the optimization parameter from the serialized file PFILE
|
||||
* --autorun immediately starts the optimization (with parameters loaded
|
||||
* from current directory if available. --hostname HOST: sets the hostname
|
||||
* for the EvAClient to HOST --nosplash: skip the splash screen. --params
|
||||
* PFILE: load the optimization parameter from the serialized file PFILE
|
||||
*
|
||||
* @param args command line parameters
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
if (TRACE) {
|
||||
System.out.println(EVAHELP.getSystemPropertyString());
|
||||
}
|
||||
|
||||
String[] keys= new String[]{"--help", "--autorun", "--nosplash", "--nogui", "--remotehost", "--params", "--treeView"};
|
||||
String[] keys = new String[]{"--help", "--autorun", "--nosplash", "--nogui", "--remotehost", "--params", "--treeView"};
|
||||
int[] arities = new int[]{0, 0, 0, 0, 1, 1, 0};
|
||||
Object[] values = new Object[keys.length];
|
||||
|
||||
Integer[] unknownArgs = StringTools.parseArguments(args, keys, arities, values, true);
|
||||
|
||||
if (unknownArgs.length>0) {
|
||||
if (unknownArgs.length > 0) {
|
||||
System.err.println("Unrecognized command line options: ");
|
||||
for (int i=0; i<unknownArgs.length; i++) System.err.println(" " + args[unknownArgs[i]]);
|
||||
if (values[0]==null) System.err.println("Try --help as argument.");
|
||||
for (int i = 0; i < unknownArgs.length; i++) {
|
||||
System.err.println(" " + args[unknownArgs[i]]);
|
||||
}
|
||||
if (values[0] == null) {
|
||||
System.err.println("Try --help as argument.");
|
||||
}
|
||||
}
|
||||
|
||||
if (values[0]!=null) {
|
||||
if (values[0] != null) {
|
||||
System.out.println(usage());
|
||||
} else {
|
||||
boolean autorun=(values[1]!=null);
|
||||
boolean nosplash=(values[2]!=null);
|
||||
boolean nogui=(values[3]!=null);
|
||||
boolean treeView=(values[6]!=null);
|
||||
String hostName=StringTools.checkSingleStringArg(keys[4], values[4], arities[4]-1);
|
||||
String paramsFile=StringTools.checkSingleStringArg(keys[5], values[5], arities[5]-1);
|
||||
boolean autorun = (values[1] != null);
|
||||
boolean nosplash = (values[2] != null);
|
||||
boolean nogui = (values[3] != null);
|
||||
boolean treeView = (values[6] != null);
|
||||
String hostName = StringTools.checkSingleStringArg(keys[4], values[4], arities[4] - 1);
|
||||
String paramsFile = StringTools.checkSingleStringArg(keys[5], values[5], arities[5] - 1);
|
||||
|
||||
if (TRACE) System.out.println("Command line arguments were: ");
|
||||
if (TRACE) System.out.println(" " + BeanInspector.toString(keys));
|
||||
if (TRACE) System.out.println(" " + BeanInspector.toString(values));
|
||||
new EvAClient(hostName, paramsFile, autorun, nosplash, nogui, treeView);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialize the client GUI with given parameters and set
|
||||
* listeners. This will return as soon as the GUI is visible and ready.
|
||||
* Initialize the client GUI with given parameters and set listeners. This
|
||||
* will return as soon as the GUI is visible and ready.
|
||||
*
|
||||
* @param goParams optimization parameters
|
||||
* @param statisticsListener statistics listener receiving data during optimization
|
||||
* @param statisticsListener statistics listener receiving data during
|
||||
* optimization
|
||||
* @param windowListener additional window listener for client frame
|
||||
*/
|
||||
public static EvAClient initClientGUI(GOParameters goParams,
|
||||
@@ -581,6 +592,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
/////////////////////////////////////////////////////////////
|
||||
m_actModuleLoad = new ExtAction("&Load", "Load Module",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
loadModuleFromServer(null, null);
|
||||
}
|
||||
@@ -588,6 +600,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
|
||||
m_actAbout = new ExtAction("&About...", "Product Information",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
logMessage(e.getActionCommand());
|
||||
showAboutDialog();
|
||||
@@ -595,6 +608,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
};
|
||||
m_actLicense = new ExtAction("&License...", "View License",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
logMessage(e.getActionCommand());
|
||||
showLicense();
|
||||
@@ -602,6 +616,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
};
|
||||
m_actHost = new ExtAction("&List of all servers", "All servers in list",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
logMessage(e.getActionCommand());
|
||||
selectAvailableHost(m_ComAdapter.getHostNameList());
|
||||
@@ -609,10 +624,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
};
|
||||
m_actAvailableHost = new ExtAction("Available &Server", "Available server",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)) {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
logMessage(e.getActionCommand());
|
||||
showPleaseWaitDialog();
|
||||
Thread xx = new Thread() {
|
||||
|
||||
public void run() {
|
||||
selectAvailableHost(m_ComAdapter.getAvailableHostNameList());
|
||||
}
|
||||
@@ -622,10 +639,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
};
|
||||
m_actKillHost = new ExtAction("&Kill server", "Kill server process on selected host",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
logMessage(e.getActionCommand());
|
||||
showPleaseWaitDialog();
|
||||
Thread xx = new Thread() {
|
||||
|
||||
public void run() {
|
||||
selectAvailableHostToKill(m_ComAdapter.getAvailableHostNameList());
|
||||
}
|
||||
@@ -635,10 +654,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
};
|
||||
m_actKillAllHosts = new ExtAction("Kill &all servers", "Kill all servers",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
logMessage(e.getActionCommand());
|
||||
showPleaseWaitDialog();
|
||||
Thread xx = new Thread() {
|
||||
|
||||
public void run() {
|
||||
selectAllAvailableHostToKill(m_ComAdapter.getAvailableHostNameList());
|
||||
}
|
||||
@@ -646,13 +667,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
xx.start();
|
||||
}
|
||||
};
|
||||
/* m_actStartServerManager = new ExtAction("Start &Server Manager", "Start &Server Manager",
|
||||
KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)){
|
||||
public void actionPerformed(ActionEvent e){
|
||||
m_LogPanel.logMessage(e.getActionCommand());
|
||||
ServerStartFrame sm = new ServerStartFrame(m_ComAdapter.getHostNameList());
|
||||
}
|
||||
};
|
||||
/*
|
||||
* m_actStartServerManager = new ExtAction("Start &Server Manager",
|
||||
* "Start &Server Manager", KeyStroke.getKeyStroke(KeyEvent.VK_S,
|
||||
* Event.CTRL_MASK)){ public void actionPerformed(ActionEvent e){
|
||||
* m_LogPanel.logMessage(e.getActionCommand()); ServerStartFrame sm =
|
||||
* new ServerStartFrame(m_ComAdapter.getHostNameList()); } };
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -666,6 +686,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
|
||||
m_mnuWindow = new JExtMenu("&Window");
|
||||
m_mnuWindow.addMenuListener(new MenuListener() {
|
||||
|
||||
public void menuSelected(MenuEvent e) {
|
||||
// System.out.println("Selected");
|
||||
m_mnuWindow.removeAll();
|
||||
@@ -677,6 +698,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
final JFrame x = ((JEFrame) framelist[i]);
|
||||
|
||||
act.addActionListener((new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (!x.isActive()) {
|
||||
x.setExtendedState(JFrame.NORMAL);
|
||||
@@ -687,20 +709,23 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
}
|
||||
}));
|
||||
if (curMenu.getItemCount()>=maxWindowMenuLength) {
|
||||
if (curMenu.getItemCount() >= maxWindowMenuLength) {
|
||||
JExtMenu subMenu = new JExtMenu("&More...");
|
||||
curMenu.add(new JSeparator());
|
||||
curMenu.add(subMenu);
|
||||
curMenu=subMenu;
|
||||
curMenu = subMenu;
|
||||
}
|
||||
curMenu.add(act);
|
||||
}
|
||||
String[] commonPrefixes = JEFrameRegister.getCommonPrefixes(10);
|
||||
if (commonPrefixes.length > 0) m_mnuWindow.add(new JSeparator());
|
||||
for (int i=0; i<commonPrefixes.length; i++) {
|
||||
if (commonPrefixes.length > 0) {
|
||||
m_mnuWindow.add(new JSeparator());
|
||||
}
|
||||
for (int i = 0; i < commonPrefixes.length; i++) {
|
||||
final String prefix = commonPrefixes[i];
|
||||
JMenuItem act = new JMenuItem("Close all of " + prefix + "...");
|
||||
act.addActionListener((new ActionListener() {
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JEFrameRegister.closeAllByPrefix(prefix);
|
||||
}
|
||||
@@ -709,12 +734,13 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void menuCanceled(MenuEvent e) {
|
||||
}
|
||||
|
||||
public void menuDeselected(MenuEvent e) {
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
m_mnuSelHosts = new JExtMenu("&Select Hosts");
|
||||
@@ -752,8 +778,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
protected void logMessage(String msg) {
|
||||
if (TRACE || m_LogPanel == null) System.out.println(msg);
|
||||
if (m_LogPanel != null) m_LogPanel.logMessage(msg);
|
||||
if (m_LogPanel != null) {
|
||||
m_LogPanel.logMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -778,7 +805,6 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
} else {
|
||||
localMode = false;
|
||||
if (TRACE) logMessage("Using RMI on m_ComAdapter.getHostName()");
|
||||
m_ComAdapter.setRunLocally(false);
|
||||
}
|
||||
if (selectedModule == null) { // show a dialog and ask for a module
|
||||
@@ -787,7 +813,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
JOptionPane.showMessageDialog(m_Frame.getContentPane(), "No modules available on " + m_ComAdapter.getHostName(), EvAInfo.infoTitle, 1);
|
||||
} else {
|
||||
String LastModuleName = Serializer.loadString("lastmodule.ser");
|
||||
if (LastModuleName == null) LastModuleName = ModuleNameList[0];
|
||||
if (LastModuleName == null) {
|
||||
LastModuleName = ModuleNameList[0];
|
||||
}
|
||||
selectedModule = (String) JOptionPane.showInputDialog(m_Frame.getContentPane(),
|
||||
"Which module do you want \n to load on host: " + m_ComAdapter.getHostName() + " ?", "Load optimization module on host",
|
||||
JOptionPane.QUESTION_MESSAGE,
|
||||
@@ -813,7 +841,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the GOParamters of a loaded module. Return null if no module is loaded.
|
||||
* Retrieve the GOParamters of a loaded module. Return null if no module is
|
||||
* loaded.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@@ -842,7 +871,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
public boolean isOptRunning() {
|
||||
if ((currentModuleAdapter != null) && (currentModuleAdapter instanceof AbstractModuleAdapter)) {
|
||||
return ((AbstractModuleAdapter) currentModuleAdapter).isOptRunning();
|
||||
} else return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void loadSpecificModule(String selectedModule, InterfaceGOParameters goParams) {
|
||||
@@ -858,7 +889,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
if (newModuleAdapter == null) {
|
||||
// When launching a Java Web Start application, baseDir will always be null!
|
||||
URL baseDir = getClass().getClassLoader().getResource("");
|
||||
String cp = System.getProperty("java.class.path",".");
|
||||
String cp = System.getProperty("java.class.path", ".");
|
||||
String dir = (baseDir == null) ? System.getProperty("user.dir") : baseDir.getPath();
|
||||
// System.err.println("Working dir: " + dir);
|
||||
if (baseDir == null) {
|
||||
@@ -875,19 +906,18 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
return;
|
||||
}
|
||||
showLoadModules = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
newModuleAdapter.setConnection(!localMode);
|
||||
if (m_ComAdapter.isRunLocally()) {
|
||||
// TODO in rmi-mode this doesnt work yet! meaning e.g. that theres no content in the info log
|
||||
newModuleAdapter.addRemoteStateListener((RemoteStateListener)this);
|
||||
newModuleAdapter.addRemoteStateListener((RemoteStateListener) this);
|
||||
}
|
||||
try {
|
||||
if (withGUI) {
|
||||
// this (or rather: EvAModuleButtonPanelMaker) is where the start button etc come from!
|
||||
frmMkr = newModuleAdapter.getModuleFrame();
|
||||
frameMaker = newModuleAdapter.getModuleFrame();
|
||||
// newModuleAdapter.setLogPanel(m_LogPanel);
|
||||
JPanel moduleContainer = frmMkr.makePanel(); // MK the main frame is actually painted in here
|
||||
JPanel moduleContainer = frameMaker.makePanel(); // MK the main frame is actually painted in here
|
||||
|
||||
boolean wasVisible = m_Frame.isVisible();
|
||||
m_Frame.setVisible(false);
|
||||
@@ -898,13 +928,13 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
infoPanel.setLayout(new BorderLayout());
|
||||
infoPanel.add(m_ProgressBar, BorderLayout.SOUTH);
|
||||
infoPanel.add(m_LogPanel, BorderLayout.NORTH);
|
||||
JComponent tree=null;
|
||||
JComponent tree = null;
|
||||
|
||||
if (withTreeView && (newModuleAdapter instanceof AbstractModuleAdapter)) {
|
||||
tree = getEvATreeView(frmMkr.getGOPanel(), "GOParameters", ((AbstractModuleAdapter)newModuleAdapter).getGOParameters());
|
||||
tree = getEvATreeView(frameMaker.getGOPanel(), "GOParameters", ((AbstractModuleAdapter) newModuleAdapter).getGOParameters());
|
||||
m_Frame.add(tree, BorderLayout.WEST);
|
||||
}
|
||||
m_Frame.add(frmMkr.getToolBar(), BorderLayout.NORTH);
|
||||
m_Frame.add(frameMaker.getToolBar(), BorderLayout.NORTH);
|
||||
m_Frame.add(moduleContainer, BorderLayout.CENTER);
|
||||
//m_Frame.add(m_ProgressBar, BorderLayout.CENTER);
|
||||
//m_Frame.add(m_LogPanel, BorderLayout.SOUTH);
|
||||
@@ -957,18 +987,20 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
// parameters to update the tree
|
||||
return treeView;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void selectAvailableHost(String[] HostNames) {
|
||||
if (TRACE) System.out.println("SelectAvailableHost");
|
||||
if (HostNames == null || HostNames.length == 0) {
|
||||
showNoHostFoundDialog();
|
||||
} else {
|
||||
String HostName = (String) JOptionPane.showInputDialog(m_Frame.getContentPane(),
|
||||
"Which active host do you want to connect to?", "Host", JOptionPane.QUESTION_MESSAGE, null,
|
||||
HostNames, m_ComAdapter.getHostName());
|
||||
if (HostName != null) selectHost(HostName);
|
||||
if (HostName != null) {
|
||||
selectHost(HostName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -979,10 +1011,6 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
logMessage("Reloading module from server...");
|
||||
loadModuleFromServer(currentModule, null);
|
||||
}
|
||||
|
||||
// m_mnuModule.setText("Select module");
|
||||
// m_mnuModule.repaint();
|
||||
// System.out.println(HostName + " selected");
|
||||
}
|
||||
|
||||
private void showPleaseWaitDialog() {
|
||||
@@ -990,14 +1018,13 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
private void showAboutDialog() {
|
||||
JOptionPane.showMessageDialog
|
||||
(m_Frame,
|
||||
EvAInfo.productName + " - " + EvAInfo.productLongName +
|
||||
"\nUniversity of Tuebingen, T\u00FCbingen, Germany\nChair for Cognitive Systems\n" +
|
||||
"Dr. M. Kronfeld, H. Planatscher, M. de Paly, Dr. A. Dr\u00E4ger,\n" +
|
||||
"Dr. F. Streichert, Dr. H. Ulmer, and Prof. Dr. A. Zell \nCoypright \u00A9 " +
|
||||
EvAInfo.copyrightYear + "\nVersion " + EvAInfo.getVersion()+
|
||||
"\nSee: " + EvAInfo.url, EvAInfo.infoTitle, 1);
|
||||
JOptionPane.showMessageDialog(m_Frame,
|
||||
EvAInfo.productName + " - " + EvAInfo.productLongName
|
||||
+ "\nUniversity of Tuebingen, T\u00FCbingen, Germany\nChair for Cognitive Systems\n"
|
||||
+ "Dr. M. Kronfeld, H. Planatscher, M. de Paly, Dr. A. Dr\u00E4ger,\n"
|
||||
+ "Dr. F. Streichert, Dr. H. Ulmer, and Prof. Dr. A. Zell \nCoypright \u00A9 "
|
||||
+ EvAInfo.copyrightYear + "\nVersion " + EvAInfo.getVersion()
|
||||
+ "\nSee: " + EvAInfo.url, EvAInfo.infoTitle, 1);
|
||||
}
|
||||
|
||||
private void showLicense() {
|
||||
@@ -1012,7 +1039,6 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
private void selectAvailableHostToKill(String[] HostNames) {
|
||||
if (TRACE) System.out.println("SelectAvailableHostToKill");
|
||||
if (HostNames == null || HostNames.length == 0) {
|
||||
showNoHostFoundDialog();
|
||||
return;
|
||||
@@ -1020,8 +1046,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
String HostName = (String) JOptionPane.showInputDialog(m_Frame.getContentPane(),
|
||||
"Which server do you want to be killed ?", "Host", JOptionPane.QUESTION_MESSAGE, null,
|
||||
HostNames, m_ComAdapter.getHostName());
|
||||
if (HostName == null)
|
||||
if (HostName == null) {
|
||||
return;
|
||||
}
|
||||
logMessage("Kill host process on = " + HostName);
|
||||
m_ComAdapter.killServer(HostName);
|
||||
// m_LogPanel.statusMessage("");
|
||||
@@ -1037,43 +1064,55 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
public void performedRestart(String infoString) {
|
||||
if (superListenerList != null) for (RemoteStateListener l : superListenerList) {
|
||||
if (superListenerList != null) {
|
||||
for (RemoteStateListener l : superListenerList) {
|
||||
l.performedRestart(infoString);
|
||||
}
|
||||
}
|
||||
logMessage("Restarted processing " + infoString);
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void performedStart(String infoString) {
|
||||
if (superListenerList != null) for (RemoteStateListener l : superListenerList) {
|
||||
if (superListenerList != null) {
|
||||
for (RemoteStateListener l : superListenerList) {
|
||||
l.performedStart(infoString);
|
||||
}
|
||||
}
|
||||
logMessage("Started processing " + infoString);
|
||||
startTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void performedStop() {
|
||||
if (superListenerList != null) for (RemoteStateListener l : superListenerList) {
|
||||
if (superListenerList != null) {
|
||||
for (RemoteStateListener l : superListenerList) {
|
||||
l.performedStop();
|
||||
}
|
||||
}
|
||||
long t = (System.currentTimeMillis() - startTime);
|
||||
logMessage(String.format("Stopped after %1$d.%2$tL s", (t / 1000), (t % 1000)));
|
||||
if (!withGUI) System.exit(0);
|
||||
if (!withGUI) {
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* When the worker needs to update the GUI we do so by queuing
|
||||
* a Runnable for the event dispatching thread with
|
||||
* SwingUtilities.invokeLater(). In this case we're just
|
||||
* changing the progress bars value.
|
||||
* When the worker needs to update the GUI we do so by queuing a Runnable
|
||||
* for the event dispatching thread with SwingUtilities.invokeLater(). In
|
||||
* this case we're just changing the progress bars value.
|
||||
*/
|
||||
public void updateProgress(final int percent, String msg) {
|
||||
if (superListenerList != null) for (RemoteStateListener l : superListenerList) {
|
||||
if (superListenerList != null) {
|
||||
for (RemoteStateListener l : superListenerList) {
|
||||
l.updateProgress(percent, msg);
|
||||
}
|
||||
if (msg != null) logMessage(msg);
|
||||
}
|
||||
if (msg != null) {
|
||||
logMessage(msg);
|
||||
}
|
||||
if (this.m_ProgressBar != null) {
|
||||
Runnable doSetProgressBarValue = new Runnable() {
|
||||
|
||||
public void run() {
|
||||
m_ProgressBar.setValue(percent);
|
||||
}
|
||||
@@ -1084,6 +1123,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
|
||||
}
|
||||
|
||||
final class SplashScreenShell {
|
||||
|
||||
SplashScreen splScr = null;
|
||||
String imgLoc = null;
|
||||
|
||||
@@ -1097,14 +1137,15 @@ final class SplashScreenShell {
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (splScr!=null) {
|
||||
if (splScr != null) {
|
||||
splScr.dispose();
|
||||
splScr=null;
|
||||
splScr = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SplashScreen extends Frame {
|
||||
|
||||
private static final long serialVersionUID = 1281793825850423095L;
|
||||
String imgLocation;
|
||||
|
||||
@@ -1116,11 +1157,12 @@ class SplashScreen extends Frame {
|
||||
* Show the splash screen to the end user.
|
||||
*
|
||||
* <P>Once this method returns, the splash screen is realized, which means
|
||||
* that almost all work on the splash screen should proceed through the event
|
||||
* dispatch thread. In particular, any call to <code>dispose</code> for the
|
||||
* splash screen must be performed in the event dispatch thread.
|
||||
* that almost all work on the splash screen should proceed through the
|
||||
* event dispatch thread. In particular, any call to
|
||||
* <code>dispose</code> for the splash screen must be performed in the event
|
||||
* dispatch thread.
|
||||
*/
|
||||
public void splash(){
|
||||
public void splash() {
|
||||
JWindow splashWindow = new JWindow(this);
|
||||
BasicResourceLoader loader = BasicResourceLoader.instance();
|
||||
byte[] bytes = loader.getBytesFromResourceLocation(imgLocation, true);
|
||||
@@ -1132,5 +1174,4 @@ class SplashScreen extends Frame {
|
||||
splashWindow.setLocation(screenSize.width / 2 - splashWindow.getSize().width / 2, screenSize.height / 2 - splashWindow.getSize().height / 2);
|
||||
splashWindow.setVisible(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,121 +1,117 @@
|
||||
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. */
|
||||
/*
|
||||
* 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;
|
||||
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());
|
||||
// m_InsideClient = insideClient;
|
||||
// m_Restart = Restart;
|
||||
System.out.println ("*******************************************************************************");
|
||||
System.out.println ("This is EvA Server Version: "+ EvAInfo.getVersion());
|
||||
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 ("*******************************************************************************");
|
||||
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.
|
||||
* 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;
|
||||
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 MyHostName = "Host";
|
||||
if (restart == true) {
|
||||
String hostName = "Host";
|
||||
try {
|
||||
MyHostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (Exception e) {
|
||||
System.out.println("ERROR getting HostName (EvAServer.main) "+e.getMessage());
|
||||
hostName = InetAddress.getLocalHost().getHostName();
|
||||
} catch (UnknownHostException e) {
|
||||
System.out.println("ERROR getting HostName (EvAServer.main) " + e.getMessage());
|
||||
}
|
||||
try {Thread.sleep(2000);}
|
||||
catch(Exception e) {
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
} catch (InterruptedException 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());
|
||||
new FileOutputStream(hostName + "_server.txt")));
|
||||
} catch (FileNotFoundException e) {
|
||||
System.out.println("System.setOut" + e.getMessage());
|
||||
}
|
||||
}
|
||||
EvAServer Application = new EvAServer(false,Restart); // false => started not inside the client, solo server
|
||||
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) {
|
||||
for (int i = 0; i < size; i++) {
|
||||
try {
|
||||
Thread.sleep(4000);
|
||||
} catch (InterruptedException 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);
|
||||
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()));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(pro.getInputStream()));
|
||||
//pro
|
||||
String line = null;
|
||||
while (true) {
|
||||
while((line = in.readLine()) != null ) {
|
||||
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());
|
||||
System.out.println("Error in calling the command:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -125,18 +121,18 @@ public class EvAServer {
|
||||
*/
|
||||
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)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -48,7 +46,6 @@ 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");
|
||||
//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();
|
||||
|
||||
Reference in New Issue
Block a user