SMILA/Documentation/5 more minutes to change the workflow

From Eclipsepedia

Jump to: navigation, search


Contents

Just another 5 minutes to change the workflow

In the 5 minutes to success all data collected by crawlers was processed with the same asynchronous "indexUpdate" workflow using the BPEL pipeline "AddPipeline". All data was indexed into the same solr/lucene index "DefaultCore". It is possible, however, to configure SMILA so that data from different data sources will go through different workflows and pipelines and will be indexed into different indices. This will require more advanced configuration features than before but still quite simple ones.

In the following sections we are going to use the generic asynchronous "importToPipeline" workflow which let you specify the BPEL pipeline to process the data. We create an additional BPEL pipeline for webcrawler records so that webcrawler data will be indexed into a separate index named "WebCore".

Configure new solr index

It's very important to shutdown and restart the SMILA engine after the following configuration changes are done because modified configurations are loaded during startup only.

To configure your own index "WebCore" follow the description in the SMILA documentation for creating your own solr index.

If you already started SMILA before (as we suppose you did), please copy your new Core configuration and the modified solr.xml file to the folder workspace\.metadata\.plugins\org.eclipse.smila.solr because the configuration will not be copied again, after the first start of the Solr bundle.

For more information about the solr indexing, please see the SMILA solr documentation.

Create a new BPEL pipeline

We need to add the AddWebPipeline pipeline to the BPEL WorkflowProcessor. For more information about BPEL WorkflowProcessor please check the BPEL WorkflowProcessor documentation. Predefined BPEL WorkflowProcessor configuration files are contained in the configuration/org.eclipse.smila.processing.bpel/pipelines directory. However, we can add new BPEL pipelines with the SMILA REST API.

Start SMILA if it's not yet running, and use your favourite REST client to add the "AddWebPipeline" BPEL pipeline: (the BPEL XML is a little bit unreadable cause we have to escape it for being valid JSON content; after posting the new pipeline you can get a readable version via monitoring REST API - see below)

