FileDocCategorySizeDatePackage
RMIPanel.javaAPI DocExample2072Sun Feb 08 21:33:42 GMT 2004None

RMIPanel

public class RMIPanel extends NetPanel implements Runnable
Displays one machines status, for RMI..
author
Ian F. Darwin, http://www.darwinsys.com/ Copyright (c) 2000, Ian F. Darwin. See LEGAL.NOTICE for licensing.
version
$Id: RMIPanel.java,v 1.4 2004/02/09 03:33:41 ian Exp $

Fields Summary
Constructors Summary
public RMIPanel(String host, Properties p)

		super(host, p);
	
Methods Summary
public voidrun()
Keep the screen updated forever, unless stop()ped.

		String thePort = props.getProperty("rmiwatch.port", "");
		String theURL = "rmi://" + hostName + ":" + thePort;
		while (!done) {
			try {
				String[] names = Naming.list(theURL);
				ta.setText("");
				for (int i=0; i<names.length; i++) {
					ta.append(i + ": " + names[i] + "\n");
				}
				// If we didnt get an exception, host is up.
				String expect = props.getProperty("rmiwatch.expect");
				String fullText = ta.getText();
				if (fullText.length() == 0) {
					ta.setText("(nothing registered!)");
					setState(EMPTY);
				} else if (expect != null && fullText.indexOf(expect)==-1) {
					setState(DUBIOUS);
				} else setState(FINE);
			} catch (java.rmi.ConnectIOException e) {
				setState(DOWN);
				ta.setText("Net error: " + e.detail.getClass());
			} catch (java.rmi.ConnectException e) {
				setState(NOREG);
				ta.setText("RMI error: " + e.getClass().getName() + "\n" +
					"  " + e.detail.getClass());
				// System.err.println(hostName + ":" + e);
			} catch (RemoteException e) {
				setState(NOREG);
				ta.setText("RMI error: " + e.getClass().getName() + "\n" +
					"  " + e.detail.getClass());
			} catch (MalformedURLException e) {
				setState(DOWN);
				ta.setText("Invalid host: " + e.toString());
			} finally {
				// sleep() in "finally" so common "down" states dont bypass.
				// Randomize time so we dont make net load bursty.
				try {
					Thread.sleep((int)(sleepTime * MSEC * 2 * Math.random()));
				} catch (InterruptedException e) {
					/*CANTHAPPEN*/
				}
			}
		}