View Javadoc

1   /*
2    * $Id: CommonHostsJDTAlerter.java,v 1.3 2004/03/11 09:49:22 johndavidtaylor
3    * Exp $ Created on Feb 20, 2004 by John Taylor jdt@roe.ac.uk .
4    */
5   package org.abraracourcix.alipes.alerters;
6   import java.net.MalformedURLException;
7   import java.net.URL;
8   import org.abraracourcix.alipes.common.Event;
9   import org.abraracourcix.alipes.listeners.filter.EventFilterListener;
10  import org.abraracourcix.alipes.listeners.logging.ConsoleListener;
11  import org.abraracourcix.alipes.listeners.status.StatusFrame;
12  import org.abraracourcix.alipes.listeners.status.StatusListener;
13  import org.abraracourcix.alipes.monitors.url.URLEvent;
14  import org.abraracourcix.alipes.monitors.url.URLMonitor;
15  import org.abraracourcix.alipes.pipes.Multiplexor;
16  /***
17   * 
18   * About as trivial as we can make it. An alerter that watches the local tomcat
19   * inst.
20   * @author jdt
21   */
22  public final class CommonHostsJDTAlerter {
23      /***
24       * Hide public Constructor
25       *  
26       */
27      private CommonHostsJDTAlerter() {
28      }
29      /***
30       * Main method - @TODO needs tarting up
31       * 
32       * @param args
33       *            ignored
34       * @throws MalformedURLException
35       *             whoops
36       * @throws InterruptedException
37       *             whoops
38       */
39      public static void main(final String[] args)
40          throws MalformedURLException, InterruptedException {
41          System.out.println("Hit ctrl-C when you get bored");
42          Event[] events =
43              { URLEvent.DOWN, URLEvent.GONE_DOWN, URLEvent.GONE_UP };
44          Multiplexor multiplex = new Multiplexor();
45          EventFilterListener filterAndConsole =
46              new EventFilterListener(
47                  new ConsoleListener(),
48                  events,
49                  EventFilterListener.FilterType.INCLUDED);
50          multiplex.addListener(filterAndConsole);
51          URLMonitor mon =
52              new URLMonitor(
53                  multiplex,
54                  5,
55                  new URL("http://uml01.astrogrid.org:8080"));
56          mon.addNewURL(new URL("http://vm05.astrogrid.org:8080"));
57          mon.addNewURL(new URL("http://vm06.astrogrid.org:8080"));
58          mon.addNewURL(new URL("http://vm07.astrogrid.org:8080"));
59          mon.addNewURL(new URL("http://localhost:8080"));
60          mon.start();
61          StatusFrame frame = new StatusFrame();
62          StatusListener statusListener = new StatusListener(frame);
63          frame.registerStatusListener(statusListener);
64          frame.show();
65          multiplex.addListener(statusListener);
66          Thread.sleep(60 * 10 * 1000);
67      }
68  }
69  /*
70   * $Log: CommonHostsJDTAlerter.java,v $
71   * Revision 1.1  2004/04/27 10:57:51  johndavidtaylor
72   * changed package name
73   *
74   * Revision 1.1  2004/03/17 21:16:51  johndavidtaylor
75   * Copied across from incubation in beanpeeler
76   *
77   * Revision 1.6  2004/03/14 18:49:14  johndavidtaylor
78   * corrected comments
79   *
80   * Revision 1.5  2004/03/11 15:46:34  johndavidtaylor
81   * Applied coding standards
82   * Revision 1.4 2004/03/11 11:33:46
83   * johndavidtaylor Refactored the way that the PollingMonitor worked.
84   * Previously it got started in its ctor, but this allowed access to subclass
85   * resources that hadn't yet been initialised. Bad. Now needs to be started
86   * explicitly post-construction. Revision 1.3 2004/03/11 09:49:22
87   * johndavidtaylor Loads of updates
88   * 
89   * Revision 1.2 2004/03/08 20:16:44 johndavidtaylor refactored to new package
90   * name
91   * 
92   * Revision 1.1 2004/03/08 19:58:24 johndavidtaylor Initial commit -transfer
93   * from previous repository
94   * 
95   * Revision 1.1 2004/03/02 23:04:37 jdt new
96   *  
97   */