blob: 053db6c161b76dc384ab9575274c545e2607a0da [file] [log] [blame]
<!DOCTYPE html>
<html lang="en" dir="ltr" class="client-nojs">
<head>
<meta charset="UTF-8" />
<title>SMILA/Documentation/HowTo/How to write a Worker - Eclipsepedia</title>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE" />
<meta name="generator" content="MediaWiki 1.23.2" />
<link rel="shortcut icon" href="http://wiki.eclipse.org/eclipse.org-common/themes/solstice/public/images/favicon.ico" />
<link rel="search" type="application/opensearchdescription+xml" href="http://wiki.eclipse.org/opensearch_desc.php" title="Eclipsepedia (en)" />
<link rel="EditURI" type="application/rsd+xml" href="http://wiki.eclipse.org/api.php?action=rsd" />
<link rel="alternate" type="application/atom+xml" title="Eclipsepedia Atom feed" href="http://wiki.eclipse.org/index.php?title=Special:RecentChanges&amp;feed=atom" />
<link rel="stylesheet" href="http://wiki.eclipse.org/load.php?debug=false&amp;lang=en&amp;modules=mediawiki.legacy.commonPrint%2Cshared%7Cmediawiki.ui.button&amp;only=styles&amp;skin=solstice&amp;*" />
<link rel="stylesheet" href="http://wiki.eclipse.org/skins/solstice/public/stylesheets/styles.min.css?303" media="screen, print" /><meta name="ResourceLoaderDynamicStyles" content="" />
<style>a:lang(ar),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}
/* cache key: my_wiki:resourceloader:filter:minify-css:7:14ece53a42aa314864e5fd8c57f0d98f */</style>
<script src="http://wiki.eclipse.org/load.php?debug=false&amp;lang=en&amp;modules=startup&amp;only=scripts&amp;skin=solstice&amp;*"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"SMILA/Documentation/HowTo/How_to_write_a_Worker","wgTitle":"SMILA/Documentation/HowTo/How to write a Worker","wgCurRevisionId":375643,"wgRevisionId":375643,"wgArticleId":33513,"wgIsArticle":true,"wgIsRedirect":false,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["SMILA"],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgPageContentModel":"wikitext","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"SMILA/Documentation/HowTo/How_to_write_a_Worker","wgIsProbablyEditable":false,"wgRestrictionEdit":[],"wgRestrictionMove":[],"wgWikiEditorEnabledModules":{"toolbar":false,"dialogs":false,"hidesig":true,"preview":false,"previewDialog":false,"publish":false},"wgCategoryTreePageCategoryOptions":"{\"mode\":0,\"hideprefix\":20,\"showcount\":true,\"namespaces\":false}"});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function($,jQuery){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"editfont":"default","editondblclick":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":1,"extendwatchlist":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nickname":"","norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"rcdays":7,"rclimit":50,"rows":25,"showhiddencats":0,"shownumberswatching":1,"showtoolbar":1,"skin":"solstice","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":1,"watchdefault":1,"watchdeletion":0,"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,
"useeditwarning":1,"prefershttps":1,"language":"en","variant-gan":"gan","variant-iu":"iu","variant-kk":"kk","variant-ku":"ku","variant-shi":"shi","variant-sr":"sr","variant-tg":"tg","variant-uz":"uz","variant-zh":"zh","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"variant":"en"});},{},{});mw.loader.implement("user.tokens",function($,jQuery){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});},{},{});
/* cache key: my_wiki:resourceloader:filter:minify-js:7:70d74423d3fc1e1c18fa9a1ff645a84a */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-javascript {line-height: normal;}
.source-javascript li, .source-javascript pre {
line-height: normal; border: 0px none white;
}
/**
* GeSHi Dynamically Generated Stylesheet
* --------------------------------------
* Dynamically generated stylesheet for javascript
* CSS class: source-javascript, CSS id:
* GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
* (http://qbnz.com/highlighter/ and http://geshi.org/)
* --------------------------------------
*/
.javascript.source-javascript .de1, .javascript.source-javascript .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.javascript.source-javascript {font-family:monospace;}
.javascript.source-javascript .imp {font-weight: bold; color: red;}
.javascript.source-javascript li, .javascript.source-javascript .li1 {font-weight: normal; vertical-align:top;}
.javascript.source-javascript .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.javascript.source-javascript .li2 {font-weight: bold; vertical-align:top;}
.javascript.source-javascript .kw1 {color: #000066; font-weight: bold;}
.javascript.source-javascript .kw2 {color: #003366; font-weight: bold;}
.javascript.source-javascript .kw3 {color: #000066;}
.javascript.source-javascript .kw5 {color: #FF0000;}
.javascript.source-javascript .co1 {color: #006600; font-style: italic;}
.javascript.source-javascript .co2 {color: #009966; font-style: italic;}
.javascript.source-javascript .coMULTI {color: #006600; font-style: italic;}
.javascript.source-javascript .es0 {color: #000099; font-weight: bold;}
.javascript.source-javascript .br0 {color: #009900;}
.javascript.source-javascript .sy0 {color: #339933;}
.javascript.source-javascript .st0 {color: #3366CC;}
.javascript.source-javascript .nu0 {color: #CC0000;}
.javascript.source-javascript .me1 {color: #660066;}
.javascript.source-javascript .ln-xtra, .javascript.source-javascript li.ln-xtra, .javascript.source-javascript div.ln-xtra {background-color: #ffc;}
.javascript.source-javascript span.xtra { display:block; }
/*]]>*/
</style><meta name="viewport" content="width=device-width, initial-scale=1.0"></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-SMILA_Documentation_HowTo_How_to_write_a_Worker skin-solstice action-view" id="solstice">
<a class="sr-only" href="How_to_write_a_Worker.html#content">Skip to main content</a>
<div class="thin-header">
<header role="banner" class="hidden-print noprint">
<div class="container-fluid">
<div id="row-logo-search">
<div id="header-left">
<div class="row">
<div class="hidden-xs col-sm-6 logo-container">
<a href="https://www.eclipse.org/" ><img class="logo-eclipse-default" src="http://wiki.eclipse.org/skins/solstice/public/images/logo/eclipse-800x188.png" alt="Eclipsepedia"></a>
</div>
<div class="navbar col-sm-18 yamm" id="main-menu">
<div class="navbar-collapse collapse" id="navbar-collapse-1">
<ul class="nav navbar-nav">
<li><a target="_self" href="https://eclipse.org/downloads/">Download</a></li>
<li><a target="_self" href="https://eclipse.org/users/">Getting Started </a></li>
<li><a target="_self" href="https://eclipse.org/membership/">Members</a></li>
<li><a target="_self" href="https://eclipse.org/projects/">Projects</a></li>
<li class="dropdown visible-xs"><a class="dropdown-toggle" data-toggle="dropdown" href="How_to_write_a_Worker.html#">Community <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="http://marketplace.eclipse.org">Marketplace</a></li><li><a href="http://events.eclipse.org">Events</a></li><li><a href="http://www.planeteclipse.org/">Planet Eclipse</a></li><li><a href="https://eclipse.org/community/eclipse_newsletter/">Newsletter</a></li><li><a href="https://www.youtube.com/user/EclipseFdn">Videos</a></li></ul></li><li class="dropdown visible-xs"><a class="dropdown-toggle" data-toggle="dropdown" href="How_to_write_a_Worker.html#">Participate <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="https://bugs.eclipse.org/bugs/">Report a Bug</a></li><li><a href="https://eclipse.org/forums/">Forums</a></li><li><a href="https://eclipse.org/mail/">Mailing Lists</a></li><li><a href="https://wiki.eclipse.org/">Wiki</a></li><li><a href="https://wiki.eclipse.org/IRC">IRC</a></li><li><a href="https://eclipse.org/contribute/">How to Contribute</a></li></ul></li><li class="dropdown visible-xs"><a class="dropdown-toggle" data-toggle="dropdown" href="How_to_write_a_Worker.html#">Working Groups <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="http://wiki.eclipse.org/Auto_IWG">Automotive</a></li><li><a href="http://iot.eclipse.org">Internet of Things</a></li><li><a href="http://locationtech.org">LocationTech</a></li><li><a href="http://lts.eclipse.org">Long-Term Support</a></li><li><a href="http://polarsys.org">PolarSys</a></li><li><a href="http://science.eclipse.org">Science</a></li><li><a href="http://openmdm.org">OpenMDM</a></li></ul></li><!-- More -->
<li class="dropdown hidden-xs"><a class="dropdown-toggle" data-toggle="dropdown">More<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>
<!-- Content container to add padding -->
<div class="yamm-content">
<div class="row">
<ul class="col-sm-8 list-unstyled"><li><p><strong>Community</strong></p></li><li><a href="http://marketplace.eclipse.org">Marketplace</a></li><li><a href="http://events.eclipse.org">Events</a></li><li><a href="http://www.planeteclipse.org/">Planet Eclipse</a></li><li><a href="https://eclipse.org/community/eclipse_newsletter/">Newsletter</a></li><li><a href="https://www.youtube.com/user/EclipseFdn">Videos</a></li></ul><ul class="col-sm-8 list-unstyled"><li><p><strong>Participate</strong></p></li><li><a href="https://bugs.eclipse.org/bugs/">Report a Bug</a></li><li><a href="https://eclipse.org/forums/">Forums</a></li><li><a href="https://eclipse.org/mail/">Mailing Lists</a></li><li><a href="https://wiki.eclipse.org/">Wiki</a></li><li><a href="https://wiki.eclipse.org/IRC">IRC</a></li><li><a href="https://eclipse.org/contribute/">How to Contribute</a></li></ul><ul class="col-sm-8 list-unstyled"><li><p><strong>Working Groups</strong></p></li><li><a href="http://wiki.eclipse.org/Auto_IWG">Automotive</a></li><li><a href="http://iot.eclipse.org">Internet of Things</a></li><li><a href="http://locationtech.org">LocationTech</a></li><li><a href="http://lts.eclipse.org">Long-Term Support</a></li><li><a href="http://polarsys.org">PolarSys</a></li><li><a href="http://science.eclipse.org">Science</a></li><li><a href="http://openmdm.org">OpenMDM</a></li></ul> </div>
</div>
</li>
</ul>
</li>
</ul>
</div>
<div class="navbar-header">
<button data-target="#navbar-collapse-1" data-toggle="collapse" class="navbar-toggle" type="button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a href="https://www.eclipse.org/" class="visible-xs navbar-brand"><img class="logo-eclipse-default" src="http://wiki.eclipse.org/skins/solstice/public/images/logo/eclipse-800x188.png" alt="Eclipsepedia" width="174"></a>
</div>
</div>
</div>
</div>
</div>
</div>
</header>
<section class="defaut-breadcrumbs hidden-print noprint hidden-print clearfix" id="breadcrumb">
<div>
<ol class="breadcrumb">
<li><a href="https://www.eclipse.org/">Home</a></li>
<li><a href="http://wiki.eclipse.org/Main_Page">Eclipse Wiki</a></li>
<li class="active">SMILA/Documentation/HowTo/How to write a Worker</li></ol>
</div>
</section>
</div>
<div class="toolbar-menu breadcrumbs-offset noprint hidden-print margin-bottom-0 clearfix">
<div class="col-md-24">
<ol class="breadcrumb" role="navigation">
<li id="pt-login">
<a href="http://wiki.eclipse.org/index.php?title=Special:UserLogin&amp;returnto=SMILA%2FDocumentation%2FHowTo%2FHow+to+write+a+Worker">
<i class="fa fa-sign-in fa-fw orange"></i> Log in </a>
</li>
</ul>
</div>
</div>
<main role="main" class="background-grey">
<div class="container-full padding-top-25">
<!-- content -->
<section id="content" class="mw-body container-full clearfix 0">
<div id="mw-js-message" style="display:none;"></div>
<!-- bodyContent -->
<div id="bodyContent">
<!-- jumpto -->
<div id="jump-to-nav" class="mw-jump">
Jump to: <a href="How_to_write_a_Worker.html#mw-head">navigation</a>,
<a href="How_to_write_a_Worker.html#p-search">search</a>
</div>
<!-- /jumpto -->
<!-- leftcol -->
<aside class="col-md-4 noprint hidden-print" id="leftcol">
<form class="input-group" role="form" id="form-eclipse-search" action="http://wiki.eclipse.org/index.php" id="searchform">
<input id="searchInput" class="search-query form-control" type="search" accesskey="f" title="Special:Search" placeholder="Search" name="search" value="">
<span class="input-group-btn">
<button value="search" id="mw-searchButton" type="submit" class="btn btn-default" title="Search the pages for this text" name="fulltext">
<i class="fa fa-search"></i>
</button>
</span>
</form>
<select class="form-control margin-top-10 margin-bottom-10 visible-xs visible-sm" onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);"><option class="fw-700 "><span class="fw-700">---Navigation---</span></option><option value="/Main_Page">Main Page</option><option value="/Eclipsepedia:Community_portal">Community portal</option><option value="/Eclipsepedia:Current_events">Current events</option><option value="/Special:RecentChanges">Recent changes</option><option value="/Special:Random">Random page</option><option value="https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents">Help</option></select><ul class="ul-left-nav fa-ul hidden-print leftnav hidden-xs hidden-sm"><li class="separator"><span class="separator">Navigation</span></li> <li class=""><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="http://wiki.eclipse.org/Main_Page" id="n-mainpage" title="Visit the main page [z]" accesskey="z">Main Page</a></li> <li class=""><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="http://wiki.eclipse.org/Eclipsepedia:Community_portal" id="n-portal" title="About the project, what you can do, where to find things">Community portal</a></li> <li class=""><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="http://wiki.eclipse.org/Eclipsepedia:Current_events" id="n-currentevents" title="Find background information on current events">Current events</a></li> <li class=""><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="http://wiki.eclipse.org/Special:RecentChanges" id="n-recentchanges" title="A list of recent changes in the wiki [r]" accesskey="r">Recent changes</a></li> <li class=""><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="http://wiki.eclipse.org/Special:Random" id="n-randompage" title="Load a random page [x]" accesskey="x">Random page</a></li> <li class=""><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Contents" id="n-help" title="The place to find out">Help</a></li></ul> <select class="form-control margin-top-10 margin-bottom-10 visible-xs visible-sm" onchange="this.options[this.selectedIndex].value && (window.location = this.options[this.selectedIndex].value);"><option class="fw-700 "><span class="fw-700">---Toolbox---</span></option><option value="/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;action=info">Page information</option><option value="/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;oldid=375643">Permanent link</option><option value="/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;printable=yes">Printable version</option><option value="/Special:SpecialPages">Special pages</option><option value="/Special:RecentChangesLinked/SMILA/Documentation/HowTo/How_to_write_a_Worker">Related changes</option><option value="/Special:WhatLinksHere/SMILA/Documentation/HowTo/How_to_write_a_Worker">What links here</option></select><ul class="ul-left-nav fa-ul hidden-print leftnav hidden-xs hidden-sm"><li class="separator"><span class="separator">Toolbox</span></li><li><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;action=info" id="t-info">Page information</a></li><li><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;oldid=375643" id="t-permalink" title="Permanent link to this revision of the page">Permanent link</a></li><li><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;printable=yes" id="t-print" rel="alternate" title="Printable version of this page [p]" accesskey="p">Printable version</a></li><li><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="http://wiki.eclipse.org/Special:SpecialPages" id="t-specialpages" title="A list of all special pages [q]" accesskey="q">Special pages</a></li><li><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="http://wiki.eclipse.org/Special:RecentChangesLinked/SMILA/Documentation/HowTo/How_to_write_a_Worker" id="t-recentchangeslinked" title="Recent changes in pages linked from this page [k]" accesskey="k">Related changes</a></li><li><i class="fa fa-angle-double-right orange fa-fw"></i> <a href="http://wiki.eclipse.org/Special:WhatLinksHere/SMILA/Documentation/HowTo/How_to_write_a_Worker" id="t-whatlinkshere" title="A list of all wiki pages that link here [j]" accesskey="j">What links here</a></li></ul> </aside>
<!-- /leftcol -->
<!-- mainContent -->
<div id="mainContent" class="col-md-20">
<ul class="nav nav-tabs noprint hidden-print" role="tablist">
<li id="ca-nstab-main" class="active"><a href="How_to_write_a_Worker.html" title="View the content page [c]" accesskey="c" tabindex="-1">Page</a></li>
<li id="ca-talk" class="new"><a href="http://wiki.eclipse.org/index.php?title=Talk:SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;action=edit&amp;redlink=1" title="Discussion about the content page [t]" accesskey="t" tabindex="-1">Discussion</a></li>
<li id="ca-viewsource"><a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;action=edit" title="This page is protected.&#10;You can view its source [e]" accesskey="e" tabindex="-1">View source</a></li>
<li id="ca-history" class="collapsible"><a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;action=history" title="Past revisions of this page [h]" accesskey="h" tabindex="-1">History</a></li>
</ul> <div class="tab-content background-white">
<div id="tab-pane-main-page-content" class="tab-pane active">
<h1 id="firstHeading" class="firstHeading page-header">
<span dir="auto">SMILA/Documentation/HowTo/How to write a Worker</span>
</h1>
<div id="main-page-content">
<!-- subtitle -->
<div id="contentSub" class="alert alert-small alert-warning"><span class="subpages">&lt; <a href="../../../SMILA.html" title="SMILA">SMILA</a>&lrm; | <a href="../../Documentation.1.html" title="SMILA/Documentation">Documentation</a>&lrm; | <a href="../HowTo.html" title="SMILA/Documentation/HowTo">HowTo</a></span></div>
<!-- /subtitle -->
<div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><p><br />
This HowTo describes the necessary steps for writing a worker in SMILA.
</p>
<div id="toc" class="toc"><div id="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1 tocsection-1"><a href="How_to_write_a_Worker.html#Preconditions"><span class="tocnumber">1</span> <span class="toctext">Preconditions</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="How_to_write_a_Worker.html#Project_templates"><span class="tocnumber">2</span> <span class="toctext">Project templates</span></a></li>
<li class="toclevel-1 tocsection-3"><a href="How_to_write_a_Worker.html#Integration"><span class="tocnumber">3</span> <span class="toctext">Integration</span></a>
<ul>
<li class="toclevel-2 tocsection-4"><a href="How_to_write_a_Worker.html#Adding_the_worker_description"><span class="tocnumber">3.1</span> <span class="toctext">Adding the worker description</span></a></li>
<li class="toclevel-2 tocsection-5"><a href="How_to_write_a_Worker.html#Adding_the_bundles_to_the_configuration"><span class="tocnumber">3.2</span> <span class="toctext">Adding the bundles to the configuration</span></a>
<ul>
<li class="toclevel-3 tocsection-6"><a href="How_to_write_a_Worker.html#config.ini"><span class="tocnumber">3.2.1</span> <span class="toctext">config.ini</span></a></li>
<li class="toclevel-3 tocsection-7"><a href="How_to_write_a_Worker.html#launcher"><span class="tocnumber">3.2.2</span> <span class="toctext">launcher</span></a></li>
</ul>
</li>
<li class="toclevel-2 tocsection-8"><a href="How_to_write_a_Worker.html#Scale_up"><span class="tocnumber">3.3</span> <span class="toctext">Scale up</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-9"><a href="How_to_write_a_Worker.html#Running"><span class="tocnumber">4</span> <span class="toctext">Running</span></a>
<ul>
<li class="toclevel-2 tocsection-10"><a href="How_to_write_a_Worker.html#Run_the_application"><span class="tocnumber">4.1</span> <span class="toctext">Run the application</span></a></li>
<li class="toclevel-2 tocsection-11"><a href="How_to_write_a_Worker.html#Run_the_test_case"><span class="tocnumber">4.2</span> <span class="toctext">Run the test case</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-12"><a href="How_to_write_a_Worker.html#Create_your_own_worker"><span class="tocnumber">5</span> <span class="toctext">Create your own worker</span></a>
<ul>
<li class="toclevel-2 tocsection-13"><a href="How_to_write_a_Worker.html#Use_template"><span class="tocnumber">5.1</span> <span class="toctext">Use template</span></a></li>
<li class="toclevel-2 tocsection-14"><a href="How_to_write_a_Worker.html#Bundle_dependencies"><span class="tocnumber">5.2</span> <span class="toctext">Bundle dependencies</span></a></li>
<li class="toclevel-2 tocsection-15"><a href="How_to_write_a_Worker.html#Worker_Implementation_Java_Class"><span class="tocnumber">5.3</span> <span class="toctext">Worker Implementation Java Class</span></a></li>
<li class="toclevel-2 tocsection-16"><a href="How_to_write_a_Worker.html#OSGI_Declarative_Service"><span class="tocnumber">5.4</span> <span class="toctext">OSGI Declarative Service</span></a></li>
<li class="toclevel-2 tocsection-17"><a href="How_to_write_a_Worker.html#Register_your_worker_in_jobmanager_configuration"><span class="tocnumber">5.5</span> <span class="toctext">Register your worker in jobmanager configuration</span></a>
<ul>
<li class="toclevel-3 tocsection-18"><a href="How_to_write_a_Worker.html#Worker_definition"><span class="tocnumber">5.5.1</span> <span class="toctext">Worker definition</span></a></li>
<li class="toclevel-3 tocsection-19"><a href="How_to_write_a_Worker.html#Workflow_definition"><span class="tocnumber">5.5.2</span> <span class="toctext">Workflow definition</span></a></li>
<li class="toclevel-3 tocsection-20"><a href="How_to_write_a_Worker.html#Bucket_definition"><span class="tocnumber">5.5.3</span> <span class="toctext">Bucket definition</span></a></li>
</ul>
</li>
<li class="toclevel-2 tocsection-21"><a href="How_to_write_a_Worker.html#Activate_the_Worker"><span class="tocnumber">5.6</span> <span class="toctext">Activate the Worker</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-22"><a href="How_to_write_a_Worker.html#Testing"><span class="tocnumber">6</span> <span class="toctext">Testing</span></a>
<ul>
<li class="toclevel-2 tocsection-23"><a href="How_to_write_a_Worker.html#Use_the_launcher"><span class="tocnumber">6.1</span> <span class="toctext">Use the launcher</span></a></li>
<li class="toclevel-2 tocsection-24"><a href="How_to_write_a_Worker.html#Create_worker_unit_test"><span class="tocnumber">6.2</span> <span class="toctext">Create worker unit test</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-25"><a href="How_to_write_a_Worker.html#Manually_installing_the_worker_in_SMILA"><span class="tocnumber">7</span> <span class="toctext">Manually installing the worker in SMILA</span></a>
<ul>
<li class="toclevel-2 tocsection-26"><a href="How_to_write_a_Worker.html#Create_a_feature_project"><span class="tocnumber">7.1</span> <span class="toctext">Create a feature project</span></a></li>
<li class="toclevel-2 tocsection-27"><a href="How_to_write_a_Worker.html#Deploy_your_worker_feature"><span class="tocnumber">7.2</span> <span class="toctext">Deploy your worker feature</span></a></li>
<li class="toclevel-2 tocsection-28"><a href="How_to_write_a_Worker.html#Install_your_worker_feature_in_a_SMILA_installation"><span class="tocnumber">7.3</span> <span class="toctext">Install your worker feature in a SMILA installation</span></a></li>
</ul>
</li>
<li class="toclevel-1 tocsection-29"><a href="How_to_write_a_Worker.html#Advanced_How_To.27s"><span class="tocnumber">8</span> <span class="toctext">Advanced How To's</span></a>
<ul>
<li class="toclevel-2 tocsection-30"><a href="How_to_write_a_Worker.html#How_to_access_another_OSGi_Service_inside_your_Worker"><span class="tocnumber">8.1</span> <span class="toctext">How to access another OSGi Service inside your Worker</span></a></li>
<li class="toclevel-2 tocsection-31"><a href="How_to_write_a_Worker.html#How_to_add_.2F_access_a_configuration_for_your_Worker"><span class="tocnumber">8.2</span> <span class="toctext">How to add / access a configuration for your Worker</span></a></li>
<li class="toclevel-2 tocsection-32"><a href="How_to_write_a_Worker.html#Exception_Handling_and_Logging"><span class="tocnumber">8.3</span> <span class="toctext">Exception Handling and Logging</span></a></li>
<li class="toclevel-2 tocsection-33"><a href="How_to_write_a_Worker.html#Create_worker_in_new_bundle_resp._rename_template_bundle"><span class="tocnumber">8.4</span> <span class="toctext">Create worker in new bundle resp. rename template bundle</span></a></li>
</ul>
</li>
</ul>
</div>
<h1><span class="mw-headline" id="Preconditions">Preconditions</span></h1>
<ul>
<li> Set up your development environment, see <a href="../../Development_Guidelines/Howto_set_up_dev_environment.html" title="SMILA/Development Guidelines/Howto set up dev environment" class="mw-redirect">How to set up the development environment</a>.
</li>
<li> You should have read and understood the documentation about the <a href="../JobManager.html" title="SMILA/Documentation/JobManager">JobManager</a>, especially the configuration of workers and workflows if you want to create new workers.
</li>
<li> You should have at least an idea about the OSGi framework and OSGi services. For links to introductory articles and tutorials see <a rel="nofollow" class="external autonumber" href="http://www.osgi.org/About/HowOSGi">[1]</a>. For a quite comprehensive overview on OSGi see <a rel="nofollow" class="external autonumber" href="http://njbartlett.name/osgibook.html">[2]</a>.
</li>
</ul>
<h1><span class="mw-headline" id="Project_templates">Project templates</span></h1>
<p>Before writing your own worker we recommend you to take a look at the sample workers. You can get them by importing the bundles from the <tt>examples</tt> directory of <a rel="nofollow" class="external text" href="https://git.eclipse.org/c/smila/org.eclipse.smila.core.git/">SMILA's repository</a> into your workspace and use them as templates:
</p>
<ul>
<li> <a rel="nofollow" class="external text" href="https://git.eclipse.org/c/smila/org.eclipse.smila.core.git/tree/examples/org.eclipse.smila.integration.worker">org.eclipse.smila.integration.worker</a>: template bundle for worker development, containing an example worker class
</li>
<li> <a rel="nofollow" class="external text" href="https://git.eclipse.org/c/smila/org.eclipse.smila.core.git/tree/examples/org.eclipse.smila.integration.worker.test">org.eclipse.smila.integration.worker.test</a>: template bundle to test a developed worker, containg an example test class
</li>
</ul>
<p>You can also download these examples from the <a rel="nofollow" class="external text" href="http://www.eclipse.org/smila/downloads.php">release downloads</a> or the <a rel="nofollow" class="external text" href="http://build.eclipse.org/rt/smila/nightly/">nightly build downloads</a>. (SMILA-...-integrator-examples.zip)
</p><p>If you do not want to use the example bundles as templates, you can also start with a new bundle by following the two HowTos:
</p>
<ul>
<li> <a href="../../Development_Guidelines/Create_a_bundle_(plug-in).html" title="SMILA/Development Guidelines/Create a bundle (plug-in)" class="mw-redirect">How to create a bundle (plug-in)</a>
</li>
<li> <a href="../../Development_Guidelines/Create_a_test_bundle_(plug-in).html" title="SMILA/Development Guidelines/Create a test bundle (plug-in)" class="mw-redirect">How to create a test bundle (plug-in)</a>
</li>
</ul>
<p>Now you have two (completely empty) bundles, one to develop your worker(s), and one to test it/them.
</p><p><i>Hint: The following steps apply only when you use the example bundles, not if you start with fresh bundles!</i>
</p>
<h1><span class="mw-headline" id="Integration">Integration</span></h1>
<p>We now need to integrate our new workers in the SMILA application.
Do the following steps to enable this:
</p>
<h2><span class="mw-headline" id="Adding_the_worker_description">Adding the worker description</span></h2>
<p>The workers' descriptions are read by the jobmanager on startup, if a worker does not provide a description it won't get any tasks, so you have to provide one.
</p>
<ul>
<li> Edit the <tt>workers.json</tt> file in <tt>SMILA.application/configuration/org.eclipse.smila.jobmanager</tt> and add the following worker description to the json array (don't forget the comma):
</li>
</ul>
<div dir="ltr" class="mw-geshi mw-code mw-content-ltr"><div class="javascript source-javascript"><pre class="de1"><span class="br0">&#123;</span>
<span class="st0">&quot;name&quot;</span><span class="sy0">:</span> <span class="st0">&quot;HelloWorldWorker&quot;</span><span class="sy0">,</span>
<span class="st0">&quot;input&quot;</span><span class="sy0">:</span> <span class="br0">&#91;</span>
<span class="br0">&#123;</span> <span class="st0">&quot;name&quot;</span><span class="sy0">:</span> <span class="st0">&quot;inputRecords&quot;</span><span class="sy0">,</span>
<span class="st0">&quot;type&quot;</span><span class="sy0">:</span> <span class="st0">&quot;recordBulks&quot;</span>
<span class="br0">&#125;</span> <span class="br0">&#93;</span><span class="sy0">,</span>
<span class="st0">&quot;output&quot;</span><span class="sy0">:</span> <span class="br0">&#91;</span>
<span class="br0">&#123;</span> <span class="st0">&quot;name&quot;</span><span class="sy0">:</span> <span class="st0">&quot;outputRecords&quot;</span><span class="sy0">,</span>
<span class="st0">&quot;type&quot;</span><span class="sy0">:</span> <span class="st0">&quot;recordBulks&quot;</span>
<span class="br0">&#125;</span> <span class="br0">&#93;</span>
<span class="br0">&#125;</span></pre></div></div>
<h2><span class="mw-headline" id="Adding_the_bundles_to_the_configuration">Adding the bundles to the configuration</span></h2>
<p>Next we need to make sure the bundle is started.
</p>
<h3><span class="mw-headline" id="config.ini">config.ini</span></h3>
<p>To start the bundle in the built application, add the following line to <tt>SMILA.application/configuration/config.ini</tt> as the second last line:
</p>
<ul>
<li> org.eclipse.smila.integration.worker@4:start, \
</li>
</ul>
<p>(To be honest, it does not matter at all, where exaclty you add your bundle in the file, as long as the syntax (end of lines must be escaped for all lines except the last one, of course) is correct.)
</p>
<h3><span class="mw-headline" id="launcher">launcher</span></h3>
<p>You also have to adapt your launcher:
</p>
<ul>
<li> Click on <i>Run configurations...</i>
</li>
<li> Select the <i>OSGi Framework</i>--&gt;<i>SMILA</i> configuration
</li>
<li> In the <i>Bundles</i> page, check the box before <tt>org.eclipse.smila.integration.worker</tt>, leave Start Level on <tt>default</tt>, set Auto-Start to <tt>true</tt>.
</li>
<li> Click <i>Apply</i>
</li>
</ul>
<h2><span class="mw-headline" id="Scale_up">Scale up</span></h2>
<p>Finally you should add the scale up limits (see <a href="../WorkerManager.html#ScaleUp" title="SMILA/Documentation/WorkerManager"> ScaleUp</a>) to the cluster configuration file (if you use the standard simple clusterconfig service, you will find the configuration file as <tt>org.eclipse.smila.clusterconfig.simple/clusterconfig.json</tt>).
</p><p>E.g. add the following snippet to the existing ones in the <span style="font-family:monospace;">workers</span> map to limit scale up of the worker to a maximum of concurrent tasks (be sure, your worker label is the same as in the <tt>workers.json</tt>). If you do not add your worker's scale up here, the worker is limited to one concurrent task.
</p><p>Example to limit the worker <tt>HelloWorldWorker</tt> to a maximum of 4 concurrent tasks:
</p>
<div dir="ltr" class="mw-geshi mw-code mw-content-ltr"><div class="javascript source-javascript"><pre class="de1"> <span class="st0">&quot;HelloWorldWorker&quot;</span><span class="sy0">:</span><span class="br0">&#123;</span>
<span class="st0">&quot;maxScaleUp&quot;</span><span class="sy0">:</span><span class="nu0">4</span>
<span class="br0">&#125;</span><span class="sy0">,</span></pre></div></div>
<h1><span class="mw-headline" id="Running">Running</span></h1>
<p>You should now test your workspace setup to make sure that everything works with the prepared stuff.
</p>
<h2><span class="mw-headline" id="Run_the_application">Run the application</span></h2>
<ul>
<li> Select "Run" -&gt; "Run Configurations" or "Debug Configurations"
</li>
<li> Select "OSGi Frameworks" -&gt; "SMILA".
</li>
<li> Click "Run" or "Debug" and SMILA should start just like when started from the command line.
</li>
</ul>
<p>When starting the <tt>SMILA.launch</tt> in eclipse, you should see something like the following output in the console window:
</p>
<pre>
...
Added worker HelloWorldWorker to WorkerManager.
...
</pre>
<p>You should also be able to read the worker definition using the jobmanager HTTP API now: Go to <tt><a rel="nofollow" class="external free" href="http://localhost:8080/smila/jobmanager/workers/">http://localhost:8080/smila/jobmanager/workers/</a></tt> to see something like this:
</p>
<pre>
{
&quot;workers&quot;&#160;: [ ...,
{
&quot;name&quot;&#160;: &quot;HelloWorldWorker&quot;,
&quot;url&quot;&#160;: &quot;http://localhost:8080/smila/jobmanager/workers/HelloWorldWorker/&quot;
}, ... ]
}
</pre>
<p>You can now click on the link to the worker description and you should see the description of the HelloWorldWorker:
</p>
<pre>
{
&quot;name&quot;&#160;: &quot;HelloWorldWorker&quot;,
&quot;input&quot;&#160;: [ {
&quot;name&quot;&#160;: &quot;inputRecords&quot;,
&quot;type&quot;&#160;: &quot;recordBulks&quot;
} ],
&quot;output&quot;&#160;: [ {
&quot;name&quot;&#160;: &quot;outputRecords&quot;,
&quot;type&quot;&#160;: &quot;recordBulks&quot;
} ]
}
</pre>
<h2><span class="mw-headline" id="Run_the_test_case">Run the test case</span></h2>
<p><b>To run the JUnit test case for the HelloWorldWorker</b>
</p>
<ul>
<li> Stop the SMILA.launch if it is running.
</li>
<li> Select "Run" -&gt; "Run Configurations".
</li>
<li> Select "JUnit Plugin Test" -&gt; "TestHelloWorldWorker".
</li>
<li> Click "Run".
</li>
<li> You should find the following message in the "Console" view:
</li>
</ul>
<pre>
TestHelloWorldWorker: Value of attribute 'greeting' = 'HelloWorldWorker was here&#160;:-)'
</pre>
<p>This shows that the HelloWorldWorker has done something. Of course, the test also contains an assertion so that it will fail when the attribute has not the expceted value.
</p>
<h1><span class="mw-headline" id="Create_your_own_worker">Create your own worker</span></h1>
<h2><span class="mw-headline" id="Use_template">Use template</span></h2>
<p>The easiest way to create a new worker is by implementing it in the bundle <tt>org.eclipse.smila.integration.worker</tt> (see <a href="How_to_write_a_Worker.html#Project_templates">Project Templates</a>). There you can just place your new worker beside the <tt>HelloWorldWorker</tt> example worker, or replace it. Things you have to do when renaming the bundle/package or creating your own worker bundle are described later on.
</p>
<h2><span class="mw-headline" id="Bundle_dependencies">Bundle dependencies</span></h2>
<p>The dependencies of the bundle are managed by the OSGi framework and have to be configured explicitly in the <tt>MANIFEST.MF</tt> file so that the OSGi framework can resolve them (in the correct versions) when the services are started.
</p><p>To create a worker that reads and writes <tt>Records</tt>, we need at least the following bundles imported as packages (see <tt>META-INF</tt> -&gt; "Dependencies" -&gt; "Imported Packages"):
</p>
<ul>
<li><tt>org.eclipse.smila.datamodel</tt>: For the <tt>Record</tt> class.
</li>
<li><tt>org.eclipse.smila.objectstore</tt>: Possible exceptions when accessing input/output streams.
</li>
<li><tt>org.eclipse.smila.taskworker</tt>: The <tt>TaskWorker</tt> bundle containing the <tt>Worker</tt> and <tt>TaskContext</tt> interfaces.
</li>
<li><tt>org.eclipse.smila.taskworker.input</tt>: Input streams of the <tt>TaskWorker</tt> bundle.
</li>
<li><tt>org.eclipse.smila.taskworker.output</tt>: Output streams of the <tt>TaskWorker</tt> bundle.
</li>
</ul>
<p>This is already configured. If access to other packages is needed, just extend the <tt>MANIFEST.MF</tt> file in section "Imported Packages" accordingly.
</p>
<h2><span class="mw-headline" id="Worker_Implementation_Java_Class">Worker Implementation Java Class</span></h2>
<p>Create a worker class which implements <tt>org.eclipse.smila.taskworker.Worker</tt>. Have a look at the example worker <tt>org.eclipse.smila.integration.worker.HelloWorldWorker</tt> that comes with the SDK in the <tt>org.eclipse.smila.integration.worker</tt> bundle. You must implement two methods:
</p>
<ul>
<li> <tt>getName()</tt> must return a unique name for your worker. Exactly the same name (case sensitive) must be used later in the worker descriptions and workflow definitions.
</li>
<li> <tt>perform()</tt> does the actual work. It is called with a <tt>TaskContext</tt> object that provides access to the task properties, input and output objects, and counters.
</li>
</ul>
<p><b>Thread safety</b>: Make sure that your worker implemention is thread safe! Otherwise you can't use it for scale up.
</p>
<h2><span class="mw-headline" id="OSGI_Declarative_Service">OSGI Declarative Service</span></h2>
<p>Every worker must be declared as an OSGi Declarative Service (DS) in order to be registered properly to the worker framework. To configure your worker as DS, you have to add an appropriate XML file to the folder <tt>org.eclipse.smila.integration.worker/OSGI-INF</tt>.
</p><p>The file can be created either manually or using the <i>Component Definition</i> wizard.
</p><p>Have a look at <tt>helloworldworker.xml</tt> as an example:
</p>
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;scr:component xmlns:scr=&quot;http://www.osgi.org/xmlns/scr/v1.1.0&quot;
name=&quot;HelloWorldWorker&quot; immediate=&quot;true&quot;&gt;
&lt;implementation class=&quot;org.eclipse.smila.integration.worker.HelloWorldWorker&quot;/&gt;
&lt;service&gt;
&lt;provide interface=&quot;org.eclipse.smila.taskworker.Worker&quot;/&gt;
&lt;/service&gt;
&lt;/scr:component&gt;
</pre>
<p>The file describes (1) the interface that the worker has to implement (and through which it will be accessed in the OSGi application by means of dependency injection), (2) the class being the concrete implementor of that interface, (3) the services that it references (our simple worker does not reference any, you can find a description later on), (4) and the name of the service.
</p><p>To describe your own worker, just create a copy of the <tt>OSGI-INF/helloworldworker.xml</tt> file in the same directory. Then change at least the "name" attribute in the root element and the "class" element in the "implementation" element.
</p><p>When you don't need the <tt>HelloWorldWorker</tt> anymore you may want to remove at least its component definition file from the bundle. Otherwise, it will always be running and asking for tasks in the final deployment. While it should not really be a problem, it causes some unnecessary overhead that can easily be avoided.
</p><p>You should check in your MANIFEST.MF that your component definition is included in the build and it is listed as <i>Service-Component</i> (e.g. as a line in your MANIFEST.MF <span style="font-family:monospace;">Service-Component: OSGI-INF/*.xml</span> and the <span style="font-family:monospace;">bin.includes</span> of the build.properties file should contain <span style="font-family:monospace;">OSGI-INF/</span>).
</p>
<h2><span class="mw-headline" id="Register_your_worker_in_jobmanager_configuration">Register your worker in jobmanager configuration</span></h2>
<p>These are the steps to use your new worker with the jobmanager framework.
</p>
<h3><span class="mw-headline" id="Worker_definition">Worker definition</span></h3>
<p>Edit <tt>workers.json</tt> from <tt>&lt;WORKSPACE&gt;/SMILA.application/configuration/org.eclipse.smila.jobmanager</tt> folder and add the definition for the new worker.
</p><p><b>Important:</b> The <tt>name</tt> in the worker definition has to be the same that is returned by the <tt>getName()</tt> method in the worker implementation!
</p><p>For the example worker <tt>HelloWorldWorker</tt> we want to use one input and output slot. And we use <tt>recordBulks</tt> as data object type cause we want to modify (bulks of) records with this worker:
</p>
<pre>
{ &quot;name&quot;: &quot;HelloWorldWorker&quot;,
&quot;input&quot;: [
{ &quot;name&quot;: &quot;inputRecords&quot;,
&quot;type&quot;: &quot;recordBulks&quot;
} ],
&quot;output&quot;: [
{ &quot;name&quot;: &quot;outputRecords&quot;,
&quot;type&quot;: &quot;recordBulks&quot;
} ]
}
</pre>
<h3><span class="mw-headline" id="Workflow_definition">Workflow definition</span></h3>
<p>To use your worker in a workflow you have to add a new workflow or change an existing one. You can either use the jobmanager API to add a workflow definition to the running system, or you can edit <tt>workflows.json</tt> from <tt>&lt;WORKSPACE&gt;/SMILA.application/configuration/org.eclipse.smila.jobmanager</tt> folder and add/change a workflow.
</p><p>This example is a test workflow that uses the <tt>HelloWorldWorker</tt> to manipulate all records which where pushed into the system using the bulkbuilder. Because it's pretty useless as such, we did not add it to <tt>SMILA.application/configuration/org.eclipse.smila.jobmanager/workflows.json</tt>, but it's used in the unit test bundle <tt>org.eclipse.smila.integration.worker.test</tt>: The test case reads the output bulk created by the <tt>HelloWorldWorker</tt> to check if it been running.
</p>
<pre>
{
&quot;name&quot;:&quot;HelloWorldWorkflow&quot;,
&quot;startAction&quot;:{
&quot;worker&quot;:&quot;bulkbuilder&quot;,
&quot;output&quot;:{
&quot;insertedRecords&quot;:&quot;importBucket&quot;
}
},
&quot;actions&quot;:[
{
&quot;worker&quot;:&quot;HelloWorldWorker&quot;,
&quot;input&quot;:{
&quot;inputRecords&quot;:&quot;importBucket&quot;
},
&quot;output&quot;:{
&quot;outputRecords&quot;:&quot;helloWorldExportBucket&quot;
}
}
]
}
</pre>
<h3><span class="mw-headline" id="Bucket_definition">Bucket definition</span></h3>
<p>If you want to use a new <i>persistent</i> bucket for your workflow (see <a href="../DataObjectTypesAndBuckets.html" title="SMILA/Documentation/DataObjectTypesAndBuckets">jobmanager documentation</a>) you have to add it via the jobmanager API or add it to the configuration: Edit <tt>buckets.json</tt> from <tt>SMILA.application/configuration/org.eclipse.smila.jobmanager</tt> folder and create desired bucket.
</p><p>Here's an example from the test bundle <tt>org.eclipse.smila.integration.worker.test</tt> for the workflow above that makes the final bucket <tt>helloWorldExportBucket</tt> persistent. For the unit test, the output bucket of the worker must be persistent so that the test case can still read the result records when the workflow has ended. Otherwise the jobmanager would remove the transient object immediately after the <tt>HelloWorldWorker</tt> has finished.
</p>
<pre>
{
&quot;name&quot;:&quot;helloWorldExportBucket&quot;,
&quot;type&quot;:&quot;recordBulks&quot;
}
</pre>
<h2><span class="mw-headline" id="Activate_the_Worker">Activate the Worker</span></h2>
<p>Add the worker bundle to the configuration and set scale-up as described <a href="How_to_write_a_Worker.html#Integration" title="SMILA/Documentation/HowTo/How to write a Worker">above</a> if you haven't already done yet.
</p>
<h1><span class="mw-headline" id="Testing">Testing</span></h1>
<h2><span class="mw-headline" id="Use_the_launcher">Use the launcher</span></h2>
<p>If everything was done correctly and you start the <tt>SMILA.launch</tt> in Eclipse, you should see the same output as described <a href="How_to_write_a_Worker.html#Running" title="SMILA/Documentation/HowTo/How to write a Worker">above</a>, but for your own worker.
</p><p>You should also check whether your new workflow definition is visible in <a rel="nofollow" class="external autonumber" href="http://localhost:8080/smila/jobmanager/workflows/">[3]</a>.
If not, you maybe misstyped a worker name or something. If there is no workflow at all, the <tt>workflows.json</tt> file has invalid syntax.
</p>
<h2><span class="mw-headline" id="Create_worker_unit_test">Create worker unit test</span></h2>
<p>You can use the test bundle template <tt>org.eclipse.smila.integration.worker.test</tt> to add a test for your worker. Have a look at the example test class <tt>org.eclipse.smila.integration.worker.test.TestHelloWorldWorker</tt> that comes with the SDK.
</p><p>All configuration files for the test are in <tt>org.eclipse.smila.integration.worker.test/configuration</tt>. This is similar to <tt>SMILA.application/configuration</tt>, but contains only the configuration files necessary to run the tests, not all files needed by a complete system. Also, some configuration files may differ from those in <tt>SMILA.application</tt>, e.g. some components may be configured with smaller limits to make tests run quicker. However, if you create a new worker, you must add its description to the <tt>workers.json</tt> in the test bundles and define persistent buckets and workflows required to run the test. Additionally make sure that the <tt>config.ini</tt> contains the names of your worker bundles and those of services your worker needs to access.
</p><p>To start the test in eclipse you have to copy the launch for TestHelloWorldWorker and adapt it to your new test class.
</p>
<h1><span class="mw-headline" id="Manually_installing_the_worker_in_SMILA">Manually installing the worker in SMILA</span></h1>
<p>In the following we describe the steps to deploy your worker manually to an existing SMILA installation.
</p><p>Alternatively, you could also <a href="How_to_integrate_new_bundle_into_build_process.html" title="SMILA/Documentation/HowTo/How to integrate new bundle into build process"> add your worker bundle to the SMILA build process</a> and build a new SMILA application.
</p>
<h2><span class="mw-headline" id="Create_a_feature_project">Create a feature project</span></h2>
<p>A feature project is a container project that defines the Plug-ins needed for a specific feature. In our case our feature is to provide a worker, so we'll only have one Plug-in included in that feature, but it can also be reasonable to include all worker Plug-ins that are necessary to extend the SMILA to be able to handle a specific scenario in one feature that can be deployed and so includes all plugins necessary.
</p><p>If you ever need to create an own feature project you can use Eclipse's <i>New...</i> wizard:
</p>
<ul>
<li> New --&gt; Plug-in Development --&gt; Feature Project
<ul>
<li> Enter a Project name (<tt>e.g. org.eclipse.smila.integration.feature</tt>)
</li>
<li> Fill in other feature properties to describe the new feature ('Version' should match the version of your new worker bundle)
</li>
</ul>
</li>
<li> Next
<ul>
<li> select your worker bundle
</li>
</ul>
</li>
<li> Finish
</li>
</ul>
<h2><span class="mw-headline" id="Deploy_your_worker_feature">Deploy your worker feature</span></h2>
<p>Now it's easy to export your custom bundles to files that can be easily deployed into SMILA:
</p>
<ul>
<li>Select your feature project
</li>
<li>Right-click on it
</li>
<li>Click on <i>Export...</i>
</li>
<li>Select <i>Plug-in Development</i> --&gt; <i>Deployable features</i>
</li>
<li>Next
</li>
<li>Select your new worker feature
</li>
<li>Select a destination folder. If you are re-exporting after changes (especially after renames), you should first delete the destination folder.
</li>
<li>Click <i>Finish</i>
</li>
</ul>
<p>After that you will find <tt>plugins</tt> and <tt>features</tt> directories in your destination directory that contain the deployable software. The export process produces two additional files <tt>artifacts.jar</tt> and <tt>contents.jar</tt> which are not for our purposes.
</p>
<h2><span class="mw-headline" id="Install_your_worker_feature_in_a_SMILA_installation">Install your worker feature in a SMILA installation</span></h2>
<ul>
<li> Copy the <tt>features</tt> and <tt>plugins</tt> folder to your SMILA installation.
</li>
<li> merge your configuration changes (e.g. <tt>configuration/org.eclipse.smila.jobmanager</tt>) into the SMILA configuration
<ul>
<li> copy your <tt>configuration/config.ini</tt> file (see above) or edit the installed <tt>config.ini</tt> directly to start up your bundle
<ul>
<li> e.g. for the above bundle and version this would be (in the second last line): <tt>org.eclipse.smila.integration.worker@4:start, \</tt>
</li>
</ul>
</li>
</ul>
</li>
<li> start your system
</li>
<li> In the console you should see:
</li>
</ul>
<pre>
...
Added worker HelloWorldWorker to WorkerManager.
...
</pre>
<p>Additionally you should be able to see the worker descriptions you added via the JobManager REST API: <a rel="nofollow" class="external free" href="http://localhost:8080/smila/jobmanager/workers">http://localhost:8080/smila/jobmanager/workers</a>
</p>
<h1><span class="mw-headline" id="Advanced_How_To.27s">Advanced How To's</span></h1>
<h2><span class="mw-headline" id="How_to_access_another_OSGi_Service_inside_your_Worker">How to access another OSGi Service inside your Worker</span></h2>
<p>With SMILA there come a lot of components with APIs for different purposes. Sometimes you may want to access such an API inside your worker. With the concept of OSGi Declarative Services (DS) this is just a matter of configuration.
</p><p><b>Example: Reading all cluster nodes</b>
</p><p>Assumed, we want to know the names of all cluster nodes in our worker. This is possible via ClusterConfigService API. Here are the steps to access this API in your worker:
</p>
<ul>
<li> Precondition: We assume you already configured your worker as OSGi Declarative Service as described before.
</li>
</ul>
<ul>
<li> To use the ClusterConfigService you have to import the appropriate package <tt>org.eclipse.smila.clusterconfig</tt> in the MANIFEST.MF/Dependencies (see "Bundle Dependencies")
</li>
</ul>
<ul>
<li> Configure ClusterConfigService as referenced service in the service description xml (OSGI-INF/...):
</li>
</ul>
<pre>
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;scr:component org.eclipse.smila.jobmanager name=&quot;MyWorker&quot; immediate=&quot;true&quot;&gt;
&lt;implementation class=&quot;mypackage.MyWorkerImpl&quot; /&gt;
&lt;service&gt;
&lt;provide interface=&quot;org.eclipse.smila.taskworker.Worker&quot;/&gt;
&lt;/service&gt;
&lt;reference bind=&quot;setClusterConfigService&quot;
cardinality=&quot;1..1&quot;
interface=&quot;org.eclipse.smila.clusterconfig.ClusterConfigService&quot;
name=&quot;ClusterConfigService&quot;
policy=&quot;static&quot;
unbind=&quot;unsetClusterConfigService&quot;/&gt;
&lt;/scr:component&gt;
</pre>
<ul>
<li> Implement the specifed methods <tt>setClusterConfigService</tt> and <tt>unsetClusterConfigService</tt> in your worker implementation. This may look like this:
</li>
</ul>
<pre>
private ClusterConfigService _ccs;
public void setClusterConfigService(final ClusterConfigService ccs) {
_ccs = ccs;
}
public void unsetClusterConfigService(final ClusterConfigService ccs) {
if (_ccs == ccs) {
_ccs = null;
}
}
</pre>
<ul>
<li> Now, the OSGi framework will automatically set the SimpleClusterConfigService (which implements the interface ClusterConfigService) in your worker at startup via the specified method. So the ClusterConfigService API will be accessible at runtime:
</li>
</ul>
<pre>
...
List&lt;String&gt; clusterNodes = _ccs.getClusterNodes();
...
</pre>
<h2><span class="mw-headline" id="How_to_add_.2F_access_a_configuration_for_your_Worker">How to add / access a configuration for your Worker</span></h2>
<p>You can add a worker configuration, e.g. a property file, by adding it to the application configuration.
</p><p><b>Example: Adding a property file "myWorker.properties" and access it in the worker</b>
</p>
<ul>
<li> To add a worker configuration create an appropriate folder in the application configuration and place the property file there:
</li>
</ul>
<pre>
SMILA.application/configuration/MY_BUNDLE_NAME/myWorker.properties
</pre>
<ul>
<li> To easiest way to access the configuration in your worker is via <tt>org.eclipse.smila.utils.config.ConfigUtils</tt> class
</li>
<li> To use this class you have to import the appropriate package <tt>org.eclipse.smila.utils.config</tt> in the MANIFEST.MF/Dependencies (see "Bundle Dependencies")
<ul>
<li> For the following example code you should also import <tt>org.apache.commons.io</tt>
</li>
</ul>
</li>
<li> Your code could look somehow like that:
</li>
</ul>
<pre>
InputStream configFileStream = null;
try {
configFileStream = ConfigUtils.getConfigStream(MY_BUNDLE_NAME, myWorker.properties);
Properties props = new Properties();
props.load(configFileStream);
...
} finally {
if (configFileStream&#160;!= null) {
IOUtils.closeQuietly(configFileStream);
}
}
</pre>
<p><b>Add on: Read configuration at startup</b>
</p>
<ul>
<li> If you want to initialize your worker by configuration at startup, you can use the <tt>activate()</tt> method automatically called by the OSGi framework at bundle startup.
</li>
<li> To use an activate method you have to import the package <tt>org.osgi.service.component</tt> in the MANIFEST.MF.
</li>
<li> Then your code could look like that
</li>
</ul>
<pre>
protected void activate(final ComponentContext context) {
try {
readConfiguration();
...
</pre>
<p><br />
</p>
<h2><span class="mw-headline" id="Exception_Handling_and_Logging">Exception Handling and Logging</span></h2>
<p><b>Exception Handling:</b>
</p><p>There are four possible outcomes of a worker:
</p>
<ul>
<li> SUCCESSFUL: The perform() method returns without exception. This is interpreted by the Worker Manager as a successful task execution so that it will finish the task with a SUCCESSFUL task completion status. All open output data objects will be committed. If this fails, it will continue as explained below, depending on the exception type. The task result includes all counters produced by the task execution so that they can be aggregated by the Job Manager in the job run data.
</li>
<li> RECOVERABLE_ERROR: The perform() method aborts with org.eclipse.smila.taskworker.RecoverableTaskException. This will be interpreted as a temporary failure when accessing input data or writing output data to DOS. The result is that the task will be finished with a RECOVERABLE_ERROR task completion status and the Job Manager will usually reschedule the task for a later retry. Any produced counters will be ignored by the Job Manager in the job run data.
</li>
<li> POSTPONE: The perform() method aborts with org.eclipse.smila.taskworker.PostponeTaskException. This means that the worker cannot yet perform the task for some reason but it should be resubmitted again later. The task will be re-added to the “todo queue” of this worker and it will be delivered again later (but quite soon, usually). Such tasks have the POSTPONE task completion status.
</li>
<li> FATAL_ERROR: The perform() method aborts with any other exception (including all exceptions of type RuntimeException). This will be interpreted as an indicator that the input data cannot be processed at all, for example, because it is corrupted or contains invalid values. Such tasks will be finished with a FATAL_ERROR completion status and will not be rescheduled. Any produced counters will be ignored by the Job Manager in the job run data.
</li>
</ul>
<p><b>Logging:</b>
</p><p>You can use the log4j logging that comes with SMILA in your worker too. Your logging output will be logged in the standard <tt>smila.log</tt>.
</p>
<ul>
<li> import the package <tt>org.apache.commons.logging</tt> in the MANIFEST.MF.
</li>
</ul>
<p>Then your code could look somehow like that:
</p>
<pre>
private final Log _log = LogFactory.getLog(getClass());
...
_log.debug(&quot;My worker was successful&quot;);
...
</pre>
<h2><span class="mw-headline" id="Create_worker_in_new_bundle_resp._rename_template_bundle">Create worker in new bundle resp. rename template bundle</span></h2>
<p><b>For creating a new bundle:</b>
</p>
<ul>
<li> Follow the description <a rel="nofollow" class="external text" href="http://wiki.eclipse.org/SMILA/Development_Guidelines/Create_a_bundle_(28plug-in)">here</a> to create a new bundle.
</li>
</ul>
<p><b>For renaming a bundle:</b>
</p>
<ul>
<li> Right-click the bundle to rename in eclipse and select (<tt>Refactor/Rename</tt>).
</li>
<li> Right-click java package and select (<tt>Refactor/Rename</tt>).
</li>
<li> Open MANIFEST.MF and set a version property to the (renamed) exported package. <tt>Runtime/Exported Packages</tt>
</li>
</ul>
<p><i>Hint: if there are strange compile problems afterwards, and refresh resp. clean projects doesn't help, try restarting your eclipse IDE.</i>
</p><p><b>MANIFEST.MF / OSGI-INF / build.properties:</b>
</p>
<ul>
<li> Apapt the changes in your OSGI-INF component description xml file
</li>
<li> Please be sure that your OSGi component definition file is included in the <tt>MANIFEST.MF</tt> file in the <i>Service-Component</i> section! Otherwise the service component will not be recognized and thus not be started.
</li>
<li> Please be sure that the <tt>OSGI-INF/</tt> folder is included in your <tt>build.properties</tt>
</li>
</ul>
<p><b>test bundle:</b>
</p>
<ul>
<li> Adapt the test bundle to the changes:
<ul>
<li> change name of test bundle and java package (<tt>Refactor/Rename</tt>, like described above for the worker bundle itself).
</li>
<li> correct the imported packages in the code and the MANIFEST.MF (if not done correctly by refactoring)
</li>
<li> adapt the test's run configuration, e.g. name, test bundle's java package, configuration file location (on tab "configuration")
</li>
<li> adapt the config.ini file
</li>
</ul>
</li>
</ul>
<p><b>Application launch:</b>
</p>
<ul>
<li> Add the new/renamed bundle to the eclipse launcher and also to your application <tt>configuration/config.ini</tt> file with an appropriate start level.
</li>
</ul>
<p><b>feature project:</b>
</p>
<ul>
<li> You have to add your new/renamed bundle to the feature project.
</li>
<li> clear the destination folder for feature exports.
</li>
</ul>
<!--
NewPP limit report
CPU time usage: 0.112 seconds
Real time usage: 0.118 seconds
Preprocessor visited node count: 321/1000000
Preprocessor generated node count: 584/1000000
Post‐expand include size: 237/2097152 bytes
Template argument size: 61/2097152 bytes
Highest expansion depth: 2/40
Expensive parser function count: 0/100
-->
<!-- Saved in parser cache with key my_wiki:pcache:idhash:33513-0!*!0!!en!*!* and timestamp 20150414013827 and revision id 375643
-->
</div>
<!-- catlinks -->
<div id='catlinks' class='catlinks'><div id="mw-normal-catlinks" class="mw-normal-catlinks"><a href="http://wiki.eclipse.org/Special:Categories" title="Special:Categories">Category</a>: <ul><li><a href="http://wiki.eclipse.org/Category:SMILA" title="Category:SMILA">SMILA</a></li></ul></div></div> <!-- /catlinks -->
</div>
</div>
</div>
</div>
<!-- /maincontent -->
<!-- printfooter -->
<div class="printfooter">
Retrieved from "<a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;oldid=375643">http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;oldid=375643</a>" </div>
<!-- /printfooter -->
<!-- debughtml -->
<!-- /debughtml -->
</div>
<!-- /bodyContent -->
</section>
<!-- /content -->
<!-- footer -->
</div> <section id="footer-contribution-info" style="border-top:1px solid #ccc;" class="footer-offset background-white margin-top-25"><div class="container text-center padding-top-10 padding-bottom-10"><p id="footercredit">This page was last modified 05:30, 19 December 2014 by <a href="http://wiki.eclipse.org/User:Juergen.schumacher.empolis.com" title="User:Juergen.schumacher.empolis.com">Juergen Schumacher</a>. Based on work by <a href="http://wiki.eclipse.org/User:Andreas.weber.empolis.com" title="User:Andreas.weber.empolis.com">Andreas Weber</a>, <a href="http://wiki.eclipse.org/index.php?title=User:Juergen.schumacher.attensity.com&amp;action=edit&amp;redlink=1" class="new" title="User:Juergen.schumacher.attensity.com (page does not exist)">Juergen Schumacher</a> and <a href="http://wiki.eclipse.org/index.php?title=User:Nadine.auslaender.attensity.com&amp;action=edit&amp;redlink=1" class="new" title="User:Nadine.auslaender.attensity.com (page does not exist)"> </a> and <a href="http://wiki.eclipse.org/index.php?title=SMILA/Documentation/HowTo/How_to_write_a_Worker&amp;action=credits" title="SMILA/Documentation/HowTo/How to write a Worker">others</a>.</p><p id="footerviews">This page has been accessed 5,604 times.</p></div></section> </main> <!-- /#main-content-container-row -->
<p id="back-to-top" class="noprint hidden-print">
<a class="visible-xs" href="How_to_write_a_Worker.html#top">Back to the top</a>
</p>
<footer role="contentinfo" class="noprint hidden-print">
<div class="container">
<div class="row">
<section id="footer-eclipse-foundation" class="col-xs-offset-1 col-xs-11 col-sm-7 col-md-6 col-md-offset-0">
<h2 class="section-title">Eclipse Foundation</h2>
<ul class="nav">
<li><a href="https://eclipse.org/org/">About us</a></li>
<li><a href="https://eclipse.org/org/foundation/contact.php">Contact Us</a></li>
<li><a href="https://eclipse.org/donate">Donate</a></li>
<li><a href="https://eclipse.org/org/documents/">Governance</a></li>
<li><a href="https://eclipse.org/artwork/">Logo and Artwork</a></li>
<li><a href="https://eclipse.org/org/foundation/directors.php">Board of Directors</a></li>
</ul>
</section>
<section id="footer-legal" class="col-xs-offset-1 col-xs-11 col-sm-7 col-md-6 col-md-offset-0">
<h2 class="section-title">Legal</h2>
<ul class="nav">
<li><a href="https://eclipse.org/legal/privacy.php">Privacy Policy</a></li>
<li><a href="https://eclipse.org/legal/termsofuse.php">Terms of Use</a></li>
<li><a href="https://eclipse.org/legal/copyright.php">Copyright Agent</a></li>
<li><a href="https://eclipse.org/org/documents/epl-v10.php">Eclipse Public License </a></li>
<li><a href="https://eclipse.org/legal/">Legal Resources </a></li>
</ul>
</section>
<section id="footer-useful-links" class="col-xs-offset-1 col-xs-11 col-sm-7 col-md-6 col-md-offset-0">
<h2 class="section-title">Useful Links</h2>
<ul class="nav">
<li><a href="https://bugs.eclipse.org/bugs/">Report a Bug</a></li>
<li><a href="http://help.eclipse.org/">Documentation</a></li>
<li><a href="https://eclipse.org/contribute/">How to Contribute</a></li>
<li><a href="https://eclipse.org/mail/">Mailing Lists</a></li>
<li><a href="https://eclipse.org/forums/">Forums</a></li>
<li><a href="http://marketplace.eclipse.org/">Marketplace</a></li>
</ul>
</section>
<section id="footer-other" class="col-xs-offset-1 col-xs-11 col-sm-7 col-md-6 col-md-offset-0">
<h2 class="section-title">Other</h2>
<ul class="nav">
<li><a href="https://eclipse.org/ide/">IDE and Tools</a></li>
<li><a href="https://eclipse.org/projects">Community of Projects</a></li>
<li><a href="https://eclipse.org/org/workinggroups/">Working Groups</a></li>
</ul>
<ul class="list-inline social-media">
<li><a href="https://twitter.com/EclipseFdn"><i class="fa fa-twitter-square"></i></a></li>
<li><a href="https://plus.google.com/+Eclipse"><i class="fa fa-google-plus-square"></i></a></li>
<li><a href="https://www.facebook.com/eclipse.org"><i class="fa fa-facebook-square"></i> </a></li>
<li><a href="https://www.youtube.com/user/EclipseFdn"><i class="fa fa-youtube-square"></i></a></li>
</ul>
</section>
<div id="copyright" class="col-xs-offset-1 col-sm-14 col-md-24 col-md-offset-0">
<div>
<span><img src="http://eclipse.org/eclipse.org-common/themes/solstice/public/images/logo/eclipse-logo-bw-800x188.png" alt="Eclipse.org black and white logo" width="166" height="39" id="logo-eclipse-white"/></span>
<p id="copyright-text">Copyright &copy; 2014 The Eclipse Foundation. All Rights Reserved.</p>
</div>
</div>
<a href="How_to_write_a_Worker.html#" class="scrollup">Back to the top</a>
</div>
</div>
</footer>
<script src="http://wiki.eclipse.org/skins/solstice/public/javascript/main.min.js"></script>
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-910670-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script> <!-- /footer -->
<script>/*<![CDATA[*/window.jQuery && jQuery.ready();/*]]>*/</script><script>if(window.mw){
mw.loader.state({"skins.solstice":"loading","site":"ready","user":"ready","user.groups":"ready"});
}</script>
<script src="http://wiki.eclipse.org/load.php?debug=false&amp;lang=en&amp;modules=skins.solstice&amp;only=scripts&amp;skin=solstice&amp;*"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.hidpi","mediawiki.page.ready","mediawiki.searchSuggest"],null,true);
}</script>
<script>if(window.mw){
mw.config.set({"wgBackendResponseTime":356});
}</script> </body>
</html>