ClRcT clAspBasicLibInitialize()
{
    ClUint32T i = 0;
    ClRcT rc = CL_OK;
    ClUint32T tableSize = sizeof(gClBasicLibInitTable) / sizeof(ClInitFinalizeDef);
    for (i = 0; i < tableSize; i++)
    {
        if (gClBasicLibInitTable[i].fn == NULL) continue;

        if (eoBasicLibs[i] == CL_TRUE)
        {

            clLog(CL_LOG_SEV_DEBUG, CL_LOG_AREA, CL_LOG_CTXT_INI, "Initializing basic library [%s]...", gClBasicLibInitTable[i].libName);
            if (CL_OK != (rc = gClBasicLibInitTable[i].fn()))
            {

                return rc;
            }
        }
    }

    rc = clDispatchLibInitialize();
    if (CL_OK != rc)
    {
	    clLog(CL_LOG_SEV_CRITICAL, CL_LOG_AREA, CL_LOG_CTXT_INI,
		      "Error Initializing Basic Library"
			  "clDispatchLibInitialize(), rc=[0x%x]\n",
			  rc);
	    return rc;
    }

    return CL_OK;
}
/*
 * This function initializes all the Basic ASP library 
 */
ClRcT clEoEssentialLibInitialize(void)
{
    ClRcT rc = CL_OK;

    ClUint32T i = 0;
    ClUint32T tableSize =  CL_EO_LIB_ID_RES; // CL_SIZEOF_ARRAY(gEssentialLibInfo);

    /*
     * Initializing the Essential Libraries
     */

    for (i = 0; i < tableSize; i++)
    {
        clLog(CL_LOG_SEV_DEBUG, CL_LOG_AREA, CL_LOG_CTXT_INI, "Initializing essential library [%s]...", gEssentialLibInfo[i].libName);
        if (CL_OK != (rc = gEssentialLibInfo[i].pLibInitializeFunc(gEssentialLibInfo[i].pConfig)))
        {
            if (CL_GET_ERROR_CODE(rc) != CL_ERR_INITIALIZED) /* Already Initialized is benign */
            {
               
            clLog(CL_LOG_SEV_CRITICAL, CL_LOG_AREA, CL_LOG_CTXT_INI, "Failed to initialize essential library [%s], error [0x%x]",
                  gEssentialLibInfo[i].libName, rc);
            return rc;
            }
            
        }
    }
    return CL_OK;
}
/**
 * Called by CPM in clCpmComponentResourceCleanup()
 */
