Importing release version 322 from old repos

This commit is contained in:
Marcel Kronfeld
2007-12-11 16:38:11 +00:00
parent 8cecdb016d
commit 7ae15be788
668 changed files with 109288 additions and 0 deletions

View File

@@ -0,0 +1,639 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.3 $
* $Date: 2004/04/28 07:50:32 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.Registry;
import java.util.ArrayList;
import java.util.Properties;
import java.util.StringTokenizer;
import javaeva.tools.Serializer;
/**
*
*/
public class ComAdapter {
static final public boolean TRACE = false;
static final public int PORT = 1099;
static final public String SEP = "_";
static protected ComAdapter m_instance = null;
public Registry m_Registry = null;
private ArrayList<RMIConnection> m_Connections = new ArrayList<RMIConnection>();
private String m_ownHostName;
private ArrayList<String> m_HostNameList = new ArrayList<String>();
private ArrayList<String> m_AvailableHostNameList = new ArrayList<String>();
// private String m_RemoteAdapterName;
private String m_UserName;
private int m_ownHostIndex = 0;
protected RMIServer m_RMIServer;
private String serverListSeparator = ",";
private boolean gettingRegistry;
/**
*
*/
public static ComAdapter getInstance() {
if (m_instance != null)
return m_instance;
m_instance = new ComAdapter();
return m_instance;
}
/**
*
*/
protected ComAdapter() {
if (TRACE) System.out.println("constructor ComAdapter");
m_UserName = System.getProperty("user.name");
m_ownHostName = "localhost"; //"192.168.0.1";
System.setProperty("java.security.policy", "server.policy");
launchRMIRegistry(false);
if (!m_HostNameList.contains("localhost")) {
// make sure localhost is in the list
m_HostNameList.add("localhost");
}
}
/**
* Parse a string of server names. The comma "," must be used as separator.
*
* @param serverList
*/
public void addServersFromString(String serverList) {
if (serverList != null) {
// parse the servernames
StringTokenizer st = new StringTokenizer(serverList, serverListSeparator);
while (st.hasMoreTokens()) {
String current = st.nextToken().trim();
if (!m_HostNameList.contains(current)) {
if (TRACE) System.out.println("adding server " + current);
m_HostNameList.add(current);
} else {
if (TRACE) System.out.println("server " + current + " was already in list");
}
}
}
}
/**
* Add a server list from a Properties instance. The key used is "ServerList".
*
* @param props
*/
public void addServersFromProperties(Properties props) {
String servs = props.getProperty("ServerList");
addServersFromString(servs);
}
/**
* Set the separator for the server list string.
*
* @return
*/
public void setServerListSeparator(String sep) {
serverListSeparator = sep;
}
/**
* The separator for the server list string.
*
* @return
*/
public String getServerListSeparator() {
return serverListSeparator;
}
/**
*
* @param c
* @param host
* @return
*/
public void setServerList(String[] server){
m_HostNameList.clear();
for (int i=0;i<server.length;i++)
m_HostNameList.add(server[i]);
}
/**
*
*
*/
public RMIInvocationHandler getRMIHandler(Object c, String host) {
System.out.println("ComAdapter.getRMIHandler() for host " + host);
m_ownHostName = host;
RMIInvocationHandler ret = null;
while (ret == null) {
ret = getConnection(m_ownHostName).getRMIHandler(c);
if (ret == null)
System.out.println("Error in getRMIHandler");
}
return ret;
}
/**
*
*
*/
public RMIThreadInvocationHandler getRMIThreadHandler(Object c, String host) {
if (TRACE)
System.out.println("ComAdapter.getRMIThreadHandler()");
m_ownHostName = host;
RMIThreadInvocationHandler ret = null;
while (ret == null) {
ret = getConnection(m_ownHostName).getRMIThreadHandler(c);
if (ret == null)
System.err.println("Error in getRMIThreadHandler");
}
return ret;
}
/**
*
*
*/
public RMIThreadInvocationHandler getRMIThreadHandler(Object c) {
if (TRACE)
System.out.println("RMIThreadInvokationHandler getRMIThreadHandler");
RMIThreadInvocationHandler ret = null;
if (m_AvailableHostNameList.size() == 0) {
evalAvailableHostNameList();
m_ownHostIndex = 0;
}
m_ownHostIndex++;
if (m_ownHostIndex >= m_AvailableHostNameList.size())
m_ownHostIndex = 0;
m_ownHostName = (String) m_AvailableHostNameList.get(m_ownHostIndex);
ret = getRMIThreadHandler(c, m_ownHostName);
return ret;
}
/**
*
*
*/
public RMIInvocationHandler getRMIHandler(Object c) {
if (TRACE)
System.out.println("RMIThreadInvokationHandler getRMIHandler");
RMIInvocationHandler ret = null;
while (m_AvailableHostNameList.size() == 0) {
evalAvailableHostNameList();
if (m_AvailableHostNameList.size() == 0)
System.err.println("no host availabe waiting !!");
m_ownHostIndex = 0;
}
m_ownHostIndex++;
if (m_ownHostIndex >= m_AvailableHostNameList.size())
m_ownHostIndex = 0;
m_ownHostName = (String) m_AvailableHostNameList.get(m_ownHostIndex);
ret = getRMIHandler(c, m_ownHostName);
return ret;
}
// /**
// *
// */
// public String getLoad() {
// if (TRACE)
// System.out.println("ComAdapter.getLoad()");
// String Load = null;
// Load = getConnection(m_ownHostName).getExecOutput("rup " + m_ownHostName);
// if (TRACE)
// System.out.println("Load of Modules on Server !! :" + Load);
//// if (m_LogPanel != null)
//// m_LogPanel.logMessage("Load of Modules on Server !! :" + Load);
// return Load;
// }
// /**
// *
// */
// public String gettokens() {
// if (TRACE)
// System.out.println("ComAdapter.gettokens()");
// String Tokens = null;
// Tokens = getConnection(m_ActualHostName).getExecOutput("tokens");
// if (TRACE)
// System.out.println("tokens on Server !! :" + Tokens);
// Tokens = getConnection(m_ActualHostName).getExecOutput(
// "klog -principal ulmerh -password ");
// if (TRACE)
// System.out.println("KLOG !!! !! :" + Tokens);
// Tokens = getConnection(m_ActualHostName).getExecOutput("tokens");
// if (TRACE)
// System.out.println("tokens on Server !! :" + Tokens);
// return Tokens;
// }
/**
*
*/
public void evalAvailableHostNameList() {
long time = System.currentTimeMillis();
if (TRACE)
System.out.println("ComAdapter.getAvailableHostNameList()");
m_AvailableHostNameList.clear();
for (int i = 0; i < m_HostNameList.size(); i++) {
if (rmiPing((String) m_HostNameList.get(i)) == true)
m_AvailableHostNameList.add((String) m_HostNameList.get(i));
String testurl = (String) m_HostNameList.get(i);
for (int j = 1; j < 3; j++) {
if (rmiPing(testurl + "_" + j) == true) {
if (TRACE) System.out.println("found EvAServer on: " + testurl);
m_AvailableHostNameList.add(testurl + "_" + j);
}
}
}
time = System.currentTimeMillis() - time;
if (TRACE) System.out.println("getAvailableHostNameList: " + m_AvailableHostNameList.size() + " found time " + time);
}
/**
*
*/
public String[] getAvailableHostNameList() {
if (m_AvailableHostNameList.size() == 0)
evalAvailableHostNameList();
String[] ret = new String[m_AvailableHostNameList.size()];
m_AvailableHostNameList.toArray(ret);
return ret;
}
/**
*
*/
public String[] getHostNameList() {
String[] x = new String[m_HostNameList.size()];
m_HostNameList.toArray(x);
return x;
}
/**
*
*/
public String getHostName() {
return m_ownHostName;
}
/**
*
*/
public void setHostName(String newHost) {
m_ownHostName = newHost;
Serializer.storeString("hostname.ser", m_ownHostName);
}
/**
* Creates a RMI-MainAdapter to host.
* @return
*/
protected MainAdapter createRMIMainConnect(String HostToConnect) {
if (TRACE)
System.out.println("RMIMainConnect.RMIMainConnect() =" + HostToConnect);
int len = HostToConnect.indexOf(SEP);
String Host = HostToConnect;
String Number = SEP + "0";
if (len != -1) {
StringTokenizer st = new StringTokenizer(HostToConnect, SEP);
Host = st.nextToken().trim();
Number = SEP + st.nextToken().trim();
}
String MainAdapterName = m_UserName + MainAdapterImpl.MAIN_ADAPTER_NAME + Number; // attention
logInfo(" RMIConnect to " + HostToConnect);
MainAdapter MainRemoteObject = null;
try {
try {
try {
//System.out.println("--> ComAdapter: "+"rmi://"+Host+":"+MainAdapterImpl.PORT+"/"+MainAdapterName);
// String[] list = Naming.list("rmi://" + Host + ":" +
// MainAdapterImpl.PORT);
//for (int i=0;i<list.length;i++)
// System.out.println("RMIName: "+list[i]);
//m_NumberOfVM = getNumberOfVM(list);
if (TRACE) System.out.println("getMain:" + "rmi://" + Host + ":" +
MainAdapterImpl.PORT + "/" + MainAdapterName);
RMIInvocationHandler invocHandler = (RMIInvocationHandler) Naming.lookup(
"rmi://" + Host + ":" + MainAdapterImpl.PORT + "/" +
MainAdapterName);
//System.out.println(" x ="+x.getClass().getName());
MainRemoteObject = getMainAdapter(invocHandler);
//MainRemoteObject = (MainAdapter)Naming.lookup("rmi://"+HostToConnect+":"+MainAdapterImpl.PORT+"/"+MainAdapterImpl.MAIN_ADAPTER_NAME);
//MainRemoteObject = (MainAdapter)LogProxy.newInstance(MainRemoteObject);
MainRemoteObject.setBuf("Ok.");
logInfo(" RMIConnect " + MainRemoteObject.getBuf());
} catch (MalformedURLException ex) {
System.err.println("MalformedURLException: Error while looking up " +
ex.getMessage());
}
} catch (NotBoundException ex) {
System.err.println("NotBoundException: Error while looking up " +
ex.getMessage());
ex.printStackTrace();
}
if (TRACE)
System.out.println("Connect to " + HostToConnect + " works fine");
} catch (RemoteException e) {
logInfo("Error while connecting Host: " + HostToConnect +
" \n ERROR: " + e.getMessage());
System.err.println("Error while connecting Host: " + HostToConnect +
" \n ERROR: " + e.getMessage());
return null;
}
return MainRemoteObject;
}
protected MainAdapter getMainAdapter(RMIInvocationHandler invocHandler) throws RemoteException {
return (MainAdapter) invocHandler.getWrapper();
}
protected void logInfo(String msg) {
System.out.println("ComAdapter-Log: " + msg);
}
/**
*
*/
protected int getNumberOfServersonHost(String testurl) {
// String MainAdapterName = m_UserName + MainAdapterImpl.MAIN_ADAPTER_NAME;
String[] list = null;
try {
list = Naming.list("rmi://" + testurl + ":" + MainAdapterImpl.PORT);
} catch (Exception e) {
//if (TRACE && m_LogPanel!=null) m_LogPanel.logMessage ("No connecting to : "+testurl );
//if (TRACE) System.out.println ("No connecting to : "+testurl );
System.err.println ("Exception : "+testurl );
return 0;
}
int ret = 0;
for (int i = 0; i < list.length; i++) {
if (list[i].indexOf(MainAdapterImpl.MAIN_ADAPTER_NAME) != -1)
ret++;
}
System.err.println("error in ComAdapter.getNumberOfServersonHost");
//System.out.println(" ret === "+ret);
return ret;
}
/**
*
*/
private boolean rmiPing(String testurl) {
if (TRACE)
System.out.println("ComAdapter.rmiPing " + testurl);
MainAdapter Test = null;
// String Load = null;
int len = testurl.indexOf(SEP);
String Host = testurl;
String Number = "_0";
if (len != -1) {
StringTokenizer st = new StringTokenizer(testurl, SEP);
Host = st.nextToken().trim();
Number = SEP + st.nextToken().trim();
}
String MainAdapterName = m_UserName + MainAdapterImpl.MAIN_ADAPTER_NAME +
Number;
try {
if (TRACE)
System.out.println("ping:" + "rmi://" + Host + ":" +
MainAdapterImpl.PORT + "/" + MainAdapterName);
RMIInvocationHandler x = (RMIInvocationHandler) Naming.lookup("rmi://" +
Host + ":" + MainAdapterImpl.PORT + "/" + MainAdapterName); // attention !!
Test = (MainAdapter) x.getWrapper();
// if (Test != null) {
// Load = Test.getExecOutput("rup " + testurl);
// }
} catch (Exception e) {
if (TRACE) {
logInfo("No connection to : " + testurl);
System.out.println("ComAdapter.rmiPing false " + e.getMessage());
}
return false;
}
if (Test != null) {
if (TRACE) logInfo("ping succeeded");
}
if (TRACE)
System.out.println("ComAdapter.rmiPing true");
return true;
}
/**
*
*/
public void killServer(String ServerToKill) {
if (TRACE)
System.out.println("ComAdapter.Killing Server :" + ServerToKill);
RMIConnection myConnection = getConnection(ServerToKill);
myConnection.killServer();
this.m_Connections.remove(myConnection);
}
/**
*
*/
public void killAllServers() {
if (TRACE)
System.out.println("ComAdapter.Killing All Servers :");
for (int i = 0; i < m_AvailableHostNameList.size(); i++) {
RMIConnection myConnection = getConnection((String)
m_AvailableHostNameList.get(i));
myConnection.killServer();
this.m_Connections.remove(myConnection);
}
}
/**
*
*/
public void restartServerAllServer() {
if (TRACE) System.out.println("ComAdapter.restartServerAllServer :");
for (int i = 0; i < m_AvailableHostNameList.size(); i++) {
RMIConnection myConnection = getConnection((String)
m_AvailableHostNameList.get(i));
myConnection.restartServer();
m_Connections.remove(myConnection);
}
}
/**
*
*/
public void restartServer(String host) {
m_ownHostName = host;
restartServer();
}
/**
*
*/
public void restartServer() {
if (TRACE)
System.out.println("ComAdapter.restartServer");
if (TRACE)
System.out.println("m_ActualHostName = " + m_ownHostName);
// System.out.println("m_ActualHostName = " + m_ActualHostName);
if (m_ownHostName.equals("localhost")) { // TODO whats this?
return;
}
if (TRACE == true)
System.out.println("ComAdapter.restartServer Server :" + m_ownHostName);
RMIConnection x = getConnection(m_ownHostName);
x.restartServer();
m_Connections.remove(x);
try {
Thread.sleep(3000);
} catch (Exception e) {
System.err.println("Error in sleep of ExitThread");
}
}
public void setRMIRegistry(Registry reg) {
m_Registry = reg;
gettingRegistry = false;
}
/**
* Install RMIregistry on default port !!
*/
protected void launchRMIRegistry(boolean ownThread) {
if (ownThread) {
Thread t = new Thread(new RMIRegistration(this));
gettingRegistry = true;
t.start();
} else {
RMIRegistration rmiReg = new RMIRegistration(this);
gettingRegistry = true;
rmiReg.run();
}
}
/**
*
*/
public void setLocalRMIServer(RMIServer Server) {
m_RMIServer = Server;
}
/**
* Just the main for testing the class.
*/
public static void main(String[] args) {
ComAdapter TestApp = ComAdapter.getInstance();
TestApp.evalAvailableHostNameList();
TestApp.killAllServers();
//TestApp.restartServerAllServer();
}
/**
*
*/
protected RMIConnection getConnection(String Host) {
if (TRACE) System.out.println("ComAdapter.getConnection for host :" + Host);
for (int i = 0; i < this.m_Connections.size(); i++) {
// search for an already established connection to the given host
// and return it if found
RMIConnection ret = (RMIConnection) m_Connections.get(i);
if (Host.equals(ret.getHostName())) return ret;
}
// else create and add new RMIConnection
RMIConnection ret = null;
if (Host.equals("localhost") && m_RMIServer != null) {
// this uses rmi on the localhost
ret = createRMIConnection(Host, m_RMIServer.getMainRemoteObject(),
new MainAdapterClientImpl("localhost"));
} else {
MainAdapter Adapter = (MainAdapter)createRMIMainConnect(Host);
if (Adapter != null)
ret = createRMIConnection(Host, Adapter,
(MainAdapterClient) RMIProxyLocal.newInstance(new MainAdapterClientImpl(Host)));
}
if (ret != null) m_Connections.add(ret);
else System.err.println("Warning no valid connection !!");
return ret;
}
protected RMIConnection createRMIConnection(String Host, MainAdapter mainRemoteObject, MainAdapterClient client) {
return new RMIConnection(Host, mainRemoteObject, client);
}
// private RMIConnection getConnection(String Host) {
// if (TRACE == true) System.out.println("ComAdapter.getConnection for host :" + Host);
// RMIConnection ret = null;
// for (int i = 0; i < this.m_Connections.size(); i++) {
// ret = (RMIConnection) m_Connections.get(i);
// if (Host.equals(ret.getHostName()) == true)
// return ret;
// }
// // create and add new RMIConnection
// if (Host.equals("localhost") && (m_RMIServer != null)) {
// ret = new RMIConnection(Host, m_RMIServer.getMainRemoteObject(),
// new MainAdapterClientImpl());
// } else {
// MainAdapter Adapter = createRMIMainConnect(Host);
// if (Adapter != null)
// ret = new RMIConnection(Host, Adapter,
// (MainAdapterClient)
// RMIProxyLocal.newInstance(new MainAdapterClientImpl()));
// }
// if (ret != null) m_Connections.add(ret);
// else System.err.println("Warning no valid connection !!");
// return ret;
// }
}
class RMIRegistration implements Runnable {
ComAdapter comAd = null;
private boolean TRACE = false;
Registry reg = null;
public RMIRegistration(ComAdapter comAdapter) {
comAd = comAdapter;
}
public void run() {
if (TRACE)
System.out.println("LaunchRMIRegistry on Client on PORT " + ComAdapter.PORT);
try {
reg = java.rmi.registry.LocateRegistry.createRegistry(ComAdapter.PORT);
}
catch (Throwable e) {
if (TRACE) System.out.println("Registry notcreated !!" + e.getMessage());
reg = null;
}
if (reg == null) {
if (TRACE) System.out.println("Try to get registry with getRegistry on PORT " + ComAdapter.PORT);
try {
reg = java.rmi.registry.LocateRegistry.getRegistry(ComAdapter.PORT);
}
catch (Throwable e) {
if (TRACE) System.out.println("registry not created !!" + e.getMessage());
reg = null;
}
}
if (reg != null && TRACE) System.out.println("--> got RMIREGISTRY");
comAd.setRMIRegistry(reg);
}
}