POST http://localhost:8080/smila/pipeline
  {
    "name":"AddWebPipeline",
    "definition":"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n<process name=\"AddWebPipeline\" targetNamespace=\"http://www.eclipse.org/smila/processor\" xmlns=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\"\r\n  xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:proc=\"http://www.eclipse.org/smila/processor\" xmlns:rec=\"http://www.eclipse.org/smila/record\"\r\n  xmlns:bpel=\"http://docs.oasis-open.org/wsbpel/2.0/process/executable\">\r\n\r\n  <import location=\"processor.wsdl\" namespace=\"http://www.eclipse.org/smila/processor\" importType=\"http://schemas.xmlsoap.org/wsdl/\" />\r\n\r\n  <partnerLinks>\r\n    <partnerLink name=\"Pipeline\" partnerLinkType=\"proc:ProcessorPartnerLinkType\" myRole=\"service\" />\r\n    <partnerLink name=\"AdaptWebCrawlerWorkerOutput\" partnerLinkType=\"proc:ProcessorPartnerLinkType\" partnerRole=\"service\" />\r\n  </partnerLinks>\r\n\r\n  <extensions>\r\n    <extension namespace=\"http://www.eclipse.org/smila/processor\" mustUnderstand=\"no\" />\r\n  </extensions>\r\n\r\n  <variables>\r\n    <variable name=\"request\" messageType=\"proc:ProcessorMessage\" />\r\n  </variables>\r\n\r\n  <sequence name=\"AddWebPipeline\">\r\n    <receive name=\"start\" partnerLink=\"Pipeline\" portType=\"proc:ProcessorPortType\" operation=\"process\" variable=\"request\"\r\n      createInstance=\"yes\" />\r\n\r\n    <invoke name=\"adaptWebCrawlerWorkerOutput\" inputVariable=\"request\" partnerLink=\"AdaptWebCrawlerWorkerOutput\"\r\n      outputVariable=\"request\" operation=\"process\" portType=\"proc:ProcessorPortType\" />\r\n\r\n    <forEach counterName=\"index\" parallel=\"yes\" name=\"iterateRecords\">\r\n      <startCounterValue>1</startCounterValue>\r\n      <finalCounterValue>count($request.records/rec:Record)</finalCounterValue>\r\n      <scope>\r\n        <variables>\r\n          <variable name=\"identifiedRecord\" messageType=\"proc:ProcessorMessage\" />\r\n        </variables>\r\n        <sequence>\r\n          <if name=\"MimeTypeNotSet\">\r\n            <condition>not($request.records/rec:Record[position()=$index]/rec:Val[@key=\"MimeType\"])</condition>\r\n            <sequence>\r\n              <extensionActivity>\r\n                <proc:invokePipelet name=\"detectMimeType\">\r\n                  <proc:pipelet class=\"org.eclipse.smila.processing.pipelets.MimeTypeIdentifyPipelet\" />\r\n                  <proc:variables input=\"request\" index=\"index\" output=\"identifiedRecord\" />\r\n                  <proc:configuration>\r\n                    <rec:Val key=\"FileExtensionAttribute\">Extension</rec:Val>\r\n                    <rec:Val key=\"MetaDataAttribute\">MetaData</rec:Val>\r\n                    <rec:Val key=\"MimeTypeAttribute\">MimeType</rec:Val>\r\n                  </proc:configuration>\r\n                </proc:invokePipelet>\r\n              </extensionActivity>\r\n              <assign name=\"copy result into original variable for next tests\">\r\n                <copy>\r\n                  <from>$identifiedRecord.records/rec:Record[1]</from>\r\n                  <to>$request.records/rec:Record[position()=$index]</to>\r\n                </copy>\r\n              </assign>\r\n            </sequence>\r\n          </if>\r\n\r\n          <!-- only process text based content, skip everything else -->\r\n          <if name=\"IsText\">\r\n            <condition>starts-with($request.records/rec:Record[position()=$index]/rec:Val[@key=\"MimeType\"],\"text/\")</condition>\r\n            <if name=\"IsHTML\">\r\n              <condition>$request.records/rec:Record[position()=$index]/rec:Val[@key=\"MimeType\"] = \"text/html\" or\r\n                $request.records/rec:Record[position()=$index]/rec:Val[@key=\"MimeType\"] = \"text/xml\"\r\n              </condition>\r\n              <!-- extract txt from html and xml files -->\r\n              <extensionActivity>\r\n                <proc:invokePipelet name=\"invokeHtml2Txt\">\r\n                  <proc:pipelet class=\"org.eclipse.smila.processing.pipelets.HtmlToTextPipelet\" />\r\n                  <proc:variables input=\"request\" index=\"index\" />\r\n                  <proc:configuration>\r\n                    <rec:Val key=\"inputType\">ATTACHMENT</rec:Val>\r\n                    <rec:Val key=\"outputType\">ATTRIBUTE</rec:Val>\r\n                    <rec:Val key=\"inputName\">Content</rec:Val>\r\n                    <rec:Val key=\"outputName\">Content</rec:Val>\r\n                    <rec:Val key=\"meta:title\">Title</rec:Val>\r\n                  </proc:configuration>\r\n                </proc:invokePipelet>\r\n              </extensionActivity>\r\n              <else>\r\n                <!-- copy txt from attachment to attribute -->\r\n                <extensionActivity>\r\n                  <proc:invokePipelet name=\"invokeCopyContent\">\r\n                    <proc:pipelet class=\"org.eclipse.smila.processing.pipelets.CopyPipelet\" />\r\n                    <proc:variables input=\"request\" index=\"index\" />\r\n                    <proc:configuration>\r\n                      <rec:Val key=\"inputType\">ATTACHMENT</rec:Val>\r\n                      <rec:Val key=\"outputType\">ATTRIBUTE</rec:Val>\r\n                      <rec:Val key=\"inputName\">Content</rec:Val>\r\n                      <rec:Val key=\"outputName\">Content</rec:Val>\r\n                      <rec:Val key=\"mode\">COPY</rec:Val>\r\n                    </proc:configuration>\r\n                  </proc:invokePipelet>\r\n                </extensionActivity>\r\n              </else>\r\n            </if>\r\n          </if>\r\n        </sequence>\r\n      </scope>\r\n    </forEach>\r\n\r\n    <extensionActivity>\r\n      <proc:invokePipelet name=\"SolrIndexPipelet\">\r\n        <proc:pipelet class=\"org.eclipse.smila.solr.index.SolrIndexPipelet\" />\r\n        <proc:variables input=\"request\" output=\"request\" />\r\n        <proc:configuration>\r\n          <rec:Val key=\"ExecutionMode\">ADD</rec:Val>\r\n          <rec:Val key=\"CoreName\">WebCore</rec:Val>\r\n          <rec:Seq key=\"CoreFields\">\r\n            <rec:Map>\r\n              <rec:Val key=\"FieldName\">_source</rec:Val>\r\n            </rec:Map>\r\n            <rec:Map>\r\n              <rec:Val key=\"FieldName\">Path</rec:Val>\r\n            </rec:Map>\r\n            <rec:Map>\r\n              <rec:Val key=\"FieldName\">Url</rec:Val>\r\n            </rec:Map>\r\n            <rec:Map>\r\n              <rec:Val key=\"FieldName\">Filename</rec:Val>\r\n            </rec:Map>\r\n            <rec:Map>\r\n              <rec:Val key=\"FieldName\">MimeType</rec:Val>\r\n            </rec:Map>\r\n            <rec:Map>\r\n              <rec:Val key=\"FieldName\">Size</rec:Val>\r\n            </rec:Map>\r\n            <rec:Map>\r\n              <rec:Val key=\"FieldName\">LastModifiedDate</rec:Val>\r\n            </rec:Map>\r\n            <rec:Map>\r\n              <rec:Val key=\"FieldName\">Content</rec:Val>\r\n            </rec:Map>\r\n            <rec:Map>\r\n              <rec:Val key=\"FieldName\">Extension</rec:Val>\r\n            </rec:Map>\r\n            <rec:Map>\r\n              <rec:Val key=\"FieldName\">Title</rec:Val>\r\n            </rec:Map>\r\n            <rec:Map>\r\n              <rec:Val key=\"FieldName\">Author</rec:Val>\r\n            </rec:Map>\r\n          </rec:Seq>\r\n        </proc:configuration>\r\n      </proc:invokePipelet>\r\n    </extensionActivity>\r\n\r\n    <reply name=\"end\" partnerLink=\"Pipeline\" portType=\"proc:ProcessorPortType\" operation=\"process\" variable=\"request\" />\r\n  </sequence>\r\n</process>\r\n"
  }