ClRcT clAspClientLibFinalize(void)
{
    ClInt32T i = 0;
    ClRcT rc = CL_OK;
    ClUint32T tableSize =
        sizeof(gClClientLibCleanupTable) / sizeof(ClInitFinalizeDef);

    for (i = tableSize - 1; i >= 0; i--)
    {
        /*
         * Ignore if function not registered to avoid a crash. Refer bug 4061.
         */
        if (gClClientLibCleanupTable[i].fn == NULL) 
            continue;

        if (eoClientLibs[i] == CL_TRUE)
        {
            clLog(CL_LOG_SEV_DEBUG, CL_LOG_AREA, CL_LOG_CTXT_FIN,
                  "Finalizing client library [%s]...",
                  gClClientLibCleanupTable[i].libName);
            if (CL_OK != (rc = gClClientLibCleanupTable[i].fn()))
            {
                clLog(CL_LOG_SEV_CRITICAL, CL_LOG_AREA, CL_LOG_CTXT_FIN,
                      "Failed to finalize client library [%s], error [0x%x]",
                      gClClientLibCleanupTable[i].libName, rc);
            }
        }
    }
    return CL_OK;
}
static ClRcT clAspBasicLibFinalize()
{
    ClInt32T i = 0;
    ClRcT rc = CL_OK;
    ClUint32T tableSize =
        sizeof(gClBasicLibCleanupTable) / sizeof(ClInitFinalizeDef);

    rc = clDispatchLibFinalize();
    if (CL_OK != rc)
    {
        clLog(CL_LOG_SEV_CRITICAL, CL_LOG_AREA, CL_LOG_CTXT_FIN,
              "Error finalizing Dispatch Library "
              "clDispatchLibFinalize(), rc=[0x%x]\n",rc);
        return rc;
    }

    for (i = tableSize - 1; i >= 0; i--)
    {
        if (gClBasicLibCleanupTable[i].fn == NULL) continue;

        if (eoBasicLibs[i] == CL_TRUE)
        {
            if (CL_OK != (rc = gClBasicLibCleanupTable[i].fn()))
            {
                clLog(CL_LOG_SEV_CRITICAL, CL_LOG_AREA, CL_LOG_CTXT_FIN,
                      "Failed to finalize basic library [%s], error [0x%x]",
                      gClBasicLibCleanupTable[i].libName, rc);
            }
        }
    }

    return CL_OK;
}
/* exec init function is called as soon as this service object is loaded. */
static int gms_exec_init_fn (struct objdb_iface_ver0 *objdb)
{
    ClRcT rc = CL_OK;
    extern ClRcT
        clCpmComponentRegister(ClCpmHandleT ,const SaNameT *,const SaNameT *);

    log_init ("GMS");
    clLog (DBG,OPN,AIS,"Initializing clovis GMS service");

    gAspNativeLeaderElection = clAspNativeLeaderElection();

    rc = clCpmComponentRegister(
            gmsGlobalInfo.cpmHandle,
            &gmsGlobalInfo.gmsComponentName,
            NULL
            );
    if(rc)
    {
        clLog(ERROR,OPN,AIS,
                "clCpmComponent register failed with rc 0x%x",rc);
    }
    clLogMultiline(DBG,OPN,AIS,
            "clCpmComponentRegister successful. Updating GMS state as RUNNING");
    gmsGlobalInfo.opState = CL_GMS_STATE_RUNNING;

    /* Initialize my ip address */
    memset(&myAddress, 0, sizeof(ClGmsNodeAddressT));
    clGmsWrapperUpdateMyIP();

    return (0);
}
ClRcT clASPFinalize(void)
{
    ClRcT rc = CL_OK;
    
    if (CL_FALSE == gClASPInitialized)
    {
        clLog(CL_LOG_SEV_ERROR, CL_LOG_AREA, CL_LOG_CTXT_FIN, "Called SAFplus finalize without initializing first.");
        
        return CL_ERR_NOT_INITIALIZED;
    }

    gClASPInitCount--;

    if(gClASPInitCount > 0)
    {
        return CL_OK;
    }
    
    /*
     * Unblock all threads. first
     */
    clEoUnblock(NULL);

    rc = clEoTearDown();
    if(rc != CL_OK)
    {
        clLog(CL_LOG_SEV_ERROR, CL_LOG_AREA, CL_LOG_CTXT_FIN, "SAFplus finalize failed, error[0x%x]", rc);
        return rc;
    }
    
    gClASPInitialized = CL_FALSE;

    return CL_OK;
}
Пример #7
0
void xrLC_GlobalData	::vertices_isolate_and_pool_reload()
{


	const u32 inital_verts_count = _g_vertices.size();
		  u32 not_empty_verts = 0;
	//for(u32 i = 0; i < inital_verts_count; ++i )
	// if(!_g_vertices[i]->m_adjacents.empty())
	//	++not_empty_verts;
/////////////////////////////////////////////////////////
	
	string_path			path_name;
	FS.update_path		( path_name, "$app_root$", "ccc__temp__vertices"  );
	{
		IWriter * file		= FS.w_open( path_name );
		R_ASSERT( file );
		for(u32 i = 0; i < inital_verts_count; ++i )
		{
			Vertex	&v = *_g_vertices[i];
			if( v.m_adjacents.empty() )
			{
				::destroy_vertex( _g_vertices[i], false );
				continue;
			}
//isolate_pool_clear_read	
//isolate_pool_clear_write

			v.isolate_pool_clear_write( *file );
			::destroy_vertex( _g_vertices[i], false );
			++not_empty_verts;
		}
		FS.w_close(file);
	}
/////////////////////////////////////////////////////////
	_g_vertices.clear_not_free();
	clLog( "mem usage before clear pool: %u", Memory.mem_usage() );


	_VertexPool.clear();
	
/////////////////////////////////////////////////////////
	{
		b_vert_not_register = true;
		_g_vertices.resize( not_empty_verts, 0 );

		Memory.mem_compact();
		clLog( "mem usage after clear pool: %u", Memory.mem_usage() );

		INetReaderFile r_verts( path_name );
		for(u32 i = 0; i < not_empty_verts; ++i )
		{
			Vertex* &v = _g_vertices[i];
			v = _VertexPool.create();
			v->isolate_pool_clear_read( r_verts );
		}
		b_vert_not_register = false;
	}
}
Пример #8
0
void	xrLC_GlobalData::clear_mu_models	()
{	

		clLog( "mem usage before mu_clear %d", Memory.mem_usage() );
		vec_clear(_mu_models);// not clear ogf
		vec_clear(_mu_refs);
		mu_mesh_clear();
		Memory.mem_compact();
		clLog( "mem usage after mu_clear: %d", Memory.mem_usage() );

}
Пример #9
0
void xrLC_GlobalData::clear_build_textures_surface()
{
	clLog( "mem usage before clear build textures surface: %u", Memory.mem_usage() );
	//xr_vector<b_BuildTexture>		_textures;
	xr_vector<b_BuildTexture>::iterator i = textures().begin();
	xr_vector<b_BuildTexture>::const_iterator e = textures().end();
	for(;i!=e;++i)
		::clear((*i));
	Memory.mem_compact();
	clLog( "mem usage after clear build textures surface: %u", Memory.mem_usage() );
}
Пример #10
0
void	xrLC_GlobalData::clear_mesh		()
{
	
	//R_ASSERT(g_XSplit.empty());
	clLog( "mem usage before clear mesh: %u", Memory.mem_usage() );
	//g_vertices().clear();
	//g_faces().clear();
	//_VertexPool.clear();
	//_FacePool.clear();
	gl_mesh_clear	();
	Memory.mem_compact();
	clLog( "mem usage after clear mesh: %u", Memory.mem_usage() );
}
Пример #11
0
void xrLC_GlobalData::clear_build_textures_surface( const xr_vector<u32> &exept )
{
	clLog( "mem usage before clear build textures surface: %u", Memory.mem_usage() );
	xr_vector<b_BuildTexture>::iterator i = textures().begin();
	xr_vector<b_BuildTexture>::const_iterator e = textures().end();
	xr_vector<b_BuildTexture>::const_iterator b = textures().begin();
	for(;i!=e;++i)
	{
		xr_vector<u32>::const_iterator ff = std::find( exept.begin(), exept.end(),u32( i - b ) );
		if( ff ==  exept.end() )
			::clear((*i));
	}
	Memory.mem_compact();
	clLog( "mem usage after clear build textures surface: %u", Memory.mem_usage() );
}
ClRcT _clGmsDbOpen(
            CL_IN      const    ClUint64T   numOfGroups,
            CL_INOUT   ClGmsDbT** const     gmsDb)
{
    if (gmsDb == NULL) 
    {
        return CL_GMS_RC(CL_ERR_NULL_POINTER);
    }

    
    *gmsDb = (ClGmsDbT *) clHeapAllocate(sizeof(ClGmsDbT)
                                        * numOfGroups);

    if (*gmsDb == NULL)
    {
        return CL_GMS_RC(CL_ERR_NO_MEMORY);
    }

    memset(*gmsDb, 0, sizeof(ClGmsDbT)* numOfGroups);

    clLog(DBG,GEN,DB,
            "Created GMS master database successfully");

    return CL_OK;
}
/* below function is required in config_ch function
 * because the totempg_ifaces_print function returns
 * the IP address corresponding to the in a different format.
 * Hence we have the below function */