View File

@@ -0,0 +1,113 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:29 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Proxy;
import java.io.Serializable;
import java.util.ArrayList;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
*
*/
public class JProxyRemoteThread implements InvocationHandler,
Serializable {
private static ComAdapter m_ComAdapter;
private Object m_Object;
private RMIThreadInvocationHandler m_RMIThreadHandler;
private String m_ObjectName;
/**
*
*/
public static Object newInstance(Serializable object, String host) throws NO_RMIServerAvailable {
return Proxy.newProxyInstance(
object.getClass().getClassLoader(),
object.getClass().getInterfaces(),
new JProxyRemoteThread(object, host));
}
/**
*
*/
public static Object newInstance(Serializable object) throws NO_RMIServerAvailable {
return Proxy.newProxyInstance(
object.getClass().getClassLoader(),
object.getClass().getInterfaces(),
new JProxyRemoteThread(object));
}
/**
*
* @param c
* @return
*/
public static String[] getServerList() {
if (m_ComAdapter == null) {
//try {
m_ComAdapter = ComAdapter.getInstance();
// } catch (NO_RMIServerAvailable ex) {
// ex.printStackTrace();
//
// }
}
m_ComAdapter.evalAvailableHostNameList();
return m_ComAdapter.getAvailableHostNameList();
}
/**
*
*/
public static void setComAdaper(ComAdapter x) {
m_ComAdapter = x;
}
/**
*
*/
private JProxyRemoteThread(Serializable object, String host) throws NO_RMIServerAvailable {
if (m_ComAdapter == null)
m_ComAdapter = ComAdapter.getInstance();
m_RMIThreadHandler = m_ComAdapter.getRMIThreadHandler(object, host);
}
/**
*
*/
private JProxyRemoteThread(Serializable object) throws NO_RMIServerAvailable {
if (m_ComAdapter == null)
m_ComAdapter = ComAdapter.getInstance();
m_RMIThreadHandler = m_ComAdapter.getRMIThreadHandler(object);
}
/**
*
*/
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object ret = null;
if (method.getName().equals("getServerName")) {
ret = m_RMIThreadHandler.getServerName();
} else {
ret = m_RMIThreadHandler.invoke(method.getName(), args);
}
//long finish = System.currentTimeMillis();
//System.out.println("Calling :"+m.getName()+" of "+m_ObjectName+ " time :"+(finish-start));
return ret;
}
}

