User’s Manual Thomas Jefferson National Accelerator Facility


All you need to convert a software application into a ClaRA service



Download 415.94 Kb.
Page8/17
Date28.01.2017
Size415.94 Kb.
#10668
1   ...   4   5   6   7   8   9   10   11   ...   17

All you need to convert a software application into a ClaRA service.

In order to present software as a ClaRA service we need 2 things:



The ClaRA transient data envelope is described in the previous chapter. The ClaRA framework provides the transient data representing class both in Java and C++. An object of this class is passed as a parameter to the ClaRA service interface methods. The table below describes the ClaRA service interface methods.




Method signature

Description

public void configure (JioSerial data);

Service configuration

public JioSerial execute (JioSerial data);

Service engine execution

public JioSerial execute (JioSerial[] data);

Service engine execution

public String getName();

Returns service engine name

public String getAuthor();

Returns name of engine author

public String getDescription();

Functional description of service engine

public String getVersion();

Returns version of engine

public String getLanguage();

Returns engine programming language

public void destruct();

Graceful withdrawal of service/engine

Table 3. ClaRA service interface. JioSerial is the class that represents transient data format in Java.




It is perhaps best explained through an example.

Let us consider a class that has a method that contains a sequence of statements that implements a specific physics data processing algorithm, for example the Clas12 central barrel tracker cross-list definition. The code is presented below, without inclusive algorithm explanation, since the goal of this exercise is to demonstrate the technical aspect of converting a class into a ClaRA service.

public class BTCrossListMaker {
public EvioEvent processEvent(EvioEvent input) {

EventBuilder builder = new EventBuilder(input);


int BT_TAG = 1000;

ArrayList hits;


//get the single strip hits

hits = BSThit.getHits(input);


//find the clusters from these hits

BSTClusterFinder_ContHits gcf = new BSTClusterFinder_ContHits();

ArrayList clusters = gcf.findClusters(hits);
//create the line-segment objects

ArrayList bstsegments= new ArrayList();

for (BSTcluster thecluster : clusters) {

BSTlinesegment theline = new BSTlinesegment(thecluster);

bstsegments.add(theline);

}
//make the crosses

BSTCrossMaker crsmk = new BSTCrossMaker();

ArrayList bstcrosses = crsmk.findCrosses(bstsegments);


// make the list of crosses

BTcrosslist btcrosslist = new BTcrosslist(bstcrosses, null, Clas12Constants.nSVTregions, 0);


//make the bank for the crosses

try {


BTEvioOutput.createBTcrosses(builder, btcrosslist, BT_TAG);

} catch (EvioException e) {

e.printStackTrace();

}

return builder.getEvent();



}

}

To make this class a service we need to present it as a ClaRA service engine. For that we need to edit the presented code and implement the following changes:


The service engine functionality is defined by two overloaded interface methods: execute. The configure method takes care of configuring the engine (in this particular case it is going to be an empty method). The comments (especially bold italic comments in the execute method) describe the steps taken.

public class BTCrossListMaker implements ICService {
@Override

public void configure(JioSerial data) {

// For this particular example we do not need configuration

}
@Override

public JioSerial execute(JioSerial data) {
// check the type of the received data
MimeType mt = data.getMimeType();
// reject the service if the data type is not EvIO
if (mt != MimeType.EVIO_OBJECT) {

JioSerial out = new JioSerial(CConstants.REJECT);

String msg = String.format("Wrong input type: %s", mt);

out.setStatus(CConstants.error);

out.setDataDescription(msg);

return out;

}
// now get the data from the transient data envelope and call the event processEvent method of the presented class
EvioEvent result = processEvent(data.getData());
// put the result data into the transient data envelope and return
JioSerial out = new JioSerial();

out.setData(result, MimeType.EVIO_OBJECT);

}
@Override

public JioSerial execute(JioSerial[] data) {

return null;

}
@Override

public void destruct() {

//do nothing

}
@Override

public String getName() {

return “BstCrossMaker”;

}
@Override

public String getAuthor() {

return “Ziegler”;

}
@Override

public String getDescription() {

return “Here can go an THML description of this engine with complete description of accepted and returned EvIO bank structures”;

}
@Override

public String getVersion() {

return “1.0”;

}
@Override

public String getLanguage() {

return CConstants.LANG_JAVA;

}

This is all what is required to present the regular PDP class as a service engine. The only thing left is to compile and copy the class file (.so file in the case of C++) into the $CLARA_SERVICES directory. We have to make sure to copy all the auxiliary library files necessary for the proper functionality of the initial class into the $CLAS/lib directory. In the Chapter 5 we will discuss in more details of how to deploy and test this BTCrossListMaker service, utilizing standard EvIO persistent to EvIO transient data convertor services in the ClaRA application designed using the application designer graphical user interface.







Download 415.94 Kb.

Share with your friends:
1   ...   4   5   6   7   8   9   10   11   ...   17




The database is protected by copyright ©ininet.org 2024
send message

    Main page