char *get_node_ip (unsigned int nodeid)
{
    static char iface_string[256 * INTERFACE_MAX];
    char one_iface[64];
    struct totem_ip_address interfaces[INTERFACE_MAX];
    char **status;
    unsigned int iface_count;
    int res;

    iface_string[0] = '\0';

    res = totempg_ifaces_get (nodeid, interfaces, &status, &iface_count);
    if (res == -1) {
        clLog(ERROR,OPN,AIS,
                "totempg_ifaces_get failed");
        return ("no interface found for nodeid");
    }
    assert(iface_count <= INTERFACE_MAX);

    /* Please note that in openais.conf file as of now we are specifying
     * ONLY ONE interface. The protocol works for multiple processes as well.
     * But we are limiting it to work on only one interface
     */
    sprintf (one_iface, "%s",totemip_print (&interfaces[0]));
    strncat (iface_string, one_iface, sizeof(iface_string)-1);

    return (iface_string);
}
void clGmsWrapperUpdateMyIP()
{
    /* This function extracts the latest "this_ip" information
     * about the IP address that this node has bound to
     * and updates a GMS specific local structure.
     * In the config change functions we update my node
     * details with the updated IP in case there was a network
     * up/down and the node has bound to new IP */
    sprintf ((char *)myAddress.value, "%s",totemip_print (this_ip));
    myAddress.length = strlen ((char *)myAddress.value);
#ifndef OPENAIS_TIPC
    if (this_ip->family == AF_INET) {
        myAddress.family = CL_GMS_AF_INET;
    } else {
        if (this_ip->family == AF_INET6) {
            myAddress.family = CL_GMS_AF_INET6;
        } else {
            assert (0);
        }
    }
#else
    myAddress.family = AF_TIPC;
#endif

    /* Also update the global gms data of thisnode with new IP */
    gmsGlobalInfo.config.thisNodeInfo.nodeIpAddress = myAddress;
       
    clLog(DBG,OPN,AIS, "My Local IP address = %s",myAddress.value);
}
ClRcT clSnmpnameTableIndexTlvGet(ClPtrT pIndexInfo, ClAlarmUtilTlvInfoPtrT pTlvList)
{
    ClAlarmUtilTlvT * pTlv = NULL;
    ClSnmpnameTableIndexInfoT * pnameTableIndex = (ClSnmpnameTableIndexInfoT *)pIndexInfo;

    if(!pIndexInfo || !pTlvList)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("NULL arguments received!"));
        return CL_ERR_NULL_POINTER;
    }
    pTlvList->pTlv = (ClAlarmUtilTlvT *) clHeapAllocate (1 * sizeof (ClAlarmUtilTlvT));
    if (pTlvList->pTlv == NULL)
    {
        clLog(CL_LOG_ERROR, CL_SNMP_AREA, CL_SNMP_GEN_OP_COTX, "nameTableIndexTlvGet unable to allocate memory!");
        return (CL_ERR_NO_MEMORY);
    }
    pTlvList->numTlvs = 1;

    pTlv = pTlvList->pTlv + 0;
    pTlv->value = clHeapAllocate (sizeof (ClUint32T));
    if (pTlv->value == NULL)
    {
        clHeapFree(pTlvList->pTlv);
        return (CL_ERR_NO_MEMORY);
    }
    memcpy(pTlv->value, &(pnameTableIndex->nodeAdd), sizeof (ClUint32T));
    pTlv->length = sizeof (ClUint32T);
    pTlv->type = CL_COR_UINT32;
    return CL_OK;
}
int main(int argc, char *argv[])
{
    ClRcT   rc = CL_OK;
    if (argc < 2){
        clLog (EMER,GEN,NA, "usage : %s", GMS_USAGE);
        exit(0);
    }

    /* Connect to the SAF cluster */
    rc = initializeAmf();
    if( rc != CL_OK)
    {
        clLogCritical(GEN,NA,
                      "GMS: gmsInitialize failed [0x%X]\n\r", rc);
        return rc;
    }
    _clGmsServiceInitialize ( argc , argv );

    
    /* Block on AMF dispatch file descriptor for callbacks.
       When this function returns its time to quit. */
    dispatchLoop();
    
    saAmfFinalize(amfHandle); 

    return 0;
}
/* Called by SaAmfInitialize, but SAFplus services do not call this */
ClRcT clASPInitialize(void)
{
    ClRcT rc = CL_OK;
    
    if(CL_TRUE == gClASPInitialized)
    {
        gClASPInitCount++;
        return CL_OK;
    }
    
    if (clLoadEnvVars() != CL_OK) exit(1);  // Returns an error if essential variables are not set
    
    rc = clEoSetup();
    if(rc != CL_OK)
    {
        clLog(CL_LOG_SEV_CRITICAL, CL_LOG_AREA, CL_LOG_CTXT_INI, "Exiting : SAFplus initialize failed, error [0x%x]", rc);
        return rc;
    }

    clCpmTargetInfoInitialize();

    gClASPInitCount++;
    gClASPInitialized = CL_TRUE;

    return CL_OK;
}
static ClRcT clEoEssentialLibFinalize(void)
{
    ClRcT rc = CL_OK;

    ClInt32T i = 0;
    ClUint32T tableSize = CL_EO_LIB_ID_RES; // CL_SIZEOF_ARRAY(gEssentialLibInfo);

    /*
     * Finalizing the Essential Libraries
     */

    for (i = tableSize-1; i >= 0; i--)
    {
        if (gEssentialLibInfo[i].pLibFinalizeFunc)
        {            
            rc = gEssentialLibInfo[i].pLibFinalizeFunc();
            if (CL_OK != rc)
            {
                clLog(CL_LOG_SEV_CRITICAL, CL_LOG_AREA, CL_LOG_CTXT_FIN, "Failed to finalize essential library [%s], error [0x%x]", gEssentialLibInfo[i].libName, rc);
                return rc;
            }
        }        
    }
    return CL_OK;
}
static void gms_confchg_fn (
	enum totem_configuration_type configuration_type,
	unsigned int *member_list, int member_list_entries,
	unsigned int *left_list, int left_list_entries,
	unsigned int *joined_list, int joined_list_entries,
	struct memb_ring_id *ring_id)
{
	int     i = 0;
    char    iface_string[256 * INTERFACE_MAX] = "";
    ClRcT   rc = CL_OK;
    ClUint32T minVersion = CL_VERSION_CODE(5, 0, 0);

