Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Epilog:

Code Block
#****Begin: Generated Statements***
#****End: Generated Statements****
CellPutS( sProcLogParams, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'Parameters' );
CellPutS( TimSt(nProcessStartTime, '\Y-\m-\d \h:\i:\s'), cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'Start Time' );
CellPutS( TimSt(Now, '\Y-\m-\d \h:\i:\s'), cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'Finish Time' );
CellPutS( GetProcessErrorFileName(), cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'TM1ProcessError File' );

If( nThreadID = 0 );
  CellPutN( 0, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'running' );
  CellPutN( 1, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'completed' );
  CellPutN( nDataRecordCount, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'Records Count' );
  CubeSaveData( cCubThreadCtrl );
  If( nThreads > 1 );
      nCompleted = CellGetN( cCubThreadCtrl, cUserName, cThisProcName, 'Total Threads', 'completed' );
      If( nLogoutput <> 0 );
          LogOutput( 'info', Expand( 'Process:%cThisProcName% (ThreadID=%pThreadID%): Waiting for child threads completion.' ));
      EndIf;
      While( nCompleted <> nMaxThreads );
          nCompleted = CellGetN( cCubThreadCtrl, cUserName, cThisProcName, 'Total Threads', 'completed' );
          nRunning = CellGetN( cCubThreadCtrl, cUserName, cThisProcName, 'Total Threads', 'running' );
          nScheduled = CellGetN( cCubThreadCtrl, cUserName, cThisProcName, 'Total Threads', 'scheduled' );
          If( nRunning = 0 & nCompleted = 1 & nScheduled <> 0 );
              nTime = NOW();
              nDeltaTime = ROUND( (nTime - nProcessStartTime) * 3600 * 24 );
              If( nDeltaTime >= cMaxInitTime );
                  nErrors = nErrors + 1;
                  sMaxInitTime = NumberToString( cMaxInitTime );
                  sMessage = Expand( 'None of the child threads have successfully initialized during timeout interval of [%sMaxInitTime%] seconds, terminating the process.');
                  sSequenceID = NumberToString( nMultiMsgJSON );
                  sMessageJSON = INSRT(' "message":"', sMessage | '"', 1);
                  sMultiMsg = Expand( '%sMultiMsg%' | If(LONG(sMultiMsg)=0, '', ', ') | '"' | NumberToString( nMultiMsgJSON ) | '":{%sMessageJSON%}' ); nMultiMsgJSON = nMultiMsgJSON + 1;
                  LogOutput( cMsgErrorLevel, Expand( cMsgErrorContent ) );
                  CellPutN( 1, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'Error Flag' );
                  Break;
              EndIf;
          EndIf;
          sCompleted = NumberToString( nCompleted );
          LogOutput( 'info', Expand( 'Process:%cThisProcName% (ThreadID=%pThreadID%): Polling child threads - %sCompleted% threads have finished.' ));
          If( nCompleted <> nMaxThreads );
              Sleep( cThreadPollingInterval * 1000 );
              CubeSaveData( cCubThreadCtrl );
          EndIf;
          If( cThreadMonitoringEnabled <> 0 );
            nTime = NOW();
            nDeltaTime = ROUND( (nTime - nProcessStartTime) * 3600 * 24 );
            If( nDeltaTime >= cMaxRunTime );
              nErrors = nErrors + 1;
              sMessage = Expand( 'Maximum runtime (%sMaxRunTime% seconds) was exceeded, terminating process. Data in target cube might not be consistent if some of child threads have committed data.');
              sSequenceID = NumberToString( nMultiMsgJSON );
              sMessageJSON = INSRT(' "message":"', sMessage | '"', 1);
              sMultiMsg = Expand( '%sMultiMsg%' | If(LONG(sMultiMsg)=0, '', ', ') | '"' | NumberToString( nMultiMsgJSON ) | '":{%sMessageJSON%}' ); nMultiMsgJSON = nMultiMsgJSON + 1;
              LogOutput( cMsgErrorLevel, Expand( cMsgErrorContent ) );
              CellPutN( 1, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'Error Flag' );
              Break;
            EndIf;
          EndIf;
      End;
      nChildErrors = CellGetN( cCubThreadCtrl, cUserName, cThisProcName, 'Total Threads', 'Error Flag' );
      nTotalRecordCount = CellGetN( cCubThreadCtrl, cUserName, cThisProcName, 'Total Threads', 'Records Count' );
      If( nLogoutput <> 0 );
          If( nChildErrors <> 0 );
              LogOutput('info', Expand( 'Process:%cThisProcName% (ThreadID=%pThreadID%): All threads have finished, but some threads have reported errors.'));
          Else;
              LogOutput('info', Expand( 'Process:%cThisProcName% (ThreadID=%pThreadID%): All threads have finished successfully.'));
          EndIf;
      EndIf;
  Else;
      nTotalRecordCount = nDataRecordCount;
  EndIf;
  CubeSetLogChanges( cCubTgt, 1 );
Else;
  CellPutN( 0, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'running' );
  CellPutN( 1, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'completed' );
  CellPutN( nDataRecordCount, cCubThreadCtrl, cUserName, cThisProcName, pThreadID, 'Records Count' );
  nTotalRecordCount = nDataRecordCount;
EndIf;