| 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 |
|
//---PACKAGE DECLARATION--- |
| 21 |
< |
package uk.ac.ukc.iscream.filter.plugins; |
| 21 |
> |
package uk.org.iscream.cms.server.filter.plugins; |
| 22 |
|
|
| 23 |
|
//---IMPORTS--- |
| 24 |
< |
import uk.ac.ukc.iscream.filter.PluginFilter; |
| 25 |
< |
import uk.ac.ukc.iscream.filter.*; |
| 26 |
< |
import uk.ac.ukc.iscream.core.*; |
| 27 |
< |
import uk.ac.ukc.iscream.util.*; |
| 24 |
> |
import uk.org.iscream.cms.server.filter.PluginFilter; |
| 25 |
> |
import uk.org.iscream.cms.server.filter.*; |
| 26 |
> |
import uk.org.iscream.cms.server.core.*; |
| 27 |
> |
import uk.org.iscream.cms.server.util.*; |
| 28 |
> |
import uk.org.iscream.cms.server.componentmanager.*; |
| 29 |
|
|
| 30 |
|
/** |
| 31 |
< |
* A first plugin! ;-) |
| 32 |
< |
* this one rejects packets that do not contain all of the 'essential' data. |
| 31 |
> |
* This plugin rejects packets that do not |
| 32 |
> |
* contain all of the 'essential' data. |
| 33 |
|
* |
| 34 |
|
* @author $Author$ |
| 35 |
|
* @version $Id$ |
| 43 |
|
*/ |
| 44 |
|
public final String REVISION = "$Revision$"; |
| 45 |
|
|
| 46 |
< |
public final String DESC = "Rejects packets that do not have an ip, machine_name, seq_no and date specified as attributes of the root packet tag."; |
| 46 |
> |
public final String DESC = "Rejects packets that do not have an ip, machine_name, seq_no, date and type specified as attributes of the root packet tag."; |
| 47 |
|
|
| 48 |
|
//---STATIC METHODS--- |
| 49 |
|
|
| 54 |
|
// apply the filter and return true if successful. |
| 55 |
|
public boolean runFilter(XMLPacket packet){ |
| 56 |
|
|
| 57 |
< |
// return false if any of the essential data is not present. |
| 57 |
> |
// return true if a heartbeat packet seems ok |
| 58 |
> |
if (packet.getParam("packet.attributes.type").equals("heartbeat") |
| 59 |
> |
&& packet.getParam("packet.attributes.date") != null |
| 60 |
> |
&& packet.getParam("packet.attributes.ip") != null |
| 61 |
> |
&& packet.getParam("packet.attributes.machine_name") != null){ |
| 62 |
> |
return true; |
| 63 |
> |
} |
| 64 |
> |
|
| 65 |
> |
// return true if a queueStat packet seems ok |
| 66 |
> |
if (packet.getParam("packet.attributes.type").equals("queueStat") |
| 67 |
> |
&& packet.getParam("packet.attributes.date") != null |
| 68 |
> |
&& packet.getParam("packet.attributes.name") != null){ |
| 69 |
> |
return true; |
| 70 |
> |
} |
| 71 |
> |
|
| 72 |
> |
// return false if any of the essential data is not present |
| 73 |
> |
// in a "data" packet |
| 74 |
|
if (packet.getParam("packet.attributes.machine_name") == null |
| 75 |
|
|| packet.getParam("packet.attributes.ip") == null |
| 76 |
|
|| packet.getParam("packet.attributes.seq_no") == null |
| 77 |
< |
|| packet.getParam("packet.attributes.date") == null){ |
| 77 |
> |
|| packet.getParam("packet.attributes.date") == null |
| 78 |
> |
|| packet.getParam("packet.attributes.type") == null){ |
| 79 |
|
return false; |
| 80 |
|
} |
| 81 |
|
|
| 88 |
|
* Overrides the {@link java.lang.Object#toString() Object.toString()} |
| 89 |
|
* method to provide clean logging (every class should have this). |
| 90 |
|
* |
| 91 |
< |
* This uses the uk.ac.ukc.iscream.util.NameFormat class |
| 91 |
> |
* This uses the uk.org.iscream.cms.server.util.NameFormat class |
| 92 |
|
* to format the toString() |
| 93 |
|
* |
| 94 |
|
* @return the name of this class and its CVS revision |