	clLog (NOTICE,OPN,AIS, "GMS CONFIGURATION CHANGE");
	clLog (NOTICE,OPN,AIS, "GMS Configuration:");
	for (i = 0; i < member_list_entries; i++) {
		clLog (NOTICE,OPN,AIS, "\t%s", totempg_ifaces_print (member_list[i]));
	}
	clLog(NOTICE,OPN,AIS, "Members Left:");
	for (i = 0; i < left_list_entries; i++) {
		clLog (NOTICE,OPN,AIS, "\t%s", totempg_ifaces_print (left_list[i]));
	}

	clLog(NOTICE,OPN,AIS, "Members Joined:");
	for (i = 0; i < joined_list_entries; i++) {
		clLog (NOTICE,OPN,AIS, "\t%s", totempg_ifaces_print (joined_list[i]));
	}
   
    clNodeCacheMinVersionGet(NULL, &minVersion);
    if(minVersion >= CL_VERSION_CODE(5, 0, 0) && gAspNativeLeaderElection)
    {
        clLog(DBG, OPN, AIS, "Skipping node leave processing since node cache is used to sync cluster views");
        return ;
    }

    for (i = 0; i < left_list_entries; i++) 
    {
        /* Call Cluster Leave for the nodes which are left.
         * To do that we need to translate IP address to gms nodeID
         * NOTE: Currently we are getting the this left_list[i] to
         * the ip address mapping from the get_interface_ip function.
         * This is not quite reliable and may get into issues when using
         * multiple interfaces...
         */
        strncpy(iface_string, get_node_ip(left_list[i]), (256*INTERFACE_MAX)-1);
        clLog(DBG,OPN,AIS, "Invoking cluster leave for node with IP %s",iface_string);
        rc = _clGmsEngineClusterLeaveWrapper(CL_GMS_CLUSTER_ID, iface_string);
    }