View File

@@ -0,0 +1,31 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:29 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/**
*
*/
public interface MainAdapter {
public String getExecOutput(String command);
public void setBuf(String s);
public void killServer();
public void restartServer();
public String getBuf();
public RMIInvocationHandler getRMIHandler(Object obj);
public RMIThreadInvocationHandler getRMIThreadHandler(Object obj);
public void setRemoteThis (MainAdapter x);
}

View File

@@ -0,0 +1,25 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/**
*
*/
public interface MainAdapterClient {
public RMIInvocationHandler getRMIHandler(Object obj);
public RMIThreadInvocationHandler getRMIThreadHandler(Object obj);
public String getHostName();
}

View File

@@ -0,0 +1,76 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.net.InetAddress;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
*
*/
public class MainAdapterClientImpl implements MainAdapterClient {
static final public String MAIN_ADAPTER_CLIENT_NAME = "Main_Remote_Object_Client_Name";
static public boolean TRACE = false;
private String m_HostName = "not__defined__";
/**
*
*/
public MainAdapterClientImpl() {
try {
m_HostName = InetAddress.getLocalHost().getHostName();
} catch (Exception e) {
System.out.println("ERROR getting HostName MainAdapterClientImpl "+e.getMessage());
}
}
/**
*
*/
public MainAdapterClientImpl(String hostName) {
m_HostName = hostName;
}
/**
*
*/
public RMIInvocationHandler getRMIHandler(Object obj) {
if (TRACE) System.out.println("MainAdapterClientImpl.getRMIHandler");
RMIInvocationHandler ret = null;
try {
ret = new RMIInvocationHandlerImpl(obj);
} catch (Exception e) {
System.out.println(" Error ret= new RMIInvokationHandlerImpl(obj);"+e.getMessage());
}
return ret;
}
/**
*
*/
public RMIThreadInvocationHandler getRMIThreadHandler(Object obj) {
if (TRACE) System.out.println("MainAdapterClientImpl.getRMIThreadHandler");
RMIThreadInvocationHandler ret = null;
try {
ret = new RMIThreadInvocationHandlerImpl(obj);
} catch (Exception e) {
System.out.println(" Error ret= new getRMIThreadHandler(obj);"+e.getMessage());
}
return ret;
}
/**
*
*/
public String getHostName () {
return m_HostName;
}
}

View File

@@ -0,0 +1,154 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
*
*/
public class MainAdapterImpl implements MainAdapter {
static final public String MAIN_ADAPTER_NAME = "MainRemoteObjectName";
static final public int PORT = 1099;
static public boolean TRACE = false;
private String m_Buf = "";
private MainAdapter m_RemoteThis;
/**
*
*/
public MainAdapterImpl() {
if (TRACE) System.out.println("Constructor MainAdapterImpl !!!!!!");
m_RemoteThis = this;
}
/**
*
*/
public void setBuf(String s) {
if (TRACE) System.out.println("MainAdapterImpl.setBuf:"+s);
m_Buf = s;
}
/**
*
*/
public void restartServer() {
System.out.println("Received message to restartServer !!!!");
try {
String Out ="";
String command = "java -cp .:../lib/jdom.jar:../lib/log4j.jar javaeva.server.EvAServer &";
System.out.println("Calling the command:"+"java javaeva.server.EvAServer");
Process pro = Runtime.getRuntime().exec(command);
BufferedReader in = new BufferedReader ( new InputStreamReader (pro.getInputStream()));
// String line = null;
// while((line = in.readLine()) != null ) {
// System.out.println(line);
// Out = Out + line;
// }
System.out.println("command="+command);
} catch (Exception e) {
System.out.println("Error in calling the command:"+e.getMessage());
}
killServer();
}
/**
*
*/
public void killServer() {
//Mail.SendMail("Received message to kill EvAServer");
System.out.println("Received message to kill EvAServer !!!!");
KillThread x = new KillThread();
x.start();
return;
}
/**
*
*/
public String getBuf() {
return m_Buf;
}
/**
*
*/
public String getExecOutput(String command) {
String Out= new String();
try {
BufferedReader in = null;
Process pro = null;
if (TRACE) System.out.println("Calling the command:"+command);
pro = Runtime.getRuntime().exec(command);
in = new BufferedReader ( new InputStreamReader (pro.getInputStream()));
String line = null;
while((line = in.readLine()) != null ) {
if (TRACE) System.out.println(line);
Out = Out + line;
}
} catch (Exception e) {
System.err.println("Error in calling the command:"+e.getMessage());
}
return Out;
}
/**
*
*/
public RMIInvocationHandler getRMIHandler(Object obj) {
System.out.println("getRMIHandler");
RMIInvocationHandler ret = null;
try {
ret = new RMIInvocationHandlerImpl(obj);
}
catch (Exception e) {
System.out.println("Error: RMIInvokationHandler getRMIHandler");
}
return ret;
}
/**
*
*/
public RMIThreadInvocationHandler getRMIThreadHandler(Object obj) {
if (TRACE) System.out.println("getRMIThreadHandler");
RMIThreadInvocationHandler ret = null;
try {
ret = new RMIThreadInvocationHandlerImpl(obj);
}
catch (Exception e) {
System.out.println("Error: RMIThreadInvokationHandler getRMIThreadHandler");
}
return ret;
}
/**
*
*/
public void setRemoteThis (MainAdapter x) {
m_RemoteThis = x;
}
}
/**
*
*/
class KillThread extends Thread {
/**
*
*/
public void run() {
try {sleep(3000);}
catch(Exception e) {
System.out.println("Error in sleep");
}
System.exit(-1);
}
}

View File

@@ -0,0 +1,24 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/**
* This exception will be thrown when no
* RMIServer con be found by the ComAdapter.
*/
public class NO_RMIServerAvailable extends Exception {
NO_RMIServerAvailable() {
printStackTrace();
}
}

View File

@@ -0,0 +1,98 @@
package wsi.ra.jproxy;
/**
*
*/
public class RMIConnection {
public static boolean TRACE = false;
private String m_HostName;
protected MainAdapter m_MainAdapter;
protected MainAdapterClient m_MainAdapterClient;
/**
*
*/
public RMIConnection(String HostName, MainAdapter Adapter,
MainAdapterClient AdapterClient) {
m_MainAdapter = Adapter;
m_HostName = HostName;
m_MainAdapterClient = AdapterClient;
}
/**
*
*/
public String getHostName() {
return m_HostName;
}
/**
*
*/
public MainAdapter getMainAdapter() {
return m_MainAdapter;
}
/**
*
*/
public void killServer() {
try {
m_MainAdapter.killServer();
} catch (Exception e) {
System.out.println("Error while killing server: " + e.getMessage());
}
}
/**
*
*/
public void restartServer() {
try {
m_MainAdapter.restartServer();
} catch (Exception e) {
System.out.println("Error while restartServer server: " + e.getMessage());
}
}
/**
*
*/
public RMIInvocationHandler getRMIHandler(Object c) {
RMIInvocationHandler ret = null;
try {
ret = m_MainAdapter.getRMIHandler(c);
} catch (Exception e) {
System.out.println("Error while getRMIHandler server: " + e.getMessage());
e.printStackTrace();
}
return ret;
}
/**
*
*/
public RMIThreadInvocationHandler getRMIThreadHandler(Object c) {
RMIThreadInvocationHandler ret = null;
try {
ret = m_MainAdapter.getRMIThreadHandler(c);
} catch (Exception e) {
System.out.println("Error while RMIThreadInvokationHandler server: " +
e.getMessage());
}
return ret;
}
/**
*
*/
public String getExecOutput(String command) {
String ret = null;
try {
ret = m_MainAdapter.getExecOutput(command);
} catch (Exception e) {
System.out.println("Error while getExecOutput server: " + e.getMessage());
}
return ret;
}
}

View File

@@ -0,0 +1,27 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.rmi.Remote;
import java.rmi.RemoteException;
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/**
*
*/
public interface RMIInvocationHandler extends Remote {
public Object invoke (String m, Object[] args)throws RemoteException;
public Object getWrapper () throws RemoteException;
public void setWrapper(Object Wrapper) throws RemoteException;
}

View File

@@ -0,0 +1,128 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.2 $
* $Date: 2004/07/31 20:02:09 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import wsi.ra.math.RNG;
import java.rmi.RemoteException;
import java.rmi.Naming;
import java.rmi.server.UnicastRemoteObject;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
*
*/
public class RMIInvocationHandlerImpl extends UnicastRemoteObject implements RMIInvocationHandler {
public static final boolean TRACE = false;
private Object m_Object;
private String m_AdapterName;
private Object m_Wrapper;
private Method[] m_list;// m_Object.getClass().getMethods();
/**
*
*/
public RMIInvocationHandlerImpl(Object obj) throws RemoteException {
if (TRACE) System.out.println("RMIInvokationHandlerImpl");
m_AdapterName = obj.getClass().getName()+"_"+RNG.randomInt(0,10000);
try {
m_Object = obj;
m_list = m_Object.getClass().getMethods();
if (TRACE) System.out.println(" --> rebind : "+m_AdapterName+" RMIInvokationHandlerImpl of object "+obj.getClass().getName());
Naming.rebind(m_AdapterName,this);
} catch (Exception e) {
System.err.println(" Naming.rebind --> ERROR" + e.getMessage());
e.printStackTrace();
}
}
/**
*
*/
public RMIInvocationHandlerImpl(Object obj,String AdapterName) throws RemoteException {
m_AdapterName = AdapterName;
try {
m_Object = obj;
m_list = m_Object.getClass().getMethods();
if (TRACE) System.out.println(" -----> rebind : "+m_AdapterName+" "+this.getClass().getName()+" of object "+obj.getClass().getName());
Naming.rebind(m_AdapterName,this);
} catch (Exception e) {
System.err.println(" Naming.rebind --> ERROR " + obj + " " + e.getMessage());
e.printStackTrace();
}
}
/**
*
*/
public void setWrapper(Object Wrapper) throws RemoteException {
m_Wrapper = Wrapper;
}
/**
*
*/
public Object getWrapper () throws RemoteException {
return m_Wrapper;
}
/**
*
*/
public Object invoke (String m, Object[] args) throws RemoteException {
Object ret=null;
String Name = "";
//System.out.println("calling "+m);
if (TRACE) Name = Thread.currentThread().getName();
try {
if (TRACE) System.out.println( Name+" Before invoke on server :" +m);
//Method[] list = m_Object.getClass().getMethods();
boolean invoked = false;
for (int i=0;i<m_list.length;i++) {
if (TRACE) System.out.println(Name+" list[i].getName() "+m_list[i].getName());
// if (m.equals("free")==true) {
// System.out.println("called free !!!!!!!!!!!!!!!!!!!!!!!!!"+m_AdapterName);
// String[] list = Naming.list("rmi://localhost:" + MainAdapterImpl.PORT);
// System.out.println("-->list :"+list.length);
// for (int j = 0; j < list.length; j++){
// System.out.println("list="+list[j]+"--"+m_AdapterName);
// if (list[j].lastIndexOf(m_AdapterName)!=-1) {
// System.out.println("unbind !!!!!!!!!!!!!!!!!!!!!!!!!!");
// Naming.unbind(list[j]);
//
// return null;
// }
// }
// System.out.println("Object not found !!!!!");
// return null;
// }
if (m.equals(m_list[i].getName())==true) {
if (TRACE) System.out.println(Name+" find "+m);
//if (args==null) System.out.println(Name+" args==null ");
ret = m_list[i].invoke(m_Object,args);
invoked= true;
break;
}
}
if (invoked==false) System.out.println(Name+ " No memberfunction found !!!!!!!!!!!!!!!!!");
}
catch ( InvocationTargetException e) {
e.printStackTrace();
System.out.println(Name+" RMIInvokationHandlerImpl InvocationTargetException "+e.getMessage());
}
catch (Exception e) {
e.printStackTrace();
System.out.println(Name+" Exception :"+e.getMessage());
}
return ret;
}
}

