@@ -11,12 +11,18 @@ var fs = require('fs'),
1111 Q = require ( 'q' ) ,
1212 pathTool = require ( 'path' ) ,
1313 //toobusy = require('toobusy'),
14+ uuid = require ( 'uuid' ) ,
1415 rcl ;
1516
17+
1618// for profiling
1719var fetchInputsTime = 0 ;
1820var sendSignalTime = 0 ;
1921
22+
23+ var global_hfid = 0 ; // global UUID of this HF engine instance (used for logging)
24+ var globalInfo = { } ; // object holding global information for a given HF engine instance
25+
2026function p0 ( ) {
2127 return ( new Date ( ) ) . getTime ( ) ;
2228}
@@ -33,7 +39,19 @@ exports.init = function(redisClient) {
3339 // optional passing of client could be possible);
3440 if ( redisClient ) {
3541 rcl = redisClient ;
42+ if ( global_hfid == 0 ) {
43+ global_hfid = uuid . v1 ( ) ;
44+
45+ // this object holds global information about this HF engine instance
46+ // written to redis as a hash map with key "globalinfo:<uuid>"
47+ // TODO: add more attributes
48+ globalInfo . hf_version = "???" ;
49+
50+ rcl . hmset ( "hflow:" + global_hfid , globalInfo , function ( err , ret ) { } ) ;
51+ }
3652 }
53+
54+ console . log ( "hfid:" , global_hfid ) ;
3755 /*rcl.on("error", function (err) {
3856 console.log("redis error: " + err);
3957 });*/
@@ -1336,7 +1354,7 @@ function public_getRemoteDataSinks(wfId, dataId, cb) {
13361354 * @insValues - array of input signal values as returned by fetchInputs
13371355 * @appConfig - configuration specific for this workflow instance (the engine.config object), e.g. working directory
13381356 */
1339- function public_invokeTaskFunction2 ( wfId , taskId , insIds_ , insValues , outsIds_ , emulate , eventServer , appConfig , cb ) {
1357+ function public_invokeProcFunction ( wfId , procId , firingId , insIds_ , insValues , outsIds_ , emulate , eventServer , appConfig , cb ) {
13401358 function isArray ( what ) {
13411359 return Object . prototype . toString . call ( what ) === '[object Array]' ;
13421360 }
@@ -1377,7 +1395,7 @@ function public_invokeTaskFunction2(wfId, taskId, insIds_, insValues, outsIds_,
13771395
13781396 //onsole.log("FUNC INS", ins);
13791397
1380- public_getTaskInfo ( wfId , taskId , function ( err , taskInfo ) {
1398+ public_getTaskInfo ( wfId , procId , function ( err , taskInfo ) {
13811399 if ( err ) return cb ( err ) ;
13821400
13831401 var asyncTasks = [ ] ;
@@ -1474,6 +1492,12 @@ function public_invokeTaskFunction2(wfId, taskId, insIds_, insValues, outsIds_,
14741492 conf [ 'eventServer' ] = eventServer ;
14751493 }
14761494
1495+ // Pass identifiers to the function
1496+ conf . hfId = global_hfid ;
1497+ conf . appId = wfId ;
1498+ conf . procId = procId ;
1499+ conf . firingId = firingId ;
1500+
14771501 f ( ins , outs , conf , function ( err , outs , options ) {
14781502 //if (outs) { onsole.log("VALUE="+outs[0].value); } // DEBUG
14791503 cb ( null , outs , options ) ;
@@ -1930,7 +1954,7 @@ return {
19301954 getRemoteDataSinks : public_getRemoteDataSinks ,
19311955 getWfMap : public_getWfMap ,
19321956 getTaskMap : public_getTaskMap ,
1933- invokeTaskFunction2 : public_invokeTaskFunction2 ,
1957+ invokeProcFunction : public_invokeProcFunction ,
19341958 //sendSignal: public_sendSignal,
19351959 sendSignal : sendSignalLua ,
19361960 getSignalInfo : getSignalInfo ,
@@ -1941,7 +1965,9 @@ return {
19411965 sendSignalLua : sendSignalLua ,
19421966 getSigByName : getSigByName ,
19431967 getSigRemoteSinks : getSigRemoteSinks ,
1944- setSigRemoteSinks : setSigRemoteSinks
1968+ setSigRemoteSinks : setSigRemoteSinks ,
1969+
1970+ hfid : global_hfid
19451971} ;
19461972
19471973} ;
0 commit comments