You can monitor the defined BPEL pipelines via browser, so you should find your new pipeline there:

http://localhost:8080/smila/pipeline

Note that we used "WebCore" index name for the Solr index in the BPEL above:

...
<proc:configuration>
  <rec:Val key="CoreName">WebCore</rec:Val>
  ...
</proc:configuration>
...

Create and start a new indexing job

We define an indexing job based on the predefined asynchronous workflow "importToPipeline" (see SMILA/configuration/org.eclipse.smila.jobmanager/workflows.json). This indexing job will process the imported data by using our new BPEL pipeline "AddWebPipeline".

The "importToPipeline" workflow contains a PipelineProcessorWorker worker which is not configured for dedicated BPEL pipelines, so the BPEL pipelines handling adds and deletes have to be set via job parameter.

Use your favourite REST Client to create an appropriate job definition:

POST http://localhost:8080/smila/jobmanager/jobs/
  {
    "name":"indexWebJob",
    "parameters":{      
      "tempStore": "temp",
      "addPipeline": "AddWebPipeline",
      "deletePipeline": "DeletePipeline" 
     },
    "workflow":"importToPipeline"
  }

Note that the "DeletePipeline" is not needed for our test szenario here, but we must fulfill all undefined workflow parameters.

Afterwards, start a job run for the defined job:

POST http://localhost:8080/smila/jobmanager/jobs/indexWebJob

Update the web crawl job

Since the web crawl job already is predefined to push the crawled records to the indexUpdate job, we now either must define a new job or update the crawl job's definition in the job.json file. Here we choose the new job option.

POST the following update json using your favorite REST client:

POST http://localhost:8080/smila/jobmanager/jobs/
{
  "name":"crawlWikiToWebCore",
  "workflow":"webCrawling",
  "parameters":{
    "tempStore":"temp",
    "dataSource":"web",
    "startUrl":"http://wiki.eclipse.org/SMILA",
    "filter":{
      "urlPrefix":"http://wiki.eclipse.org/SMILA"
    },
    "jobToPushTo":"indexWebJob"
  }
}

Please note that we used the following line to let the crawl job push the records to our new job:

"jobToPushTo":"indexWebJob"

Now start the crawl job (don't forget runOnce!):

POST http://localhost:8080/smila/jobmanager/jobs/crawlWikiToWebCore
{
  "mode": "runOnce"
}

After a sufficiently long time to crawl, process and commit the data, you can have another look at the SMILA search page to find your new core listed among the available cores, and if you choose it, you can search for e.g. SMILA in the new WebCore.

Put it all together

Ok, now it seems that we have finally finished configuring SMILA for using separate BPEL pipelines for file system and web crawling and index data from these crawlers into different indices. Here is what we have done so far:

  1. We added the WebCore index to the Solr configuration and copied it to the workspace.
  2. We created a new BPEL pipeline for Web crawler data referencing the new Lucene index.
  3. We used a separate job for web indexing that references the new BPEL pipeline.
  4. We updated the web crawl job to push the records to a different indexing job which references the new BPEL pipeline.

Configuration overview

SMILA configuration files are located in the configuration directory of the SMILA application. The following lists the configuration files and documentation links relevant to this tutorial, regarding SMILA components:

Jobmanager

BPEL Pipelines

Solr