View File

@@ -0,0 +1,111 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.2 $
* $Date: 2004/04/15 12:28:34 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
*
*/
public class RMIProxyLocal implements InvocationHandler, Serializable {
private RMIInvocationHandler m_RMIHandler;
public static boolean TRACE = false;
private Class originalClass = null;
/**
*
*/
public static Object newInstance (Object c, String RMIName) {
if (TRACE) System.out.println("RMIProxyLocal:"+c.getClass().getName());
RMIProxyLocal proxyLocal = new RMIProxyLocal(c,RMIName);
Object ret = java.lang.reflect.Proxy.newProxyInstance (
c.getClass().getClassLoader(),
c.getClass().getInterfaces(),
proxyLocal);
proxyLocal.setWrapper(ret);
proxyLocal.setOriginalClass(c.getClass());
if (TRACE) System.out.println(" --> " + ret.getClass());
return ret;
}
/**
*
*/
public static Object newInstance (Object c) {
if (TRACE) System.out.println("RMIProxyLocal:"+c.getClass().getName());
RMIProxyLocal proxyLocal = new RMIProxyLocal(c);
Object ret = java.lang.reflect.Proxy.newProxyInstance (
c.getClass().getClassLoader(),
c.getClass().getInterfaces(),
proxyLocal);
proxyLocal.setWrapper(ret);
proxyLocal.setOriginalClass(c.getClass());
if (TRACE) System.out.println(" --> " + ret.getClass());
return ret;
}
/**
*
*/
private RMIProxyLocal (Object c) {
if (TRACE) System.out.println("RMIProxyLocal:"+c.getClass().getName());
try {
m_RMIHandler = new RMIInvocationHandlerImpl(c);
} catch (Exception e) {
System.err.println("Error in m_RMIHandler = new RMIInvokationHandlerImpl(c)");
e.printStackTrace();
}
}
/**
*
*/
private RMIProxyLocal (Object c,String RMIName) {
try {
m_RMIHandler = new RMIInvocationHandlerImpl(c,RMIName);
} catch (Exception e) {
System.out.println("Error in m_RMIHandler = new RMIInvokationHandlerImpl(c)");
e.printStackTrace();
}
}
/**
*
*/
public void setWrapper(Object Wrapper) {
try {
m_RMIHandler.setWrapper(Wrapper);
} catch (Exception e) {
System.out.println("Error in setWrapper "+e.getMessage());
}
}
/**
*
*/
public Object invoke (Object proxy, Method m, Object[] args) throws Throwable {
return m_RMIHandler.invoke(m.getName(),args);
}
/**
* @return the originalClass
*/
public Class getOriginalClass() {
return originalClass;
}
/**
* @param originalClass the originalClass to set
*/
public void setOriginalClass(Class originalClass) {
if (TRACE) System.out.println("setting original proxy class "+originalClass.getName());
this.originalClass = originalClass;
}
}

View File

@@ -0,0 +1,116 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
*
*/
public class RMIProxyLocalThread implements InvocationHandler,Serializable {
private RMIInvocationHandler m_RMIHandler;
private final static boolean TRACE = true;
/**
*
*/
public static Object newInstance (Object c,String RMIName) {
//System.out.println("RMIProxyLocal.newInstance !!!!!!!!!!!!!!!");
RMIProxyLocalThread Proxy = new RMIProxyLocalThread(c,RMIName);
Object ret = java.lang.reflect.Proxy.newProxyInstance (
c.getClass().getClassLoader(),
c.getClass().getInterfaces(),
Proxy);
Proxy.setWrapper(ret);
if (TRACE) System.out.println("RMIProxyLocalThread "+c.getClass() + " ret " + ret.getClass());
return ret;
}
/**
*
*/
public static Object newInstance (Object c) {
RMIProxyLocalThread Proxy = new RMIProxyLocalThread(c);
Object ret = java.lang.reflect.Proxy.newProxyInstance (
c.getClass().getClassLoader(),
c.getClass().getInterfaces(),
Proxy);
Proxy.setWrapper(ret);
if (TRACE) System.out.println("RMIProxyLocalThread "+c.getClass() + " ret " + ret.getClass());
return ret;
}
/**
*
*/
private RMIProxyLocalThread (Object c) {
System.out.println("RMIProxyLocal:"+c.getClass().getName());
try {
m_RMIHandler = new RMIInvocationHandlerImpl(ThreadProxy.newInstance(c));
} catch (Exception e) {
System.out.println("Error in m_RMIHandler = new RMIInvokationHandlerImpl(c)");
e.printStackTrace();
}
}
/**
*
*/
private RMIProxyLocalThread (Object c,String RMIName) {
System.out.println("RMIProxyLocal:"+RMIName);
System.out.println("RMIProxyLocal:"+c.getClass().getName());
try {
m_RMIHandler = new RMIInvocationHandlerImpl(ThreadProxy.newInstance(c),RMIName);
} catch (Exception e) {
System.out.println("Error in m_RMIHandler = new RMIInvokationHandlerImpl(c)");
e.printStackTrace();
}
}
/**
*
*/
public void setWrapper(Object Wrapper) {
try {
m_RMIHandler.setWrapper(Wrapper);
} catch (Exception e) {
System.out.println("Error in setWrapper "+e.getMessage());
}
}
/**
*
*/
public Object invoke (Object proxy, Method m, Object[] args) throws Throwable {
//long start = System.currentTimeMillis();
//System.out.println("Before invoke:" +m.getName());
//Object ret = m_RMIHandler.invoke(m.getName(),args);
//long finish = System.currentTimeMillis();
//System.out.println("Calling :"+m.getName()+" of "+m_ObjectName+ " time :"+(finish-start));
//return ret;
return m_RMIHandler.invoke(m.getName(),args);
}
/**
*
*/
public static void main(String[] args) {
//
//Doit x = new DoitImpl();
// Doit xx = (Doit) RMIProxyRemote.newInstance(x,"primergy4.informatik.uni-tuebingen.de");
// Doit2 yy = (Doit2) RMIProxyLocal.newInstance(new Doit2Impl());
// System.out.println(" jhdfjldf");
// yy.doit();
// yy.doit();
// xx.newdoit(yy);
}
}

View File

@@ -0,0 +1,116 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
*
*/
public class RMIProxyRemote implements InvocationHandler,Serializable {
private static ComAdapter m_Adapter;
private static boolean TRACE = true;
private Object m_Object;
private String m_ObjectName;
private RMIInvocationHandler m_RMIHandler=null;
private long m_counter=0;
/**
*
*/
public static Object newInstance (Object c,MainAdapterClient Client) {
return java.lang.reflect.Proxy.newProxyInstance (
c.getClass().getClassLoader(),
c.getClass().getInterfaces(),
new RMIProxyRemote(c,Client));
}
/**
*
*/
public static Object newInstance (Object c,String host) {
return java.lang.reflect.Proxy.newProxyInstance (
c.getClass().getClassLoader(),
c.getClass().getInterfaces(),
new RMIProxyRemote(c,host));
}
/**
*
*/
public static Object newInstance (Object c) {
return java.lang.reflect.Proxy.newProxyInstance (
c.getClass().getClassLoader(),
c.getClass().getInterfaces(),
new RMIProxyRemote(c));
}
/**
*
*/
public static void setComAdaper(ComAdapter x) {
m_Adapter = x;
}
/**
*
*/
private RMIProxyRemote (Object c, String host) {
m_ObjectName = c.getClass().getName();
if (m_Adapter==null) m_Adapter = ComAdapter.getInstance();
m_RMIHandler = m_Adapter.getRMIHandler(c,host);
if (TRACE) System.out.println("creating RMIProxyRemote " + c.getClass() + " " + host);
}
/**
*
*/
private RMIProxyRemote (Object c, MainAdapterClient Client) {
m_ObjectName = c.getClass().getName();
try {
m_RMIHandler = Client.getRMIHandler(c);
} catch (Exception e) {
System.out.println("RMIProxyRemote error ex "+e.getMessage());
e.printStackTrace();
}
if (TRACE) System.out.println("creating RMIProxyRemote " + c.getClass() + " " + Client.getClass());
}
/**
*
*/
private RMIProxyRemote (Object c) {
m_ObjectName = c.getClass().getName();
if (m_Adapter==null) m_Adapter = ComAdapter.getInstance();
m_RMIHandler = m_Adapter.getRMIHandler(c);
}
/**
*
*/
public Object invoke (Object proxy, Method m, Object[] args) throws Throwable {
long start = System.currentTimeMillis();
++m_counter;
//System.out.println("Before invoke:" +m.getName());
Object ret = m_RMIHandler.invoke(m.getName(),args);
long finish = System.currentTimeMillis();
//System.out.println("Calling :"+m.getName()+" of "+m_ObjectName+ " time :"+(finish-start));
return ret;
}
/**
*
*/
// public static void main(String[] args) {
// Doit remotex = (Doit) RMIProxyRemote.newInstance(new DoitImpl(),"primergy4.informatik.uni-tuebingen.de");
// remotex.doit();
// remotex.doit();
// remotex.doit();
// remotex.doit();
// }
}

View File

@@ -0,0 +1,136 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.2 $
* $Date: 2004/04/28 07:50:33 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
*
*/
public class RMIProxyRemoteThread implements InvocationHandler,
Serializable {
private static ComAdapter m_Adapter;
private Object m_Object;
private String m_ObjectName;
private RMIThreadInvocationHandler m_RMIThreadHandler;
/**
*
*/
public static Object newInstance (Object c,MainAdapterClient Client) {
return java.lang.reflect.Proxy.newProxyInstance (
c.getClass().getClassLoader(),
c.getClass().getInterfaces(),
new RMIProxyRemoteThread(c,Client));
}
/**
*
*/
public static Object newInstance (Object c,String host) {
return java.lang.reflect.Proxy.newProxyInstance (
c.getClass().getClassLoader(),
c.getClass().getInterfaces(),
new RMIProxyRemoteThread(c,host));
}
/**
*
* @param c
* @return
*/
public static String[] getServerList() {
if (m_Adapter==null) m_Adapter = ComAdapter.getInstance();
m_Adapter.evalAvailableHostNameList();
return m_Adapter.getAvailableHostNameList();
}
public static void setServerList(String[] servers ) {
if (m_Adapter==null) m_Adapter = ComAdapter.getInstance();
m_Adapter.setServerList(servers);
m_Adapter.evalAvailableHostNameList();
}
/**
*
*/
public static Object newInstance (Object c) {
return java.lang.reflect.Proxy.newProxyInstance (
c.getClass().getClassLoader(),
c.getClass().getInterfaces(),
new RMIProxyRemoteThread(c));
}
/**
*
*/
public static void setComAdaper(ComAdapter x) {
m_Adapter = x;
}
/**
*
*/
private RMIProxyRemoteThread (Object c, String host) {
m_ObjectName = c.getClass().getName();
if (m_Adapter==null) m_Adapter = ComAdapter.getInstance();
m_RMIThreadHandler = m_Adapter.getRMIThreadHandler(c,host);
}
/**
*
*/
private RMIProxyRemoteThread (Object c, MainAdapterClient Client) {
m_ObjectName = c.getClass().getName();
try {
m_RMIThreadHandler = Client.getRMIThreadHandler(c);
} catch (Exception e) {
System.out.println("RMIProxyRemoteThreaderror ex "+e.getMessage());
e.printStackTrace();
}
}
/**
*
*/
private RMIProxyRemoteThread (Object c) {
m_ObjectName = c.getClass().getName();
if (m_Adapter==null) m_Adapter = ComAdapter.getInstance();
m_RMIThreadHandler = m_Adapter.getRMIThreadHandler(c);
}
/**
*
*/
public Object invoke (Object proxy, Method m, Object[] args) throws Throwable {
//long start = System.currentTimeMillis();
//System.out.println("Before invoke:" +m.getName());
Object ret = null;
if (m.getName().equals("getServerName")) {
ret = m_RMIThreadHandler.getServerName();
} else {
ret = m_RMIThreadHandler.invoke(m.getName(), args);
}
//long finish = System.currentTimeMillis();
//System.out.println("Calling :"+m.getName()+" of "+m_ObjectName+ " time :"+(finish-start));
return ret;
}
/**
*
*/
// public static void main(String[] args) {
// Doit remotex = (Doit) RMIProxyRemoteThread.newInstance(new DoitImpl(),
// "ranode1.informatik.uni-tuebingen.de");
// remotex.doit();
// remotex.doit();
// remotex.doit();
// remotex.doit();
// }
}

View File

