16.20 - Integrating with Teradata Ecosystem Manager 16.20 C/C++ API - Teradata Ecosystem Manager

Teradata® Ecosystem Manager API Reference

prodname
Teradata Ecosystem Manager
vrm_release
16.20
created_date
December 2020
category
Programming Reference
featnum
B035-3204-107K

There are two ways to use the Teradata MSM functions added in Ecosystem Manager 16.20

  • Link libtmsmapistub.so. Client links to libtmsmapistub during the build process.
    This approach is recommended when integrating this release of the API.

    On HP-UX IA platforms, the client application links to libtmsmapistub.sl. On AIX platforms the client application links to libtmsmapistub.a. On Windows platforms, the client application links to tmsmapistub.lib.

    For example, assume that SendStart is client-executable on a SUSE Linux Enterprise 10 system which uses Teradata Ecosystem Manager 16.20 API.

    gcc $(CFLAGS) -o SendStart SendStart.o $(LIB) -lc -ldl -lstdc++ -lnsl -luuid -ltmsmapistub -L/opt/teradata/client/em/lib

    For z/OS platforms, if the Teradata MSM API (USS) is invoked from PDSE dataset, add the following to the client’s JCL to point to the correct HFS. This assumes that Teradata MSM was installed in /usr/local/opt/teradata/client/em.

    // PARM='ENVAR("_CEE_ENVFILE_S=DD:ENVFILE")'
    //ENVFILE DD PATH='/usr/local/opt/teradata/client/em/conf/em.env'

    Sample JCLs are located here: /local/opt/teradata/client/em/jcl/samples

  • Get handle to libtmsmapistub.so. This approach is used when a client does not want to link to libtmsmapistub.so in the makefile during its build process. The following snippet shows that the client application can still use the functions.
    The following snippet does not check for NULL values, even though this is strongly recommended, and was tested only on a SUSE Linux Enterprise 10 platform. Clients must provide OS_LINUX macro when compiling (for example, DOS_LINUX). For other platforms, client applications can perform direct dlopen calls against loader stub (libtmsmapistub.so/libtmsmapistub.sl/libtmsmapistub.a). For example, instead of MSM_GetLoaderHandle(), you can use:
    hLib=dlopen(“/opt/teradata/client/em/lib/libtmsmapistub.so”,RTLD_LAZY | RTLD_GLOBAL);
    	void* hLIB = NULL;
    	TM_Context* pCtx = NULL;
    	MSM_UofW* pUOW = NULL;
    	typedef MSM_UofW* (*pMSM_CreateUOW)(TM_Context* pCtx);
    	typedef void (*pMSM_FreeUOW)(TM_Context* pCtx, MSM_UofW* pUOW);
    	typedef MSM_WEvent* (*pMSM_CreateWEvent)(TM_Context* pCtx, MSM_UofW* pUOW);
    	typedef void (*pMSM_FreeWEvent)(TM_Context* pCtx, MSM_WEvent* pWEvent);
    	typedef error_code_t (*pMSM_AddWTable)(TM_Context* pCtx, MSM_WEvent* 		 	pWEvent,wchar_t*
    	table);
    	typedef error_code_t (*pMSM_AddWResourceType)(TM_Context* pCtx,MSM_WEvent*
    	pWEvent,wchar_t * resourceType);
    	typedef error_code_t (*pMSM_AddWDatabase)(TM_Context* pCtx,MSM_WEvent* 		pWEvent,wchar_t *
    	database);
    	typedef error_code_t (*pMSM_AddWDmlMode)(TM_Context* pCtx, MSM_WEvent* 		pWEvent,wchar_t *
    	dmlMode);
    	typedef error_code_t (*pMSM_AddWHealthString)(TM_Context* pCtx,MSM_WEvent*
    	pWEvent,wchar_t * healthString);
    	typedef error_code_t (*pMSM_AddWActivityCount)(TM_Context* pCtx, MSM_WEvent*
    	pWEvent,long activityCount);
    	typedef error_code_t (*pMSM_FreeWEventMembers)(TM_Context* pCtx,MSM_WEvent 		*pWEvent);
    	typedef error_code_t (*pMSM_FreeAndClearWEventMembers)(TM_Context 		*pCtx,MSM_WEvent*
    	pWEvent);
    	typedef void (*pMSM_ClearUofWMembers)(TM_Context* pCtx, MSM_UofW* pUOW);
    	typedef error_code_t (*pMSM_UpdateUofWFromEnvironment)(TM_Context* pCtx,MSM_UofW* 		pUOW);
    	typedef error_code_t (*pMSM_UpdateUofWWithUniqueId)(TM_Context* pCtx,MSM_UofW* 		pUOW);
    	typedef error_code_t (*pMSM_UpdateWEventFromEnvironment)(TM_Context* 		pCtx,MSM_WEvent*
    	pWEvent);
    	typedef error_code_t (*pMSM_SendWEvent)(TM_Context* pCtx,MSM_WEvent *pWEvent);
    	//pointers to TMSM functions
    	pMSM_CreateUOW pFunc_MSM_CreateUOW = NULL;
    	pMSM_FreeUOW pFunc_MSM_FreeUOW = NULL;
    	pMSM_CreateWEvent pFunc_MSM_CreateWEvent = NULL;
    	pMSM_FreeWEvent pFunc_MSM_FreeWEvent = NULL;
    	pMSM_AddWTable pFunc_MSM_AddWTable = NULL;
    	pMSM_AddWResourceType pFunc_MSM_AddWResourceType = NULL;
    	pMSM_AddWDatabase pFunc_MSM_AddWDatabase = NULL;
    	pMSM_AddWDmlMode pFunc_MSM_AddWDmlMode = NULL;
    	pMSM_AddWHealthString pFunc_MSM_AddWHealthString = NULL;
    	pMSM_AddWActivityCount pFunc_MSM_AddWActivityCount =NULL;
    	pMSM_FreeWEventMembers pFunc_MSM_FreeWEventMembers = NULL;
    	pMSM_FreeAndClearWEventMembers pFunc_MSM_FreeAndClearWEventMembers = NULL;
    	pMSM_ClearUofWMembers pFunc_MSM_ClearUofWMembers = NULL;
    	pMSM_UpdateUofWFromEnvironment pFunc_MSM_UpdateUofWFromEnvironment = NULL;
    	pMSM_UpdateUofWWithUniqueId pFunc_MSM_UpdateUofWWithUniqueId = NULL;
    	pMSM_UpdateWEventFromEnvironment pFunc_MSM_UpdateWEventFromEnvironment = NULL;
    	pMSM_SendWEvent pFunc_MSM_SendWEvent = NULL;
    	//Get handle to libtmsmpaistub
    	hLIB=MSM_GetLoaderHandle();
    	if (hLIB != NULL)
    	{		
    		//Grab the address of funtions.
    		pFunc_MSM_CreateUOW = (pMSM_CreateUOW)dlsym(hLIB, "MSM_CreateUOW");
    		pFunc_MSM_FreeUOW = (pMSM_FreeUOW)dlsym(hLIB, "MSM_FreeUOW");
    		pFunc_MSM_CreateWEvent = (pMSM_CreateWEvent)dlsym(hLIB,"MSM_CreateWEvent");
    		pFunc_MSM_FreeWEvent = (pMSM_FreeWEvent)dlsym(hLIB, "MSM_FreeWEvent");
    		pFunc_MSM_AddWTable = (pMSM_AddWTable)dlsym(hLIB, "MSM_AddWTable");
    		pFunc_MSM_AddWResourceType =
    		(pMSM_AddWResourceType)dlsym(hLIB,"MSM_AddWResourceType");
    		pFunc_MSM_AddWDatabase = (pMSM_AddWDatabase)dlsym(hLIB,"MSM_AddWDatabase");
    		pFunc_MSM_AddWDmlMode = (pMSM_AddWDmlMode)dlsym(hLIB, "MSM_AddWDmlMode");
    		pFunc_MSM_AddWHealthString =
    		(pMSM_AddWHealthString)dlsym(hLIB,"MSM_AddWHealthString");
    		pFunc_MSM_AddWActivityCount =
    		(pMSM_AddWActivityCount)dlsym(hLIB,"MSM_AddWActivityCount");
    		pFunc_MSM_FreeWEventMembers =
     		(pMSM_FreeWEventMembers)dlsym(hLIB,"MSM_FreeWEventMembers");
    		pFunc_MSM_FreeAndClearWEventMembers =
    		(pMSM_FreeAndClearWEventMembers)dlsym(hLIB,"MSM_FreeAndClearWEventMembers");
    		pFunc_MSM_ClearUofWMembers =
    		(pMSM_ClearUofWMembers)dlsym(hLIB,"MSM_ClearUofWMembers");
    		pFunc_MSM_UpdateUofWFromEnvironment =
    		(pMSM_UpdateUofWFromEnvironment)dlsym(hLIB,"MSM_UpdateUofWFromEnvironment");
    		pFunc_MSM_UpdateUofWWithUniqueId =
    		(pMSM_UpdateUofWWithUniqueId)dlsym(hLIB,"MSM_UpdateUofWWithUniqueId");
    			 	pFunc_MSM_UpdateWEventFromEnvironment=(pMSM_UpdateWEventFromEnvironment)dlsym(hLIB,
    	„MSM_UpdateWEventFromEnvironment");
    		pFunc_MSM_SendWEvent = (pMSM_SendWEvent)dlsym(hLIB, "MSM_SendWEvent");
    		//Check if all above function pointers have non-NULL values and then only 									 	proceed
    		pCtx=TM_Init();
    		pUOW= pFunc_MSM_CreateUOW(pCtx);
    	}