some refactoring
This commit is contained in:
parent
cd71a9cc12
commit
b71ccf8dd8
@ -101,120 +101,15 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() {
|
||||
break;
|
||||
}
|
||||
case(ReportingType::UPDATE_HK): {
|
||||
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
|
||||
// Update packets shall only be generated from datasets.
|
||||
continue;
|
||||
}
|
||||
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
|
||||
receiver.dataId.sid);
|
||||
if(dataSet->hasChanged()) {
|
||||
// prepare and send update notification
|
||||
ReturnValue_t result = generateHousekeepingPacket(
|
||||
receiver.dataId.sid, dataSet, true);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
}
|
||||
handleChangeResetLogic(receiver.dataType, receiver.dataId,
|
||||
dataSet);
|
||||
handleHkUpdate(receiver, status);
|
||||
break;
|
||||
}
|
||||
case(ReportingType::UPDATE_NOTIFICATION): {
|
||||
MarkChangedIF* toReset = nullptr;
|
||||
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
|
||||
LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(
|
||||
receiver.dataId.localPoolId);
|
||||
if(poolObj == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if(poolObj->hasChanged()) {
|
||||
// prepare and send update notification.
|
||||
CommandMessage notification;
|
||||
HousekeepingMessage::setUpdateNotificationVariableCommand(
|
||||
¬ification, receiver.dataId.localPoolId);
|
||||
ReturnValue_t result = hkQueue->sendMessage(
|
||||
receiver.destinationQueue, ¬ification);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
toReset = poolObj;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
|
||||
receiver.dataId.sid);
|
||||
if(dataSet == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if(dataSet->hasChanged()) {
|
||||
// prepare and send update notification
|
||||
CommandMessage notification;
|
||||
HousekeepingMessage::setUpdateNotificationSetCommand(
|
||||
¬ification, receiver.dataId.sid);
|
||||
ReturnValue_t result = hkQueue->sendMessage(
|
||||
receiver.destinationQueue, ¬ification);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
toReset = dataSet;
|
||||
}
|
||||
}
|
||||
if(toReset != nullptr) {
|
||||
handleChangeResetLogic(receiver.dataType,
|
||||
receiver.dataId, toReset);
|
||||
}
|
||||
handleNotificationUpdate(receiver, status);
|
||||
break;
|
||||
}
|
||||
case(ReportingType::UPDATE_SNAPSHOT): {
|
||||
MarkChangedIF* toReset = nullptr;
|
||||
// check whether data has changed and send messages in case it has.
|
||||
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
|
||||
LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(
|
||||
receiver.dataId.localPoolId);
|
||||
if(poolObj == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if(poolObj->hasChanged()) {
|
||||
// prepare and send update snapshot.
|
||||
CommandMessage notification;
|
||||
// todo: serialize into store with timestamp.
|
||||
store_address_t storeId;
|
||||
HousekeepingMessage::setUpdateSnapshotSetCommand(
|
||||
¬ification, receiver.dataId.sid, storeId);
|
||||
ReturnValue_t result = hkQueue->sendMessage(
|
||||
receiver.destinationQueue, ¬ification);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
toReset = poolObj;
|
||||
}
|
||||
}
|
||||
else {
|
||||
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
|
||||
receiver.dataId.sid);
|
||||
if(dataSet == nullptr) {
|
||||
continue;
|
||||
}
|
||||
if(dataSet->hasChanged()) {
|
||||
// prepare and send update snapshot.
|
||||
CommandMessage notification;
|
||||
// todo: serialize into store with timestamp.
|
||||
store_address_t storeId;
|
||||
HousekeepingMessage::setUpdateSnapshotVariableCommand(
|
||||
¬ification, receiver.dataId.localPoolId, storeId);
|
||||
ReturnValue_t result = hkQueue->sendMessage(
|
||||
receiver.destinationQueue, ¬ification);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
toReset = dataSet;
|
||||
}
|
||||
}
|
||||
if(toReset != nullptr) {
|
||||
handleChangeResetLogic(receiver.dataType,
|
||||
receiver.dataId, toReset);
|
||||
}
|
||||
handleNotificationSnapshot(receiver, status);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -226,6 +121,129 @@ ReturnValue_t LocalDataPoolManager::performHkOperation() {
|
||||
return status;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::handleHkUpdate(HkReceiver& receiver,
|
||||
ReturnValue_t& status) {
|
||||
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
|
||||
// Update packets shall only be generated from datasets.
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
|
||||
receiver.dataId.sid);
|
||||
if(dataSet->hasChanged()) {
|
||||
// prepare and send update notification
|
||||
ReturnValue_t result = generateHousekeepingPacket(
|
||||
receiver.dataId.sid, dataSet, true);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
}
|
||||
handleChangeResetLogic(receiver.dataType, receiver.dataId,
|
||||
dataSet);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::handleNotificationUpdate(
|
||||
HkReceiver& receiver, ReturnValue_t& status) {
|
||||
MarkChangedIF* toReset = nullptr;
|
||||
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
|
||||
LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(
|
||||
receiver.dataId.localPoolId);
|
||||
if(poolObj == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if(poolObj->hasChanged()) {
|
||||
// prepare and send update notification.
|
||||
CommandMessage notification;
|
||||
HousekeepingMessage::setUpdateNotificationVariableCommand(
|
||||
¬ification, receiver.dataId.localPoolId);
|
||||
ReturnValue_t result = hkQueue->sendMessage(
|
||||
receiver.destinationQueue, ¬ification);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
toReset = poolObj;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
|
||||
receiver.dataId.sid);
|
||||
if(dataSet == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if(dataSet->hasChanged()) {
|
||||
// prepare and send update notification
|
||||
CommandMessage notification;
|
||||
HousekeepingMessage::setUpdateNotificationSetCommand(
|
||||
¬ification, receiver.dataId.sid);
|
||||
ReturnValue_t result = hkQueue->sendMessage(
|
||||
receiver.destinationQueue, ¬ification);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
toReset = dataSet;
|
||||
}
|
||||
}
|
||||
if(toReset != nullptr) {
|
||||
handleChangeResetLogic(receiver.dataType,
|
||||
receiver.dataId, toReset);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::handleNotificationSnapshot(
|
||||
HkReceiver& receiver, ReturnValue_t& status) {
|
||||
MarkChangedIF* toReset = nullptr;
|
||||
// check whether data has changed and send messages in case it has.
|
||||
if(receiver.dataType == DataType::LOCAL_POOL_VARIABLE) {
|
||||
LocalPoolObjectBase* poolObj = owner->getPoolObjectHandle(
|
||||
receiver.dataId.localPoolId);
|
||||
if(poolObj == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if(poolObj->hasChanged()) {
|
||||
// prepare and send update snapshot.
|
||||
CommandMessage notification;
|
||||
// todo: serialize into store with timestamp.
|
||||
store_address_t storeId;
|
||||
HousekeepingMessage::setUpdateSnapshotSetCommand(
|
||||
¬ification, receiver.dataId.sid, storeId);
|
||||
ReturnValue_t result = hkQueue->sendMessage(
|
||||
receiver.destinationQueue, ¬ification);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
toReset = poolObj;
|
||||
}
|
||||
}
|
||||
else {
|
||||
LocalPoolDataSetBase* dataSet = owner->getDataSetHandle(
|
||||
receiver.dataId.sid);
|
||||
if(dataSet == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if(dataSet->hasChanged()) {
|
||||
// prepare and send update snapshot.
|
||||
CommandMessage notification;
|
||||
// todo: serialize into store with timestamp.
|
||||
store_address_t storeId;
|
||||
HousekeepingMessage::setUpdateSnapshotVariableCommand(
|
||||
¬ification, receiver.dataId.localPoolId, storeId);
|
||||
ReturnValue_t result = hkQueue->sendMessage(
|
||||
receiver.destinationQueue, ¬ification);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
status = result;
|
||||
}
|
||||
toReset = dataSet;
|
||||
}
|
||||
}
|
||||
if(toReset != nullptr) {
|
||||
handleChangeResetLogic(receiver.dataType,
|
||||
receiver.dataId, toReset);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void LocalDataPoolManager::handleChangeResetLogic(
|
||||
DataType type, DataId dataId, MarkChangedIF* toReset) {
|
||||
if(hkUpdateResetList == nullptr) {
|
||||
|
@ -350,6 +350,13 @@ private:
|
||||
void handleChangeResetLogic(DataType type,
|
||||
DataId dataId, MarkChangedIF* toReset);
|
||||
void resetHkUpdateResetHelper();
|
||||
|
||||
ReturnValue_t handleHkUpdate(HkReceiver& hkReceiver,
|
||||
ReturnValue_t& status);
|
||||
ReturnValue_t handleNotificationUpdate(HkReceiver& hkReceiver,
|
||||
ReturnValue_t& status);
|
||||
ReturnValue_t handleNotificationSnapshot(HkReceiver& hkReceiver,
|
||||
ReturnValue_t& status);
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user