ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/server/uk/org/iscream/cms/server/client/ClientServant.java
(Generate patch)

Comparing projects/cms/source/server/uk/org/iscream/cms/server/client/ClientServant.java (file contents):
Revision 1.3 by tdb, Mon Feb 5 04:03:22 2001 UTC vs.
Revision 1.11 by tdb, Sat May 18 18:16:00 2002 UTC

# Line 1 | Line 1
1 < package uk.ac.ukc.iscream.client;
1 > /*
2 > * i-scream central monitoring system
3 > * Copyright (C) 2000-2002 i-scream
4 > *
5 > * This program is free software; you can redistribute it and/or
6 > * modify it under the terms of the GNU General Public License
7 > * as published by the Free Software Foundation; either version 2
8 > * of the License, or (at your option) any later version.
9 > *
10 > * This program is distributed in the hope that it will be useful,
11 > * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 > * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 > * GNU General Public License for more details.
14 > *
15 > * You should have received a copy of the GNU General Public License
16 > * along with this program; if not, write to the Free Software
17 > * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 > */
19  
20 < import uk.ac.ukc.iscream.client.*;
21 < import uk.ac.ukc.iscream.clientinterface.*;
5 < import uk.ac.ukc.iscream.util.*;
6 < import org.omg.CosNaming.*;
7 < import org.omg.CORBA.*;
8 < import org.omg.PortableServer.*;
9 < import java.io.*;
20 > //---PACKAGE DECLARATION---
21 > package uk.org.iscream.cms.server.client;
22  
23 + //---IMPORTS---
24 + import uk.org.iscream.cms.server.componentmanager.*;
25 + import uk.org.iscream.cms.server.core.*;
26 + import uk.org.iscream.cms.server.util.*;
27 +
28 + /**
29 + * A servant for the LocalClient.
30 + * This represents the Client interface for CORBA
31 + * clients connecting to the i-scream system on the ClientInterface.
32 + *
33 + * The i-scream ClientInterface pumps data over CORBA into the
34 + * queue, using the recieveXML method.  The MonitorManager
35 + * then handles pulling the data out of this queue.
36 + *
37 + * @author  $Author$
38 + * @version $Id$
39 + */
40   class ClientServant extends ClientPOA {
41 +
42 + //---FINAL ATTRIBUTES---
43 +
44 +    /**
45 +     * The current CVS revision of this class
46 +     */
47 +    public static final String REVISION = "$Revision$";
48 +    
49 + //---STATIC METHODS---
50 +
51 + //---CONSTRUCTORS---
52 +    
53 +    /**
54 +     * Construct a new ClientServant, with a given Queue.
55 +     *
56 +     * @param queue The Queue that will link this class to the MonitorManager
57 +     */
58 +    public ClientServant(Queue queue) {
59 +        _queue = queue;
60 +    }
61 +
62 + //---PUBLIC METHODS---
63 +    
64 +    /**
65 +     * Adds the inbound data to our queue when the CORBA method is called.
66 +     *
67 +     * @param xml The String of XML data
68 +     */
69      public void receiveXML(String xml) {
70 <        XMLPacketMaker xmlPacketMaker = new XMLPacketMaker(xml);
14 <        XMLPacket packet = xmlPacketMaker.createXMLPacket();
15 <        String machine_name = packet.getParam("packet.attributes.machine_name");
16 <        String cpuuser = packet.getParam("packet.cpu.user");
17 <        System.out.println("Hostname: " + machine_name + "\t\tUser CPU: " + cpuuser);
18 <        if(cpuuser != null) {
19 <            double c = new Double(cpuuser).doubleValue();
20 <            if (c > 80.0) {
21 <                String alert = "WARNING: Host "+machine_name+" has reached "+cpuuser+"% user CPU, which exceeds the threshold of 80%";
22 <                try {
23 <                    Smtp smtp = new Smtp("mercury.ukc.ac.uk");
24 <                    smtp.from("tdb1@ukc.ac.uk");
25 <                    smtp.to("dev@i-scream.org.uk");
26 <                    PrintWriter out = smtp.getOutputStream();
27 <                    out.println("Subject: i-scream Local Client proof-of-concept Test");
28 <                    out.println();
29 <                    out.println(alert);
30 <                    smtp.sendMessage();
31 <                    smtp.close();
32 <                } catch(IOException e) {System.out.println(e);}
33 <            }
34 <        }
70 >        _queue.add(xml);
71      }
36 }
72  
73 +    /**
74 +     * Overrides the {@link java.lang.Object#toString() Object.toString()}
75 +     * method to provide clean logging (every class should have this).
76 +     *
77 +     * This uses the uk.org.iscream.cms.server.util.FormatName class
78 +     * to format the toString()
79 +     *
80 +     * @return the name of this class and its CVS revision
81 +     */
82 +    public String toString() {
83 +        return FormatName.getName(
84 +            _name,
85 +            getClass().getName(),
86 +            REVISION);
87 +    }
88 +
89 + //---PRIVATE METHODS---
90 +
91 + //---ACCESSOR/MUTATOR METHODS---
92 +
93 + //---ATTRIBUTES---
94 +
95 +    /**
96 +     * This is the friendly identifier of the
97 +     * component this class is running in.
98 +     * eg, a Filter may be called "filter1",
99 +     * If this class does not have an owning
100 +     * component,  a name from the configuration
101 +     * can be placed here.  This name could also
102 +     * be changed to null for utility classes.
103 +     */
104 +    private String _name = ClientMain.NAME;
105 +
106 +    /**
107 +     * This holds a reference to the
108 +     * system logger that is being used.
109 +     */
110 +    private Logger _logger = ReferenceManager.getInstance().getLogger();
111 +
112 +    /**
113 +     * A reference to our Queue to place the inbond data into.
114 +     */
115 +    private Queue _queue;
116 +
117 + //---STATIC ATTRIBUTES---
118 +
119 + }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines