Logging Statistics

Rather than create global variable to increment, use your connector's stats object or stats.xxx fields to log information: 

task.logmsg( "INFO","Processing Entry: " + <your_iterator_name>.getStats().numGet());

Note that for <your_iterator_name> you must explicitly use the name of your iterator from the Feed section at the top of your assembly line if that's what you want. If you just use thisConnector you will get the connector in the flow session (seemingly the first or closest one).

Above, we are just taking advantage of the connector object's field values. There are many more to use, but can also delve into the TaskStatistics object.  Get a reference to the object  and use it like below. Here's the example from the older, 6.1 user's guide (I cannot locate this info in the 7.1.1 docs anymore!)

var status = myConn.getStats();
task.logmsg("Dumping myConn status:");

task.logmsg("Number of add operations performed: " + status.numAdd());
task.logmsg("Number of delete operations performed: " + 
	status.numDelete());
task.logmsg("Number of errors: " + status.numErrors());
task.logmsg("Number of get operations performed: " +  status.numGet());
task.logmsg("Number of entries ignored: " + status.numIgnored());
task.logmsg("Number of lookup operations performed: " + 
	status.numLookup());
task.logmsg("Number of modify operations performed: " + 
	status.numModify());
task.logmsg("Number of no-change entries: " + status.numNoChange());
task.logmsg("Number of entries skipped: " + status.numSkipped());
Notes:

We used to use 

task.logmsg( "INFO","Proce " + <your_iterator_name>.stats.get );

But for an unknown reason this now returns the entire stat line as below, which is not always as useful

Get:1, getclient:0, Add:0, Modify:0, Delete:0, Errors:0, Skip:0, Lookup:0, CallReply:0, reply:0, Ignore:0, Switches:0, Nochange:0



Assembly Line Summaries - Variables and Entries

Chance are that you need some formatted output of what your assembly line did. Something other than just the server's logs. To do this, you will need to store counters and what not over the course of the assembly line.  

You can handle this two main ways; a global variables or a global entry object.  Globals are simple, but an entry is more the TDI way of doing it.

In case you arn't up on entries, it is a construct to which you attach attributes. These attributes have values.

....inprogress



Declare in the iterator, in the "Before Initialize" hook

// Create an entry to hold some data
var counterEntry = system.newEntry();
var multiList = system.newAttribute("multiList");
var misList = system.newAttribute("misList");
counterEntry.setAttribute(multiList);
counterEntry.setAttribute(misList);

Use in the course of your scripts and hooks
counterEntry.multiList.addValue(work.UID.getValue);

Summarize in the "After Close" hook of the iterator

task.logmsg("------------------------------------------------------");
task.logmsg("Multiple Entires: " + multiHits);
task.logmsg("List of people:")
task.logmsg(counterEntry.multiList.toString());
task.logmsg("");
task.logmsg("Missing Entires: " + multiHits);
task.logmsg("List of people:")
task.logmsg(counterEntry.misList.toString());
task.logmsg("------------------------------------------------------");

it is possible to 'blow the entry up' by assigning too many values to a given attribute.



unique data set logging (uniq)

Sometimes you're processing what is supposed to be a defined set of flags, but the actual data is all over the map. You can efficiently identify the entire set with a java hash.

Declare the hash in your iterator's After Initialise hook

var statusTypes = new java.util.HashSet();

Any time you're in the assembly line, add the value

statusTypes.add(work.MD_PERSON_STATUS.getValue());

Then in the iterator's After Close

task.logmsg(statusTypes.toString());
Comments