Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Extending Eclipse monitoring, profiling, and testing functions
Previous Page Home Next Page

Implementing a log analyzer

The log analyzer is plugged into the workbench and exposes the analysis engine to the user interface.

In order to plug an analysis engine into the workbench, the extension point org.eclipse.hyades.analysis.engine.LogAnalyzer must be extended. The extension point associates the log analyzer with the analysis engine. The LogAnalyzer extension is recognized by the Log View of the Log and Trace Analyzer, and is added as a menu selection for the Analyze and Analyze All menu actions.

Image of the customized log analyzer

To create a log analyzer, follow these steps:

  1. Create a new plug-in project by selecting File > New > Other > Plug-in project.
  2. Create a name for your plug-in project. Click Finish. Your plug-in project is created in the workspace.
  3. Add the org.eclipse.hyades.analysis.engine plug-in to the project build path:
    1. Select the project and right-click. Click Properties. The Properties dialog opens.
    2. Select Java Build Path.
    3. Select the Libraries tab.
    4. Click Add Variable....
    5. Select ECLIPSE_HOME.
    6. Click Extend....
    7. Expand plugins and select the org.eclipse.hyades.analysis.engine JAR file, for example, org.eclipse.hyades.analysis.engine_4.1.0.jar. Click OK and then OK again to save the changes and close the Properties dialog.
  4. Create a new class that implements the interface org.eclipse.hyades.analysis.engine.ILogAnalyzer. This is required to plug the analysis engine into the workbench. The interface contains four methods that need to be implemented:
    • public void loadDatabase()
      Used by the log viewer to load any necessary symptom catalogs. The current Log and Trace Analyzer framework supports only EMF-based symptom catalogs. This method can be used to load a symptom catalog.

      If you choose to use one of the catalogs imported into the workbench, this method should check the org.eclipse.hyades.sdb.internal.util.SdUIConstants.SYMPTOM_DB_PATH_KEY preferences string. For example,
      String symptomdbPath = SDbPlugin.getDefault().getPreferenceStore().getString(SdUIConstants.SYMPTOM_DB_PATH_KEY);

      The preference string is structured as follows:

      symptom_db_path=project_path/symptomdb1_name.trcdbxmi,N;/project_path/symptomdb1_name.trcdbxmi,N

      symptom_db_path is the symptom catalog key
      project_path is the project folder where the catalog has been imported into
      symptomdb1_name.trcdbxmi and symptomdb2_name.trcdbxmi are the names of different symptom catalog files
      N is a flag that indicates whether or not a catalog should be used for analysis. A value of 1 indicates that the catalog should be used for the log analysis. The symptom catalog entries are separated by semi-colons.

    • public void unloadDatabase()
      Unload any symptom catalogs used for analysis purposes.
    • public String errorMsg()
      If an error occurs during the analysis process, this method returns the corresponding error message. If there is no error, this method returns null.
    • public String analyze(Object aObject, IAnalysisMonitor monitor)
      Analyzes an object or a collection of objects. The IAnalysisMonitor can be specified if a progress monitor is being used.
      • The method public String analyze(Object aObject) is called by the Log Viewer when the menu item corresponding to the contributed log analyzer is selected. The implementation of this method should identify the incidents corresponding to the analyzed objects, taking into account that the viewer is passing an IStructuredSelection to this method.
      • The actual analysis processing should be delegated to the method public Object[] analyze(Incident incident) of the IAnalysisEngine implementation. This method should return an array of matched symptoms.
      • The framework ignores the returned String of the public String analyze(Object aObject) method; only the analyzed object's symptoms list is used to display the analysis result.
      • Every CBEDefaultEvent, in particular, the CBECommonBaseEvent object can keep a list of corresponding symptoms. The implementation should add the list of matched symptoms to this which is used by the framework to display the analysis results for every analyzed CBEDefaultEvent object. To obtain the list of symptoms, type
        EList symptoms = ((CBEDefaultEvent)object).getSymptoms();
  5. Contribute the newly created class to the extension point org.eclipse.hyades.analysis.engine.logAnalyzer. Open the plugin.xml file and add the following lines:
    <extension point="org.eclipse.hyades.analysis.engine.logAnalyzer">
     <logAnalyzer
       id="sampleLogAnalyzer.LogAnalyzerImpl"
       name="My Log Analyzer"
       type="org.eclipse.hyades.models.cbe.CBEDefaultEvent"
       class="sampleLogAnalyzer.LogAnalyzerImpl"/>
     </extension>
    
    The name attribute will be the name of analyzer that shows up in the Analyze and Analyze All menu items.
    The type attribute is used to specify the type of objects which are analyzed by the contributed log analyzer. Any object instantiated from a class implementing one of the following two interfaces is analyzable with the contributed log analyzer:
    • org.eclipse.hyades.models.cbe.CBEDefaultEvent
    • org.eclipse.hyades.models.cbe.CBECommonBaseEvent
    The class attribute is used to specify the implementation of the interface ILogAnalyzer, that is, the contributed log analyzer.
    The id attribute is used to uniquely identify the extension point contribution.
  6. Save the changes to the plugin.xml file.

 

Related tasks
Creating an analysis engine
Implementing an analysis engine
Testing the analysis engine


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire