Presentation is loading. Please wait.

Presentation is loading. Please wait.

HelloWorld Service Clara-2.x Tutorial-2 By V. Gyurjyan.

Similar presentations


Presentation on theme: "HelloWorld Service Clara-2.x Tutorial-2 By V. Gyurjyan."— Presentation transcript:

1 HelloWorld Service Clara-2.x Tutorial-2 By V. Gyurjyan

2 Clara-2..x Design Concept Review  Cloud consists of distributed processes, called Clara- Data-Processing-Environment (JVM’s) running one in each computing node. Master Clara-Container is called Platform and runs administrative services.  Each Clara-Container runs a pub-sub server and contains one or many Service-Containers  Service-Container deploys one or many User-Engines as a services.

3 Clara-2.x naming Convention  Service Name : DPE-Host/Service-Container/User-Engine  Service-Container name is arbitrary (given by the user)  User-Engine name is defined by the engine developer and accessed through the Clara interface method: @Override public String getName() { return ”myName” }

4 HelloWorldService class package examples.service; import org.jlab.clas12.tools.MimeType; import org.jlab.coda.clara.core.JioSerial; import org.jlab.coda.clara.system.CConstants; import org.jlab.coda.clara.system.CUtil; import org.jlab.coda.clara.user.JService; /** * Hello world service * * @author Vardan Gyurjyan * @version 2.x */ public class HelloWorldService extends JService {

5 HelloWorldService class @Override public String getName() { return "Hello"; } @Override public String getAuthor() { return "Gyurjyan"; } @Override public String getDescription() { return "Hello World service"; }

6 HelloWorldService class @Override public String getVersion() { return "1.0"; } @Override public String getLanguage() { return CConstants.LANG_JAVA; }

7 HelloWorldService class @Override public JioSerial execute(JioSerial[] data) { return null; } @Override public void configure(JioSerial data) { } @Override public void destruct() { }

8 HelloWorldService class @Override public JioSerial execute(JioSerial data) { // output transient data object JioSerial out = new JioSerial(); out.setLanguage(CConstants.LANG_JAVA); // check the input data mime-type if(data.getMimeType().type().equals(MimeType.STRING.type())){ // get the data content String inputDataObject = data.getStringObject(); // generate the output data out.setData(CUtil.getCurrentTime()+": Hello World from "+inputDataObject); out.setDataDescription("response to " + inputDataObject); out.setStatus(CConstants.info);

9 HelloWorldService class } else { // Reject with an execution status = error out.setData(CConstants.REJECT); out.setDataDescription("I can accept only strings"); out.setStatus(CConstants.error); } return out; }

10 Compiling javac -cp $CLARA_SERVICES/lib/Clara.jar:$CLARA_SERVICES/lib/j tools-1.0.jar:$CLARA_SERVICES/lib/cMsg-3.3.jar HelloWorldService.java -d $CLARA_SERVCIES/


Download ppt "HelloWorld Service Clara-2.x Tutorial-2 By V. Gyurjyan."

Similar presentations


Ads by Google