static void clCompAppAMFCSISet(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT csiDescriptor) { /* * ---BEGIN_APPLICATION_CODE--- */ clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%d]. CSISet called\n", compName->value, mypid); clPyGlueCsiSet(compName, haState,&csiDescriptor); clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%d]. PyGlueCsiSet() returned OK\n", compName->value, mypid); /* if (haState != SA_AMF_HA_QUIESCING) */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); /* GAS TODO: put in a separate python-visible callback */ if (haState == SA_AMF_HA_QUIESCING) saAmfCSIQuiescingComplete(amfHandle, invocation, SA_AIS_OK); /* * ---END_APPLICATION_CODE--- */ /* * Print information about the CSI Set */ clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%d]. CSI Set Received\n", compName->value, mypid); clCompAppAMFPrintCSI(csiDescriptor, haState); }
void clCompAppAMFCSISet( SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT csiDescriptor) { /* * Print information about the CSI Set */ clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. CSI Set Received\n", compName->length, compName->value, mypid); clCompAppAMFPrintCSI(csiDescriptor, haState); /* * Take appropriate action based on state */ switch ( haState ) { case CL_AMS_HA_STATE_ACTIVE: { /* * AMF has requested application to take the active HA state * for the CSI. */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case CL_AMS_HA_STATE_STANDBY: { /* * AMF has requested application to take the standby HA state * for this CSI. */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case CL_AMS_HA_STATE_QUIESCED: { /* * AMF has requested application to quiesce the CSI currently * assigned the active or quiescing HA state. The application * must stop work associated with the CSI immediately. */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case CL_AMS_HA_STATE_QUIESCING: { /* * AMF has requested application to quiesce the CSI currently * assigned the active HA state. The application must stop work * associated with the CSI gracefully and not accept any new * workloads while the work is being terminated. */ saAmfCSIQuiescingComplete(amfHandle, invocation, SA_AIS_OK); break; } default: { assert(0); break; } } return; }
ClRcT clCompAppAMFCSISet( ClInvocationT invocation, const SaNameT *compName, ClAmsHAStateT haState, ClAmsCSIDescriptorT csiDescriptor) { /* * Print information about the CSI Set */ clprintf ("Component [%s] : PID [%d]. CSI Set Received\n", compName->value, mypid); clCompAppAMFPrintCSI(csiDescriptor, haState); /* * Take appropriate action based on state */ switch ( haState ) { case CL_AMS_HA_STATE_ACTIVE: { /* * AMF has requested application to take the active HA state * for the CSI. */ /* * ---BEGIN_APPLICATION_CODE--- */ // ... /* * ---END_APPLICATION_CODE--- */ clCpmResponse(cpmHandle, invocation, CL_OK); break; } case CL_AMS_HA_STATE_STANDBY: { /* * AMF has requested application to take the standby HA state * for this CSI. */ /* * ---BEGIN_APPLICATION_CODE--- */ // ... /* * ---END_APPLICATION_CODE--- */ clCpmResponse(cpmHandle, invocation, CL_OK); break; } case CL_AMS_HA_STATE_QUIESCED: { /* * AMF has requested application to quiesce the CSI currently * assigned the active or quiescing HA state. The application * must stop work associated with the CSI immediately. */ /* * ---BEGIN_APPLICATION_CODE--- */ // ... /* * ---END_APPLICATION_CODE--- */ clCpmResponse(cpmHandle, invocation, CL_OK); break; } case CL_AMS_HA_STATE_QUIESCING: { /* * AMF has requested application to quiesce the CSI currently * assigned the active HA state. The application must stop work * associated with the CSI gracefully and not accept any new * workloads while the work is being terminated. */ /* * ---BEGIN_APPLICATION_CODE--- */ // ... /* * ---END_APPLICATION_CODE--- */ clCpmCSIQuiescingComplete(cpmHandle, invocation, CL_OK); break; } default: { /* * Should never happen. Ignore. */ } } return CL_OK; }
void clCompAppAMFCSISet(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT csiDescriptor) { /* * Print information about the CSI Set */ clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. CSI Set Received\n", compName->length, compName->value, mypid); clCompAppAMFPrintCSI(csiDescriptor, haState); SaAisErrorT rc = SA_AIS_OK; /* create a checkpoint based on the csi descriptor name to ensure uniqueness Both processes will attempt to open/create the checkpoint. The first one will create it. */ if (alarmClockCkptHdl == 0) { strcpy(alarmClockCkptName, (char *)csiDescriptor.csiName.value); rc = alarmClockCkptCreate(alarmClockCkptName, 1, sizeof(acClockT), &alarmClockCkptHdl); if (rc != SA_AIS_OK) { alarmClockLogWrite(CL_LOG_SEV_ERROR, "alarmClockCkptCreate failed code [%d]", rc); assert(0); alarmClockCkptHdl = 0; } } /* * Take appropriate action based on state */ switch ( haState ) { case SA_AMF_HA_ACTIVE: { /* * AMF has requested application to take the active HA state * for the CSI. */ rc = alarmClockCkptActivate(alarmClockCkptHdl, 1); if (rc != SA_AIS_OK) { alarmClockLogWrite(CL_LOG_SEV_ERROR, "alarmClockCkptCreate(pid=%d): Failed to activate ckpt :0x%x\n", getpid(), rc); } if (rc == SA_AIS_OK) /* try to read the checkpoint regardless of prior state if I become active prevHaState == SA_AMF_HA_STANDBY) */ { /* this way the ckpt will be read on process restart */ acClockT alarmClock = {{0}}; alarmClockLogWrite(CL_LOG_SEV_INFO, "Reading checkpoint to recover the time"); rc = alarmClockCkptRead ( alarmClockCkptHdl, 1, &alarmClock, sizeof(acClockT)); if (rc == SA_AIS_OK) { alarmClockCopyAndStart( &alarmClock); } else { alarmClockStart(); } } else { alarmClockStart(); } prevHaState = haState; saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case SA_AMF_HA_STANDBY: { /* * AMF has requested application to take the standby HA state * for this CSI. */ alarmClockLogWrite(CL_LOG_SEV_INFO, "I am standby"); prevHaState = haState; saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case SA_AMF_HA_QUIESCED: { /* * AMF has requested application to quiesce the CSI currently * assigned the active or quiescing HA state. The application * must stop work associated with the CSI immediately. */ alarmClockStop(); prevHaState = haState; saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case SA_AMF_HA_QUIESCING: { /* * AMF has requested application to quiesce the CSI currently * assigned the active HA state. The application must stop work * associated with the CSI gracefully and not accept any new * workloads while the work is being terminated. */ saAmfCSIQuiescingComplete(amfHandle, invocation, SA_AIS_OK); break; } default: { assert(0); break; } } return; }
void clCompAppAMFCSISet(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT csiDescriptor) { ClRcT rc = CL_OK; /* * Print information about the CSI Set */ clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. CSI Set Received\n", compName->length, compName->value, mypid); clCompAppAMFPrintCSI(csiDescriptor, haState); /* * Take appropriate action based on state */ switch ( haState ) { case SA_AMF_HA_ACTIVE: { /* * AMF has requested application to take the active HA state * for the CSI. */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); rc = clAlarmEventSubscribe(&alarm_event_subscribe_callback); if (CL_OK != rc) { clprintf(CL_LOG_SEV_ERROR,"%s: Failed while subscribing for the alarm events. rc[0x%x]", appname, rc); return; } break; } case SA_AMF_HA_STANDBY: { /* * AMF has requested application to take the standby HA state * for this CSI. */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case SA_AMF_HA_QUIESCED: { /* * AMF has requested application to quiesce the CSI currently * assigned the active or quiescing HA state. The application * must stop work associated with the CSI immediately. */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); rc = clAlarmEventUnsubscribe(); if (CL_OK != rc) { clprintf(CL_LOG_SEV_ERROR,"%s: Failed while un-subscribing for the alarm evnets. rc[0x%x] ", appname, rc); return; } break; } case SA_AMF_HA_QUIESCING: { /* * AMF has requested application to quiesce the CSI currently * assigned the active HA state. The application must stop work * associated with the CSI gracefully and not accept any new * workloads while the work is being terminated. */ saAmfCSIQuiescingComplete(amfHandle, invocation, SA_AIS_OK); break; } default: { assert(0); break; } } return; }
ClRcT clCompAppAMFCSISet( ClInvocationT invocation, const ClNameT *compName, ClAmsHAStateT haState, ClAmsCSIDescriptorT csiDescriptor) { /* * ---BEGIN_APPLICATION_CODE--- */ ClRcT rc = CL_OK; /* * ---END_APPLICATION_CODE--- */ /* * Print information about the CSI Set */ clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%ld]. CSI Set Received", compName->value, mypid); clCompAppAMFPrintCSI(csiDescriptor, haState); /* * Take appropriate action based on state */ switch ( haState ) { case CL_AMS_HA_STATE_ACTIVE: { /* * AMF has requested application to take the active HA state * for the CSI. */ /* * ---BEGIN_APPLICATION_CODE--- */ // ... /* * ---END_APPLICATION_CODE--- */ clCpmResponse(cpmHandle, invocation, CL_OK); rc = clAlarmEventSubscribe(&alarm_event_subscribe_callback); if (CL_OK != rc) { clprintf(CL_LOG_SEV_ERROR,"%s: Failed while subscribing for the alarm events. rc[0x%x]", appname, rc); return rc; } break; } case CL_AMS_HA_STATE_STANDBY: { /* * AMF has requested application to take the standby HA state * for this CSI. */ /* * ---BEGIN_APPLICATION_CODE--- */ // ... /* * ---END_APPLICATION_CODE--- */ clCpmResponse(cpmHandle, invocation, CL_OK); break; } case CL_AMS_HA_STATE_QUIESCED: { /* * AMF has requested application to quiesce the CSI currently * assigned the active or quiescing HA state. The application * must stop work associated with the CSI immediately. */ /* * ---BEGIN_APPLICATION_CODE--- */ // ... /* * ---END_APPLICATION_CODE--- */ clCpmResponse(cpmHandle, invocation, CL_OK); rc = clAlarmEventUnsubscribe(); if (CL_OK != rc) { clprintf(CL_LOG_SEV_ERROR,"%s: Failed while un-subscribing for the alarm evnets. rc[0x%x] ", appname, rc); return rc; } break; } case CL_AMS_HA_STATE_QUIESCING: { /* * AMF has requested application to quiesce the CSI currently * assigned the active HA state. The application must stop work * associated with the CSI gracefully and not accept any new * workloads while the work is being terminated. */ /* * ---BEGIN_APPLICATION_CODE--- */ // ... /* * ---END_APPLICATION_CODE--- */ clCpmCSIQuiescingComplete(cpmHandle, invocation, CL_OK); break; } default: { /* * Should never happen. Ignore. */ } } return CL_OK; }
ClRcT clCompAppAMFCSISet( ClInvocationT invocation, const ClNameT *compName, ClAmsHAStateT haState, ClAmsCSIDescriptorT csiDescriptor) { /* * ---BEGIN_APPLICATION_CODE--- */ // ... /* * ---END_APPLICATION_CODE--- */ /* * Print information about the CSI Set */ clprintf (CL_LOG_SEV_INFO, "Component [%s] : PID [%ld]. CSI Set Received", compName->value, mypid); clCompAppAMFPrintCSI(csiDescriptor, haState); /* * Take appropriate action based on state */ switch ( haState ) { case CL_AMS_HA_STATE_ACTIVE: { /* * AMF has requested application to take the active HA state * for the CSI. */ /* * ---BEGIN_APPLICATION_CODE--- */ clprintf(CL_LOG_SEV_INFO,"csa102: ACTIVE state requested; activating service"); running = 1; /* * ---END_APPLICATION_CODE--- */ clCpmResponse(cpmHandle, invocation, CL_OK); break; } case CL_AMS_HA_STATE_STANDBY: { /* * AMF has requested application to take the standby HA state * for this CSI. */ /* * ---BEGIN_APPLICATION_CODE--- */ clprintf(CL_LOG_SEV_INFO,"csa102: New state is not the ACTIVE; deactivating service"); running = 0; /* * ---END_APPLICATION_CODE--- */ clCpmResponse(cpmHandle, invocation, CL_OK); break; } case CL_AMS_HA_STATE_QUIESCED: { /* * AMF has requested application to quiesce the CSI currently * assigned the active or quiescing HA state. The application * must stop work associated with the CSI immediately. */ /* * ---BEGIN_APPLICATION_CODE--- */ clprintf(CL_LOG_SEV_INFO,"csa102: Acknowledging new state"); running = 0; /* * ---END_APPLICATION_CODE--- */ clCpmResponse(cpmHandle, invocation, CL_OK); break; } case CL_AMS_HA_STATE_QUIESCING: { /* * AMF has requested application to quiesce the CSI currently * assigned the active HA state. The application must stop work * associated with the CSI gracefully and not accept any new * workloads while the work is being terminated. */ /* * ---BEGIN_APPLICATION_CODE--- */ clprintf(CL_LOG_SEV_INFO,"csa102: Signaling completion of QUIESCING"); running = 0; /* * ---END_APPLICATION_CODE--- */ clCpmCSIQuiescingComplete(cpmHandle, invocation, CL_OK); break; } default: { break; } } return CL_OK; }
void clCompAppAMFCSISet(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT csiDescriptor) { /* * Print information about the CSI Set */ clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. CSI Set Received\n", compName->length, compName->value, mypid); clCompAppAMFPrintCSI(csiDescriptor, haState); /* * Take appropriate action based on state */ switch ( haState ) { case SA_AMF_HA_ACTIVE: { /* * AMF has requested application to take the active HA state * for the CSI. */ if ((csiDescriptor.csiFlags == CL_AMS_CSI_FLAG_TARGET_ALL)||(csiDescriptor.csiFlags == CL_AMS_CSI_FLAG_TARGET_ONE)) { /* Do not reload the virtual address info for the "TARGET" flag -- the CSI is not filled in. We will use the values that were cached when the "standby" assignment occurred. */ } else /* CL_AMS_CSI_FLAG_ADD_ONE */ { GetVirtualAddressInfo(&csiDescriptor, &gVirtualIp); } AddRemVirtualAddress("up",&gVirtualIp); saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case SA_AMF_HA_STANDBY: { /* * AMF has requested application to take the standby HA state * for this CSI. */ GetVirtualAddressInfo(&csiDescriptor, &gVirtualIp); AddRemVirtualAddress("down",&gVirtualIp); /* Bring it down just in case it is up from a prior run */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case SA_AMF_HA_QUIESCED: { /* * AMF has requested application to quiesce the CSI currently * assigned the active or quiescing HA state. The application * must stop work associated with the CSI immediately. */ if ((csiDescriptor.csiFlags == CL_AMS_CSI_FLAG_TARGET_ALL)||(csiDescriptor.csiFlags == CL_AMS_CSI_FLAG_TARGET_ONE)) { AddRemVirtualAddress("down",&gVirtualIp); } else /* CL_AMS_CSI_FLAG_ADD_ONE */ { VirtualIpAddress temp; GetVirtualAddressInfo(&csiDescriptor, &temp); AddRemVirtualAddress("down",&temp); } saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case SA_AMF_HA_QUIESCING: { /* * AMF has requested application to quiesce the CSI currently * assigned the active HA state. The application must stop work * associated with the CSI gracefully and not accept any new * workloads while the work is being terminated. */ saAmfCSIQuiescingComplete(amfHandle, invocation, SA_AIS_OK); break; } default: { assert(0); break; } } return; }
void clCompAppAMFCSISet(SaInvocationT invocation, const SaNameT *compName, SaAmfHAStateT haState, SaAmfCSIDescriptorT csiDescriptor) { /* * Print information about the CSI Set */ clprintf (CL_LOG_SEV_INFO, "Component [%.*s] : PID [%d]. CSI Set Received\n", compName->length, compName->value, mypid); clCompAppAMFPrintCSI(csiDescriptor, haState); /* * Take appropriate action based on state */ switch ( haState ) { case SA_AMF_HA_ACTIVE: { /* * AMF has requested application to take the active HA state * for the CSI. */ if (csiDescriptor.csiFlags == CL_AMS_CSI_FLAG_TARGET_ALL) { ClRcT rc; ClCpmCompCSIRefT csiRef = { 0 }; ClInt32T i; rc = clCpmCompCSIList((SaNameT*)compName, &csiRef); if(rc != CL_OK) { clLogError("APP", "CSISET", "Comp CSI get returned [%#x]", rc); } else { for(i = 0; i < csiRef.numCSIs; ++i) { VirtualIpAddress temp; ClCpmCompCSIT *pCSI = &csiRef.pCSIList[i]; clprintf(CL_LOG_SEV_INFO,"Comp [%.*s], CSI [%.*s], HA state [%s]", compName->length, compName->value, pCSI->csiDescriptor.csiName.length, pCSI->csiDescriptor.csiName.value, STRING_HA_STATE((ClUint32T)pCSI->haState)); GetVirtualAddressInfoAsp(&pCSI->csiDescriptor, &temp); AddRemVirtualAddress("up",&temp); } if(csiRef.pCSIList) clHeapFree(csiRef.pCSIList); } } else /* CL_AMS_CSI_FLAG_ADD_ONE */ { GetVirtualAddressInfo(&csiDescriptor, &gVirtualIp); AddRemVirtualAddress("up",&gVirtualIp); } saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case SA_AMF_HA_STANDBY: { /* * AMF has requested application to take the standby HA state * for this CSI. */ GetVirtualAddressInfo(&csiDescriptor, &gVirtualIp); AddRemVirtualAddress("down",&gVirtualIp); /* Bring it down just in case it is up from a prior run */ saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case SA_AMF_HA_QUIESCED: { /* * AMF has requested application to quiesce the CSI currently * assigned the active or quiescing HA state. The application * must stop work associated with the CSI immediately. */ if (csiDescriptor.csiFlags == CL_AMS_CSI_FLAG_TARGET_ONE) { AddRemVirtualAddress("down",&gVirtualIp); } else if (csiDescriptor.csiFlags == CL_AMS_CSI_FLAG_TARGET_ALL) { ClRcT rc; ClCpmCompCSIRefT csiRef = { 0 }; ClInt32T i; rc = clCpmCompCSIList((SaNameT*)compName, &csiRef); if(rc != CL_OK) { clLogError("APP", "CSISET", "Comp CSI get returned [%#x]", rc); } else { for(i = 0; i < csiRef.numCSIs; ++i) { VirtualIpAddress temp; ClCpmCompCSIT *pCSI = &csiRef.pCSIList[i]; clprintf(CL_LOG_SEV_INFO,"Comp [%.*s], CSI [%.*s], HA state [%s]", compName->length, compName->value, pCSI->csiDescriptor.csiName.length, pCSI->csiDescriptor.csiName.value, STRING_HA_STATE((ClUint32T)pCSI->haState)); GetVirtualAddressInfoAsp(&pCSI->csiDescriptor, &temp); AddRemVirtualAddress("down",&temp); } if(csiRef.pCSIList) clHeapFree(csiRef.pCSIList); } } else /* CL_AMS_CSI_FLAG_ADD_ONE */ { VirtualIpAddress temp; GetVirtualAddressInfo(&csiDescriptor, &temp); AddRemVirtualAddress("down",&temp); } saAmfResponse(amfHandle, invocation, SA_AIS_OK); break; } case SA_AMF_HA_QUIESCING: { /* * AMF has requested application to quiesce the CSI currently * assigned the active HA state. The application must stop work * associated with the CSI gracefully and not accept any new * workloads while the work is being terminated. */ saAmfCSIQuiescingComplete(amfHandle, invocation, SA_AIS_OK); break; } default: { assert(0); break; } } return; }