    return;
}
ClRcT clSnmpocTrainDefaultInstXlator (CL_IN const struct ClMedAgentId *pAgntId,
                     CL_IN ClCorMOIdPtrT         hmoId,
                     CL_IN ClCorAttrPathPtrT containedPath,
                     CL_OUT void**         pRetInstData,
                     CL_OUT ClUint32T     *pInstLen,
                     CL_OUT ClPtrT        pCorAttrValueDescList,
                     CL_IN ClMedInstXlationOpEnumT instXlnOp,
                     CL_IN ClPtrT cookie)
{
    ClUint32T   len = 0;
    ClSNMPRequestInfoT *pInst = NULL;

    clLog(CL_LOG_DEBUG, CL_SNMP_AREA, CL_SNMP_GEN_XLA_COTX, "Default Instant Xlation for MOID : ");
    CL_MED_COR_STR_MOID_PRINT(hmoId);

    if(!pAgntId || !pRetInstData || !pInstLen)
    {
        clLog(CL_LOG_ERROR, CL_SNMP_AREA, CL_SNMP_GEN_XLA_COTX, "clSnmpInstXlator received NULL arguments!");
        return CL_ERR_NULL_POINTER;   
    }

    pInst = (ClSNMPRequestInfoT*)*pRetInstData;

    if (pInst == NULL)
    {
        pInst = (ClSNMPRequestInfoT *) clHeapAllocate (sizeof (ClSNMPRequestInfoT));
        if (pInst == NULL)
        {
            clLog(CL_LOG_ERROR, CL_SNMP_AREA, CL_SNMP_GEN_XLA_COTX, "clSnmpocTrainDefaultInstXlator Unable to allocate memory for the instance translation!");
            return (CL_ERR_NO_MEMORY);
        }
        *pInstLen = sizeof (ClSNMPRequestInfoT);
        memset(pInst, 0, *pInstLen);
        *pRetInstData = (void**)pInst;
    }
    for(len = 0; len < pAgntId->len; len++)
    {
        pInst->oid[len] = pAgntId->id[len];
    }

    pInst->tableType = CL_OCTRAIN_SCALARS;
    return CL_OK;
}
static void gms_exec_message_endian_convert (void *msg)
{
    /* We only need to convert the header as all the other
     * elements are being marshalled/unmarshalled using xdr
     */
    mar_req_header_t              *header = msg;

    clLog(DBG,OPN,AIS, "Converting endianness for this message");

    swab_mar_req_header_t (header);
}
/*----------------------------------------------------------------------------
 *  Cluster Track Callback Handler
 *---------------------------------------------------------------------------*/
ClRcT clGmsClusterTrackCallbackHandler(
    CL_IN   ClGmsClusterTrackCallbackDataT* const res)
{
    ClRcT rc = CL_OK;
    struct gms_instance *gms_instance_ptr = NULL;
    ClGmsHandleT gmsHandle = CL_GMS_INVALID_HANDLE;

    CL_ASSERT(res != NULL);
    clLog(INFO,NA,NA,"received cluster track callback");

    gmsHandle = res->gmsHandle;
    rc = clHandleCheckout(gmsHandleDb, gmsHandle, (void**)&gms_instance_ptr);
    if (rc != CL_OK)
    {
        goto error_free_res;
    }

    if (gms_instance_ptr == NULL)
    {
        rc = CL_GMS_RC(CL_ERR_NULL_POINTER);
        goto error_free_res;
    }

    if (gms_instance_ptr->callbacks.clGmsClusterTrackCallback == NULL)
    {
        rc = CL_GMS_RC(CL_ERR_NO_CALLBACK);
        goto error_checkin_free_res;
    }

    /*
     * Calling the user's callback function with the data.  The user cannot
     * free the data we provide.  If it needs to reatin it, it has to copy
     * it out from what we provide here.
     */
            (*gms_instance_ptr->callbacks.clGmsClusterTrackCallback)
            (gmsHandle, &res->buffer, res->numberOfMembers, res->rc);
  

error_checkin_free_res:
    if (clHandleCheckin(gmsHandleDb, gmsHandle) != CL_OK)
    {
        clLogError(CLM,NA,
                   "\nclHandleCheckin failed");
    }

error_free_res:
    /* Need to free data (res) if are not able to call the actual callback */
    if (res->buffer.notification != NULL)
    {
        clHeapFree((void*)res->buffer.notification);
    }
    clHeapFree((void*)res);
    return rc;
}
ClRcT clSnmpalarmTrapIndexGet(ClUint32T objectType, ClCorMOIdPtrT pMoId, ClAlarmUtilTlvInfoPtrT pTlvList )
{
    ClSNMPRequestInfoT *pInst = NULL;
    ClUint32T instLen = 0;
    ClMedAgentIdT oid = { (ClUint8T *)"0.0", 4 }; /* Dummy OID. */
    ClRcT rc = CL_OK;

    if(NULL == pMoId)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("moId is passed as NULL"));
        return CL_ERR_NULL_POINTER;
    }
    if(NULL == pTlvList)
    {
        CL_DEBUG_PRINT(CL_DEBUG_ERROR,("pTlvList is passed as NULL"));
        return CL_ERR_NULL_POINTER;
    }

    switch(objectType)
    {
    case ALARMTRAP_CLOCKID:
    {
        /* OID = .1.3.6.1.4.1.103.2.1.1.2 */
        rc = clSnmpclockTableInstXlator ( &oid, pMoId, NULL, (void **)&pInst, &instLen, NULL, 0);
        if(rc != CL_OK)
        {
            clLog(CL_LOG_ERROR, CL_SNMP_AREA, CL_SNMP_GEN_OP_COTX, "clockTableInstXlator returned : [0x%x]", rc);
        }
        rc = clSnmpclockTableIndexTlvGet(&(pInst->index.clockTableInfo), pTlvList);
        if(rc != CL_OK)
        {
            clLog(CL_LOG_ERROR, CL_SNMP_AREA, CL_SNMP_GEN_OP_COTX, "clockTableIndexTlvGet returned : [0x%x]", rc);
            return rc;
        }
        break;
    }
    }
    return rc;
}
Пример #24
0
void __cdecl clMsg( const char *format, ...)
{
	va_list		mark;
	char buf	[4*256];
	va_start	( mark, format );
	vsprintf	( buf, format, mark );


	string1024		_out_;
	strconcat		(sizeof(_out_),_out_,"    |    | ", buf );
	clLog			(_out_);

}
                         // coverity[pass_by_value]
ClRcT _clCorSubTreeDelete(ClCorMOIdT moId)
{
    ClRcT       rc = CL_OK;

    CL_FUNC_ENTER();

    rc = _clCorObjectWalk(&moId, NULL, _corObjSubtreeDelete, CL_COR_MO_SUBTREE_WALK, 0);
    if (rc != CL_OK)
    {
        clLog(CL_LOG_SEV_DEBUG, "CLI", "OBT", "Failed to walk the object tree. rc [0x%x]", rc);
        CL_FUNC_EXIT();
        return rc;
    }
    
    CL_FUNC_EXIT();
    return CL_OK;
}
static ClRcT gmsLeaderElect (
                    CL_IN   ClUint32T argc,
                    CL_IN   ClCharT** argv,
                    CL_OUT  ClCharT** ret)
{
    ClRcT    rc = CL_OK;
    ClGmsClusterLeaderElectRequestT         req = {0};
    ClGmsClusterLeaderElectResponseT        res = {0};


    /* Allocate maximum possible */ 
    *ret = clHeapAllocate(1020);
    if( *ret == NULL ){
        clLog (ERROR,GEN,NA,
                "Memory allocation failed");
        return CL_ERR_NO_MEMORY;
    }
    memset(*ret,0,1020);

    if (argc != 2)
    {
        _clGmsCliMakeError( ret, LEADER_ELECT_USAGE );
        return CL_OK;
    }

    req.gmsHandle = 0;
    req.preferredLeaderNode = atoi(argv[1]);
    req.clientVersion = gmsGlobalInfo.config.versionsSupported.versionsSupported[0] ;

    rc = clGmsClusterLeaderElectHandler(&req, &res);
    if ((rc != CL_OK) && (rc != CL_ERR_ALREADY_EXIST))
    {
        _clGmsCliPrint(ret, "ClusterLeaderElect failed with rc 0x%x \n",rc);
        return rc;
    }

    if (rc == CL_ERR_ALREADY_EXIST)
    {
        _clGmsCliPrint(ret, "Node [%d] is already the leader node\n",req.preferredLeaderNode);
    }

    _clGmsCliPrint(ret, "New leader = %d\nNew Deputy = %d\nLeadership Changed = %s\n",
            res.leader,res.deputy,(res.leadershipChanged == CL_TRUE) ? "Yes" : "No");

    return CL_OK;
}
static ClCharT* _clTxnCmdNameGet(ClUint32T cmd)
{
    switch(cmd)
    {
        case CL_TXN_CMD_PREPARE:
            return "PREPARE";
        case CL_TXN_CMD_1PC_COMMIT:
            return "1PC COMMIT";
        case CL_TXN_CMD_2PC_COMMIT:
            return "2PC COMMIT";
        case CL_TXN_CMD_ROLLBACK:
            return "ROLLBACK";
        default:
            clLog(CL_DEBUG_ERROR, "AGT", NULL,
                    "Cannot find valid cmd corresponding to [%d]", 
                    cmd);
            return "INVALID";

    }
}
void 
_clGmsLoadUserAlgorithm(const ClUint32T groupid , 
                        char* const    pluginPath)
{
    const ClGmsLeaderElectionAlgorithmT algorithm = NULL;


    /* load the plugin in to process address space */ 
    pluginHandle = dlopen(pluginPath, RTLD_NOW | RTLD_GLOBAL );
    if(pluginHandle == NULL)
    {
        clLogMultiline(ERROR,GEN,NA,
                 "Unable to open the leader election plugin :[%s],"
                 "reason: [%s] ",pluginPath,dlerror()
                 );
        return;
    }

    /* Get the algorithm from the plugin */ 
    *(void**)&algorithm =dlsym( 
            pluginHandle, 
            LEADER_ELECTION_ALGORITHM);
    if(algorithm == NULL)
    {
        clLog(ERROR,GEN,NA,
                 "Unable to find the algorithm in plugin:[%s] %s",
                 pluginPath,dlerror());
        dlclose(pluginHandle);
        return;
    }

    /* Store the algorithm handle in the groups slot of the GmsConfiguration
     *  structure */ 
    clLogMultiline (INFO,GEN,NA, 
             "Group [%d] is using [%s] for leader election; Loaded from [%s]", 
            groupid, LEADER_ELECTION_ALGORITHM, pluginPath);
    gmsGlobalInfo.config.leaderAlgDb[groupid] = algorithm;

    return;
}
void _corObjSubtreeDelete(void * pMoId, ClBufferHandleT buffer)
{
    ClRcT rc = CL_OK;
    ClCorMOIdT moId;

    CL_FUNC_ENTER();

    moId = *(ClCorMOIdT *) pMoId;

    clCorMoIdServiceSet(&moId, CL_COR_INVALID_SVC_ID);

    rc = clCorUtilMoAndMSODelete(&moId);
    if (rc != CL_OK)
    {
        clLog(CL_LOG_SEV_DEBUG, "CLI", "OBT", "Failed to delete Mo and Mso objects. rc [0x%x]", rc);
        CL_FUNC_EXIT();
        return;
    }

    CL_FUNC_EXIT();
    return;
}
ClRcT clSnmpnameTableIndexCorAttrGet(ClPtrT pInst, ClPtrT pCorAttrValueDescList)
{
    ClRcT rc = CL_OK;
    ClSNMPRequestInfoT *pReqInfo = (ClSNMPRequestInfoT *) pInst;
    ClAlarmUtilTlvInfoT indexTlvList = {0};
    ClCorAttrValueDescriptorListPtrT pAttrDescList = (ClCorAttrValueDescriptorListPtrT) pCorAttrValueDescList;
    ClCorAttrValueDescriptorPtrT pAttrDescriptor = NULL;
    ClAlarmUtilTlvT * pTlv = NULL;
    ClUint32T count = 0;

    if(pInst == NULL || pCorAttrValueDescList == NULL)
    {
        clLog(CL_LOG_ERROR, CL_SNMP_AREA, CL_SNMP_GEN_OP_COTX, "NULL arguments received!");
        return CL_ERR_NULL_POINTER;
    }

    rc = clSnmpnameTableIndexTlvGet(&(pReqInfo->index.nameTableInfo), &indexTlvList);
    if(rc != CL_OK)
    {
        clLog(CL_LOG_ERROR, CL_SNMP_AREA, CL_SNMP_GEN_OP_COTX, "clSnmpnameTableIndexTlvGet returned error rc : [0x%x]", (ClUint32T)rc);
        return rc;
    }

    pAttrDescList->numOfDescriptor = 1;
    pAttrDescList->pAttrDescriptor = (ClCorAttrValueDescriptorT *)
                                     clHeapAllocate(1 * sizeof(ClCorAttrValueDescriptorT));

    pAttrDescriptor = pAttrDescList->pAttrDescriptor;
    if(pAttrDescriptor == NULL)
    {
        rc = CL_ERR_NO_MEMORY;
    }

    if(CL_OK == rc)
    {
        for(count = 0; count < pAttrDescList->numOfDescriptor; count++)
        {
            ClCorAttrValueDescriptorT * pAttrDesc = pAttrDescriptor + count;
            pTlv = (indexTlvList.pTlv) + count;

            pAttrDesc->pAttrPath = nameTableIndexCorAttrIdList[count].pAttrPath;
            pAttrDesc->attrId = nameTableIndexCorAttrIdList[count].attrId;
            pAttrDesc->index = -1;
            pAttrDesc->pJobStatus = (ClCorJobStatusT *)clHeapAllocate(sizeof(ClCorJobStatusT));
            if(pAttrDesc->pJobStatus == NULL)
            {
                rc = CL_ERR_NO_MEMORY;
                break;
            }

            pAttrDesc->bufferSize = pTlv->length;
            pAttrDesc->bufferPtr = clHeapAllocate(pAttrDesc->bufferSize);
            if(pAttrDesc->bufferPtr == NULL)
            {
                rc = CL_ERR_NO_MEMORY;
                break;
            }
            memcpy(pAttrDesc->bufferPtr, pTlv->value, pAttrDesc->bufferSize);
        }
    }
    /* CLEAN UP */
    {
        if(rc != CL_OK && pAttrDescriptor != NULL)
        {
            for(count = 0; count < pAttrDescList->numOfDescriptor; count++)
            {
                ClCorAttrValueDescriptorT * pAttrDesc = pAttrDescriptor + count;
                clHeapFree(pAttrDesc->pJobStatus);
                clHeapFree(pAttrDesc->bufferPtr);
            }
        }
        for(count = 0; count < indexTlvList.numTlvs; count++)
        {
            pTlv = (indexTlvList.pTlv) + count;
            clHeapFree(pTlv->value);
        }
        clHeapFree(indexTlvList.pTlv);
        indexTlvList.pTlv = NULL;
    }

    return CL_OK;
}