|
|
|
|
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.
To create a log analyzer, follow these steps:
- Create a new plug-in project by selecting File > New > Other > Plug-in project.
- Create a name for your plug-in project. Click Finish. Your plug-in project is created in the workspace.
- Add the org.eclipse.hyades.analysis.engine plug-in to the project build path:
- Select the project and right-click. Click Properties. The Properties dialog opens.
- Select Java Build Path.
- Select the Libraries tab.
- Click Add Variable....
- Select ECLIPSE_HOME.
- Click Extend....
- 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.
- 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.
- 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.
- Save the changes to the plugin.xml file.
Related tasks
Creating an analysis engine
Implementing an analysis engine
Testing the analysis engine
|
|
|