Unix
Unix
Unix
/bin/ksh
#*******************************************************************************
***********************
#@@@@@@@@@@@@@@@ Updated Wrapper Script supporting workflow instance concurrency
@@@@@@@@@@@@@@@@@@@@@#
* For more details switch to bottom of script
############################################ ROHIT SAINI (E20038884) ########
###################################
#*******************************************************************************
***********************
#*******************************************************************************
***********************
##################################################
##--- Source Informatica environment -----##
##################################################
. .infa_env
export
export
export
export
export
FOLDER=""
Parameterfile=""
INSTANCE_ID=""
WORKFLOW_NAME=""
wrkflw_log_file_name=""
write_log()
# write in the custom created log file c
reated in "log" folder
{
echo "`date` : $1" | tee -a ${LOG_FILE}
}
displyhelp()
# function to display the usage of wrapp
er script
{
echo "*USAGE=>SCRIPT -LOC <SCRIPT_ADDRESS> -FOLDER <FOLDER_NAME> -PAR
AM <Parameter_File> [-INST_ID <Instance_ID>] -WF <Workflow_Name> -INTGS [Integra
tion Servic]>"
echo "*Option within [] are optional"
echo "*USAGE==>> SCRIPT -HELP for help"
exit
}
wait_for_wrkflw()
one of the following state
{
sleep 5
export STATUS_ENV=$1
of pmcmd command
check_status()
# function to display the status of the
pmcmd command as well as act accordingly with failure of workflow
{
EXT_STATUS=$1
# status passed as an argument
if [ $1 -eq 0 ]
# if workflow successfully executed with
proper functioning of pmcmd command
then
(( RET_STATUS=RET_STATUS+EXT_STATUS ))
# customized ret
urn value for capturing in run environment
if [ ! -z ${TASK_NAME} ]
# delete the .re
c file of successfull workflow
then
rm ${PMRootDir}/bin/${INSTANCE_ID}_${FOLDER}_${WORKFLOW
_NAME}_${TASK_NAME}.rec
fi
else
case "$1" in
1)
write_log "Integration Service is not available,
or pmcmd cannot connect to the Integration Service. There is a problem with the
TCP/IP host name or port number or with the network."
;;
2)
write_log "Task name, workflow name, or folder n
ame does not exist."
exit RET_STATUS
;;
3)
write_log "An error occurred starting or running
the workflow or task."
;;
4)
write_log "Usage error. You passed the wrong opt
ions to pmcmd. "
;;
5)
write_log "An internal pmcmd error occurred. Con
tact Informatica Global Customer Support. "
;;
7)
write_log "You used an invalid user name or pass
word. "
;;
8)
write_log "You do not have the appropriate permi
ssions or privileges to perform this task. "
;;
9)
write_log "Connection to the Integration Service
timed out while sending the request. "
;;
12)
write_log "Integration Service cannot start reco
very because the session or workflow is scheduled, waiting for an event, waiting
, initializing, aborting, stopping, disabled, or running. "
;;
13)
write_log "User name environment variable is set
to an empty value. "
;;
14)
write_log "Password environment variable is set
to an empty value. "
;;
15)
write_log "User name environment variable is mis
sing. "
;;
16)
write_log "Password environment variable is miss
ing. "
;;
17)
write_log "Parameter file does not exist. "
;;
18)
write_log "Integration Service found the paramet
er file, but it did not have the initial values for the session parameters, such
as $input or $output. "
;;
19)
write_log "Integration Service cannot resume the
session because the workflow is configured to run continuously. "
;;
20)
write_log "A repository error has occurred. Make
sure that the Repository Service and the database are running and the number of
connections to the database is not exceeded. "
;;
21)
write_log "Integration Service is shutting down
and it is not accepting new requests. "
;;
22)
write_log "Integration Service cannot find a uni
que instance of the workflow/session you specified. Enter the command again with
the folder name and workflow name. "
;;
23)
write_log "There is no data available for the re
quest. "
;;
24)
write_log "Out of memory. "
;;
25)
write_log "Command is cancelled. "
;;
# xxxxxxxxxxxxxxxxxxxxxxxxxxx Custom created Error Codes for var
ious purpose xxxxxxxxxxxxxxxxxxxx
100)
;;
101)
write_log "Workflow -- $WORKFLOW_NAME -- is Disa
bled"
;;
102)
write_log "Workflow -- $WORKFLOW_NAME -- is Fail
ed"
;;
103)
while [ ! -z $1 ]
eters
do
case $1 in
"-LOC")
shift
export LOC=$1
;;
"-FOLDER")
shift
export FOLDER=$1
;;
"-PARAM")
shift
export PARMFILE=$1
;;
"-INST_ID")
shift
export INSTANCE_ID=$1
;;
"-WF")
shift
export WORKFLOW_NAME=$1
;;
"-WF")
shift
export WORKFLOW_NAME=$1
;;
"-INTGS")
shift
export INTGS=$1
;;
"-HELP")
displyhelp
;;
"-help")
displyhelp
;;
*)
echo "
id >>>>"
displyhelp
exit
;;
esac
shift
done
if [ -z $LOC ] || [ -z $FOLDER ] || [ -z $PARMFILE ] || [ -z $WORKFLOW_NAME ] ;
then
echo " INVALID ARGUMENTS.. missing LOCATION or FOLDER or PARMFILE or WOR
KFLOW_NAME or Integration Service "
displyhelp
exit 1
fi
. $LOC/${FOLDER}_config.cfg
f the script configuration file
if [ -z $INSTANCE_ID ]
es then assign default session_id to the workflow
then
export INSTANCE_ID="Default_Inst_ID"
fi
if [ ! -z $INTGS ]
# provides with the defa
ult Integration Service
then
export INTEG_SERVICE=$INTGS
elif [ -z $INTEG_SERVICE ]
then
echo "INTEGRATION SERVICE NOT SET....PLEASE SET IT"
exit 99
fi
# following code make the script backward compatible
if [ $VERSION != "V2.0" ];then
# check for the version
defined in Config file and prepare the execution accordingly
echo " Informatica Wrapper Version : INFORMATICA_WRAPPER_${VERSION}.ksh
"
case $VERSION in
"V1.0")
return_value=`$LOC/INFORMATICA_WRAPPER_${VERSION}.ksh $FOLDER $P
ARMFILE $WORKFLOW_NAME $INTEG_SERVICE`
echo " Return Status of Script ===> $return_value "
exit $return_value
;;
*)
echo " INVALID Version Defined In Config File "
;;
esac
fi
write_log "Using integration service = $INTEG_SERVICE"
write_log "PMCMD_start_Normal_mode: Running workflow"
write_log "Log Path for capturing any failed session in workflow -> ${REC_FILE}"
export RET_STATUS=0
if [ -s ${REC_FILE} ]
then
task
write_log
OOOOOOOOOOOOOO"
write_log
write_log
write_log
OOOOOOOOOOOOOO"
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
"
Recovery File exists........."
"
Running in Recovery mode"
"OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
done
if [ $STATUS_ENV -eq 0 ];then
rm -rf $REC_FILE
fi
exit $STATUS_ENV
fi
write_log "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
OOOOOOOOOOOOOO"
write_log "
Running workflow in re-start mode ENDS
"
write_log "OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
OOOOOOOOOOOOOO"
#----------------------------- end of RECOVER TASK -------------------------------#
else
$INFA_HOME/server/bin/pmcmd startworkflow -sv $INTEG_SERVICE -d
$DOMAIN -uv User -pv PASS -f $FOLDER -paramfile $PMRootDir/BWParam/$PARMFILE -r
in $INSTANCE_ID $WORKFLOW_NAME 1>$LOG_FILE 2> $LOG_FILE
export STATUS_ENV=$?
wait_for_wrkflw $STATUS_ENV
hat see the workflow status
check_status $STATUS_ENV
if [ $STATUS_ENV -eq 0 ]
then
write_log " Process completed successfully "
fi
fi
if [ $RET_STATUS -eq 0 ]
then
rm -rf ${REC_FILE}
fi
exit $RET_STATUS
#--------------- 2) Same Instance ID for the two concurrent Instance within the
same workflow is not allowed in this script
#--------------- 3) pmcmd -wait option is not being used here to prevent from t
he suspended conditions
#--------------- 4) Should be aware of the difference between failed, aborted,
suspended, terminated workflow conditions
#--------------- 5) Yet scheduled and unscheduled concept is not being introduc
ed in this wrapper script
#--------------- 6) recoverworkflow is being used when task name cannot be reco
vered ,so startworkflow -startfrom is used in other conditions
#--------------- 7) Two or more concurrent INSTANCES cannot run on the default
INSTANCE ID, in that case INSTANCE_ID is mandatory
#--------------- 8) We have two different "full detailed workflow log file" and
"customized log file"
#--------------- 9) Custom Workflow log file can be found in "log" directory an
d Session log file in "SessLogs" directory as designed by architect team
#--------------- 10) sleep <seconds> is used to wait for the response from the I
nformatica..
#--------------- 11) If somehow your workflow is not able to get execute, then y
ou would not be able to recover it because of no recovery points
#--------------- 12) If you are not able to recover the workflow than delete all
related ".rec" files and have restart of the workflow through this script
#--------------- 13) Sometime Informatica Integration Service may go down so don
't get panic!
#--------------- 14) Recovery Strategy should be decided properly.
#--------------- 15) Option ==> "Write Backward Compatible Workflow Log File" sh
ould be checked.
#--------------- 16) Many times session log could not be fetched out so no file
would be generated in SessLogs folder
#--------------- 17) Options - commit type, commit interval, HA Recovery should
be taken into consideration as they plays a major role in recovery process.
#--------------- 18) Once one of the failed sessions is recovered , but other do
es not , then while re-running of the recovery process would not touch the recov
ered session.