Some more fixups.
This commit is contained in:
2012-04-13 15:12:35 +00:00
parent 3a86783da5
commit b8ca6891d2
4 changed files with 1143 additions and 1176 deletions

View File

@@ -1,18 +1,12 @@
package eva2.client; package eva2.client;
/* /*
* Title: EvA2 * Title: EvA2 Description: The main client class of the EvA framework.
* Description: The main client class of the EvA framework. * Copyright: Copyright (c) 2008 Company: University of Tuebingen, Computer
* Copyright: Copyright (c) 2008 * Architecture @author Holger Ulmer, Felix Streichert, Hannes Planatscher
* Company: University of Tuebingen, Computer Architecture * @version: $Revision: 322 $ $Date: 2007-12-11 17:24:07 +0100 (Tue, 11 Dec
* @author Holger Ulmer, Felix Streichert, Hannes Planatscher * 2007) $ $Author: mkron $
* @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.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Event; import java.awt.Event;
@@ -82,6 +76,7 @@ import eva2.tools.jproxy.RemoteStateListener;
* *
*/ */
public class EvAClient implements RemoteStateListener, Serializable { public class EvAClient implements RemoteStateListener, Serializable {
/** /**
* Generated serial version identifier. * Generated serial version identifier.
*/ */
@@ -89,12 +84,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
private final int splashScreenTime = 1500; private final int splashScreenTime = 1500;
private final int maxWindowMenuLength = 30; private final int maxWindowMenuLength = 30;
private boolean clientInited = false; private boolean clientInited = false;
public static boolean TRACE = false;
public JEFrame m_Frame; public JEFrame m_Frame;
Runnable initRnbl = null; private Runnable initRnbl = null;
private EvAComAdapter m_ComAdapter; private EvAComAdapter m_ComAdapter;
private transient JMenuBar m_barMenu; private transient JMenuBar m_barMenu;
private transient JExtMenu m_mnuAbout; private transient JExtMenu m_mnuAbout;
@@ -103,15 +94,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
private transient JExtMenu m_mnuWindow; private transient JExtMenu m_mnuWindow;
private transient JExtMenu m_mnuOptions; private transient JExtMenu m_mnuOptions;
private transient JProgressBar m_ProgressBar; private transient JProgressBar m_ProgressBar;
// public ArrayList m_ModulGUIContainer = new ArrayList(); // public ArrayList m_ModulGUIContainer = new ArrayList();
// LogPanel // LogPanel
private LogPanel m_LogPanel; private LogPanel m_LogPanel;
// Module: // Module:
private ExtAction m_actModuleLoad; private ExtAction m_actModuleLoad;
// GUI: // GUI:
// Hosts: // Hosts:
private ExtAction m_actHost; private ExtAction m_actHost;
private ExtAction m_actAvailableHost; private ExtAction m_actAvailableHost;
@@ -121,11 +109,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
// About: // About:
private ExtAction m_actAbout; private ExtAction m_actAbout;
private ExtAction m_actLicense; private ExtAction m_actLicense;
// private JPanel m_panelTool; // private JPanel m_panelTool;
// private FrameCloseListener m_frameCloseListener; // private FrameCloseListener m_frameCloseListener;
// private JFileChooser m_FileChooser; // private JFileChooser m_FileChooser;
// if not null, the module is loaded automatically and no other can be selected // if not null, the module is loaded automatically and no other can be selected
private String useDefaultModule = null;//"Genetic_Optimization"; private String useDefaultModule = null;//"Genetic_Optimization";
private boolean showLoadModules = false; private boolean showLoadModules = false;
@@ -137,27 +123,29 @@ public class EvAClient implements RemoteStateListener, Serializable {
private long startTime = 0; private long startTime = 0;
// remember the module in use // remember the module in use
private transient String currentModule = null; private transient String currentModule = null;
Vector<RemoteStateListener> superListenerList = null; Vector<RemoteStateListener> superListenerList = null;
private boolean withGUI = true; private boolean withGUI = true;
private boolean withTreeView = false; private boolean withTreeView = false;
private EvATabbedFrameMaker frmMkr = null; private EvATabbedFrameMaker frameMaker = null;
public void addRemoteStateListener(RemoteStateListener l) { public void addRemoteStateListener(RemoteStateListener l) {
if (superListenerList == null) superListenerList = new Vector<RemoteStateListener>(); if (superListenerList == null) {
superListenerList = new Vector<RemoteStateListener>();
}
superListenerList.add(l); superListenerList.add(l);
} }
public boolean removeRemoteStateListener(RemoteStateListener l) { public boolean removeRemoteStateListener(RemoteStateListener l) {
if (superListenerList != null) { if (superListenerList != null) {
return superListenerList.remove(l); return superListenerList.remove(l);
} else return false; } else {
return false;
}
} }
/** /**
* Constructor of GUI of EvA2. * Constructor of GUI of EvA2. Works as client for the EvA2 server. Note
* Works as client for the EvA2 server. * that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary. * 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. * A constructor. Splash screen is optional, Gui is activated, no parent
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} * window. Note that the EvAClient initialized multi-threaded for
* to await full initialization if necessary. * efficiency. Use {@link #awaitGuiInitialized()} to await full
* initialization if necessary.
* *
* @see #EvAClient(String, Window, String, boolean, boolean, boolean) * @see #EvAClient(String, Window, String, boolean, boolean, boolean)
* @param hostName * @param hostName
@@ -181,9 +170,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
/** /**
* A constructor with optional spash screen. * A constructor with optional spash screen. Note that the EvAClient is
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} * initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary. * to await full initialization if necessary.
*
* @see #EvAClient(String, String, boolean, boolean) * @see #EvAClient(String, String, boolean, boolean)
* *
* @param hostName * @param hostName
@@ -195,8 +185,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
/** /**
* A constructor with optional splash screen. * A constructor with optional splash screen. Note that the EvAClient
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} * initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary. * to await full initialization if necessary.
* *
* @see #EvAClient(String, String, boolean, boolean) * @see #EvAClient(String, String, boolean, boolean)
@@ -211,8 +201,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
/** /**
* A constructor with optional splash screen. * A constructor with optional splash screen. Note that the EvAClient
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} * initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()}
* to await full initialization if necessary. * to await full initialization if necessary.
* *
* @see #EvAClient(String, String, boolean, boolean) * @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 * Main constructor of the EvA2 client GUI. Works as standalone verson
* as client for the EvA2 server. GO parameters may be * locally or as client for the EvA2 server. GO parameters may be loaded
* loaded from a file (paramsFile) or given directly as a java instance. Both may be null * from a file (paramsFile) or given directly as a java instance. Both may
* to start with standard parameters. If both are non null, the java instance has the * be null to start with standard parameters. If both are non null, the java
* higher priority. * instance has the higher priority. Note that the EvAClient initialized
* Note that the EvAClient initialized multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} * multi-threaded for efficiency. Use {@link #awaitGuiInitialized()} to
* to await full initialization if necessary. * await full initialization if necessary.
* *
* @param hostName * @param hostName
* @param parent * @param parent
@@ -282,6 +272,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
m_ComAdapter = EvAComAdapter.getInstance(); m_ComAdapter = EvAComAdapter.getInstance();
SwingUtilities.invokeLater(initRnbl = new Runnable() { SwingUtilities.invokeLater(initRnbl = new Runnable() {
public void run() { public void run() {
synchronized (this) { synchronized (this) {
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
@@ -289,21 +280,31 @@ public class EvAClient implements RemoteStateListener, Serializable {
long wait = System.currentTimeMillis() - startTime; long wait = System.currentTimeMillis() - startTime;
if (!autorun) { if (!autorun) {
if (!noSplash) try { if (!noSplash) {
try {
// if splashScreenTime has not passed, sleep some more // if splashScreenTime has not passed, sleep some more
if (wait < splashScreenTime) Thread.sleep(splashScreenTime - wait); if (wait < splashScreenTime) {
} catch (Exception e) {} Thread.sleep(splashScreenTime - wait);
}
} catch (Exception e) {
}
}
} else { } else {
if (!withGUI && (currentModuleAdapter instanceof GenericModuleAdapter)) { if (!withGUI && (currentModuleAdapter instanceof GenericModuleAdapter)) {
// do not save new parameters for an autorun without GUI - they werent changed manually anyways. // do not save new parameters for an autorun without GUI - they werent changed manually anyways.
((GenericModuleAdapter) currentModuleAdapter).getStatistics().setSaveParams(false); ((GenericModuleAdapter) currentModuleAdapter).getStatistics().setSaveParams(false);
System.out.println("Autorun without GUI - not saving statistics parameters..."); System.out.println("Autorun without GUI - not saving statistics parameters...");
} }
if (withGUI) frmMkr.onUserStart(); if (withGUI) {
else currentModuleAdapter.startOpt(); frameMaker.onUserStart();
} else {
currentModuleAdapter.startOpt();
}
} }
// close splash screen // close splash screen
if (!noSplash && withGUI) fSplashScreen.dispose(); if (!noSplash && withGUI) {
fSplashScreen.dispose();
}
clientInited = true; clientInited = true;
notify(); notify();
} }
@@ -312,9 +313,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
/** /**
* Since the constructor runs multi-threaded for efficiency, this method * Since the constructor runs multi-threaded for efficiency, this method may
* may be called to await the full initialization of a client instance. * be called to await the full initialization of a client instance. As soon
* As soon as it returns, the EvAClient GUI is fully initialized. * as it returns, the EvAClient GUI is fully initialized.
*/ */
public void awaitClientInitialized() { public void awaitClientInitialized() {
if (initRnbl != null) { if (initRnbl != null) {
@@ -337,8 +338,8 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
/** /**
* Try to start the optimization with current parameters on the loaded module. * Try to start the optimization with current parameters on the loaded
* Return true on success, otherwise false. * module. Return true on success, otherwise false.
* *
* @return * @return
*/ */
@@ -346,7 +347,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
if (currentModuleAdapter != null) { if (currentModuleAdapter != null) {
currentModuleAdapter.startOpt(); currentModuleAdapter.startOpt();
return true; 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) { private void init(String hostName, String paramsFile, InterfaceGOParameters goParams, final Window parent) {
//EVA_EDITOR_PROPERTIES //EVA_EDITOR_PROPERTIES
@@ -386,7 +390,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
if (useDefaultModule != null) { if (useDefaultModule != null) {
useDefaultModule = useDefaultModule.trim(); useDefaultModule = useDefaultModule.trim();
if (useDefaultModule.length() < 1) useDefaultModule = null; if (useDefaultModule.length() < 1) {
useDefaultModule = null;
}
} }
if (withGUI) { if (withGUI) {
@@ -411,21 +417,26 @@ public class EvAClient implements RemoteStateListener, Serializable {
m_ProgressBar = new JProgressBar(); m_ProgressBar = new JProgressBar();
m_Frame.getContentPane().add(m_ProgressBar, BorderLayout.SOUTH); m_Frame.getContentPane().add(m_ProgressBar, BorderLayout.SOUTH);
if (EvAInfo.propShowModules() != null) showLoadModules = true; if (EvAInfo.propShowModules() != null) {
else showLoadModules = false; // may be set to true again if default module couldnt be loaded showLoadModules = true;
} else {
showLoadModules = false; // may be set to true again if default module couldnt be loaded
}
createActions(); createActions();
} }
if (useDefaultModule != null) { if (useDefaultModule != null) {
// if goParams are not defined and a params file is defined // if goParams are not defined and a params file is defined
// try to load parameters from file // 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 loadModuleFromServer(useDefaultModule, goParams);//loadSpecificModule
} }
if (withGUI) { if (withGUI) {
buildMenu(); buildMenu();
m_Frame.addWindowListener(new WindowAdapter() { m_Frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) { public void windowClosing(WindowEvent e) {
System.out.println("Closing EvA2 Client. Bye!"); System.out.println("Closing EvA2 Client. Bye!");
m_Frame.dispose(); m_Frame.dispose();
@@ -433,14 +444,18 @@ public class EvAClient implements RemoteStateListener, Serializable {
if (keys.contains("MATLAB")) { if (keys.contains("MATLAB")) {
System.out.println("Seems like Ive been started from Matlab: not killing JVM"); System.out.println("Seems like Ive been started from Matlab: not killing JVM");
} else { } else {
if (parent == null) System.exit(1); if (parent == null) {
System.exit(1);
}
} }
} }
}); });
} }
if (m_ComAdapter != null) { if (m_ComAdapter != null) {
if (hostName != null) selectHost(hostName); if (hostName != null) {
selectHost(hostName);
}
m_ComAdapter.setLogPanel(m_LogPanel); m_ComAdapter.setLogPanel(m_LogPanel);
logMessage("Selected Host: " + m_ComAdapter.getHostName()); logMessage("Selected Host: " + m_ComAdapter.getHostName());
} }
@@ -462,29 +477,24 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
/** /**
* Refresh the parameter panels (if settings have been changed outside * Refresh the parameter panels (if settings have been changed outside of
* of the GUI which should be updated in the GUI. * the GUI which should be updated in the GUI.
* *
*/ */
public void refreshMainPanels() { public void refreshMainPanels() {
frmMkr.refreshPanels(); frameMaker.refreshPanels();
} }
/** /**
* The one and only main of the client program. Possible arguments: * The one and only main of the client program. Possible arguments:
* --autorun immediately starts the optimization (with parameters loaded from current * --autorun immediately starts the optimization (with parameters loaded
* directory if available. * from current directory if available. --hostname HOST: sets the hostname
* --hostname HOST: sets the hostname for the EvAClient to HOST * for the EvAClient to HOST --nosplash: skip the splash screen. --params
* --nosplash: skip the splash screen. * PFILE: load the optimization parameter from the serialized file PFILE
* --params PFILE: load the optimization parameter from the serialized file PFILE
* *
* @param args command line parameters * @param args command line parameters
*/ */
public static void main(String[] args) { 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}; int[] arities = new int[]{0, 0, 0, 0, 1, 1, 0};
Object[] values = new Object[keys.length]; Object[] values = new Object[keys.length];
@@ -493,8 +503,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
if (unknownArgs.length > 0) { if (unknownArgs.length > 0) {
System.err.println("Unrecognized command line options: "); System.err.println("Unrecognized command line options: ");
for (int i=0; i<unknownArgs.length; i++) System.err.println(" " + args[unknownArgs[i]]); for (int i = 0; i < unknownArgs.length; i++) {
if (values[0]==null) System.err.println("Try --help as argument."); 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) {
@@ -507,20 +521,17 @@ public class EvAClient implements RemoteStateListener, Serializable {
String hostName = StringTools.checkSingleStringArg(keys[4], values[4], arities[4] - 1); String hostName = StringTools.checkSingleStringArg(keys[4], values[4], arities[4] - 1);
String paramsFile = StringTools.checkSingleStringArg(keys[5], values[5], arities[5] - 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); new EvAClient(hostName, paramsFile, autorun, nosplash, nogui, treeView);
} }
} }
/** /**
* Initialize the client GUI with given parameters and set * Initialize the client GUI with given parameters and set listeners. This
* listeners. This will return as soon as the GUI is visible and ready. * will return as soon as the GUI is visible and ready.
* *
* @param goParams optimization parameters * @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 * @param windowListener additional window listener for client frame
*/ */
public static EvAClient initClientGUI(GOParameters goParams, public static EvAClient initClientGUI(GOParameters goParams,
@@ -581,6 +592,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
///////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////
m_actModuleLoad = new ExtAction("&Load", "Load Module", m_actModuleLoad = new ExtAction("&Load", "Load Module",
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
loadModuleFromServer(null, null); loadModuleFromServer(null, null);
} }
@@ -588,6 +600,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
m_actAbout = new ExtAction("&About...", "Product Information", m_actAbout = new ExtAction("&About...", "Product Information",
KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
showAboutDialog(); showAboutDialog();
@@ -595,6 +608,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
}; };
m_actLicense = new ExtAction("&License...", "View License", m_actLicense = new ExtAction("&License...", "View License",
KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_L, Event.CTRL_MASK)) {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
showLicense(); showLicense();
@@ -602,6 +616,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
}; };
m_actHost = new ExtAction("&List of all servers", "All servers in list", m_actHost = new ExtAction("&List of all servers", "All servers in list",
KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK)) {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
selectAvailableHost(m_ComAdapter.getHostNameList()); selectAvailableHost(m_ComAdapter.getHostNameList());
@@ -609,10 +624,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
}; };
m_actAvailableHost = new ExtAction("Available &Server", "Available server", m_actAvailableHost = new ExtAction("Available &Server", "Available server",
KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_H, Event.CTRL_MASK)) {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
showPleaseWaitDialog(); showPleaseWaitDialog();
Thread xx = new Thread() { Thread xx = new Thread() {
public void run() { public void run() {
selectAvailableHost(m_ComAdapter.getAvailableHostNameList()); 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", m_actKillHost = new ExtAction("&Kill server", "Kill server process on selected host",
KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
showPleaseWaitDialog(); showPleaseWaitDialog();
Thread xx = new Thread() { Thread xx = new Thread() {
public void run() { public void run() {
selectAvailableHostToKill(m_ComAdapter.getAvailableHostNameList()); selectAvailableHostToKill(m_ComAdapter.getAvailableHostNameList());
} }
@@ -635,10 +654,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
}; };
m_actKillAllHosts = new ExtAction("Kill &all servers", "Kill all servers", m_actKillAllHosts = new ExtAction("Kill &all servers", "Kill all servers",
KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) { KeyStroke.getKeyStroke(KeyEvent.VK_K, Event.CTRL_MASK)) {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
logMessage(e.getActionCommand()); logMessage(e.getActionCommand());
showPleaseWaitDialog(); showPleaseWaitDialog();
Thread xx = new Thread() { Thread xx = new Thread() {
public void run() { public void run() {
selectAllAvailableHostToKill(m_ComAdapter.getAvailableHostNameList()); selectAllAvailableHostToKill(m_ComAdapter.getAvailableHostNameList());
} }
@@ -646,13 +667,12 @@ public class EvAClient implements RemoteStateListener, Serializable {
xx.start(); xx.start();
} }
}; };
/* m_actStartServerManager = new ExtAction("Start &Server Manager", "Start &Server Manager", /*
KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK)){ * m_actStartServerManager = new ExtAction("Start &Server Manager",
public void actionPerformed(ActionEvent e){ * "Start &Server Manager", KeyStroke.getKeyStroke(KeyEvent.VK_S,
m_LogPanel.logMessage(e.getActionCommand()); * Event.CTRL_MASK)){ public void actionPerformed(ActionEvent e){
ServerStartFrame sm = new ServerStartFrame(m_ComAdapter.getHostNameList()); * 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 = new JExtMenu("&Window");
m_mnuWindow.addMenuListener(new MenuListener() { m_mnuWindow.addMenuListener(new MenuListener() {
public void menuSelected(MenuEvent e) { public void menuSelected(MenuEvent e) {
// System.out.println("Selected"); // System.out.println("Selected");
m_mnuWindow.removeAll(); m_mnuWindow.removeAll();
@@ -677,6 +698,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
final JFrame x = ((JEFrame) framelist[i]); final JFrame x = ((JEFrame) framelist[i]);
act.addActionListener((new ActionListener() { act.addActionListener((new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (!x.isActive()) { if (!x.isActive()) {
x.setExtendedState(JFrame.NORMAL); x.setExtendedState(JFrame.NORMAL);
@@ -696,11 +718,14 @@ public class EvAClient implements RemoteStateListener, Serializable {
curMenu.add(act); curMenu.add(act);
} }
String[] commonPrefixes = JEFrameRegister.getCommonPrefixes(10); String[] commonPrefixes = JEFrameRegister.getCommonPrefixes(10);
if (commonPrefixes.length > 0) m_mnuWindow.add(new JSeparator()); if (commonPrefixes.length > 0) {
m_mnuWindow.add(new JSeparator());
}
for (int i = 0; i < commonPrefixes.length; i++) { for (int i = 0; i < commonPrefixes.length; i++) {
final String prefix = commonPrefixes[i]; final String prefix = commonPrefixes[i];
JMenuItem act = new JMenuItem("Close all of " + prefix + "..."); JMenuItem act = new JMenuItem("Close all of " + prefix + "...");
act.addActionListener((new ActionListener() { act.addActionListener((new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
JEFrameRegister.closeAllByPrefix(prefix); JEFrameRegister.closeAllByPrefix(prefix);
} }
@@ -709,12 +734,13 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
} }
public void menuCanceled(MenuEvent e) { public void menuCanceled(MenuEvent e) {
} }
public void menuDeselected(MenuEvent e) { public void menuDeselected(MenuEvent e) {
} }
} });
);
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
m_mnuSelHosts = new JExtMenu("&Select Hosts"); m_mnuSelHosts = new JExtMenu("&Select Hosts");
@@ -752,8 +778,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
protected void logMessage(String msg) { protected void logMessage(String msg) {
if (TRACE || m_LogPanel == null) System.out.println(msg); if (m_LogPanel != null) {
if (m_LogPanel != null) m_LogPanel.logMessage(msg); m_LogPanel.logMessage(msg);
}
} }
/** /**
@@ -778,7 +805,6 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
} else { } else {
localMode = false; localMode = false;
if (TRACE) logMessage("Using RMI on m_ComAdapter.getHostName()");
m_ComAdapter.setRunLocally(false); m_ComAdapter.setRunLocally(false);
} }
if (selectedModule == null) { // show a dialog and ask for a module 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); JOptionPane.showMessageDialog(m_Frame.getContentPane(), "No modules available on " + m_ComAdapter.getHostName(), EvAInfo.infoTitle, 1);
} else { } else {
String LastModuleName = Serializer.loadString("lastmodule.ser"); 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(), 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", "Which module do you want \n to load on host: " + m_ComAdapter.getHostName() + " ?", "Load optimization module on host",
JOptionPane.QUESTION_MESSAGE, 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 * @return
*/ */
@@ -842,7 +871,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
public boolean isOptRunning() { public boolean isOptRunning() {
if ((currentModuleAdapter != null) && (currentModuleAdapter instanceof AbstractModuleAdapter)) { if ((currentModuleAdapter != null) && (currentModuleAdapter instanceof AbstractModuleAdapter)) {
return ((AbstractModuleAdapter) currentModuleAdapter).isOptRunning(); return ((AbstractModuleAdapter) currentModuleAdapter).isOptRunning();
} else return false; } else {
return false;
}
} }
private void loadSpecificModule(String selectedModule, InterfaceGOParameters goParams) { private void loadSpecificModule(String selectedModule, InterfaceGOParameters goParams) {
@@ -875,8 +906,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
return; return;
} }
showLoadModules = true; showLoadModules = true;
} } else {
else {
newModuleAdapter.setConnection(!localMode); newModuleAdapter.setConnection(!localMode);
if (m_ComAdapter.isRunLocally()) { if (m_ComAdapter.isRunLocally()) {
// TODO in rmi-mode this doesnt work yet! meaning e.g. that theres no content in the info log // TODO in rmi-mode this doesnt work yet! meaning e.g. that theres no content in the info log
@@ -885,9 +915,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
try { try {
if (withGUI) { if (withGUI) {
// this (or rather: EvAModuleButtonPanelMaker) is where the start button etc come from! // this (or rather: EvAModuleButtonPanelMaker) is where the start button etc come from!
frmMkr = newModuleAdapter.getModuleFrame(); frameMaker = newModuleAdapter.getModuleFrame();
// newModuleAdapter.setLogPanel(m_LogPanel); // 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(); boolean wasVisible = m_Frame.isVisible();
m_Frame.setVisible(false); m_Frame.setVisible(false);
@@ -901,10 +931,10 @@ public class EvAClient implements RemoteStateListener, Serializable {
JComponent tree = null; JComponent tree = null;
if (withTreeView && (newModuleAdapter instanceof AbstractModuleAdapter)) { 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(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(moduleContainer, BorderLayout.CENTER);
//m_Frame.add(m_ProgressBar, BorderLayout.CENTER); //m_Frame.add(m_ProgressBar, BorderLayout.CENTER);
//m_Frame.add(m_LogPanel, BorderLayout.SOUTH); //m_Frame.add(m_LogPanel, BorderLayout.SOUTH);
@@ -957,18 +987,20 @@ public class EvAClient implements RemoteStateListener, Serializable {
// parameters to update the tree // parameters to update the tree
return treeView; return treeView;
} }
/** /**
* *
*/ */
private void selectAvailableHost(String[] HostNames) { private void selectAvailableHost(String[] HostNames) {
if (TRACE) System.out.println("SelectAvailableHost");
if (HostNames == null || HostNames.length == 0) { if (HostNames == null || HostNames.length == 0) {
showNoHostFoundDialog(); showNoHostFoundDialog();
} else { } else {
String HostName = (String) JOptionPane.showInputDialog(m_Frame.getContentPane(), String HostName = (String) JOptionPane.showInputDialog(m_Frame.getContentPane(),
"Which active host do you want to connect to?", "Host", JOptionPane.QUESTION_MESSAGE, null, "Which active host do you want to connect to?", "Host", JOptionPane.QUESTION_MESSAGE, null,
HostNames, m_ComAdapter.getHostName()); 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..."); logMessage("Reloading module from server...");
loadModuleFromServer(currentModule, null); loadModuleFromServer(currentModule, null);
} }
// m_mnuModule.setText("Select module");
// m_mnuModule.repaint();
// System.out.println(HostName + " selected");
} }
private void showPleaseWaitDialog() { private void showPleaseWaitDialog() {
@@ -990,14 +1018,13 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
private void showAboutDialog() { private void showAboutDialog() {
JOptionPane.showMessageDialog JOptionPane.showMessageDialog(m_Frame,
(m_Frame, EvAInfo.productName + " - " + EvAInfo.productLongName
EvAInfo.productName + " - " + EvAInfo.productLongName + + "\nUniversity of Tuebingen, T\u00FCbingen, Germany\nChair for Cognitive Systems\n"
"\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. 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 "
"Dr. F. Streichert, Dr. H. Ulmer, and Prof. Dr. A. Zell \nCoypright \u00A9 " + + EvAInfo.copyrightYear + "\nVersion " + EvAInfo.getVersion()
EvAInfo.copyrightYear + "\nVersion " + EvAInfo.getVersion()+ + "\nSee: " + EvAInfo.url, EvAInfo.infoTitle, 1);
"\nSee: " + EvAInfo.url, EvAInfo.infoTitle, 1);
} }
private void showLicense() { private void showLicense() {
@@ -1012,7 +1039,6 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
private void selectAvailableHostToKill(String[] HostNames) { private void selectAvailableHostToKill(String[] HostNames) {
if (TRACE) System.out.println("SelectAvailableHostToKill");
if (HostNames == null || HostNames.length == 0) { if (HostNames == null || HostNames.length == 0) {
showNoHostFoundDialog(); showNoHostFoundDialog();
return; return;
@@ -1020,8 +1046,9 @@ public class EvAClient implements RemoteStateListener, Serializable {
String HostName = (String) JOptionPane.showInputDialog(m_Frame.getContentPane(), String HostName = (String) JOptionPane.showInputDialog(m_Frame.getContentPane(),
"Which server do you want to be killed ?", "Host", JOptionPane.QUESTION_MESSAGE, null, "Which server do you want to be killed ?", "Host", JOptionPane.QUESTION_MESSAGE, null,
HostNames, m_ComAdapter.getHostName()); HostNames, m_ComAdapter.getHostName());
if (HostName == null) if (HostName == null) {
return; return;
}
logMessage("Kill host process on = " + HostName); logMessage("Kill host process on = " + HostName);
m_ComAdapter.killServer(HostName); m_ComAdapter.killServer(HostName);
// m_LogPanel.statusMessage(""); // m_LogPanel.statusMessage("");
@@ -1037,43 +1064,55 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
public void performedRestart(String infoString) { public void performedRestart(String infoString) {
if (superListenerList != null) for (RemoteStateListener l : superListenerList) { if (superListenerList != null) {
for (RemoteStateListener l : superListenerList) {
l.performedRestart(infoString); l.performedRestart(infoString);
} }
}
logMessage("Restarted processing " + infoString); logMessage("Restarted processing " + infoString);
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
} }
public void performedStart(String infoString) { public void performedStart(String infoString) {
if (superListenerList != null) for (RemoteStateListener l : superListenerList) { if (superListenerList != null) {
for (RemoteStateListener l : superListenerList) {
l.performedStart(infoString); l.performedStart(infoString);
} }
}
logMessage("Started processing " + infoString); logMessage("Started processing " + infoString);
startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
} }
public void performedStop() { public void performedStop() {
if (superListenerList != null) for (RemoteStateListener l : superListenerList) { if (superListenerList != null) {
for (RemoteStateListener l : superListenerList) {
l.performedStop(); l.performedStop();
} }
}
long t = (System.currentTimeMillis() - startTime); long t = (System.currentTimeMillis() - startTime);
logMessage(String.format("Stopped after %1$d.%2$tL s", (t / 1000), (t % 1000))); 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 * When the worker needs to update the GUI we do so by queuing a Runnable
* a Runnable for the event dispatching thread with * for the event dispatching thread with SwingUtilities.invokeLater(). In
* SwingUtilities.invokeLater(). In this case we're just * this case we're just changing the progress bars value.
* changing the progress bars value.
*/ */
public void updateProgress(final int percent, String msg) { 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); l.updateProgress(percent, msg);
} }
if (msg != null) logMessage(msg); }
if (msg != null) {
logMessage(msg);
}
if (this.m_ProgressBar != null) { if (this.m_ProgressBar != null) {
Runnable doSetProgressBarValue = new Runnable() { Runnable doSetProgressBarValue = new Runnable() {
public void run() { public void run() {
m_ProgressBar.setValue(percent); m_ProgressBar.setValue(percent);
} }
@@ -1084,6 +1123,7 @@ public class EvAClient implements RemoteStateListener, Serializable {
} }
final class SplashScreenShell { final class SplashScreenShell {
SplashScreen splScr = null; SplashScreen splScr = null;
String imgLoc = null; String imgLoc = null;
@@ -1105,6 +1145,7 @@ final class SplashScreenShell {
} }
class SplashScreen extends Frame { class SplashScreen extends Frame {
private static final long serialVersionUID = 1281793825850423095L; private static final long serialVersionUID = 1281793825850423095L;
String imgLocation; String imgLocation;
@@ -1116,9 +1157,10 @@ class SplashScreen extends Frame {
* Show the splash screen to the end user. * Show the splash screen to the end user.
* *
* <P>Once this method returns, the splash screen is realized, which means * <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 * that almost all work on the splash screen should proceed through the
* dispatch thread. In particular, any call to <code>dispose</code> for the * event dispatch thread. In particular, any call to
* splash screen must be performed in the event dispatch thread. * <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); JWindow splashWindow = new JWindow(this);
@@ -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.setLocation(screenSize.width / 2 - splashWindow.getSize().width / 2, screenSize.height / 2 - splashWindow.getSize().height / 2);
splashWindow.setVisible(true); splashWindow.setVisible(true);
} }
} }

View File

@@ -1,45 +1,35 @@
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; public EvAMainAdapter m_MainRemoteObject;
//private EvAComAdapter m_ComAdapter; //private EvAComAdapter m_ComAdapter;
public static String m_UserName; public static String m_UserName;
public static int m_NumberOfVM = 0; public static int m_NumberOfVM = 0;
private RMIServerEvA m_RMIServer; private RMIServerEvA m_RMIServer;
/** /**
* Constructor of EvAServer. * Constructor of EvAServer. Calls RMIConnection().
* Calls RMIConnection().
*/ */
public EvAServer(boolean insideClient, boolean Restart) { public EvAServer(boolean insideClient, boolean Restart) {
System.out.println("Number of CPUs :" + Runtime.getRuntime().availableProcessors()); System.out.println("Number of CPUs :" + Runtime.getRuntime().availableProcessors());
// m_InsideClient = insideClient;
// 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") );
@@ -50,56 +40,62 @@ public class EvAServer {
// RMIProxyRemote.setComAdaper(m_ComAdapter); // RMIProxyRemote.setComAdaper(m_ComAdapter);
m_RMIServer = RMIServerEvA.getInstance(); m_RMIServer = RMIServerEvA.getInstance();
} }
/** /**
* Main method of this class. * Main method of this class. Is the starting point of the server
* Is the starting point of the server application. * application.
*/ */
static public void main(String[] args) { static public void main(String[] args) {
boolean Restart = false; boolean restart = false;
boolean nomulti = false; boolean noMulti = false;
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
System.out.println("args = " + args[i]); System.out.println("args = " + args[i]);
if (args[i].equals("restart")) if (args[i].equals("restart")) {
Restart = true; restart = true;
if (args[i].equals("nomulti")) }
nomulti = true; if (args[i].equals("nomulti")) {
noMulti = true;
}
} }
//Runtime.getRuntime().addShutdownHook(new ExitThread()); //Runtime.getRuntime().addShutdownHook(new ExitThread());
if (Restart== true) { if (restart == true) {
String MyHostName = "Host"; String hostName = "Host";
try { try {
MyHostName = InetAddress.getLocalHost().getHostName(); hostName = InetAddress.getLocalHost().getHostName();
} catch (Exception e) { } catch (UnknownHostException e) {
System.out.println("ERROR getting HostName (EvAServer.main) " + e.getMessage()); System.out.println("ERROR getting HostName (EvAServer.main) " + e.getMessage());
} }
try {Thread.sleep(2000);} try {
catch(Exception e) { Thread.sleep(2000);
} catch (InterruptedException e) {
System.out.println("Error in sleep of ExitThread"); System.out.println("Error in sleep of ExitThread");
} }
try { try {
System.setOut(new PrintStream( System.setOut(new PrintStream(
new FileOutputStream(MyHostName+"_server.txt"))); new FileOutputStream(hostName + "_server.txt")));
} catch (Exception e) { } catch (FileNotFoundException e) {
System.out.println("System.setOut" + e.getMessage()); 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) // if (nomulti==false)
// Application.multiServers(1); // evaServer.multiServers(1);
} }
/** /**
* *
*/ */
public void multiServers(int size) { public void multiServers(int size) {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
try {Thread.sleep(4000);} try {
catch(Exception e) { Thread.sleep(4000);
} catch (InterruptedException e) {
System.out.println("Error in sleep of ExitThread"); System.out.println("Error in sleep of ExitThread");
} }
if (TRACE) System.out.println(" start multiServers int i= "+i);
try { try {
String cmd = "java -cp \".\" eva2.server.EvAServer nomulti"; String cmd = "java -cp \".\" eva2.server.EvAServer nomulti";
System.out.println("Calling the command:" + cmd); System.out.println("Calling the command:" + cmd);
@@ -133,10 +129,10 @@ public class EvAServer {
private int getNumberOfVM(String[] list) { private int getNumberOfVM(String[] list) {
int ret = 0; int ret = 0;
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {
if (list[i].indexOf(EvAMainAdapterImpl.MAIN_ADAPTER_NAME)!= -1) if (list[i].indexOf(EvAMainAdapterImpl.MAIN_ADAPTER_NAME) != -1) {
ret++; ret++;
} }
if (TRACE) System.out.println(" getNumberOfVM() NumberOfVM ="+ret); }
return ret; return ret;
} }
} }

View File

@@ -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)

View File

@@ -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();