### Eclipse Workspace Patch 1.0 #P org.eclipse.hyades.logging.adapter Index: .project =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.adapter/.project,v retrieving revision 1.1 diff -u -r1.1 .project --- .project 26 Jan 2005 16:02:17 -0000 1.1 +++ .project 1 Feb 2006 15:54:00 -0000 @@ -3,8 +3,6 @@ org.eclipse.hyades.logging.adapter - org.apache.jakarta_oro - org.eclipse.hyades.logging.core Index: .classpath =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.adapter/.classpath,v retrieving revision 1.3 diff -u -r1.3 .classpath --- .classpath 17 May 2005 15:35:37 -0000 1.3 +++ .classpath 1 Feb 2006 15:54:00 -0000 @@ -1,8 +1,8 @@ - - + + Index: plugin.xml =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.adapter/plugin.xml,v retrieving revision 1.6 diff -u -r1.6 plugin.xml --- plugin.xml 15 Aug 2005 18:09:52 -0000 1.6 +++ plugin.xml 1 Feb 2006 15:54:00 -0000 @@ -5,6 +5,7 @@ + 0) { - MessageString[] messages=new MessageString[entries.length]; + + MessageString[] tmpMessages=new MessageString[entries.length]; + int validMsgCount = 0; for(int i=0; i + + + + + + + + This extension point is used for registering IFilterExit classes with the adapter. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [Enter the first release in which this extension point appears.] + + + + + + + + + <pre> + <extension point="org.eclipse.hyades.logging.adapter.filterExit"> + <filterClassname name="com.xxx.adapter.util.MyFilter"> + </filterClassname> + </extension> +</pre> + + + + + + + + + The value of the name attribute of the filterExitClassname element must be an implementation of <samp>org.eclipse.hyades.logging.adapter.util.IFilterExit</samp>. + + + + + + + + + [Enter information about supplied implementation of this extension point.] + + + + + + + + + Copyright (c) 2005 IBM Corporation and others. +All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> + + + + #P org.eclipse.hyades.logging.parsers Index: src/org/eclipse/hyades/logging/parsers/Parser.java =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/src/org/eclipse/hyades/logging/parsers/Parser.java,v retrieving revision 1.10 diff -u -r1.10 Parser.java --- src/org/eclipse/hyades/logging/parsers/Parser.java 26 Jan 2006 20:33:22 -0000 1.10 +++ src/org/eclipse/hyades/logging/parsers/Parser.java 1 Feb 2006 15:54:23 -0000 @@ -20,6 +20,11 @@ import java.util.Locale; import org.apache.commons.logging.Log; +import org.eclipse.hyades.logging.adapter.sensors.BasicFilterExit; +import org.eclipse.hyades.logging.adapter.util.FilterExitLoaderUtil; +import org.eclipse.hyades.logging.adapter.util.IFilterExit; +import org.eclipse.hyades.logging.adapter.util.InvalidFilterSpecification; +import org.eclipse.hyades.logging.adapter.util.Messages; import org.eclipse.hyades.logging.adapter.util.MultipleFilesReader; import org.eclipse.hyades.logging.adapter.util.SequenceNumbersByTime; import org.eclipse.hyades.logging.events.cbe.CommonBaseEvent; @@ -130,6 +135,21 @@ * String to hold lines read from log file to be parsed. */ protected String curLine = ""; + + /** + * Regular expression for filter specification + */ + protected String filter = null; + + /** + * filterExit class name + */ + protected String filterExitClass = null; + + /** + * Instance of filterExit class + */ + protected IFilterExit filterExitClassInstance = null; /** * Factory for creating events. @@ -401,6 +421,67 @@ totalSize = file.length(); logFile = new RandomAccessFile(file,"r"); } + /** + * bugzilla 79565. It allows user to define rules for GLA sensor or extractor + * to filter out lines, records or data that are not of interest. + * filter is used to store the rule. + * filterExitClass is used to store the name of filterEixt class which is + * provided by users. If users only define the filter rules, but not provide filterExitClass, + * the BasicFilterExit class will be used with the user defined filter rules. + */ + filter = ((String) (table.get(ParserConstants.FILTER_SPECIFICATION_KEY))); + filterExitClass = ((String) (table.get(ParserConstants.FILTER_EXIT_CLASS))); + + if (filter != null) { + filter = filter.trim(); + if (filter.length() == 0) { + filter = null; + } + } + + if (filterExitClass != null) { + filterExitClass = filterExitClass.trim(); + if (filterExitClass.length() == 0) { + filterExitClass = null; + } + } + //Check if the filterExit property is not null + if (filterExitClass !=null && !filterExitClass.equals("")) { + try { + // load the class and instantiate an object + filterExitClassInstance = FilterExitLoaderUtil.instantiate(filterExitClass); + if(filter != null && !filter.equals("")) + { + try + { + filterExitClassInstance.setFilterSpecification(filter); + }catch (InvalidFilterSpecification ex) + { + throw new LogParserException(ParserUtilities.getResourceString("LOG_PARSER_INVALID_FILTER_SPECIFICATION_ERROR_",filter)); + } + } + } + catch (Exception e) { + + throw new LogParserException(ParserUtilities.getResourceString("LOG_PARSER_LOAD_FILTEREXIT_CLASS_ERROR_",filterExitClass)); + } + }else if(filter != null && !filter.equals("")) + { + //users don't provide the filter class, but give the filter specification, + // then use BasicFilterExit class + filterExitClassInstance = new BasicFilterExit(); + try + { + filterExitClassInstance.setFilterSpecification(filter); + }catch (InvalidFilterSpecification ex) + { + + throw new LogParserException(ParserUtilities.getResourceString("LOG_PARSER_INVALID_FILTER_SPECIFICATION_ERROR_",filter)); + + } + + } + charset = ((String) (table.get(ParserConstants.FILE_CHARSET_KEY))); fileLocale = ((Locale)(table.get(ParserConstants.FILE_LOCALE_KEY))); @@ -789,4 +870,12 @@ public long getTotalSize() { return totalSize; } + + /** + * Get the instance of IFilteExit class + * @returns filterExitClassInstance + */ + public IFilterExit getFilterExitClassInstance() { + return filterExitClassInstance; + } } Index: src/org/eclipse/hyades/logging/parsers/AbstractAccessLogParser.java =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/src/org/eclipse/hyades/logging/parsers/AbstractAccessLogParser.java,v retrieving revision 1.7 diff -u -r1.7 AbstractAccessLogParser.java --- src/org/eclipse/hyades/logging/parsers/AbstractAccessLogParser.java 25 Jan 2006 23:29:43 -0000 1.7 +++ src/org/eclipse/hyades/logging/parsers/AbstractAccessLogParser.java 1 Feb 2006 15:54:23 -0000 @@ -25,6 +25,7 @@ import java.util.Date; import java.util.Locale; +import org.eclipse.hyades.logging.adapter.AdapterException; import org.eclipse.hyades.logging.core.Guid; import org.eclipse.hyades.logging.events.cbe.CommonBaseEvent; import org.eclipse.hyades.logging.events.cbe.ComponentIdentification; @@ -176,6 +177,26 @@ //Only parse non-empty (e.g. lines with one or more non-whitespace characters) lines: if (curLine.length() > 0) { + + if(filterExitClassInstance != null) + { + try + { + boolean pass = filterExitClassInstance.filter(curLine); + if(!pass) + { + //Read the next line in the file: + curLine = readALine(); + continue; + } + + }catch (AdapterException e) + { + + throw new LogParserException(ParserUtilities.getResourceString("LOG_PARSER_FILTERING_ERROR_", curLine)); + } + + } //Parse the log record: //ASSUMPTION: Access log records do NOT span multiple lines. Each log record is contained on one line. Index: src/org/eclipse/hyades/logging/parsers/ParserConstants.java =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/src/org/eclipse/hyades/logging/parsers/ParserConstants.java,v retrieving revision 1.9 diff -u -r1.9 ParserConstants.java --- src/org/eclipse/hyades/logging/parsers/ParserConstants.java 26 Jan 2006 20:33:23 -0000 1.9 +++ src/org/eclipse/hyades/logging/parsers/ParserConstants.java 1 Feb 2006 15:54:23 -0000 @@ -55,7 +55,9 @@ public final static String FILE_CHARSET_KEY = "characater_set"; public final static String FILE_LOCALE_KEY = "locale"; public final static String CONTINUOUS_KEY = "continuous"; - + public final static String FILTER_SPECIFICATION_KEY = "filter"; + public final static String FILTER_EXIT_CLASS = "filterExitClass"; + public final static String APACHE_VERSION_KEY = "APACHE_VERSION"; public final static String APPLICATION_VERSION_KEY = "version"; public final static String APACHE_HTTP_SERVER = "Apache HTTP Server"; Index: src/org/eclipse/hyades/logging/parsers/AbstractErrorLogParser.java =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/src/org/eclipse/hyades/logging/parsers/AbstractErrorLogParser.java,v retrieving revision 1.6 diff -u -r1.6 AbstractErrorLogParser.java --- src/org/eclipse/hyades/logging/parsers/AbstractErrorLogParser.java 25 Jan 2006 23:29:43 -0000 1.6 +++ src/org/eclipse/hyades/logging/parsers/AbstractErrorLogParser.java 1 Feb 2006 15:54:23 -0000 @@ -24,6 +24,8 @@ import java.util.Date; import java.util.Locale; +import org.eclipse.hyades.logging.adapter.AdapterException; +import org.eclipse.hyades.logging.adapter.util.IFilterExit; import org.eclipse.hyades.logging.core.Guid; import org.eclipse.hyades.logging.events.cbe.CommonBaseEvent; import org.eclipse.hyades.logging.events.cbe.ComponentIdentification; @@ -145,6 +147,7 @@ curLine = readALine(); arrayIndex = 0; + IFilterExit filterExitClassInstance = getFilterExitClassInstance(); try { @@ -156,6 +159,25 @@ //Only parse non-empty (e.g. lines with one or more non-whitespace characters) lines: if (curLine.length() > 0) { + if(filterExitClassInstance != null) + { + try + { + boolean pass = filterExitClassInstance.filter(curLine); + if(!pass) + { + //Read the next line in the file: + curLine = readALine(); + continue; + } + + }catch (AdapterException e) + { + + throw new LogParserException(ParserUtilities.getResourceString("LOG_PARSER_FILTERING_ERROR_", curLine)); + } + + } //ASSUMPTION: At least one valid log record (e.g. containing at least a time stamp, category and message) appears in each log file, otherwise the log file is deemed invalid. Index: src/org/eclipse/hyades/logging/parsers/MonitoringParser.java =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/src/org/eclipse/hyades/logging/parsers/MonitoringParser.java,v retrieving revision 1.9 diff -u -r1.9 MonitoringParser.java --- src/org/eclipse/hyades/logging/parsers/MonitoringParser.java 7 Oct 2005 19:48:32 -0000 1.9 +++ src/org/eclipse/hyades/logging/parsers/MonitoringParser.java 1 Feb 2006 15:54:23 -0000 @@ -23,8 +23,12 @@ import java.util.Hashtable; import java.util.Locale; +import org.eclipse.hyades.logging.adapter.sensors.BasicFilterExit; import org.eclipse.hyades.logging.adapter.util.BufferedPeriodicReader; import org.eclipse.hyades.logging.adapter.util.BufferedSinglePassReader; +import org.eclipse.hyades.logging.adapter.util.FilterExitLoaderUtil; +import org.eclipse.hyades.logging.adapter.util.IFilterExit; +import org.eclipse.hyades.logging.adapter.util.InvalidFilterSpecification; import org.eclipse.hyades.logging.adapter.util.MultipleFilesReader; import org.eclipse.hyades.logging.events.cbe.CommonBaseEvent; /** @@ -51,7 +55,7 @@ /* Support for multiple log files */ private boolean multi = false; // specify whether multi files are being monitored private RandomAccessFile tmpLog = null; - + /** * This function is called to provide user-specified information to the parser. * Currently, this superclass method handles the path and name of the log file @@ -205,6 +209,67 @@ input.setMultiFile(multi); } + /** + * bugzilla 79565. It allows user to define rules for GLA sensor or extractor + * to filter out lines, records or data that are not of interest. + * filter is used to store the rule. + * filterExitClass is used to store the name of filterEixt class which is + * provided by users. If users only define the filter rules, but not provide filterExitClass, + * the BasicFilterExit class will be used with the user defined filter rules. + */ + filter = ((String) (table.get(ParserConstants.FILTER_SPECIFICATION_KEY))); + filterExitClass = ((String) (table.get(ParserConstants.FILTER_EXIT_CLASS))); + + if (filter != null) { + filter = filter.trim(); + if (filter.length() == 0) { + filter = null; + } + } + + if (filterExitClass != null) { + filterExitClass = filterExitClass.trim(); + if (filterExitClass.length() == 0) { + filterExitClass = null; + } + } + //Check if the filterExit property is not null + if (filterExitClass !=null && !filterExitClass.equals("")) { + try { + // load the class and instantiate an object + filterExitClassInstance = FilterExitLoaderUtil.instantiate(filterExitClass); + if(filter != null && !filter.equals("")) + { + try + { + filterExitClassInstance.setFilterSpecification(filter); + }catch (InvalidFilterSpecification ex) + { + throw new LogParserException(ParserUtilities.getResourceString("LOG_PARSER_INVALID_FILTER_SPECIFICATION_ERROR_",filter)); + } + } + } + catch (Exception e) { + + throw new LogParserException(ParserUtilities.getResourceString("LOG_PARSER_LOAD_FILTEREXIT_CLASS_ERROR_",filterExitClass)); + } + }else if(filter != null && !filter.equals("")) + { + //users don't provide the filter class, but give the filter specification, + // then use BasicFilterExit class + filterExitClassInstance = new BasicFilterExit(); + try + { + filterExitClassInstance.setFilterSpecification(filter); + }catch (InvalidFilterSpecification ex) + { + + throw new LogParserException(ParserUtilities.getResourceString("LOG_PARSER_INVALID_FILTER_SPECIFICATION_ERROR_",filter)); + + } + + } + array_size = (Integer)table.get(ParserConstants.MESSAGE_ARRAY_SIZE_KEY); if (array_size != null) { MessageArraySize = array_size.intValue(); Index: plugin.properties =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/plugin.properties,v retrieving revision 1.12 diff -u -r1.12 plugin.properties --- plugin.properties 27 Jan 2006 19:25:30 -0000 1.12 +++ plugin.properties 1 Feb 2006 15:54:23 -0000 @@ -37,7 +37,10 @@ REMOTE_LOG_PARSER_CONFIG_PARAMETER_ERROR_ = IWAT0075E The log parser's initialization parameters are not set properly. LOG_PARSER_INVALID_FILE_NAME_ERROR_ = IWAT0243E The log file {0} does not exist. LOG_PARSER_CANNOT_READ_FILE_ERROR_ = IWAT0244E Cannot read the log file {0}. +LOG_PARSER_INVALID_FILTER_SPECIFICATION_ERROR_ = IWAT0245E Invalid regular expression syntax for filter specification {0}. +LOG_PARSER_LOAD_FILTEREXIT_CLASS_ERROR_ = IWAT0246E Errors occurred loading the {0} class. LOG_PARSER_PARSING_ERROR_ = IWAT0412E Errors occurred parsing the log file {0}. +LOG_PARSER_FILTERING_ERROR_ = IWAT0413E Errors occurred filtering the line {0}. #java util logging simple format exception JAVA_UTIL_LOGGIN_GENERAL_EXCEPTION_MESSAGE_ERROR_ = IWAT0479E Error parsing Java Logging XML log. Index: .project =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/.project,v retrieving revision 1.1 diff -u -r1.1 .project --- .project 26 Jan 2005 16:02:17 -0000 1.1 +++ .project 1 Feb 2006 15:54:23 -0000 @@ -3,8 +3,6 @@ org.eclipse.hyades.logging.parsers - org.eclipse.hyades.logging.commons - org.eclipse.hyades.logging.core Index: .classpath =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/.classpath,v retrieving revision 1.5 diff -u -r1.5 .classpath --- .classpath 17 May 2005 15:35:37 -0000 1.5 +++ .classpath 1 Feb 2006 15:54:23 -0000 @@ -3,7 +3,7 @@ - + Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/tptp/monitoring/org.eclipse.hyades.logging.parsers/META-INF/MANIFEST.MF,v retrieving revision 1.5 diff -u -r1.5 MANIFEST.MF --- META-INF/MANIFEST.MF 25 Jan 2006 23:29:43 -0000 1.5 +++ META-INF/MANIFEST.MF 1 Feb 2006 15:54:23 -0000 @@ -17,8 +17,8 @@ org.eclipse.hyades.logging.parsers.importer, org.eclipse.hyades.logging.parsers.internal.importer Require-Bundle: org.eclipse.hyades.logging.core;visibility:=reexport, - org.eclipse.hyades.logging.adapter;visibility:=reexport, org.eclipse.swt, org.eclipse.core.resources, - com.ibm.icu + com.ibm.icu, + org.eclipse.hyades.logging.adapter Eclipse-AutoStart: true