@@ -0,0 +1,194 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:31 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.UnknownHostException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.Registry;
///////////////////////////////////////////////////////////////
// -Xrunhprof:cpu=times
// -Djava.security.policy=server.policy
///////////////////////////////////////////////////////////////
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
*
*/
public class RMIServer {
/* Version string of the server application. */
public static boolean TRACE = false;
// public static Registry m_Registry;
protected static RMIServer m_instance;
/* Name of host on which the server is running. */
private String m_MyHostName = "undefined";
/* IP of host on which the server is running. */
private String m_MyHostIP = "undefined";
/* MainAdapterImp object. This is need for the first
connection between the server and the client program. */
public MainAdapter m_MainRemoteObject;
/* String describing the properties of the enviroment. */
// private ComAdapter m_ComAdapter;
public static String m_UserName;
public static int m_NumberOfVM = 0;
Registry m_Registry = null;
/**
*
*/
public static RMIServer getInstance() {
if (m_instance == null) {
m_instance = new RMIServer();
}
return m_instance;
}
/**
* Constructor of EvAServer.
* Calls RMIConnection().
*/
protected RMIServer() {
m_UserName = System.getProperty("user.name");
//System.out.println(EVAHELP.getSystemPropertyString());
initConnection();
// m_ComAdapter = ComAdapter.getInstance();
}
/**
* Main method of this class.
* Is the starting point of the server application.
*/
static public void main(String[] args) {
System.out.println("Start RMIServer !");
RMIServer Application = RMIServer.getInstance();
}
/**
* Launchs the RMIRegistry and makes the registration
* of the MainAdapterImpl class at the rmiregistry.
* @param
*/
private void initConnection() {
String MainAdapterName = m_UserName + MainAdapterImpl.MAIN_ADAPTER_NAME;
System.setProperty("java.security.policy", "server.policy");
launchRMIRegistry();
try {
m_MyHostIP = InetAddress.getLocalHost().getHostAddress();
m_MyHostName = InetAddress.getLocalHost().getHostName();
} catch (Exception e) {
System.out.println("ERROR getting HostName (RMIServer.initConnection)" + e.getMessage());
}
System.out.println("Start of EvA RMI-Server on host " + m_MyHostName + " = " + m_MyHostIP);
// Object test = null;
try {
try {
String[] list =
Naming.list("rmi://localhost:" + MainAdapterImpl.PORT);
// System.out.println("-->list");
// for (int i = 0; i < list.length; i++)
// System.out.println("-->RMIName" + list[i]);
m_NumberOfVM = getNumberOfVM(list);
} catch (RemoteException e) {
System.err.println("no RMI registry available yet...");
if (TRACE)
System.out.println(
"RemoteException OK IAM the first server for this rmiregistry: "
+ e.getMessage());
}
} catch (MalformedURLException ex) {
System.out.println(
"MalformedURLException: Error while looking up "
+ ex.getMessage());
}
createMainRemoteObject(MainAdapterName);
System.out.println("End of RMI-Server Initialisation");
System.out.println(" --> OK on Host: " + m_MyHostName + " = " + m_MyHostIP + ", adapter name is " + MainAdapterName);
System.out.println("Waiting for a client ..............");
}
protected void createMainRemoteObject(String mainAdapterName) {
try {
m_MainRemoteObject = new MainAdapterImpl();
m_MainRemoteObject =
(MainAdapter) RMIProxyLocal.newInstance(m_MainRemoteObject,mainAdapterName + "_" + m_NumberOfVM);
m_MainRemoteObject.setRemoteThis(m_MainRemoteObject);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
*
*/
public MainAdapter getMainRemoteObject() {
return m_MainRemoteObject;
}
/**
* Install RMIregistry on default port !!
*/
private void launchRMIRegistry() {
if (TRACE)
System.out.println(
"LaunchRMIRegistry on Server on PORT " + MainAdapterImpl.PORT);
try {
m_Registry =
java.rmi.registry.LocateRegistry.createRegistry(
MainAdapterImpl.PORT);
} catch (Throwable e) {
if (TRACE)
System.out.println("Registry not created !!" + e.getMessage());
m_Registry = null;
}
if (m_Registry == null) {
System.out.println(
"Try to get registry with getRegistry on PORT "
+ MainAdapterImpl.PORT);
try {
m_Registry =
java.rmi.registry.LocateRegistry.getRegistry(
MainAdapterImpl.PORT);
if (TRACE)
System.out.println(
"m_Registry.REGISTRY_PORT=" + m_Registry.REGISTRY_PORT);
} catch (Throwable e) {
if (TRACE)
System.out.println(
"registry notcreated !!" + e.getMessage());
m_Registry = null;
}
}
if (m_Registry == null) {
System.err.println("--> got no RMIREGISTRY");
} else if (TRACE) System.out.println("--> got RMIREGISTRY");
}
/**
*
*/
private int getNumberOfVM(String[] list) {
int ret = 0;
for (int i = 0; i < list.length; i++) {
if (list[i].indexOf(MainAdapterImpl.MAIN_ADAPTER_NAME) != -1)
ret++;
}
if (TRACE)
System.out.println(" getNumberOfVM() NumberOfVM =" + ret);
return ret;
}
}

View File

@@ -0,0 +1,27 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:31 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.rmi.Remote;
import java.rmi.RemoteException;
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/**
*
*/
public interface RMIThreadInvocationHandler extends Remote {
public Object invoke (String m, Object[] args)throws RemoteException;
public Object getWrapper () throws RemoteException;
public void setWrapper(Object Wrapper) throws RemoteException;
public String getServerName()throws RemoteException;
}

View File

@@ -0,0 +1,147 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.2 $
* $Date: 2004/04/15 12:28:34 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import wsi.ra.math.RNG;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
*
*/
public class RMIThreadInvocationHandlerImpl extends UnicastRemoteObject implements RMIThreadInvocationHandler {
public static final boolean TRACE = false;
private Object m_Object;
private String m_AdapterName;
private Object m_Wrapper;
private Method[] m_list;
private String m_hostname;
/**
*
* @return
*/
public String getServerName() {
return m_hostname;
}
/**
*
*/
public RMIThreadInvocationHandlerImpl(Object obj) throws RemoteException {
try {
m_hostname = InetAddress.getLocalHost().getHostName();
}
catch (Exception e) {
System.out.println("ERROR getting HostName (RMIThreadInvokationHandlerImpl(obj))" + e.getMessage());
}
m_AdapterName = obj.getClass().getName()+"_"+RNG.randomInt(0,10000);
try {
m_Object = ThreadProxy.newInstance(obj);
m_list = m_Object.getClass().getMethods();
if (TRACE) System.out.println(" --> rebind : "+m_AdapterName+" RMIThreadInvokationHandlerImpl of object "+obj.getClass().getName());
Naming.rebind(m_AdapterName,this);
} catch (Exception e) {
System.out.println(" Naming.rebind --> ERROR" + e.getMessage());
e.printStackTrace();
}
}
/**
*
*/
public RMIThreadInvocationHandlerImpl(Object obj,String AdapterName) throws RemoteException {
try {
m_hostname = InetAddress.getLocalHost().getHostName();
}
catch (Exception e) {
System.out.println("ERROR getting HostName (RMIThreadInvokationHandlerImpl(obj,adapt))" + e.getMessage());
}
m_AdapterName = AdapterName;
try {
m_Object = ThreadProxy.newInstance(obj);
m_list = m_Object.getClass().getMethods();
if (TRACE) System.out.println(" -----> rebind : "+m_AdapterName+" "+this.getClass().getName()+" of object "+obj.getClass().getName());
Naming.rebind(m_AdapterName,this);
} catch (Exception e) {
System.out.println(" Naming.rebind --> ERROR" + e.getMessage());
}
}
/**
*
*/
public void setWrapper(Object Wrapper) throws RemoteException {
m_Wrapper = Wrapper;
}
/**
*
*/
public Object getWrapper () throws RemoteException {
return m_Wrapper;
}
/**
*
*/
public Object invoke (String m, Object[] args) throws RemoteException {
Object ret=null;
String Name = "";
if (TRACE) Name = Thread.currentThread().getName();
try {
if (TRACE) System.out.println( Name+" Before invoke on server :" +m);
//Method[] list = m_Object.getClass().getMethods();
boolean invoked = false;
for (int i=0;i<m_list.length;i++) {
//if (TRACE) System.out.println(Name+" list[i].getName() "+list[i].getName());
if (m.startsWith("free") == true) {
// System.out.println("called free !!!!!!!!!!!!!!!!!!!!!!!!!" + m_AdapterName);
String[] list = Naming.list("rmi://localhost:" + MainAdapterImpl.PORT);
// System.out.println("-->list :" + list.length);
for (int j = 0; j < list.length; j++) {
// System.out.println("list=" + list[j] + "--" + m_AdapterName);
if (list[j].lastIndexOf(m_AdapterName) != -1) {
// System.out.println("unbind !!!!!!!!!!!!!!!!!!!!!!!!!!");
Naming.unbind(list[j]);
return null;
}
}
System.out.println("Object not found !!!!!");
return null;
}
if (m.equals(m_list[i].getName())==true) {
//if (TRACE)System.out.println(Name+" find "+m);
//if (args==null) System.out.println(Name+" args==null ");
ret = m_list[i].invoke(m_Object,args);
invoked= true;
break;
}
}
if (invoked==false) System.out.println(Name+ " No memberfunction found !!!!!!!!!!!!!!!!!");
}
catch ( InvocationTargetException e) {
e.printStackTrace();
System.out.println(Name+" RMIThreadInvokationHandlerImpl InvocationTargetException "+e.getMessage());
}
catch (Exception e) {
e.printStackTrace();
System.out.println(Name+" Exception :"+e.getMessage());
}
return ret;
}
}

View File

@@ -0,0 +1,27 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.1 $
* $Date: 2004/04/15 09:12:30 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
/*==========================================================================*
* INTERFACE DECLARATION
*==========================================================================*/
/**
*
*/
public interface RemoteStateListener {
public void performedStop();
public void performedStart(String infoString);
public void performedRestart(String infoString);
public void updateProgress(final int percent);
}

View File

@@ -0,0 +1,96 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.2 $
* $Date: 2004/04/28 07:50:33 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.io.Serializable;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/*==========================================================================*
* CLASS DECLARATION
*==========================================================================*/
/**
*
*/
public class ThreadProxy implements InvocationHandler,
Serializable {
private Object m_Object;
private ThreadWrapper m_ThreadWrapper;
private int m_maxthreads = 8;
/**
*
*/
public static Object newInstance (Object obj) {
return Proxy.newProxyInstance(
obj.getClass().getClassLoader(),
obj.getClass().getInterfaces(),
new ThreadProxy(obj));
}
/**
*
*/
public static Object newInstance (Object obj,int maxthreads) {
return Proxy.newProxyInstance(
obj.getClass().getClassLoader(),
obj.getClass().getInterfaces(),
new ThreadProxy(obj,maxthreads));
}
/**
*
*/
public ThreadProxy (Object obj) {
m_Object = obj;
}
/**
*
*/
public ThreadProxy (Object obj,int maxthreads) {
m_Object = obj;
m_maxthreads = maxthreads;
}
/**
*
*/
public Object invoke (Object proxy,Method method,Object[] args) throws Throwable {
Class rettype = method.getReturnType();
if (rettype.equals(Void.TYPE)== true) {
if (m_ThreadWrapper == null) {
m_ThreadWrapper = new ThreadWrapper(m_maxthreads);
}
else {
m_ThreadWrapper.pleasewait();
}
m_ThreadWrapper.invoke(m_Object,method,args);
return null;
}
Object ret = null;
try {
if (method.getName().equals("isAlive")) {
if (m_ThreadWrapper != null) {
Boolean rret = new Boolean(m_ThreadWrapper.isAlive());
// System.out.println("calling is alive" +rret);
return rret;
}
}
if (m_ThreadWrapper != null)
m_ThreadWrapper.pleasewait();
ret = method.invoke(m_Object, args);
} catch (Exception e) {
System.out.println("ERROR +" + e.getMessage());
e.printStackTrace();
}
return ret;
}
}

View File

@@ -0,0 +1,83 @@
package wsi.ra.jproxy;
/**
* Title: The JProxy Framework
* Description: API for distributed and parallel computing.
* Copyright: Copyright (c) 2004
* Company: University of Tuebingen
* @version: $Revision: 1.2 $
* $Date: 2004/04/28 07:50:33 $
* $Author: ulmerh $
*/
/*==========================================================================*
* IMPORTS
*==========================================================================*/
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.io.Serializable;
/*
* ==========================================================================*
* CLASS DECLARATION
* ==========================================================================
*/
public class ThreadWrapper extends ArrayList {
private int m_counter = 0;
private ArrayList m_ThreadContainer = new ArrayList();
private static int m_numberofMAXThreads = 4;
/**
*
*/
public ThreadWrapper(int number) {
m_numberofMAXThreads = number;
}
/**
*
*/
public ThreadWrapper() {
}
/**
*
*/
public synchronized void invoke(Object x, String Method, Object[] Para) {
m_ThreadContainer.add(XThread.getXThread(x, Method, Para, m_numberofMAXThreads));
// System.out.println("ADDED to THREADWRAPPER LIST" + m_ThreadContainer.size());
}
/**
*
*/
public synchronized void invoke(Object x, Method m, Object[] Para) {
m_ThreadContainer.add(XThread.getXThread(x, m, Para, m_numberofMAXThreads));
// System.out.println("ADDED to THREADWRAPPER LIST" + m_ThreadContainer.size());
}
/**
*
*/
public synchronized void pleasewait() {
for (int i = 0; i < m_ThreadContainer.size(); i++) {
try {
((Thread) m_ThreadContainer.get(i)).join();
m_ThreadContainer.remove(i); // testhu
} catch (InterruptedException e) {
e.printStackTrace();
System.out.println("Error");
}
}
}
/**
*
*/
public synchronized boolean isAlive() {
for (int i = 0; i < m_ThreadContainer.size(); i++) {
boolean alive = ((Thread) m_ThreadContainer.get(i)).isAlive();
if (alive == true)
return true;
}
return false;
}
}

View File

@@ -0,0 +1,257 @@
package wsi.ra.jproxy;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.io.Serializable;
/*
* ==========================================================================*
* CLASS DECLARATION
* ==========================================================================
*/
public class XThread extends Thread implements Serializable {
private Object m_Object;
private volatile Method m_Method;
private volatile Object[] m_Para;
//private static byte m_instances = 0;
private static XThread[] m_Instances;
private static int m_MAXinstances = 10;
private static int m_index = 0;
public static void init(int x) {
m_MAXinstances = x;
m_Instances = new XThread[m_MAXinstances];
m_index = 0;
}
// private static void instup() {
// m_instances++;
// }
//
// private static void instdown() {
// m_instances--;
// }
public static int get() {
int ret =0;
if (m_Instances==null) return ret;
for (int i=0;i<m_Instances.length;i++) {
if (m_Instances[i]==null) continue;
if (m_Instances[i].isAlive() == true)
ret++;
}
return ret;
}
/**
*
*/
public static XThread getXThread(Object x, Method m, Object[] Para, int MAXinstances) {
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)
init(MAXinstances);
if (m_index >= m_Instances.length)
m_index = 0;
if (m_Instances[m_index] == null) {
ret = new XThread(x, m, Para);
m_Instances[m_index] = ret;
m_index++;
return ret;
}
int w = 1;
while (true) {
for (int i = 0; i < m_Instances.length; i++) {
if (m_Instances[i] == null) {
m_index = i;
ret = new XThread(x, m, Para);
m_Instances[m_index] = ret;
m_index++;
return ret;
}
if (m_Instances[i].isAlive() == false) {
m_index = i;
ret = new XThread(x, m, Para);
m_Instances[m_index] = ret;
m_index++;
return ret;
}
}
try {
Thread.sleep(w);
w = 2 * w; //System.out.println(""+i);
} catch (Exception e) {
System.out.println("Error in sleep of XThread");
}
} // 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) {
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);
if (m_index >= m_Instances.length)
m_index = 0;
if (m_Instances[m_index] == null) {
ret = new XThread(x, m, Para);
m_Instances[m_index] = ret;
m_index++;
return ret;
}
int w = 1;
while (true) {
for (int i = 0; i < m_Instances.length; i++) {
if (m_Instances[i] == null) {
m_index = i;
ret = new XThread(x, m, Para);
m_Instances[m_index] = ret;
m_index++;
return ret;
}
if (m_Instances[i].isAlive() == false) {
m_index = i;
ret = new XThread(x, m, Para);
m_Instances[m_index] = ret;
m_index++;
return ret;
}
}
try {
Thread.sleep(w);
w = 2 * w; //System.out.println(""+i);
} catch (Exception e) {
System.out.println("Error in sleep of XThread");
}
} // end of while true
}
/**
*
*/
// 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++) {
System.out.println("TRYING TO REMOVE");
if (this.m_Instances[i] == this) {
this.m_Instances[i] = null;
System.out.println("REMOVED");
return;
}
}
System.out.println("DANGER!!!!!!!!! XTHREAD ->NOT<- REMOVED");
}
/**
*
*/
private XThread(Object object, Method method, Object[] Para) {
System.out.println("XTHREAD INSTANZIERT");
m_Object = object;
m_Para = Para;
m_Method = method;
start();
}
/**
*
*/
private XThread(Object x, String method, Object[] Para) {
System.out.println("XTHREAD INSTANZIERT");
m_Object = x;
m_Para = Para;
try {
Method[] methods = x.getClass().getDeclaredMethods();
for (int i = 0; i < methods.length; i++) {
if (methods[i].getName().equals(method) == true) {
m_Method = methods[i];
break;
}
}
} catch (Exception e) {
System.out.println(" ERROR in XTHREAD +" + e.getMessage());
e.printStackTrace();
}
start();
}
/**
*
*/
public void run() {
System.out.println("XTHREAD CALLED RUN");
if (m_Method != null) {
//setPriority(Thread.MAX_PRIORITY);
try {
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.out.println("ERROR +" + e.getMessage());
e.printStackTrace();
}
} else {
System.out.println("Warning Method == null !!!!! in ThreadWrapper");
}
removemyself();
}
}