⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 libckpt.c

📁 linux集群服务器软件代码包
💻 C
📖 第 1 页 / 共 5 页
字号:
	libRequest->client = libClient;	libRequest->timeoutTag = 0;	libRequest->clientRequest = clientRequest;	clientRequest->clientHandle = libClient->clientHandle;	clientRequest->requestNO = SaCkptLibGetReqNO();	clientRequest->req = REQ_CKPT_ULNK;	clientRequest->reqParamLength = sizeof(SaCkptReqUlnkParamT);	clientRequest->dataLength = 0;	clientRequest->reqParam = unlinkParam;	clientRequest->data = NULL;	unlinkParam->clientHandle = *ckptHandle;	unlinkParam->ckptName.length = checkpointName->length;	memcpy(unlinkParam->ckptName.value,		checkpointName->value,		checkpointName->length);		ch = libClient->channel[0];	libError = SaCkptLibRequestSend(ch, libRequest->clientRequest);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Send checkpoint_unlink request failed");		goto unlinkError;	}	libError = SaCkptLibResponseReceive(ch, 		libRequest->clientRequest->requestNO,		&clientResponse);	if (libError != SA_OK) {		cl_log(LOG_ERR, "Receive response failed");		goto unlinkError;	}	if (clientResponse == NULL) {		cl_log(LOG_ERR, "Received null response");		libError = SA_ERR_LIBRARY;		goto unlinkError;	}	if (clientResponse->retVal != SA_OK) {		cl_log(LOG_ERR, "Checkpoint daemon returned error");		libError = clientResponse->retVal;		goto unlinkError;	}	libError = SA_OK;unlinkError:		if (libRequest != NULL) {		ha_free(libRequest);	}		if (clientRequest != NULL) {		ha_free(clientRequest);	}		if (unlinkParam != NULL) {		ha_free(unlinkParam);	}	if (clientResponse != NULL) {		if (clientResponse->dataLength > 0) {			ha_free(clientResponse->data);		}		ha_free(clientResponse);	}	return libError; }/*  * set the checkpoint duration. */SaErrorTsaCkptCheckpointRetentionDurationSet(	const SaCkptCheckpointHandleT *checkpointHandle,	SaTimeT retentionDuration){	SaCkptLibClientT* libClient = NULL;	SaCkptLibRequestT* libRequest = NULL;	SaCkptClientRequestT* clientRequest = NULL;	SaCkptReqRtnParamT* rtnParam = NULL; 	SaCkptClientResponseT* clientResponse = NULL;	SaCkptLibCheckpointT* libCheckpoint = NULL;		SaErrorT libError = SA_OK;	IPC_Channel* ch = NULL;	if (checkpointHandle == NULL) {		cl_log(LOG_ERR, 		"Null handle in saCkptCheckpointRetentionDurationSet");		return SA_ERR_INVALID_PARAM;	}	libCheckpoint = SaCkptGetLibCheckpointByHandle(		*checkpointHandle);	if (libCheckpoint == NULL) {		cl_log(LOG_ERR, 			"Checkpoint is not open");		return SA_ERR_INVALID_PARAM;	}	libClient = libCheckpoint->client;	  	libRequest = (SaCkptLibRequestT*)ha_malloc(					sizeof(SaCkptLibRequestT));	clientRequest = (SaCkptClientRequestT*)ha_malloc(					sizeof(SaCkptClientRequestT));	rtnParam = (SaCkptReqRtnParamT*)ha_malloc(					sizeof(SaCkptReqRtnParamT)); 	if ((libRequest == NULL) ||		(clientRequest == NULL) ||		(rtnParam == NULL)) {		cl_log(LOG_ERR, 			"No memory in saCkptCheckpointRetentionDurationSet");		libError = SA_ERR_NO_MEMORY;		goto rtnError;	}		memset(libRequest, 0, sizeof(SaCkptLibRequestT));	memset(clientRequest, 0, sizeof(SaCkptClientRequestT));	memset(rtnParam, 0, sizeof(SaCkptReqRtnParamT));		libRequest->client = libClient;	libRequest->timeoutTag = 0;	libRequest->clientRequest = clientRequest;	clientRequest->clientHandle = libClient->clientHandle;	clientRequest->requestNO = SaCkptLibGetReqNO();	clientRequest->req = REQ_CKPT_RTN_SET;	clientRequest->reqParamLength = sizeof(SaCkptReqRtnParamT);	clientRequest->dataLength = 0;	clientRequest->reqParam = rtnParam;	clientRequest->data = NULL;	rtnParam->checkpointHandle = *checkpointHandle;	rtnParam->retention = retentionDuration;		ch = libClient->channel[0];	libError = SaCkptLibRequestSend(ch, libRequest->clientRequest);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Send retention duration failed");		goto rtnError;	}	libError = SaCkptLibResponseReceive(ch, 		libRequest->clientRequest->requestNO,		&clientResponse);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Receive response failed");		goto rtnError;	}	if (clientResponse == NULL) {		cl_log(LOG_ERR, 			"Received null response");		libError = SA_ERR_LIBRARY;		goto rtnError;	}	if (clientResponse->retVal != SA_OK) {		cl_log(LOG_ERR, 			"Checkpoint daemon returned error");		libError = clientResponse->retVal;		goto rtnError;	}	libCheckpoint->createAttributes.retentionDuration = retentionDuration;	libError = SA_OK;rtnError:		if (libRequest != NULL) {		ha_free(libRequest);	}		if (clientRequest != NULL) {		ha_free(clientRequest);	}		if (rtnParam != NULL) {		ha_free(rtnParam);	}	if (clientResponse != NULL) {		if (clientResponse->dataLength > 0) {			ha_free(clientResponse->data);		}		ha_free(clientResponse);	}	return libError; }/*  * set the local replica as the active replica. */SaErrorTsaCkptActiveCheckpointSet(const SaCkptCheckpointHandleT *checkpointHandle){	SaCkptLibClientT* libClient = NULL;	SaCkptLibRequestT* libRequest = NULL;	SaCkptClientRequestT* clientRequest = NULL;	SaCkptReqActSetParamT* activeParam = NULL; 	SaCkptClientResponseT* clientResponse = NULL;	SaCkptLibCheckpointT* libCheckpoint = NULL;		SaErrorT libError = SA_OK;	IPC_Channel* ch = NULL;	if (checkpointHandle == NULL) {		cl_log(LOG_ERR, 			"Null handle in saCkptActiveCheckpointSet");		return SA_ERR_INVALID_PARAM;	}	libCheckpoint = SaCkptGetLibCheckpointByHandle(		*checkpointHandle);	if (libCheckpoint == NULL) {		cl_log(LOG_ERR, 			"Checkpoint is not open");		return SA_ERR_INVALID_PARAM;	}	libClient = libCheckpoint->client;	  	libRequest = (SaCkptLibRequestT*)ha_malloc(					sizeof(SaCkptLibRequestT));	clientRequest = (SaCkptClientRequestT*)ha_malloc(					sizeof(SaCkptClientRequestT));	activeParam = (SaCkptReqActSetParamT*)ha_malloc(					sizeof(SaCkptReqActSetParamT)); 	if ((libRequest == NULL) ||		(clientRequest == NULL) ||		(activeParam == NULL)) {		cl_log(LOG_ERR, 			"No memory in saCkptActiveCheckpointSet");		libError = SA_ERR_NO_MEMORY;		goto activeError;	}		memset(libRequest, 0, sizeof(SaCkptLibRequestT));	memset(clientRequest, 0, sizeof(SaCkptClientRequestT));	memset(activeParam, 0, sizeof(SaCkptReqActSetParamT));		libRequest->client = libClient;	libRequest->timeoutTag = 0;	libRequest->clientRequest = clientRequest;	clientRequest->clientHandle = libClient->clientHandle;	clientRequest->requestNO = SaCkptLibGetReqNO();	clientRequest->req = REQ_CKPT_ACT_SET;	clientRequest->reqParamLength = sizeof(SaCkptReqActSetParamT);	clientRequest->dataLength = 0;	clientRequest->reqParam = activeParam;	clientRequest->data = NULL;	activeParam->checkpointHandle = *checkpointHandle;		ch = libClient->channel[0];	libError = SaCkptLibRequestSend(ch, libRequest->clientRequest);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Send activate_checkpoint_set request failed");		goto activeError;	}	libError = SaCkptLibResponseReceive(ch, 		libRequest->clientRequest->requestNO,		&clientResponse);	if (libError != SA_OK) {		cl_log(LOG_ERR, "Receive response failed");		goto activeError;	}	if (clientResponse == NULL) {		cl_log(LOG_ERR, "Received null response");		libError = SA_ERR_LIBRARY;		goto activeError;	}	if (clientResponse->retVal != SA_OK) {		cl_log(LOG_ERR, "Checkpoint daemon returned error");		libError = clientResponse->retVal;		goto activeError;	}	libError = SA_OK;activeError:		if (libRequest != NULL) {		ha_free(libRequest);	}		if (clientRequest != NULL) {		ha_free(clientRequest);	}		if (activeParam != NULL) {		ha_free(activeParam);	}	if (clientResponse != NULL) {		if (clientResponse->dataLength > 0) {			ha_free(clientResponse->data);		}		ha_free(clientResponse);	}	return libError; }/* get the checkpoint status */SaErrorTsaCkptCheckpointStatusGet(	const SaCkptCheckpointHandleT *checkpointHandle,	SaCkptCheckpointStatusT *checkpointStatus/*[out]*/){	SaCkptLibClientT* libClient = NULL;	SaCkptLibRequestT* libRequest = NULL;	SaCkptClientRequestT* clientRequest = NULL;	SaCkptReqStatGetParamT* statParam = NULL; 	SaCkptClientResponseT* clientResponse = NULL;	SaCkptLibCheckpointT* libCheckpoint = NULL;		SaErrorT libError = SA_OK;	IPC_Channel* ch = NULL;	if (checkpointHandle == NULL) {		cl_log(LOG_ERR, 		"Null checkpoint handle in saCkptCheckpointStatusGet");		return SA_ERR_INVALID_PARAM;	}	if (checkpointStatus == NULL) {		cl_log(LOG_ERR, 			"Null status in saCkptCheckpointStatusGet");		return SA_ERR_INVALID_PARAM;	}	libCheckpoint = SaCkptGetLibCheckpointByHandle(		*checkpointHandle);	if (libCheckpoint == NULL) {		cl_log(LOG_ERR, 			"Checkpoint is not open");		return SA_ERR_INVALID_PARAM;	}	libClient = libCheckpoint->client;	  	libRequest = (SaCkptLibRequestT*)ha_malloc(					sizeof(SaCkptLibRequestT));	clientRequest = (SaCkptClientRequestT*)ha_malloc(					sizeof(SaCkptClientRequestT));	statParam = (SaCkptReqStatGetParamT*)ha_malloc(					sizeof(SaCkptReqStatGetParamT)); 	if ((libRequest == NULL) ||		(clientRequest == NULL) ||		(statParam == NULL)) {		cl_log(LOG_ERR, 			"No memory in saCkptCheckpointStatusGet");		libError = SA_ERR_NO_MEMORY;		goto statError;	}		memset(libRequest, 0, sizeof(SaCkptLibRequestT));	memset(clientRequest, 0, sizeof(SaCkptClientRequestT));	memset(statParam, 0, sizeof(SaCkptReqStatGetParamT));		libRequest->client = libClient;	libRequest->timeoutTag = 0;	libRequest->clientRequest = clientRequest;	clientRequest->clientHandle = libClient->clientHandle;	clientRequest->requestNO = SaCkptLibGetReqNO();	clientRequest->req = REQ_CKPT_STAT_GET;	clientRequest->reqParamLength = sizeof(SaCkptReqStatGetParamT);	clientRequest->dataLength = 0;	clientRequest->reqParam = statParam;	clientRequest->data = NULL;	statParam->checkpointHandle = *checkpointHandle;		ch = libClient->channel[0];	libError = SaCkptLibRequestSend(ch, libRequest->clientRequest);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Send status_get request failed");		goto statError;	}	libError = SaCkptLibResponseReceive(ch, 		libRequest->clientRequest->requestNO,		&clientResponse);	if (libError != SA_OK) {		cl_log(LOG_ERR, 			"Receive response failed");		goto statError;	}	if (clientResponse == NULL) {		cl_log(LOG_ERR, 			"Received null response");		libError = SA_ERR_LIBRARY;		goto statError;	}	if (clientResponse->retVal != SA_OK) {		cl_log(LOG_ERR, 			"Checkpoint daemon returned error");		libError = clientResponse->retVal;		goto statError;	}	if (clientResponse->dataLength < 		(SaSizeT)sizeof(SaCkptCheckpointStatusT)) {		cl_log(LOG_ERR, 			"Checkpoint daemon returned error data");		libError = clientResponse->retVal;		goto statError;	}	memcpy(checkpointStatus, clientResponse->data,		clientResponse->dataLength);	libError = SA_OK;statError:		if (libRequest != NULL) {		ha_free(libRequest);	}		if (clientRequest != NULL) {		ha_free(clientRequest);	}		if (statParam != NULL) {		ha_free(statParam);	}	if (clientResponse != NULL) {		if (clientResponse->dataLength > 0) {			ha_free(clientResponse->data);		}		ha_free(clientResponse);	}	return libError; }/* create a new section within the checkpoint and fill with the initial data. */SaErrorTsaCkptSectionCreate(	const SaCkptCheckpointHandleT *checkpointHandle,	SaCkptSectionCreationAttributesT *sectionCreationAttributes,	const void *initialData,	SaUint32T initialDataSize){	SaCkptLibClientT* libClient = NULL;	SaCkptLibRequestT* libRequest = NULL;	SaCkptClientRequestT* clientRequest = NULL;	SaCkptReqSecCrtParamT* secCrtParam = NULL; 	SaCkptClientResponseT* clientResponse = NULL;	SaCkptLibCheckpointT* libCheckpoint = NULL;		SaErrorT libError = SA_OK;	IPC_Channel* ch = NULL;	SaCkptSectionIdT* sectionId = NULL;	void* data = NULL;		time_t currentTime;	if (checkpointHandle == NULL) {		cl_log(LOG_ERR, 			"Null handle in saCkptSectionCreate");		return SA_ERR_INVALID_PARAM;	}	if (sectionCreationAttributes == NULL) {		cl_log(LOG_ERR, 			"Null section attribute in saCkptSectionCreate");		return SA_ERR_INVALID_PARAM;	}	if (sectionCreationAttributes->sectionId == NULL) {		cl_log(LOG_ERR, 			"Null section ID in saCkptSectionCreate");		return SA_ERR_INVALID_PARAM;	}	if ((sectionCreationAttributes->sectionId->idLen < 0)) {		cl_log(LOG_ERR, 			"Negative sectionId idLen in saCkptSectionCreate");		return SA_ERR_INVALID_PARAM;		}	if ((sectionCreationAttributes->sectionId->id == NULL) ^ 		(sectionCreationAttributes->sectionId->idLen == 0)) {		cl_log(LOG_ERR, 			"Miss match sectionId id and idLen in saCkptSectionCreate");		return SA_ERR_INVALID_PARAM;				}	/*	 * if the section ID is SA_CKPT_GENERATED_SECTION_ID,	 * generate a random ID for the section	 */	if ((sectionCreationAttributes->sectionId->id == NULL) && 		(sectionCreationAttributes->sectionId->idLen == 0)) {		int randomNumber = 0;				time(&currentTime);		srand(currentTime);		randomNumber = rand();		sectionCreationAttributes->sectionId->idLen = sizeof(int);		sectionCreationAttributes->sectionId->id = 			(SaUint8T*)ha_malloc(sizeof(int));		if (sectionCreationAttributes->sectionId->id == NULL) {			cl_log(LOG_ERR, 				"No memory in saCkptSectionCreate");			return SA_ERR_NO_MEMORY;		}		memcpy(sectionCreationAttributes->sectionId->id,			&randomNumber, sizeof(int));	}	if ((initialDataSize != 0) && (initialData == NULL)) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -