SMILA is a framework with a lot of functionality. Most is invoke automatically by internal operations. Nevertheless, the user has to configure and start an initial operation. All functions a user can execute are accessible from the JMX Management Agent. On the following pages you will learn how to use SMILA with the aid of Java's built in JConsole and to handle the JMXClient which features access to SMILA commands via batch files.
Management with the aid of jconsole
The jconsole is a little tool for monitoring java applications nested in the JDK. Over a JMX connection it’s possible to connect an application with the swing UI of jconsole. If you start up SMILA engine and open jconsole you can connect the Jconsole to SMILA immediately.
After connecting you can find SMILA operation on MBeans tab in the Tree on the left site.
Smila manageable Components
There are four components of SMILA which you can access over jconsole.
Here you can manage the crawling jobs. The following commands are available:
- startCrawl(String dataSourceID): starts a crawling job with the given dataSourceID, for example file or web.
- stopCrawl(String dataSourceID): stops the crawling job for the given dataSourceID. Note: the crawler is only signaled to stop and may do so at its own discretion. In other words: depending on the implementation it might take a while until it actually stops crawling. It thus gives the crawler the chance to clean up all open resources and finish whatever business it needs to.
- getActiveCrawls(): opens a dialog which show a list containing the dataSourceID for all active crawl jobs. If no job is running the dialog shows null.
- getActiveCrawlsStatus(): opens a dialog telling you how many crawl jobs are active at the moment.
- getStatus(String dataSourceID): opens a dialog which shows you the status of the crawling job for a given dataSourceID. Possible states are: RUNNING, FINISHED, STOPPED or ABORTED.
The RecordRecycler gives you the possibly to push already crawled records into Data Flow Process again. For example it could be useful if you want to modify record in the index with another pipeline. To control RecordRecycler there are following operations available.
- startRecycling(String configurationID, String dataSourceId): fires a recycling event with the given configurationID ( the configurationID must match the name of a configuration file located at configuration/org.eclipse.smila.connectivity.framework.queue.worker/recyclers) and dataSourceID (get records from RecordStorage which have this dataSourceID). See QueueWorker documentation for further enlightenment on the Recycler.
- stopRecycling(String dataSourceID): stops the recycle event for the given dataSourceID.
- getRecordsRecycled(String dataSourceID): opens a dialog shows how many records are recycled.
- getConfigurations(String dataSourceID): show a list containing all available recycle configuration files.
- getStatus(String dataSourceID): open dialog showing the status of recycling event for given dataSourceID. Possible states are: STARTED, IN_PROCESS, STOPPING, STOPPED, FINISHED.
The DeltaIndexManager stores a hash value of each record. It is part of the Connectivity Framework and signals a crawler that a given record has (not) changed since the last crawl. See DeltaIndexing documentation. Within jconsole you can use the following commands:
- clear(String dataSourceID): Clear all entries of the DeltaIndexingManager for the given dataSourceID. You cannot execute this command on an already locked data source. If you want to clear a locked data source you have to unlock it first.
- clearAll(): Clears all entries of the DeltaIndexingManager including entries of any active sessions! Note that this may cause errors in clients currently using any of the closed sessions.
- unlock(String dataSourceID): Unlock the given data source and removes the sessions. Note that this may cause exceptions in a client currently using the closed sessions.
- unlockAll(): Unlock all data sources and removes all sessions. Note that this may cause exceptions in clients currently using any of the closed sessions.
- getLockStates(): Get an overview what data sources are locked or unlocked.
- getEntryCount(String dataSourceID): Get the number of delta indexing entries for the given dataSourceID.
- getEntryCounts(): Get the number of delta indexing entries for all data sources.
With Lucene you have the possibility to invoke several method concerning the index. Following operation are available:
- deleteIndex(String indexName): removes the index with the given name if available. Otherwise an error dialog is shown.
- indexExists(String indexName): ask the framework if the given Index exists. Returns true or false.
- createIndex (String indexName): creates an index with the given name.
- reorganizeIndex(String indexName): reorganizes the index with the given name. This will clean up the index, in that deleted entries are physically removed resulting in a smaller index size.
- renameIndex(String currentIndexName, String newIndexName): rename the index with the given name (currentIndexname) into the value of newIndexName.
- flushIndex(String indexName): flushes the index with the given name if available.
- removeWriteLock(String indexName): removes the write.lock file of the index with the given name if available. This may be helpful if SMILA process was killed.
A PerformanceCounter monitors the activity of a component. In SMILA currently two kinds of PerformanceCounters are available, one for Crawlers and another for Processing within the Data Flow Process. With the aid of jconsole you have the possibility to look at interesting counters of SMILA. There exist a lot of views that allow you to get information about different situations.
Crawlers performance counters
After you start a crawl job immediately a new branch in MBeans-tree appears with the following nodes/values:
- FileSystem - Crawler type
- file - Data source Id
- 19786841 - Crawler instance, one node for every crawl job
- file - Data source Id
- Total - Crawler type sub-total
- Web - Crawler type
- web - Data source Id
- 2611152 - Crawler instance, one node for every crawl job
- web - Data source Id
- Total - Crawler type sub-total
- FileSystem - Crawler type
The nodes contain a subset collection of these possible counters:
- AttachmentBytesTransfered: total records attachment bytes transfered
- AttachmentTransferRate: records attachment bytes transfer rate (bytes/sec)
- AverageAttachmentTransferRate: overall (whole crawl job) records attachment bytes transfer rate (bytes/sec)
- AverageDeltaIndicesProcessingTime: average delta index processing time (sec)
- AverageRecordsProcessingTime: average record processing time (sec)
- OverallAverageDeltaIndicesProcessingTime: overall delta index processing time (sec)
- OverallAverageRecordsProcessingTime: overall record processing time (sec)
- Error: contains a collection of all errors occurred. On operation tab you can find a method to show all errors in a dialog box.
- Delta-indices: number of delta indices created in LuceneIndex.
- Exceptions(critical): number of critical exceptions.
- Exceptions(non-critical): number of non-critical exceptions.
- Exceptions(producer): number of producer exceptions.
- Files: number of files which were crawled. (only FileSystemCrawler)
- Folder: number of folder walked through. (only FileSystemCrawler)
- Records: number of records created.
- Bytes: how much bytes were downloaded
- http-fetch-time: average of each http-fetch-time, i.e. the time it costs to download a webpage.
- Pages: how many pages were visited.
Processing performance counters
As soon as Router puts Records into MQ the Listener pushes them into Data Flow Process. This time a new section with the following hierarchy (only an example, because PerformanceCounters vary according to your personal usage of SMILA) appears in MBeans-tree:
- Pipeline: lists all invoked pipelines.
- Processing Service: lists all processing services which were invoked, sorted by pipelines
- Simple Pipelet: lists all pipelets which were used, sorted by pipelines
The JMX Client is a lightweight and very easy to use command line driven component to use access most JMX Management operations. It works without jconsole and provides only a few commands. If you want to have full control over SMILA framework you have to use jconsole as described in the chapter above. But if you only want to start a crawl job or check if a crawl job is still active, you don’t have to use the jconsole. Furthermore you have the possibility to expand functionality of JMX Client. It is highly configurable with only one single configuration file.
Pre-defined commands (batch-files)
Note:The job jobName in the following descriptions refer to an import job which must be running. For an example see SMILA/Documentation_for_5_Minutes_to_Success
- crawlFILE jobName: start a crawl job with the data source "file" for the job with name jobName.
- crawlFILEandWait jobName: same as command above with the exception that the console-window stays open till the crawl job has finished.
- crawlFILEstop: stop the crawl job for data source "file", if one is active.
- crawlWEB jobName: start a crawl job for data source "web" for the job with name jobName.
- crawlWEBandWait jobName: same as command above with the exception that the console-windows stays open till the crawl job has finished.
- crawlWEBstop: stop the crawl job for data source "web", if one is active.
- getActiveCrawls: show all active crawl jobs on console.
- agentFEEDS jobName start agent for the data source "feeds" for the job with name jobName.
- agentFEEDSStop stop agent for the data source "feeds", if one is active
- getActiveAgents: show all active agent jobs on console.
- indexOptimize: invoke a reorganize of LuceneIndex (default test_index).
- clearOntology: remove all statements from "native" ontology.
- importRDF: import RDF file into "native" ontology. First argument is path to the RDF file (different formats are supported if the suffix is correct, see SMILA/Documentation/SesameOntologyManager#JMX Management Agent, second argument is the baseURI for all "relative" resources defined in the file. The value is irrelevant if the file contains only "absolute" URIs.
- exportRDF: export all statements from "natvie" ontology to file "export.rdf" in RDF/XML format.
If you open command window in folder SMILA/jmxclient and execute run.bat you'll get very useful help.
The JMX Client can be used to simplify JMX Management while using batch-files for most important functions. But that’s not all. With the aid of JMX Client you have the possibility to use SMILA completely from your console or write own batch files which could invoke for example one method after another. The Client works with commands. These commands are managed in only one configuration file. In addition to the pre-defined commands you are able to create own commands. You only need to know the fully qualified class name and method name of function you want to invoke. To execute a command simply use this pattern: run.bat commandName commandParameters. The JMX client is able to execute any JMX operation and get any JMX attribute and to make it in one batch with reusing previous results.
There is a configuration file located at org.eclipse.smila.management.jmx.client/schemas/jmxclient.xsd (Source) and jmxclient/schemas/jmxclient.xsd (Build). The default configuration file could be found at org.eclipse.smila.management.jmx.client/config.xml (Source) and jmxclient/config.xml.
To use commands which interact with JMX a connection is needed
<connection id="local" host="localhost" port="9004"/>
To create your own command you have to use cmd command after this schema
- id: name of the command.
- echo: something to display on console if command is execute.
- domain: JMX property root is DOMAIN inside each domain paths (to leafs) are identified by KEY for leafs there are operstions and attributes.
- key: Class containing method.
- name: name of the method to invoke.
- echo: something to display on console if method is invoked.
- parameter: one tag for each parameter.
- echo: description for the parameter.
- parameter: one tag for each parameter.
To keep the console open and inform you about actual status you can use the wait tag
- STEP 1:
<cmd id="crawlW" echo="Starting crawler by datasource id and wait for finished"> <operation key="CrawlerController" name="startCrawling" echo="Starting crawl [%1]"> <parameter echo="data source id"/> <parameter echo="job name"/> </operation> ...
- for the MBean of DOMAIN "SMILA" with KEY „CrawlerController" the operation "startCrawlerTask" with two input parameters (with String type - default) is executed. JMX will return a result to the client, e.g. "Crawler with the dataSourceId 'file' pushing to job 'indexUpdateJob' successfully started! (import run id: 595826)"
- STEP 2:
- we need to extract the hash code (which is the import run id) from the crawler's feedback to track its activities. This can be done by the following regexp tag which would return "595826" as its result for the above example.
<regexp pattern="^.*\(\D*(\d+)\).*$" group="1" echo="Extracting crawler hash code"/>
- STEP 3 is an unconditional simple wait task. We have to wait for the jmx counters to be created before we can access them in the next step.
<wait echo="Waiting for jmx counters" pause="1000" />
- STEP 4 is a wait task - the most complex task - we will wait until the crawl is finished. This wait tag is defined by using two subnodes
<wait echo="Waiting while crawl ends" pause="1000"> <in> <cmd id="-" echo="Getting crawler status by datasource id"> <operation key="CrawlerController" name="getStatus" echo="Crawl [%1] status"> <!-- value="%1" --> <parameter echo="data source id"/> </operation> </cmd> <const value="Finished" echo="Crawling finished status"/> <const value="Stopped" echo="Crawling stopped status"/> <const value="Aborted" echo="Crawling aborted status"/> </in> <cmd id="-" echo="Reading crawler performance counters"> <attribute key="Crawlers/%3/Total" name="Records" echo="Total records"/> ... </cmd> </wait>
- First subnode ( here its logical IN ) is a condition defining when to exit from the WAIT task. The second subnode is a command to execute in each iteration of the wait loop.
- If the condition is not evaluated to true, the wait task will pause for the given amount of milliseconds before entering the next iteration. So each 1000 ms the following will be executed:
- three performance counters defined in cmd with id="-" will be printed.
- it will read the number of records, ask for the crawler's status checks if the status is "Finished", "Stopped" or "Aborted".
- if it is, the crawling has finished and so the loop exits, otherwise the next iteration of the loop is started.
JMX Client in OSGi console
Since rev 464 (after M2), the JMX client is also added to the Equinox OSGi console as a command provider. Thus you can now invoke the same configured actions also from the OSGi console without having to open a seperate window. The command name is smila followed by the same arguments used with the run script in SMILA/jmxclient. Use help to get a description of the supported commands, the output should look like this:
Usually a lot more help output for the standard Equinox commands follows so you may need to scroll back a lot to find the description of the smila command.
See the next screenshot for an example session in which an agent and an crawler is controlled using the OSGi JMX client only. You'll see that the commands are exactly like when using the run script, only the command name is smila, not run.